@postenbring/hedwig-react 0.0.82 → 0.0.84

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 (213) hide show
  1. package/dist/accordion/accordion-content.d.ts.map +1 -1
  2. package/dist/accordion/accordion-content.js +1 -0
  3. package/dist/accordion/accordion-content.js.map +1 -1
  4. package/dist/accordion/accordion-content.mjs +2 -2
  5. package/dist/accordion/accordion-header.d.ts.map +1 -1
  6. package/dist/accordion/accordion-header.js +1 -0
  7. package/dist/accordion/accordion-header.js.map +1 -1
  8. package/dist/accordion/accordion-header.mjs +2 -2
  9. package/dist/accordion/accordion-item.d.ts.map +1 -1
  10. package/dist/accordion/accordion-item.js +2 -1
  11. package/dist/accordion/accordion-item.js.map +1 -1
  12. package/dist/accordion/accordion-item.mjs +2 -2
  13. package/dist/accordion/accordion.js +4 -1
  14. package/dist/accordion/accordion.js.map +1 -1
  15. package/dist/accordion/accordion.mjs +5 -5
  16. package/dist/accordion/context.d.ts +1 -0
  17. package/dist/accordion/context.d.ts.map +1 -1
  18. package/dist/accordion/context.js.map +1 -1
  19. package/dist/accordion/context.mjs +1 -1
  20. package/dist/accordion/index.js +4 -1
  21. package/dist/accordion/index.js.map +1 -1
  22. package/dist/accordion/index.mjs +7 -7
  23. package/dist/badge/badge.d.ts +13 -4
  24. package/dist/badge/badge.d.ts.map +1 -1
  25. package/dist/badge/badge.js +22 -42
  26. package/dist/badge/badge.js.map +1 -1
  27. package/dist/badge/badge.mjs +3 -9
  28. package/dist/badge/index.d.ts +1 -1
  29. package/dist/badge/index.d.ts.map +1 -1
  30. package/dist/badge/index.js +22 -42
  31. package/dist/badge/index.js.map +1 -1
  32. package/dist/badge/index.mjs +3 -9
  33. package/dist/button/button.d.ts +17 -5
  34. package/dist/button/button.d.ts.map +1 -1
  35. package/dist/button/button.js +4 -17
  36. package/dist/button/button.js.map +1 -1
  37. package/dist/button/button.mjs +3 -5
  38. package/dist/button/index.d.ts +1 -1
  39. package/dist/button/index.d.ts.map +1 -1
  40. package/dist/button/index.js +4 -17
  41. package/dist/button/index.js.map +1 -1
  42. package/dist/button/index.mjs +3 -5
  43. package/dist/{chunk-67TP3E2D.mjs → chunk-6FBPKLWB.mjs} +3 -3
  44. package/dist/chunk-6FBPKLWB.mjs.map +1 -0
  45. package/dist/{chunk-KEKPEN2C.mjs → chunk-6MR5XZOX.mjs} +4 -16
  46. package/dist/chunk-6MR5XZOX.mjs.map +1 -0
  47. package/dist/{chunk-4WQWU5TL.mjs → chunk-AXQCREUJ.mjs} +2 -2
  48. package/dist/chunk-AXQCREUJ.mjs.map +1 -0
  49. package/dist/{chunk-M3Y3XOGC.mjs → chunk-B6L7IFDX.mjs} +6 -6
  50. package/dist/{chunk-F2C3KZFX.mjs → chunk-BVPSZ3JI.mjs} +2 -2
  51. package/dist/chunk-BVPSZ3JI.mjs.map +1 -0
  52. package/dist/chunk-CYDWEPFL.mjs +1 -0
  53. package/dist/{chunk-6AGDK5V3.mjs → chunk-EVUKWONG.mjs} +2 -2
  54. package/dist/chunk-GQUFERB2.mjs +37 -0
  55. package/dist/chunk-GQUFERB2.mjs.map +1 -0
  56. package/dist/{chunk-C34HEQXO.mjs → chunk-GRWLX5BC.mjs} +5 -5
  57. package/dist/chunk-GRWLX5BC.mjs.map +1 -0
  58. package/dist/{chunk-3EFAPJ3H.mjs → chunk-HJYS664B.mjs} +3 -2
  59. package/dist/chunk-HJYS664B.mjs.map +1 -0
  60. package/dist/{chunk-LCJSUBCZ.mjs → chunk-IHZ2MRF6.mjs} +4 -4
  61. package/dist/chunk-IHZ2MRF6.mjs.map +1 -0
  62. package/dist/{chunk-3WVRY6CC.mjs → chunk-L4YBHIS3.mjs} +20 -12
  63. package/dist/chunk-L4YBHIS3.mjs.map +1 -0
  64. package/dist/{chunk-6R7AXKBR.mjs → chunk-OIC2CPID.mjs} +19 -13
  65. package/dist/chunk-OIC2CPID.mjs.map +1 -0
  66. package/dist/{chunk-7UD72WOC.mjs → chunk-QZZIOBF4.mjs} +2 -2
  67. package/dist/{chunk-A2H2LAII.mjs → chunk-SKVM7G76.mjs} +5 -4
  68. package/dist/chunk-SKVM7G76.mjs.map +1 -0
  69. package/dist/chunk-SRLM3K2X.mjs +1 -0
  70. package/dist/{chunk-DEX36MFK.mjs → chunk-TDXU2IC6.mjs} +3 -4
  71. package/dist/chunk-TDXU2IC6.mjs.map +1 -0
  72. package/dist/{chunk-GLAEI3SD.mjs → chunk-VCQIR53Y.mjs} +3 -2
  73. package/dist/chunk-VCQIR53Y.mjs.map +1 -0
  74. package/dist/{chunk-V3PAFMK5.mjs → chunk-YQFL5UN4.mjs} +1 -1
  75. package/dist/chunk-YQFL5UN4.mjs.map +1 -0
  76. package/dist/footer/footer.js +7 -15
  77. package/dist/footer/footer.js.map +1 -1
  78. package/dist/footer/footer.mjs +7 -7
  79. package/dist/footer/index.js +7 -15
  80. package/dist/footer/index.js.map +1 -1
  81. package/dist/footer/index.mjs +7 -7
  82. package/dist/form/date-picker/date-picker.js +1 -1
  83. package/dist/form/date-picker/date-picker.js.map +1 -1
  84. package/dist/form/date-picker/date-picker.mjs +2 -2
  85. package/dist/form/date-picker/index.js +1 -1
  86. package/dist/form/date-picker/index.js.map +1 -1
  87. package/dist/form/date-picker/index.mjs +2 -2
  88. package/dist/form/index.js +1 -1
  89. package/dist/form/index.js.map +1 -1
  90. package/dist/form/index.mjs +2 -2
  91. package/dist/index-no-css.d.ts +1 -1
  92. package/dist/index-no-css.d.ts.map +1 -1
  93. package/dist/index-no-css.js +237 -242
  94. package/dist/index-no-css.js.map +1 -1
  95. package/dist/index-no-css.mjs +43 -42
  96. package/dist/index.js +237 -242
  97. package/dist/index.js.map +1 -1
  98. package/dist/index.mjs +43 -42
  99. package/dist/index.mjs.map +1 -1
  100. package/dist/modal/index.js +1 -1
  101. package/dist/modal/index.js.map +1 -1
  102. package/dist/modal/index.mjs +2 -2
  103. package/dist/modal/modal.d.ts +4 -4
  104. package/dist/modal/modal.js +1 -1
  105. package/dist/modal/modal.js.map +1 -1
  106. package/dist/modal/modal.mjs +2 -2
  107. package/dist/navbar/index.js +18 -12
  108. package/dist/navbar/index.js.map +1 -1
  109. package/dist/navbar/index.mjs +3 -3
  110. package/dist/navbar/navbar-expandable-menu.d.ts +7 -1
  111. package/dist/navbar/navbar-expandable-menu.d.ts.map +1 -1
  112. package/dist/navbar/navbar-expandable-menu.js +18 -12
  113. package/dist/navbar/navbar-expandable-menu.js.map +1 -1
  114. package/dist/navbar/navbar-expandable-menu.mjs +2 -2
  115. package/dist/navbar/navbar.js +18 -12
  116. package/dist/navbar/navbar.js.map +1 -1
  117. package/dist/navbar/navbar.mjs +3 -3
  118. package/dist/show-more/index.d.ts +0 -2
  119. package/dist/show-more/index.d.ts.map +1 -1
  120. package/dist/show-more/index.js +5 -143
  121. package/dist/show-more/index.js.map +1 -1
  122. package/dist/show-more/index.mjs +1 -6
  123. package/dist/tabs/index.js +1 -1
  124. package/dist/tabs/index.js.map +1 -1
  125. package/dist/tabs/index.mjs +3 -3
  126. package/dist/tabs/tabs-list.js +1 -1
  127. package/dist/tabs/tabs-list.js.map +1 -1
  128. package/dist/tabs/tabs-list.mjs +2 -2
  129. package/dist/tabs/tabs.js +1 -1
  130. package/dist/tabs/tabs.js.map +1 -1
  131. package/dist/tabs/tabs.mjs +3 -3
  132. package/dist/utils/auto-animate-height.d.ts.map +1 -0
  133. package/dist/{utilities → utils}/auto-animate-height.js +3 -3
  134. package/dist/utils/auto-animate-height.js.map +1 -0
  135. package/dist/utils/auto-animate-height.mjs +9 -0
  136. package/dist/{utilities → utils}/index.d.ts +1 -0
  137. package/dist/utils/index.d.ts.map +1 -0
  138. package/dist/{utilities → utils}/index.js +81 -11
  139. package/dist/utils/index.js.map +1 -0
  140. package/dist/utils/index.mjs +19 -0
  141. package/dist/{utils.d.ts → utils/utils.d.ts} +0 -4
  142. package/dist/utils/utils.d.ts.map +1 -0
  143. package/dist/{utils.js → utils/utils.js} +1 -3
  144. package/dist/utils/utils.js.map +1 -0
  145. package/dist/utils/utils.mjs +14 -0
  146. package/dist/warning-banner/index.js +28 -94
  147. package/dist/warning-banner/index.js.map +1 -1
  148. package/dist/warning-banner/index.mjs +1 -3
  149. package/dist/warning-banner/warning-banner.d.ts.map +1 -1
  150. package/dist/warning-banner/warning-banner.js +28 -94
  151. package/dist/warning-banner/warning-banner.js.map +1 -1
  152. package/dist/warning-banner/warning-banner.mjs +1 -3
  153. package/package.json +5 -5
  154. package/src/accordion/accordion-content.tsx +1 -0
  155. package/src/accordion/accordion-header.tsx +1 -0
  156. package/src/accordion/accordion-item.tsx +3 -2
  157. package/src/accordion/context.ts +1 -0
  158. package/src/badge/badge.stories.tsx +6 -4
  159. package/src/badge/badge.tsx +32 -40
  160. package/src/badge/index.tsx +1 -1
  161. package/src/button/button.stories.tsx +19 -17
  162. package/src/button/button.tsx +19 -18
  163. package/src/button/index.tsx +1 -1
  164. package/src/footer/footer.tsx +3 -3
  165. package/src/form/date-picker/date-picker.tsx +1 -1
  166. package/src/form/input/input.stories.tsx +6 -6
  167. package/src/index-no-css.tsx +1 -1
  168. package/src/modal/modal.stories.tsx +9 -9
  169. package/src/modal/modal.tsx +5 -5
  170. package/src/navbar/navbar-expandable-menu.tsx +26 -15
  171. package/src/show-more/index.ts +0 -3
  172. package/src/show-more/show-more.stories.tsx +1 -1
  173. package/src/skeleton/skeleton.stories.tsx +3 -3
  174. package/src/tabs/tabs-list.tsx +1 -1
  175. package/src/{utilities → utils}/auto-animate-height.tsx +1 -1
  176. package/src/{utilities → utils}/index.ts +2 -0
  177. package/src/{utils.ts → utils/utils.ts} +1 -1
  178. package/src/warning-banner/warning-banner.tsx +24 -13
  179. package/dist/chunk-3EFAPJ3H.mjs.map +0 -1
  180. package/dist/chunk-3WVRY6CC.mjs.map +0 -1
  181. package/dist/chunk-4WQWU5TL.mjs.map +0 -1
  182. package/dist/chunk-67TP3E2D.mjs.map +0 -1
  183. package/dist/chunk-6R7AXKBR.mjs.map +0 -1
  184. package/dist/chunk-A2H2LAII.mjs.map +0 -1
  185. package/dist/chunk-C34HEQXO.mjs.map +0 -1
  186. package/dist/chunk-DEX36MFK.mjs.map +0 -1
  187. package/dist/chunk-DZNH5JHY.mjs +0 -1
  188. package/dist/chunk-F2C3KZFX.mjs.map +0 -1
  189. package/dist/chunk-GLAEI3SD.mjs.map +0 -1
  190. package/dist/chunk-KEKPEN2C.mjs.map +0 -1
  191. package/dist/chunk-LCJSUBCZ.mjs.map +0 -1
  192. package/dist/chunk-MSFHJVHD.mjs +0 -1
  193. package/dist/chunk-P6KBFRF4.mjs +0 -54
  194. package/dist/chunk-P6KBFRF4.mjs.map +0 -1
  195. package/dist/chunk-V3PAFMK5.mjs.map +0 -1
  196. package/dist/utilities/auto-animate-height.d.ts.map +0 -1
  197. package/dist/utilities/auto-animate-height.js.map +0 -1
  198. package/dist/utilities/auto-animate-height.mjs +0 -9
  199. package/dist/utilities/index.d.ts.map +0 -1
  200. package/dist/utilities/index.js.map +0 -1
  201. package/dist/utilities/index.mjs +0 -10
  202. package/dist/utils.d.ts.map +0 -1
  203. package/dist/utils.js.map +0 -1
  204. package/dist/utils.mjs +0 -16
  205. /package/dist/{chunk-M3Y3XOGC.mjs.map → chunk-B6L7IFDX.mjs.map} +0 -0
  206. /package/dist/{chunk-DZNH5JHY.mjs.map → chunk-CYDWEPFL.mjs.map} +0 -0
  207. /package/dist/{chunk-6AGDK5V3.mjs.map → chunk-EVUKWONG.mjs.map} +0 -0
  208. /package/dist/{chunk-7UD72WOC.mjs.map → chunk-QZZIOBF4.mjs.map} +0 -0
  209. /package/dist/{chunk-MSFHJVHD.mjs.map → chunk-SRLM3K2X.mjs.map} +0 -0
  210. /package/dist/{utilities → utils}/auto-animate-height.d.ts +0 -0
  211. /package/dist/{utilities → utils}/auto-animate-height.mjs.map +0 -0
  212. /package/dist/{utilities → utils}/index.mjs.map +0 -0
  213. /package/dist/{utils.mjs.map → utils/utils.mjs.map} +0 -0
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __defProps = Object.defineProperties;
5
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
5
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
7
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
- var __getProtoOf = Object.getPrototypeOf;
10
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
9
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
10
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -46,158 +44,23 @@ var __copyProps = (to, from, except, desc) => {
46
44
  }
47
45
  return to;
48
46
  };
49
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
50
- // If the importer is in node compatibility mode or this is not an ESM
51
- // file that has been converted to a CommonJS file using a Babel-
52
- // compatible transform (i.e. "__esModule" has not been set), then set
53
- // "default" to the CommonJS "module.exports" for node compatibility.
54
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
55
- mod
56
- ));
57
47
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
48
 
59
49
  // src/show-more/index.ts
60
50
  var show_more_exports = {};
61
51
  __export(show_more_exports, {
62
- AutoAnimateHeight: () => AutoAnimateHeight,
63
52
  ShowMoreButton: () => ShowMoreButton
64
53
  });
65
54
  module.exports = __toCommonJS(show_more_exports);
66
55
 
67
- // src/utilities/auto-animate-height.tsx
68
- var import_react2 = require("react");
69
-
70
- // src/utils.ts
71
- var React = __toESM(require("react"));
72
- var import_react = require("react");
73
- function useMergeRefs(refs) {
74
- return React.useMemo(() => {
75
- if (refs.every((ref) => ref === null)) {
76
- return null;
77
- }
78
- return (value) => {
79
- refs.forEach((ref) => {
80
- if (typeof ref === "function") {
81
- ref(value);
82
- } else if (ref !== null) {
83
- ref.current = value;
84
- }
85
- });
86
- };
87
- }, refs);
88
- }
89
-
90
- // src/utilities/auto-animate-height.tsx
91
- var import_jsx_runtime = require("react/jsx-runtime");
92
- var AutoAnimateHeight = (0, import_react2.forwardRef)(
93
- (_a, ref) => {
94
- var _b = _a, {
95
- children,
96
- style,
97
- animationDuration = "quick",
98
- animationEasing = "normal",
99
- onTransitionEnd
100
- } = _b, rest = __objRest(_b, [
101
- "children",
102
- "style",
103
- "animationDuration",
104
- "animationEasing",
105
- "onTransitionEnd"
106
- ]);
107
- var _a2, _b2;
108
- const rootRef = (0, import_react2.useRef)(null);
109
- const mergedRef = useMergeRefs([rootRef, ref]);
110
- const measurementRef = (0, import_react2.useRef)(null);
111
- const [height, setHeight] = (0, import_react2.useState)(
112
- void 0
113
- );
114
- const [clonedChildren, setClonedChildren] = (0, import_react2.useState)(
115
- () => (0, import_react2.cloneElement)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children }), {})
116
- );
117
- (0, import_react2.useEffect)(() => {
118
- var _a3;
119
- if (!rootRef.current)
120
- return;
121
- if (!measurementRef.current)
122
- return;
123
- if (document.body.scrollHeight === 0)
124
- return;
125
- const currentMeasurement = measurementRef.current;
126
- const { height: newHeight } = currentMeasurement.getBoundingClientRect();
127
- let previouslyObservedHeight = newHeight;
128
- const resizeObserver = new ResizeObserver(() => {
129
- const { height: resizedHeight } = currentMeasurement.getBoundingClientRect();
130
- if (resizedHeight === previouslyObservedHeight)
131
- return;
132
- previouslyObservedHeight = resizedHeight;
133
- setHeight({ height: resizedHeight, shouldAnimate: false });
134
- });
135
- resizeObserver.observe(currentMeasurement);
136
- setHeight({ height: newHeight, shouldAnimate: true });
137
- const nextClonedChildren = (0, import_react2.cloneElement)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children }), {});
138
- if (newHeight >= ((_a3 = height == null ? void 0 : height.height) != null ? _a3 : 0)) {
139
- setClonedChildren(nextClonedChildren);
140
- return () => {
141
- resizeObserver.disconnect();
142
- };
143
- }
144
- const currentRoot = rootRef.current;
145
- function onTransitionEndHandler(e) {
146
- if (e.propertyName !== "height")
147
- return;
148
- setClonedChildren(nextClonedChildren);
149
- }
150
- currentRoot.addEventListener("transitionend", onTransitionEndHandler);
151
- return () => {
152
- resizeObserver.disconnect();
153
- currentRoot.removeEventListener("transitionend", onTransitionEndHandler);
154
- };
155
- }, [children]);
156
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
157
- "div",
158
- __spreadProps(__spreadValues({
159
- ref: mergedRef,
160
- onTransitionEnd,
161
- style: __spreadValues({
162
- position: "relative",
163
- overflow: "hidden",
164
- height: (_b2 = height == null ? void 0 : height.height) != null ? _b2 : (_a2 = measurementRef.current) == null ? void 0 : _a2.getBoundingClientRect().height,
165
- transitionProperty: (height == null ? void 0 : height.shouldAnimate) ? "height" : "none",
166
- transitionDuration: `var(--hds-micro-animation-duration-${animationDuration})`,
167
- transitionTimingFunction: `var(--hds-micro-animation-easing-${animationEasing})`,
168
- willChange: "height"
169
- }, style)
170
- }, rest), {
171
- children: [
172
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
173
- "div",
174
- {
175
- "aria-hidden": true,
176
- ref: measurementRef,
177
- style: {
178
- position: "absolute",
179
- visibility: "hidden",
180
- pointerEvents: "none"
181
- },
182
- children
183
- }
184
- ),
185
- clonedChildren
186
- ]
187
- })
188
- );
189
- }
190
- );
191
- AutoAnimateHeight.displayName = "AutoAnimateHeight";
192
-
193
56
  // src/show-more/show-more.tsx
194
57
  var import_typed_classname = require("@postenbring/hedwig-css/typed-classname");
195
- var import_react3 = require("react");
196
- var import_jsx_runtime2 = require("react/jsx-runtime");
197
- var ShowMoreButton = (0, import_react3.forwardRef)(
58
+ var import_react = require("react");
59
+ var import_jsx_runtime = require("react/jsx-runtime");
60
+ var ShowMoreButton = (0, import_react.forwardRef)(
198
61
  (_a, ref) => {
199
62
  var _b = _a, { text, variant, expanded, className } = _b, rest = __objRest(_b, ["text", "variant", "expanded", "className"]);
200
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
63
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
201
64
  "button",
202
65
  __spreadProps(__spreadValues({
203
66
  ref,
@@ -211,7 +74,7 @@ var ShowMoreButton = (0, import_react3.forwardRef)(
211
74
  }, rest), {
212
75
  children: [
213
76
  text,
214
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: (0, import_typed_classname.clsx)("hds-show-more__icon") })
77
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: (0, import_typed_classname.clsx)("hds-show-more__icon") })
215
78
  ]
216
79
  })
217
80
  );
@@ -220,7 +83,6 @@ var ShowMoreButton = (0, import_react3.forwardRef)(
220
83
  ShowMoreButton.displayName = "ShowMoreButton";
221
84
  // Annotate the CommonJS export names for ESM import in node:
222
85
  0 && (module.exports = {
223
- AutoAnimateHeight,
224
86
  ShowMoreButton
225
87
  });
226
88
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/show-more/index.ts","../../src/utilities/auto-animate-height.tsx","../../src/utils.ts","../../src/show-more/show-more.tsx"],"sourcesContent":["export { AutoAnimateHeight } from \"../utilities/auto-animate-height\";\nexport type * from \"../utilities/auto-animate-height\";\n\nexport { ShowMoreButton } from \"./show-more\";\nexport type * from \"./show-more\";\n","import { cloneElement, forwardRef, useEffect, useRef, useState } from \"react\";\nimport { useMergeRefs } from \"../utils\";\n\nexport interface AutoAnimateHeightProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Time of the animation, using the hedwig animation tokens\n * quick: 0.1s\n * normal: 0.3s\n * slow: 0.7s\n *\n * default is \"quick\"\n */\n animationDuration?: \"quick\" | \"normal\" | \"slow\";\n\n /**\n * Callback fired when animiation transition ends\n * Use this to do effects after resizing is done, e.g. scrolling to the element\n * using `element.scrollIntoView()`\n */\n onTransitionEnd?: () => void;\n\n /**\n * Which hedwig easing function to use, default is \"normal\"\n */\n animationEasing?: \"in\" | \"out\" | \"normal\";\n children: React.ReactNode;\n style?: React.CSSProperties;\n}\n\n/**\n * Helper component to animate the height of the children when they change\n * It's done by rendering two versions of the passed children,\n * one hidden to measure the height and one visible to only changes after the height is measured.\n *\n * **IMPORTANT** Do not pass any components with effects (like data fetching), as they will trigger twice.\n */\nexport const AutoAnimateHeight = forwardRef<HTMLDivElement, AutoAnimateHeightProps>(\n (\n {\n children,\n style,\n animationDuration = \"quick\",\n animationEasing = \"normal\",\n onTransitionEnd,\n ...rest\n },\n ref,\n ) => {\n const rootRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([rootRef, ref]);\n const measurementRef = useRef<HTMLDivElement>(null);\n const [height, setHeight] = useState<{ height: number; shouldAnimate: boolean } | undefined>(\n undefined,\n );\n const [clonedChildren, setClonedChildren] = useState<React.ReactNode>(() =>\n cloneElement(<>{children}</>, {}),\n );\n\n useEffect(() => {\n if (!rootRef.current) return;\n if (!measurementRef.current) return;\n if (document.body.scrollHeight === 0) return;\n const currentMeasurement = measurementRef.current;\n const { height: newHeight } = currentMeasurement.getBoundingClientRect();\n\n // Listen for resize events on the measurement element\n // Keep the children in sync with the height\n // But don't animate it.\n let previouslyObservedHeight = newHeight;\n const resizeObserver = new ResizeObserver(() => {\n const { height: resizedHeight } = currentMeasurement.getBoundingClientRect();\n if (resizedHeight === previouslyObservedHeight) return;\n previouslyObservedHeight = resizedHeight;\n setHeight({ height: resizedHeight, shouldAnimate: false });\n });\n resizeObserver.observe(currentMeasurement); // This is cleaned up down below in the return functions\n\n // Set the new height when children changes\n setHeight({ height: newHeight, shouldAnimate: true });\n\n // Update children\n const nextClonedChildren = cloneElement(<>{children}</>, {});\n\n // When increasing in height update immediately so the new content is shown during the animation\n if (newHeight >= (height?.height ?? 0)) {\n setClonedChildren(nextClonedChildren);\n return () => {\n resizeObserver.disconnect();\n };\n }\n\n // When decreasing in height, wait until the animation is done so that we don't get a sudden flash of empty content\n const currentRoot = rootRef.current;\n function onTransitionEndHandler(e: TransitionEvent) {\n if (e.propertyName !== \"height\") return;\n setClonedChildren(nextClonedChildren);\n }\n currentRoot.addEventListener(\"transitionend\", onTransitionEndHandler);\n return () => {\n resizeObserver.disconnect();\n currentRoot.removeEventListener(\"transitionend\", onTransitionEndHandler);\n };\n\n // eslint-disable-next-line react-hooks/exhaustive-deps -- I know better\n }, [children]);\n\n return (\n <div\n ref={mergedRef}\n onTransitionEnd={onTransitionEnd}\n style={{\n position: \"relative\",\n overflow: \"hidden\",\n height: height?.height ?? measurementRef.current?.getBoundingClientRect().height,\n transitionProperty: height?.shouldAnimate ? \"height\" : \"none\",\n transitionDuration: `var(--hds-micro-animation-duration-${animationDuration})`,\n transitionTimingFunction: `var(--hds-micro-animation-easing-${animationEasing})`,\n willChange: \"height\",\n ...style,\n }}\n {...rest}\n >\n <div\n aria-hidden\n ref={measurementRef}\n style={{\n position: \"absolute\",\n visibility: \"hidden\",\n pointerEvents: \"none\",\n }}\n >\n {children}\n </div>\n {clonedChildren}\n </div>\n );\n },\n);\nAutoAnimateHeight.displayName = \"AutoAnimateHeight\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nexport function releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n","import { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef } from \"react\";\n\ntype Variant =\n | {\n variant?: \"show-more\";\n expanded?: never;\n }\n | {\n variant: \"show-more-show-less\";\n expanded: boolean;\n };\n\nexport type ShowMoreProps = React.HTMLAttributes<HTMLButtonElement> & {\n text: React.ReactNode;\n} & Variant;\n\n/**\n * Simple button for triggering more content.\n *\n * You have to add the logic for what happens when the button is clicked yourself.\n *\n * @example\n * ```tsx\n * function Content() {\n * const [items, fetchMoreItems, moreItemsAvailable] = useYourData();\n * function onShowMoreItems() {\n * fetchMoreItems();\n * }\n * return (\n * <>\n * <ul>\n * {items.map((item) => (\n * <li key={item.id}>{item.text}</li>\n * ))}\n * </ul>\n * {moreItemsAvailable ?\n * <ShowMoreButton className=\"mt-8\" onClick={onShowMoreItems} lang=\"en\" /> :\n * null\n * }\n * </>\n * )\n * }\n * ```\n */\nexport const ShowMoreButton = forwardRef<HTMLButtonElement, ShowMoreProps>(\n ({ text, variant, expanded, className, ...rest }, ref) => {\n return (\n <button\n ref={ref}\n className={clsx(\n \"hds-show-more\",\n variant === \"show-more-show-less\" && \"hds-show-more--show-less\",\n className as undefined,\n )}\n data-state={expanded ? \"expanded\" : undefined}\n type=\"button\"\n {...rest}\n >\n {text}\n <span className={clsx(\"hds-show-more__icon\")} />\n </button>\n );\n },\n);\nShowMoreButton.displayName = \"ShowMoreButton\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAAsE;;;ACAtE,YAAuB;AACvB,mBAAiD;AAM1C,SAAS,aACd,MACoC;AACpC,SAAa,cAAQ,MAAM;AACzB,QAAI,KAAK,MAAM,CAAC,QAAQ,QAAQ,IAAI,GAAG;AACrC,aAAO;AAAA,IACT;AAEA,WAA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IAAAC,sBAAA;AAHC,IAAM,qBAAiB;AAAA,EAC5B,CAAC,IAAiD,QAAQ;AAAzD,iBAAE,QAAM,SAAS,UAAU,UA9C9B,IA8CG,IAAyC,iBAAzC,IAAyC,CAAvC,QAAM,WAAS,YAAU;AAC1B,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,eAAW;AAAA,UACT;AAAA,UACA,YAAY,yBAAyB;AAAA,UACrC;AAAA,QACF;AAAA,QACA,cAAY,WAAW,aAAa;AAAA,QACpC,MAAK;AAAA,SACD,OATL;AAAA,QAWE;AAAA;AAAA,UACD,6CAAC,UAAK,eAAW,6BAAK,qBAAqB,GAAG;AAAA;AAAA;AAAA,IAChD;AAAA,EAEJ;AACF;AACA,eAAe,cAAc;","names":["import_react","_a","_b","import_react","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../../src/show-more/index.ts","../../src/show-more/show-more.tsx"],"sourcesContent":["export { ShowMoreButton } from \"./show-more\";\nexport type * from \"./show-more\";\n","import { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef } from \"react\";\n\ntype Variant =\n | {\n variant?: \"show-more\";\n expanded?: never;\n }\n | {\n variant: \"show-more-show-less\";\n expanded: boolean;\n };\n\nexport type ShowMoreProps = React.HTMLAttributes<HTMLButtonElement> & {\n text: React.ReactNode;\n} & Variant;\n\n/**\n * Simple button for triggering more content.\n *\n * You have to add the logic for what happens when the button is clicked yourself.\n *\n * @example\n * ```tsx\n * function Content() {\n * const [items, fetchMoreItems, moreItemsAvailable] = useYourData();\n * function onShowMoreItems() {\n * fetchMoreItems();\n * }\n * return (\n * <>\n * <ul>\n * {items.map((item) => (\n * <li key={item.id}>{item.text}</li>\n * ))}\n * </ul>\n * {moreItemsAvailable ?\n * <ShowMoreButton className=\"mt-8\" onClick={onShowMoreItems} lang=\"en\" /> :\n * null\n * }\n * </>\n * )\n * }\n * ```\n */\nexport const ShowMoreButton = forwardRef<HTMLButtonElement, ShowMoreProps>(\n ({ text, variant, expanded, className, ...rest }, ref) => {\n return (\n <button\n ref={ref}\n className={clsx(\n \"hds-show-more\",\n variant === \"show-more-show-less\" && \"hds-show-more--show-less\",\n className as undefined,\n )}\n data-state={expanded ? \"expanded\" : undefined}\n type=\"button\"\n {...rest}\n >\n {text}\n <span className={clsx(\"hds-show-more__icon\")} />\n </button>\n );\n },\n);\nShowMoreButton.displayName = \"ShowMoreButton\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,6BAAqB;AACrB,mBAA2B;AA+CrB;AAHC,IAAM,qBAAiB;AAAA,EAC5B,CAAC,IAAiD,QAAQ;AAAzD,iBAAE,QAAM,SAAS,UAAU,UA9C9B,IA8CG,IAAyC,iBAAzC,IAAyC,CAAvC,QAAM,WAAS,YAAU;AAC1B,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,eAAW;AAAA,UACT;AAAA,UACA,YAAY,yBAAyB;AAAA,UACrC;AAAA,QACF;AAAA,QACA,cAAY,WAAW,aAAa;AAAA,QACpC,MAAK;AAAA,SACD,OATL;AAAA,QAWE;AAAA;AAAA,UACD,4CAAC,UAAK,eAAW,6BAAK,qBAAqB,GAAG;AAAA;AAAA;AAAA,IAChD;AAAA,EAEJ;AACF;AACA,eAAe,cAAc;","names":[]}
@@ -1,14 +1,9 @@
1
- import "../chunk-MSFHJVHD.mjs";
1
+ import "../chunk-SRLM3K2X.mjs";
2
2
  import {
3
3
  ShowMoreButton
4
4
  } from "../chunk-UB2R7TCG.mjs";
5
- import {
6
- AutoAnimateHeight
7
- } from "../chunk-67TP3E2D.mjs";
8
- import "../chunk-DEX36MFK.mjs";
9
5
  import "../chunk-R4SQKVDQ.mjs";
10
6
  export {
11
- AutoAnimateHeight,
12
7
  ShowMoreButton
13
8
  };
14
9
  //# sourceMappingURL=index.mjs.map
@@ -115,7 +115,7 @@ TabsContent.displayName = "Tabs.Content";
115
115
  var import_react4 = require("react");
116
116
  var import_typed_classname2 = require("@postenbring/hedwig-css/typed-classname");
117
117
 
118
- // src/utils.ts
118
+ // src/utils/utils.ts
119
119
  var React = __toESM(require("react"));
120
120
  var import_react3 = require("react");
121
121
  function useMergeRefs(refs) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tabs/index.tsx","../../src/tabs/tabs.tsx","../../src/tabs/context.ts","../../src/tabs/tabs-content.tsx","../../src/tabs/tabs-list.tsx","../../src/utils.ts"],"sourcesContent":["export { Tabs } from \"./tabs\";\nexport { TabsList, TabsTab } from \"./tabs-list\";\nexport { TabsContents, TabsContent } from \"./tabs-content\";\n\nexport type * from \"./tabs\";\nexport type * from \"./tabs-list\";\nexport type * from \"./tabs-content\";\n","import type { HTMLAttributes, ReactElement } from \"react\";\nimport { forwardRef, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { TabsContext } from \"./context\";\nimport { TabsContent, TabsContents, type TabsContentsProps } from \"./tabs-content\";\nimport { TabsList, TabsTab, type TabsListProps } from \"./tabs-list\";\n\nexport interface TabsProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactElement<TabsListProps | TabsContentsProps>[] | ReactElement;\n\n /**\n * Define which tab to use as default. Must be one of the <Tab/>s identifier.\n */\n defaultTab: string;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Tabs = forwardRef<HTMLDivElement, TabsProps>(\n ({ asChild, defaultTab, children, ...rest }, ref) => {\n const [activeTabId, setActiveTabId] = useState<string>(defaultTab);\n const Component = asChild ? Slot : \"div\";\n return (\n <Component className={clsx(\"hds-tabs\")} ref={ref} {...rest}>\n <TabsContext.Provider value={{ activeTabId, toggleActiveTabId: setActiveTabId }}>\n {children}\n </TabsContext.Provider>\n </Component>\n );\n },\n) as TabsType;\nTabs.displayName = \"Tabs\";\n\ntype TabsType = ReturnType<typeof forwardRef<HTMLDivElement, TabsProps>> & {\n List: typeof TabsList;\n Tab: typeof TabsTab;\n Contents: typeof TabsContents;\n Content: typeof TabsContent;\n};\n\nTabs.List = TabsList;\nTabs.Tab = TabsTab;\nTabs.Contents = TabsContents;\nTabs.Content = TabsContent;\n","import { createContext, useContext } from \"react\";\n\nexport interface TabsContextProps {\n activeTabId: string;\n toggleActiveTabId: (tabId: string) => void;\n}\n\nexport const TabsContext = createContext<TabsContextProps | null>(null);\n\nexport function useTabsContext() {\n const context = useContext(TabsContext);\n if (!context) {\n throw new Error(\n \"Tabs context required. Did you use `<Tabs.List />`, `<Tabs.Tab />`, or `<Tabs.Content />` outside of <Tabs/>?\",\n );\n }\n return context;\n}\n","import type { HTMLAttributes, ReactElement } from \"react\";\nimport { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { useTabsContext } from \"./context\";\n\nexport interface TabsContentsProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactElement<TabsContentProps> | ReactElement<TabsContentProps>[];\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const TabsContents = forwardRef<HTMLDivElement, TabsContentsProps>(\n ({ asChild, children, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component ref={ref} className={clsx(\"hds-tabs__contents\")} {...rest}>\n {children}\n </Component>\n );\n },\n);\nTabsContents.displayName = \"Tabs.Contents\";\n\nexport interface TabsContentProps extends HTMLAttributes<HTMLElement> {\n children: ReactElement<HTMLElement> | ReactElement<HTMLElement>[] | string;\n\n /**\n * Content for the referenced tabId\n */\n forTabId: string;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const TabsContent = forwardRef<HTMLDivElement, TabsContentProps>(\n ({ asChild, forTabId, children, ...rest }, ref) => {\n const context = useTabsContext();\n const Component = asChild ? Slot : \"div\";\n\n if (context.activeTabId === forTabId) {\n return (\n <Component {...rest} ref={ref}>\n {children}\n </Component>\n );\n }\n return null;\n },\n);\n\nTabsContent.displayName = \"Tabs.Content\";\n","import type { HTMLAttributes, ReactElement, MouseEvent } from \"react\";\nimport { forwardRef, useEffect, useRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { useResize, useHydrated, useMergeRefs } from \"../utils\";\nimport { useTabsContext } from \"./context\";\n\nexport interface TabsListProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactElement<TabsTabProps> | ReactElement<TabsTabProps>[];\n\n /**\n * Direction of the tabs. Can either be vertical or horizontal.\n * Horizontal breaks on window width with fallback back to vertical\n *\n * @default \"horizontal\"\n */\n direction?: \"vertical\" | \"horizontal\";\n}\n\nexport const TabsList = forwardRef<HTMLDivElement, TabsListProps>(\n ({ children, direction = \"horizontal\", className, ...rest }, ref) => {\n const { activeTabId } = useTabsContext();\n const tabsListRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([tabsListRef, ref]);\n const { width: tabsWidth } = useResize(tabsListRef);\n\n const isClientSide = useHydrated();\n const { innerWidth } = isClientSide ? window : { innerWidth: 1000 };\n const wideEnough = innerWidth >= tabsWidth;\n\n const previousTabId = useRef(activeTabId);\n\n // Marker animation\n useEffect(() => {\n const tabList = tabsListRef.current;\n const activeTab = tabList?.querySelector(`[data-tabid=\"${activeTabId}\"]`);\n if (!activeTab || !tabList) return;\n\n const { offsetHeight: containerHeight, offsetWidth: containerWidth } = tabList;\n const { offsetHeight, offsetWidth, offsetTop, offsetLeft } = activeTab as HTMLElement;\n\n // Calculate the height and width of the marker relative to the container\n const height = offsetHeight / containerHeight;\n const width = offsetWidth / containerWidth;\n\n // NOTE: Doing a DOM manipulation here to set the CSS variables for the marker\n // Not really the react idomatic way, but as long as it works we are able to skip some intermidiate `useState`\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-height\", String(height));\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-width\", String(width));\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-top\", `${offsetTop}px`);\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-left\", `${offsetLeft}px`);\n\n // Start with border fallback, then switch to the animated marker when the user changes tabs\n // This way the marker is placed immediately to the default tab, then animates smoothly to the next when selected\n if (previousTabId.current !== activeTabId) {\n tabsListRef.current.style.setProperty(\n \"--_hds-tabs-marker-animated-color\",\n \"var(--_hds-tabs-marker-color)\",\n );\n tabsListRef.current.style.setProperty(\n \"--_hds-tabs-marker-border-fallback-color\",\n \"transparent\",\n );\n }\n previousTabId.current = activeTabId;\n }, [activeTabId, innerWidth]);\n\n return (\n <div\n className={clsx(\n \"hds-tabs__list\",\n direction === \"horizontal\"\n ? {\n \"hds-tabs__list--horizontal\": wideEnough,\n \"hds-tabs__list--vertical\": !wideEnough,\n }\n : {\n \"hds-tabs__list--vertical\": true,\n },\n className as undefined,\n )}\n ref={mergedRef}\n role=\"tablist\"\n {...rest}\n >\n {children}\n </div>\n );\n },\n);\nTabsList.displayName = \"Tabs.List\";\n\nexport interface TabsTabProps extends HTMLAttributes<HTMLButtonElement> {\n children: ReactElement<HTMLElement> | string;\n\n /**\n * Identifier for the tab\n */\n tabId: string;\n}\n\nexport const TabsTab = forwardRef<HTMLButtonElement, TabsTabProps>(\n ({ children, tabId, className, onClick, ...rest }, ref) => {\n const context = useTabsContext();\n\n const toggleTab = (e: MouseEvent<HTMLButtonElement>) => {\n e.preventDefault();\n context.toggleActiveTabId(tabId);\n onClick?.(e);\n };\n return (\n <button\n className={clsx(\n \"hds-tabs__tab\",\n { \"hds-tabs__tab--active\": context.activeTabId === tabId },\n className as undefined,\n )}\n data-tabid={tabId}\n onClick={toggleTab}\n ref={ref}\n type=\"button\"\n role=\"tab\"\n {...rest}\n >\n {children}\n </button>\n );\n },\n);\nTabsTab.displayName = \"Tabs.Tab\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nexport function releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,IAAAA,gBAAqC;AACrC,IAAAC,0BAAqB;AACrB,IAAAC,qBAAqB;;;ACHrB,mBAA0C;AAOnC,IAAM,kBAAc,4BAAuC,IAAI;AAE/D,SAAS,iBAAiB;AAC/B,QAAM,cAAU,yBAAW,WAAW;AACtC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;;;AChBA,IAAAC,gBAA2B;AAC3B,6BAAqB;AACrB,wBAAqB;AAkBf;AAJC,IAAM,mBAAe;AAAA,EAC1B,CAAC,IAAgC,QAAQ;AAAxC,iBAAE,WAAS,SAlBd,IAkBG,IAAwB,iBAAxB,IAAwB,CAAtB,WAAS;AACV,UAAM,YAAY,UAAU,yBAAO;AACnC,WACE,4CAAC,0CAAU,KAAU,eAAW,6BAAK,oBAAoB,KAAO,OAA/D,EACE,WACH;AAAA,EAEJ;AACF;AACA,aAAa,cAAc;AAkBpB,IA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Gd,IAAAC,sBAAA;AAND,IAAM,WAAO;AAAA,EAClB,CAAC,IAA4C,QAAQ;AAApD,iBAAE,WAAS,YAAY,SAzB1B,IAyBG,IAAoC,iBAApC,IAAoC,CAAlC,WAAS,cAAY;AACtB,UAAM,CAAC,aAAa,cAAc,QAAI,wBAAiB,UAAU;AACjE,UAAM,YAAY,UAAU,0BAAO;AACnC,WACE,6CAAC,0CAAU,eAAW,8BAAK,UAAU,GAAG,OAAc,OAArD,EACC,uDAAC,YAAY,UAAZ,EAAqB,OAAO,EAAE,aAAa,mBAAmB,eAAe,GAC3E,UACH,IACF;AAAA,EAEJ;AACF;AACA,KAAK,cAAc;AASnB,KAAK,OAAO;AACZ,KAAK,MAAM;AACX,KAAK,WAAW;AAChB,KAAK,UAAU;","names":["import_react","import_typed_classname","import_react_slot","import_react","import_react","import_typed_classname","import_react","import_jsx_runtime","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../../src/tabs/index.tsx","../../src/tabs/tabs.tsx","../../src/tabs/context.ts","../../src/tabs/tabs-content.tsx","../../src/tabs/tabs-list.tsx","../../src/utils/utils.ts"],"sourcesContent":["export { Tabs } from \"./tabs\";\nexport { TabsList, TabsTab } from \"./tabs-list\";\nexport { TabsContents, TabsContent } from \"./tabs-content\";\n\nexport type * from \"./tabs\";\nexport type * from \"./tabs-list\";\nexport type * from \"./tabs-content\";\n","import type { HTMLAttributes, ReactElement } from \"react\";\nimport { forwardRef, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { TabsContext } from \"./context\";\nimport { TabsContent, TabsContents, type TabsContentsProps } from \"./tabs-content\";\nimport { TabsList, TabsTab, type TabsListProps } from \"./tabs-list\";\n\nexport interface TabsProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactElement<TabsListProps | TabsContentsProps>[] | ReactElement;\n\n /**\n * Define which tab to use as default. Must be one of the <Tab/>s identifier.\n */\n defaultTab: string;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Tabs = forwardRef<HTMLDivElement, TabsProps>(\n ({ asChild, defaultTab, children, ...rest }, ref) => {\n const [activeTabId, setActiveTabId] = useState<string>(defaultTab);\n const Component = asChild ? Slot : \"div\";\n return (\n <Component className={clsx(\"hds-tabs\")} ref={ref} {...rest}>\n <TabsContext.Provider value={{ activeTabId, toggleActiveTabId: setActiveTabId }}>\n {children}\n </TabsContext.Provider>\n </Component>\n );\n },\n) as TabsType;\nTabs.displayName = \"Tabs\";\n\ntype TabsType = ReturnType<typeof forwardRef<HTMLDivElement, TabsProps>> & {\n List: typeof TabsList;\n Tab: typeof TabsTab;\n Contents: typeof TabsContents;\n Content: typeof TabsContent;\n};\n\nTabs.List = TabsList;\nTabs.Tab = TabsTab;\nTabs.Contents = TabsContents;\nTabs.Content = TabsContent;\n","import { createContext, useContext } from \"react\";\n\nexport interface TabsContextProps {\n activeTabId: string;\n toggleActiveTabId: (tabId: string) => void;\n}\n\nexport const TabsContext = createContext<TabsContextProps | null>(null);\n\nexport function useTabsContext() {\n const context = useContext(TabsContext);\n if (!context) {\n throw new Error(\n \"Tabs context required. Did you use `<Tabs.List />`, `<Tabs.Tab />`, or `<Tabs.Content />` outside of <Tabs/>?\",\n );\n }\n return context;\n}\n","import type { HTMLAttributes, ReactElement } from \"react\";\nimport { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { useTabsContext } from \"./context\";\n\nexport interface TabsContentsProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactElement<TabsContentProps> | ReactElement<TabsContentProps>[];\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const TabsContents = forwardRef<HTMLDivElement, TabsContentsProps>(\n ({ asChild, children, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component ref={ref} className={clsx(\"hds-tabs__contents\")} {...rest}>\n {children}\n </Component>\n );\n },\n);\nTabsContents.displayName = \"Tabs.Contents\";\n\nexport interface TabsContentProps extends HTMLAttributes<HTMLElement> {\n children: ReactElement<HTMLElement> | ReactElement<HTMLElement>[] | string;\n\n /**\n * Content for the referenced tabId\n */\n forTabId: string;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const TabsContent = forwardRef<HTMLDivElement, TabsContentProps>(\n ({ asChild, forTabId, children, ...rest }, ref) => {\n const context = useTabsContext();\n const Component = asChild ? Slot : \"div\";\n\n if (context.activeTabId === forTabId) {\n return (\n <Component {...rest} ref={ref}>\n {children}\n </Component>\n );\n }\n return null;\n },\n);\n\nTabsContent.displayName = \"Tabs.Content\";\n","import type { HTMLAttributes, ReactElement, MouseEvent } from \"react\";\nimport { forwardRef, useEffect, useRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { useResize, useHydrated, useMergeRefs } from \"../utils/utils\";\nimport { useTabsContext } from \"./context\";\n\nexport interface TabsListProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactElement<TabsTabProps> | ReactElement<TabsTabProps>[];\n\n /**\n * Direction of the tabs. Can either be vertical or horizontal.\n * Horizontal breaks on window width with fallback back to vertical\n *\n * @default \"horizontal\"\n */\n direction?: \"vertical\" | \"horizontal\";\n}\n\nexport const TabsList = forwardRef<HTMLDivElement, TabsListProps>(\n ({ children, direction = \"horizontal\", className, ...rest }, ref) => {\n const { activeTabId } = useTabsContext();\n const tabsListRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([tabsListRef, ref]);\n const { width: tabsWidth } = useResize(tabsListRef);\n\n const isClientSide = useHydrated();\n const { innerWidth } = isClientSide ? window : { innerWidth: 1000 };\n const wideEnough = innerWidth >= tabsWidth;\n\n const previousTabId = useRef(activeTabId);\n\n // Marker animation\n useEffect(() => {\n const tabList = tabsListRef.current;\n const activeTab = tabList?.querySelector(`[data-tabid=\"${activeTabId}\"]`);\n if (!activeTab || !tabList) return;\n\n const { offsetHeight: containerHeight, offsetWidth: containerWidth } = tabList;\n const { offsetHeight, offsetWidth, offsetTop, offsetLeft } = activeTab as HTMLElement;\n\n // Calculate the height and width of the marker relative to the container\n const height = offsetHeight / containerHeight;\n const width = offsetWidth / containerWidth;\n\n // NOTE: Doing a DOM manipulation here to set the CSS variables for the marker\n // Not really the react idomatic way, but as long as it works we are able to skip some intermidiate `useState`\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-height\", String(height));\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-width\", String(width));\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-top\", `${offsetTop}px`);\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-left\", `${offsetLeft}px`);\n\n // Start with border fallback, then switch to the animated marker when the user changes tabs\n // This way the marker is placed immediately to the default tab, then animates smoothly to the next when selected\n if (previousTabId.current !== activeTabId) {\n tabsListRef.current.style.setProperty(\n \"--_hds-tabs-marker-animated-color\",\n \"var(--_hds-tabs-marker-color)\",\n );\n tabsListRef.current.style.setProperty(\n \"--_hds-tabs-marker-border-fallback-color\",\n \"transparent\",\n );\n }\n previousTabId.current = activeTabId;\n }, [activeTabId, innerWidth]);\n\n return (\n <div\n className={clsx(\n \"hds-tabs__list\",\n direction === \"horizontal\"\n ? {\n \"hds-tabs__list--horizontal\": wideEnough,\n \"hds-tabs__list--vertical\": !wideEnough,\n }\n : {\n \"hds-tabs__list--vertical\": true,\n },\n className as undefined,\n )}\n ref={mergedRef}\n role=\"tablist\"\n {...rest}\n >\n {children}\n </div>\n );\n },\n);\nTabsList.displayName = \"Tabs.List\";\n\nexport interface TabsTabProps extends HTMLAttributes<HTMLButtonElement> {\n children: ReactElement<HTMLElement> | string;\n\n /**\n * Identifier for the tab\n */\n tabId: string;\n}\n\nexport const TabsTab = forwardRef<HTMLButtonElement, TabsTabProps>(\n ({ children, tabId, className, onClick, ...rest }, ref) => {\n const context = useTabsContext();\n\n const toggleTab = (e: MouseEvent<HTMLButtonElement>) => {\n e.preventDefault();\n context.toggleActiveTabId(tabId);\n onClick?.(e);\n };\n return (\n <button\n className={clsx(\n \"hds-tabs__tab\",\n { \"hds-tabs__tab--active\": context.activeTabId === tabId },\n className as undefined,\n )}\n data-tabid={tabId}\n onClick={toggleTab}\n ref={ref}\n type=\"button\"\n role=\"tab\"\n {...rest}\n >\n {children}\n </button>\n );\n },\n);\nTabsTab.displayName = \"Tabs.Tab\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nfunction releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,IAAAA,gBAAqC;AACrC,IAAAC,0BAAqB;AACrB,IAAAC,qBAAqB;;;ACHrB,mBAA0C;AAOnC,IAAM,kBAAc,4BAAuC,IAAI;AAE/D,SAAS,iBAAiB;AAC/B,QAAM,cAAU,yBAAW,WAAW;AACtC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR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AC,MAAqC;AACtD,QAAE,eAAe;AACjB,cAAQ,kBAAkB,KAAK;AAC/B,yCAAU;AAAA,IACZ;AACA,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW;AAAA,UACT;AAAA,UACA,EAAE,yBAAyB,QAAQ,gBAAgB,MAAM;AAAA,UACzD;AAAA,QACF;AAAA,QACA,cAAY;AAAA,QACZ,SAAS;AAAA,QACT;AAAA,QACA,MAAK;AAAA,QACL,MAAK;AAAA,SACD,OAXL;AAAA,QAaE;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,QAAQ,cAAc;;;AHlGd,IAAAC,sBAAA;AAND,IAAM,WAAO;AAAA,EAClB,CAAC,IAA4C,QAAQ;AAApD,iBAAE,WAAS,YAAY,SAzB1B,IAyBG,IAAoC,iBAApC,IAAoC,CAAlC,WAAS,cAAY;AACtB,UAAM,CAAC,aAAa,cAAc,QAAI,wBAAiB,UAAU;AACjE,UAAM,YAAY,UAAU,0BAAO;AACnC,WACE,6CAAC,0CAAU,eAAW,8BAAK,UAAU,GAAG,OAAc,OAArD,EACC,uDAAC,YAAY,UAAZ,EAAqB,OAAO,EAAE,aAAa,mBAAmB,eAAe,GAC3E,UACH,IACF;AAAA,EAEJ;AACF;AACA,KAAK,cAAc;AASnB,KAAK,OAAO;AACZ,KAAK,MAAM;AACX,KAAK,WAAW;AAChB,KAAK,UAAU;","names":["import_react","import_typed_classname","import_react_slot","import_react","import_react","import_typed_classname","import_react","import_jsx_runtime","import_jsx_runtime"]}
@@ -1,17 +1,17 @@
1
1
  import "../chunk-7YWW46R3.mjs";
2
2
  import {
3
3
  Tabs
4
- } from "../chunk-7UD72WOC.mjs";
4
+ } from "../chunk-QZZIOBF4.mjs";
5
5
  import {
6
6
  TabsList,
7
7
  TabsTab
8
- } from "../chunk-4WQWU5TL.mjs";
8
+ } from "../chunk-AXQCREUJ.mjs";
9
9
  import {
10
10
  TabsContent,
11
11
  TabsContents
12
12
  } from "../chunk-CCVZAHYA.mjs";
13
13
  import "../chunk-KQITCS3U.mjs";
14
- import "../chunk-DEX36MFK.mjs";
14
+ import "../chunk-TDXU2IC6.mjs";
15
15
  import "../chunk-R4SQKVDQ.mjs";
16
16
  export {
17
17
  Tabs,
@@ -66,7 +66,7 @@ module.exports = __toCommonJS(tabs_list_exports);
66
66
  var import_react3 = require("react");
67
67
  var import_typed_classname = require("@postenbring/hedwig-css/typed-classname");
68
68
 
69
- // src/utils.ts
69
+ // src/utils/utils.ts
70
70
  var React = __toESM(require("react"));
71
71
  var import_react = require("react");
72
72
  function useMergeRefs(refs) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tabs/tabs-list.tsx","../../src/utils.ts","../../src/tabs/context.ts"],"sourcesContent":["import type { HTMLAttributes, ReactElement, MouseEvent } from \"react\";\nimport { forwardRef, useEffect, useRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { useResize, useHydrated, useMergeRefs } from \"../utils\";\nimport { useTabsContext } from \"./context\";\n\nexport interface TabsListProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactElement<TabsTabProps> | ReactElement<TabsTabProps>[];\n\n /**\n * Direction of the tabs. Can either be vertical or horizontal.\n * Horizontal breaks on window width with fallback back to vertical\n *\n * @default \"horizontal\"\n */\n direction?: \"vertical\" | \"horizontal\";\n}\n\nexport const TabsList = forwardRef<HTMLDivElement, TabsListProps>(\n ({ children, direction = \"horizontal\", className, ...rest }, ref) => {\n const { activeTabId } = useTabsContext();\n const tabsListRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([tabsListRef, ref]);\n const { width: tabsWidth } = useResize(tabsListRef);\n\n const isClientSide = useHydrated();\n const { innerWidth } = isClientSide ? window : { innerWidth: 1000 };\n const wideEnough = innerWidth >= tabsWidth;\n\n const previousTabId = useRef(activeTabId);\n\n // Marker animation\n useEffect(() => {\n const tabList = tabsListRef.current;\n const activeTab = tabList?.querySelector(`[data-tabid=\"${activeTabId}\"]`);\n if (!activeTab || !tabList) return;\n\n const { offsetHeight: containerHeight, offsetWidth: containerWidth } = tabList;\n const { offsetHeight, offsetWidth, offsetTop, offsetLeft } = activeTab as HTMLElement;\n\n // Calculate the height and width of the marker relative to the container\n const height = offsetHeight / containerHeight;\n const width = offsetWidth / containerWidth;\n\n // NOTE: Doing a DOM manipulation here to set the CSS variables for the marker\n // Not really the react idomatic way, but as long as it works we are able to skip some intermidiate `useState`\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-height\", String(height));\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-width\", String(width));\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-top\", `${offsetTop}px`);\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-left\", `${offsetLeft}px`);\n\n // Start with border fallback, then switch to the animated marker when the user changes tabs\n // This way the marker is placed immediately to the default tab, then animates smoothly to the next when selected\n if (previousTabId.current !== activeTabId) {\n tabsListRef.current.style.setProperty(\n \"--_hds-tabs-marker-animated-color\",\n \"var(--_hds-tabs-marker-color)\",\n );\n tabsListRef.current.style.setProperty(\n \"--_hds-tabs-marker-border-fallback-color\",\n \"transparent\",\n );\n }\n previousTabId.current = activeTabId;\n }, [activeTabId, innerWidth]);\n\n return (\n <div\n className={clsx(\n \"hds-tabs__list\",\n direction === \"horizontal\"\n ? {\n \"hds-tabs__list--horizontal\": wideEnough,\n \"hds-tabs__list--vertical\": !wideEnough,\n }\n : {\n \"hds-tabs__list--vertical\": true,\n },\n className as undefined,\n )}\n ref={mergedRef}\n role=\"tablist\"\n {...rest}\n >\n {children}\n </div>\n );\n },\n);\nTabsList.displayName = \"Tabs.List\";\n\nexport interface TabsTabProps extends HTMLAttributes<HTMLButtonElement> {\n children: ReactElement<HTMLElement> | string;\n\n /**\n * Identifier for the tab\n */\n tabId: string;\n}\n\nexport const TabsTab = forwardRef<HTMLButtonElement, TabsTabProps>(\n ({ children, tabId, className, onClick, ...rest }, ref) => {\n const context = useTabsContext();\n\n const toggleTab = (e: MouseEvent<HTMLButtonElement>) => {\n e.preventDefault();\n context.toggleActiveTabId(tabId);\n onClick?.(e);\n };\n return (\n <button\n className={clsx(\n \"hds-tabs__tab\",\n { \"hds-tabs__tab--active\": context.activeTabId === tabId },\n className as undefined,\n )}\n data-tabid={tabId}\n onClick={toggleTab}\n ref={ref}\n type=\"button\"\n role=\"tab\"\n {...rest}\n >\n {children}\n </button>\n );\n },\n);\nTabsTab.displayName = \"Tabs.Tab\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nexport function releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n","import { createContext, useContext } from \"react\";\n\nexport interface TabsContextProps {\n activeTabId: string;\n toggleActiveTabId: (tabId: string) => void;\n}\n\nexport const TabsContext = createContext<TabsContextProps | null>(null);\n\nexport function useTabsContext() {\n const context = useContext(TabsContext);\n if (!context) {\n throw new Error(\n \"Tabs context required. Did you use `<Tabs.List />`, `<Tabs.Tab />`, or `<Tabs.Content />` outside of <Tabs/>?\",\n );\n }\n return context;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAAA,gBAA8C;AAC9C,6BAAqB;;;ACFrB,YAAuB;AACvB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ACF;AACA,oBAAY,QAAQ,MAAM;AAAA,UACxB;AAAA,UACA;AAAA,QACF;AAAA,MACF;AACA,oBAAc,UAAU;AAAA,IAC1B,GAAG,CAAC,aAAa,UAAU,CAAC;AAE5B,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW;AAAA,UACT;AAAA,UACA,cAAc,eACV;AAAA,YACE,8BAA8B;AAAA,YAC9B,4BAA4B,CAAC;AAAA,UAC/B,IACA;AAAA,YACE,4BAA4B;AAAA,UAC9B;AAAA,UACJ;AAAA,QACF;AAAA,QACA,KAAK;AAAA,QACL,MAAK;AAAA,SACD,OAfL;AAAA,QAiBE;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,SAAS,cAAc;AAWhB,IAAM,cAAU;AAAA,EACrB,CAAC,IAAkD,QAAQ;AAA1D,iBAAE,YAAU,OAAO,WAAW,QArGjC,IAqGG,IAA0C,iBAA1C,IAA0C,CAAxC,YAAU,SAAO,aAAW;AAC7B,UAAM,UAAU,eAAe;AAE/B,UAAM,YAAY,CAAC,MAAqC;AACtD,QAAE,eAAe;AACjB,cAAQ,kBAAkB,KAAK;AAC/B,yCAAU;AAAA,IACZ;AACA,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW;AAAA,UACT;AAAA,UACA,EAAE,yBAAyB,QAAQ,gBAAgB,MAAM;AAAA,UACzD;AAAA,QACF;AAAA,QACA,cAAY;AAAA,QACZ,SAAS;AAAA,QACT;AAAA,QACA,MAAK;AAAA,QACL,MAAK;AAAA,SACD,OAXL;AAAA,QAaE;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,QAAQ,cAAc;","names":["import_react","import_react"]}
1
+ {"version":3,"sources":["../../src/tabs/tabs-list.tsx","../../src/utils/utils.ts","../../src/tabs/context.ts"],"sourcesContent":["import type { HTMLAttributes, ReactElement, MouseEvent } from \"react\";\nimport { forwardRef, useEffect, useRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { useResize, useHydrated, useMergeRefs } from \"../utils/utils\";\nimport { useTabsContext } from \"./context\";\n\nexport interface TabsListProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactElement<TabsTabProps> | ReactElement<TabsTabProps>[];\n\n /**\n * Direction of the tabs. Can either be vertical or horizontal.\n * Horizontal breaks on window width with fallback back to vertical\n *\n * @default \"horizontal\"\n */\n direction?: \"vertical\" | \"horizontal\";\n}\n\nexport const TabsList = forwardRef<HTMLDivElement, TabsListProps>(\n ({ children, direction = \"horizontal\", className, ...rest }, ref) => {\n const { activeTabId } = useTabsContext();\n const tabsListRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([tabsListRef, ref]);\n const { width: tabsWidth } = useResize(tabsListRef);\n\n const isClientSide = useHydrated();\n const { innerWidth } = isClientSide ? window : { innerWidth: 1000 };\n const wideEnough = innerWidth >= tabsWidth;\n\n const previousTabId = useRef(activeTabId);\n\n // Marker animation\n useEffect(() => {\n const tabList = tabsListRef.current;\n const activeTab = tabList?.querySelector(`[data-tabid=\"${activeTabId}\"]`);\n if (!activeTab || !tabList) return;\n\n const { offsetHeight: containerHeight, offsetWidth: containerWidth } = tabList;\n const { offsetHeight, offsetWidth, offsetTop, offsetLeft } = activeTab as HTMLElement;\n\n // Calculate the height and width of the marker relative to the container\n const height = offsetHeight / containerHeight;\n const width = offsetWidth / containerWidth;\n\n // NOTE: Doing a DOM manipulation here to set the CSS variables for the marker\n // Not really the react idomatic way, but as long as it works we are able to skip some intermidiate `useState`\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-height\", String(height));\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-width\", String(width));\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-top\", `${offsetTop}px`);\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-left\", `${offsetLeft}px`);\n\n // Start with border fallback, then switch to the animated marker when the user changes tabs\n // This way the marker is placed immediately to the default tab, then animates smoothly to the next when selected\n if (previousTabId.current !== activeTabId) {\n tabsListRef.current.style.setProperty(\n \"--_hds-tabs-marker-animated-color\",\n \"var(--_hds-tabs-marker-color)\",\n );\n tabsListRef.current.style.setProperty(\n \"--_hds-tabs-marker-border-fallback-color\",\n \"transparent\",\n );\n }\n previousTabId.current = activeTabId;\n }, [activeTabId, innerWidth]);\n\n return (\n <div\n className={clsx(\n \"hds-tabs__list\",\n direction === \"horizontal\"\n ? {\n \"hds-tabs__list--horizontal\": wideEnough,\n \"hds-tabs__list--vertical\": !wideEnough,\n }\n : {\n \"hds-tabs__list--vertical\": true,\n },\n className as undefined,\n )}\n ref={mergedRef}\n role=\"tablist\"\n {...rest}\n >\n {children}\n </div>\n );\n },\n);\nTabsList.displayName = \"Tabs.List\";\n\nexport interface TabsTabProps extends HTMLAttributes<HTMLButtonElement> {\n children: ReactElement<HTMLElement> | string;\n\n /**\n * Identifier for the tab\n */\n tabId: string;\n}\n\nexport const TabsTab = forwardRef<HTMLButtonElement, TabsTabProps>(\n ({ children, tabId, className, onClick, ...rest }, ref) => {\n const context = useTabsContext();\n\n const toggleTab = (e: MouseEvent<HTMLButtonElement>) => {\n e.preventDefault();\n context.toggleActiveTabId(tabId);\n onClick?.(e);\n };\n return (\n <button\n className={clsx(\n \"hds-tabs__tab\",\n { \"hds-tabs__tab--active\": context.activeTabId === tabId },\n className as undefined,\n )}\n data-tabid={tabId}\n onClick={toggleTab}\n ref={ref}\n type=\"button\"\n role=\"tab\"\n {...rest}\n >\n {children}\n </button>\n );\n },\n);\nTabsTab.displayName = \"Tabs.Tab\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nfunction releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n","import { createContext, useContext } from \"react\";\n\nexport interface TabsContextProps {\n activeTabId: string;\n toggleActiveTabId: (tabId: string) => void;\n}\n\nexport const TabsContext = createContext<TabsContextProps | null>(null);\n\nexport function useTabsContext() {\n const context = useContext(TabsContext);\n if (!context) {\n throw new Error(\n \"Tabs context required. Did you use `<Tabs.List />`, `<Tabs.Tab />`, or `<Tabs.Content />` outside of <Tabs/>?\",\n );\n }\n return context;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAAA,gBAA8C;AAC9C,6BAAqB;;;ACFrB,YAAuB;AACvB,mBAAiD;AAM1C,SAAS,aACd,MACoC;AACpC,SAAa,cAAQ,MAAM;AACzB,QAAI,KAAK,MAAM,CAAC,QAAQ,QAAQ,IAAI,GAAG;AACrC,aAAO;AAAA,IACT;AAEA,WAAO,CAAC,UAAU;AAChB,WAAK,QAAQ,CAAC,QAAQ;AACpB,YAAI,OAAO,QAAQ,YAAY;AAC7B,cAAI,KAAK;AAAA,QACX,WAAW,QAAQ,MAAM;AACvB,UAAC,IAAgD,UAAU;AAAA,QAC7D;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EAEF,GAAG,IAAI;AACT;AAEO,SAAS,UACd,KACmC;AACnC,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAiB,CAAC;AAC5C,QAAM,CAAC,QAAQ,SAAS,QAAI,uBAAiB,CAAC;AAC9C,QAAM,mBAAe,0BAAY,MAAM;AAjCzC;AAkCI,SAAI,2BAAK,aAAY,M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0C,CAAxC,YAAU,SAAO,aAAW;AAC7B,UAAM,UAAU,eAAe;AAE/B,UAAM,YAAY,CAAC,MAAqC;AACtD,QAAE,eAAe;AACjB,cAAQ,kBAAkB,KAAK;AAC/B,yCAAU;AAAA,IACZ;AACA,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW;AAAA,UACT;AAAA,UACA,EAAE,yBAAyB,QAAQ,gBAAgB,MAAM;AAAA,UACzD;AAAA,QACF;AAAA,QACA,cAAY;AAAA,QACZ,SAAS;AAAA,QACT;AAAA,QACA,MAAK;AAAA,QACL,MAAK;AAAA,SACD,OAXL;AAAA,QAaE;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,QAAQ,cAAc;","names":["import_react","import_react"]}
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  TabsList,
3
3
  TabsTab
4
- } from "../chunk-4WQWU5TL.mjs";
4
+ } from "../chunk-AXQCREUJ.mjs";
5
5
  import "../chunk-KQITCS3U.mjs";
6
- import "../chunk-DEX36MFK.mjs";
6
+ import "../chunk-TDXU2IC6.mjs";
7
7
  import "../chunk-R4SQKVDQ.mjs";
8
8
  export {
9
9
  TabsList,
package/dist/tabs/tabs.js CHANGED
@@ -109,7 +109,7 @@ TabsContent.displayName = "Tabs.Content";
109
109
  var import_react4 = require("react");
110
110
  var import_typed_classname2 = require("@postenbring/hedwig-css/typed-classname");
111
111
 
112
- // src/utils.ts
112
+ // src/utils/utils.ts
113
113
  var React = __toESM(require("react"));
114
114
  var import_react3 = require("react");
115
115
  function useMergeRefs(refs) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tabs/tabs.tsx","../../src/tabs/context.ts","../../src/tabs/tabs-content.tsx","../../src/tabs/tabs-list.tsx","../../src/utils.ts"],"sourcesContent":["import type { HTMLAttributes, ReactElement } from \"react\";\nimport { forwardRef, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { TabsContext } from \"./context\";\nimport { TabsContent, TabsContents, type TabsContentsProps } from \"./tabs-content\";\nimport { TabsList, TabsTab, type TabsListProps } from \"./tabs-list\";\n\nexport interface TabsProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactElement<TabsListProps | TabsContentsProps>[] | ReactElement;\n\n /**\n * Define which tab to use as default. Must be one of the <Tab/>s identifier.\n */\n defaultTab: string;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Tabs = forwardRef<HTMLDivElement, TabsProps>(\n ({ asChild, defaultTab, children, ...rest }, ref) => {\n const [activeTabId, setActiveTabId] = useState<string>(defaultTab);\n const Component = asChild ? Slot : \"div\";\n return (\n <Component className={clsx(\"hds-tabs\")} ref={ref} {...rest}>\n <TabsContext.Provider value={{ activeTabId, toggleActiveTabId: setActiveTabId }}>\n {children}\n </TabsContext.Provider>\n </Component>\n );\n },\n) as TabsType;\nTabs.displayName = \"Tabs\";\n\ntype TabsType = ReturnType<typeof forwardRef<HTMLDivElement, TabsProps>> & {\n List: typeof TabsList;\n Tab: typeof TabsTab;\n Contents: typeof TabsContents;\n Content: typeof TabsContent;\n};\n\nTabs.List = TabsList;\nTabs.Tab = TabsTab;\nTabs.Contents = TabsContents;\nTabs.Content = TabsContent;\n","import { createContext, useContext } from \"react\";\n\nexport interface TabsContextProps {\n activeTabId: string;\n toggleActiveTabId: (tabId: string) => void;\n}\n\nexport const TabsContext = createContext<TabsContextProps | null>(null);\n\nexport function useTabsContext() {\n const context = useContext(TabsContext);\n if (!context) {\n throw new Error(\n \"Tabs context required. Did you use `<Tabs.List />`, `<Tabs.Tab />`, or `<Tabs.Content />` outside of <Tabs/>?\",\n );\n }\n return context;\n}\n","import type { HTMLAttributes, ReactElement } from \"react\";\nimport { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { useTabsContext } from \"./context\";\n\nexport interface TabsContentsProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactElement<TabsContentProps> | ReactElement<TabsContentProps>[];\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const TabsContents = forwardRef<HTMLDivElement, TabsContentsProps>(\n ({ asChild, children, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component ref={ref} className={clsx(\"hds-tabs__contents\")} {...rest}>\n {children}\n </Component>\n );\n },\n);\nTabsContents.displayName = \"Tabs.Contents\";\n\nexport interface TabsContentProps extends HTMLAttributes<HTMLElement> {\n children: ReactElement<HTMLElement> | ReactElement<HTMLElement>[] | string;\n\n /**\n * Content for the referenced tabId\n */\n forTabId: string;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const TabsContent = forwardRef<HTMLDivElement, TabsContentProps>(\n ({ asChild, forTabId, children, ...rest }, ref) => {\n const context = useTabsContext();\n const Component = asChild ? Slot : \"div\";\n\n if (context.activeTabId === forTabId) {\n return (\n <Component {...rest} ref={ref}>\n {children}\n </Component>\n );\n }\n return null;\n },\n);\n\nTabsContent.displayName = \"Tabs.Content\";\n","import type { HTMLAttributes, ReactElement, MouseEvent } from \"react\";\nimport { forwardRef, useEffect, useRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { useResize, useHydrated, useMergeRefs } from \"../utils\";\nimport { useTabsContext } from \"./context\";\n\nexport interface TabsListProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactElement<TabsTabProps> | ReactElement<TabsTabProps>[];\n\n /**\n * Direction of the tabs. Can either be vertical or horizontal.\n * Horizontal breaks on window width with fallback back to vertical\n *\n * @default \"horizontal\"\n */\n direction?: \"vertical\" | \"horizontal\";\n}\n\nexport const TabsList = forwardRef<HTMLDivElement, TabsListProps>(\n ({ children, direction = \"horizontal\", className, ...rest }, ref) => {\n const { activeTabId } = useTabsContext();\n const tabsListRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([tabsListRef, ref]);\n const { width: tabsWidth } = useResize(tabsListRef);\n\n const isClientSide = useHydrated();\n const { innerWidth } = isClientSide ? window : { innerWidth: 1000 };\n const wideEnough = innerWidth >= tabsWidth;\n\n const previousTabId = useRef(activeTabId);\n\n // Marker animation\n useEffect(() => {\n const tabList = tabsListRef.current;\n const activeTab = tabList?.querySelector(`[data-tabid=\"${activeTabId}\"]`);\n if (!activeTab || !tabList) return;\n\n const { offsetHeight: containerHeight, offsetWidth: containerWidth } = tabList;\n const { offsetHeight, offsetWidth, offsetTop, offsetLeft } = activeTab as HTMLElement;\n\n // Calculate the height and width of the marker relative to the container\n const height = offsetHeight / containerHeight;\n const width = offsetWidth / containerWidth;\n\n // NOTE: Doing a DOM manipulation here to set the CSS variables for the marker\n // Not really the react idomatic way, but as long as it works we are able to skip some intermidiate `useState`\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-height\", String(height));\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-width\", String(width));\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-top\", `${offsetTop}px`);\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-left\", `${offsetLeft}px`);\n\n // Start with border fallback, then switch to the animated marker when the user changes tabs\n // This way the marker is placed immediately to the default tab, then animates smoothly to the next when selected\n if (previousTabId.current !== activeTabId) {\n tabsListRef.current.style.setProperty(\n \"--_hds-tabs-marker-animated-color\",\n \"var(--_hds-tabs-marker-color)\",\n );\n tabsListRef.current.style.setProperty(\n \"--_hds-tabs-marker-border-fallback-color\",\n \"transparent\",\n );\n }\n previousTabId.current = activeTabId;\n }, [activeTabId, innerWidth]);\n\n return (\n <div\n className={clsx(\n \"hds-tabs__list\",\n direction === \"horizontal\"\n ? {\n \"hds-tabs__list--horizontal\": wideEnough,\n \"hds-tabs__list--vertical\": !wideEnough,\n }\n : {\n \"hds-tabs__list--vertical\": true,\n },\n className as undefined,\n )}\n ref={mergedRef}\n role=\"tablist\"\n {...rest}\n >\n {children}\n </div>\n );\n },\n);\nTabsList.displayName = \"Tabs.List\";\n\nexport interface TabsTabProps extends HTMLAttributes<HTMLButtonElement> {\n children: ReactElement<HTMLElement> | string;\n\n /**\n * Identifier for the tab\n */\n tabId: string;\n}\n\nexport const TabsTab = forwardRef<HTMLButtonElement, TabsTabProps>(\n ({ children, tabId, className, onClick, ...rest }, ref) => {\n const context = useTabsContext();\n\n const toggleTab = (e: MouseEvent<HTMLButtonElement>) => {\n e.preventDefault();\n context.toggleActiveTabId(tabId);\n onClick?.(e);\n };\n return (\n <button\n className={clsx(\n \"hds-tabs__tab\",\n { \"hds-tabs__tab--active\": context.activeTabId === tabId },\n className as undefined,\n )}\n data-tabid={tabId}\n onClick={toggleTab}\n ref={ref}\n type=\"button\"\n role=\"tab\"\n {...rest}\n >\n {children}\n </button>\n );\n },\n);\nTabsTab.displayName = \"Tabs.Tab\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nexport function releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAA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ACF;AACA,SAAS,cAAc;AAWhB,IAAM,cAAU;AAAA,EACrB,CAAC,IAAkD,QAAQ;AAA1D,iBAAE,YAAU,OAAO,WAAW,QArGjC,IAqGG,IAA0C,iBAA1C,IAA0C,CAAxC,YAAU,SAAO,aAAW;AAC7B,UAAM,UAAU,eAAe;AAE/B,UAAM,YAAY,CAAC,MAAqC;AACtD,QAAE,eAAe;AACjB,cAAQ,kBAAkB,KAAK;AAC/B,yCAAU;AAAA,IACZ;AACA,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW;AAAA,UACT;AAAA,UACA,EAAE,yBAAyB,QAAQ,gBAAgB,MAAM;AAAA,UACzD;AAAA,QACF;AAAA,QACA,cAAY;AAAA,QACZ,SAAS;AAAA,QACT;AAAA,QACA,MAAK;AAAA,QACL,MAAK;AAAA,SACD,OAXL;AAAA,QAaE;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,QAAQ,cAAc;;;AHlGd,IAAAC,sBAAA;AAND,IAAM,WAAO;AAAA,EAClB,CAAC,IAA4C,QAAQ;AAApD,iBAAE,WAAS,YAAY,SAzB1B,IAyBG,IAAoC,iBAApC,IAAoC,CAAlC,WAAS,cAAY;AACtB,UAAM,CAAC,aAAa,cAAc,QAAI,wBAAiB,UAAU;AACjE,UAAM,YAAY,UAAU,0BAAO;AACnC,WACE,6CAAC,0CAAU,eAAW,8BAAK,UAAU,GAAG,OAAc,OAArD,EACC,uDAAC,YAAY,UAAZ,EAAqB,OAAO,EAAE,aAAa,mBAAmB,eAAe,GAC3E,UACH,IACF;AAAA,EAEJ;AACF;AACA,KAAK,cAAc;AASnB,KAAK,OAAO;AACZ,KAAK,MAAM;AACX,KAAK,WAAW;AAChB,KAAK,UAAU;","names":["import_react","import_typed_classname","import_react_slot","import_react","import_react","import_typed_classname","import_react","import_jsx_runtime","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../../src/tabs/tabs.tsx","../../src/tabs/context.ts","../../src/tabs/tabs-content.tsx","../../src/tabs/tabs-list.tsx","../../src/utils/utils.ts"],"sourcesContent":["import type { HTMLAttributes, ReactElement } from \"react\";\nimport { forwardRef, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { TabsContext } from \"./context\";\nimport { TabsContent, TabsContents, type TabsContentsProps } from \"./tabs-content\";\nimport { TabsList, TabsTab, type TabsListProps } from \"./tabs-list\";\n\nexport interface TabsProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactElement<TabsListProps | TabsContentsProps>[] | ReactElement;\n\n /**\n * Define which tab to use as default. Must be one of the <Tab/>s identifier.\n */\n defaultTab: string;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Tabs = forwardRef<HTMLDivElement, TabsProps>(\n ({ asChild, defaultTab, children, ...rest }, ref) => {\n const [activeTabId, setActiveTabId] = useState<string>(defaultTab);\n const Component = asChild ? Slot : \"div\";\n return (\n <Component className={clsx(\"hds-tabs\")} ref={ref} {...rest}>\n <TabsContext.Provider value={{ activeTabId, toggleActiveTabId: setActiveTabId }}>\n {children}\n </TabsContext.Provider>\n </Component>\n );\n },\n) as TabsType;\nTabs.displayName = \"Tabs\";\n\ntype TabsType = ReturnType<typeof forwardRef<HTMLDivElement, TabsProps>> & {\n List: typeof TabsList;\n Tab: typeof TabsTab;\n Contents: typeof TabsContents;\n Content: typeof TabsContent;\n};\n\nTabs.List = TabsList;\nTabs.Tab = TabsTab;\nTabs.Contents = TabsContents;\nTabs.Content = TabsContent;\n","import { createContext, useContext } from \"react\";\n\nexport interface TabsContextProps {\n activeTabId: string;\n toggleActiveTabId: (tabId: string) => void;\n}\n\nexport const TabsContext = createContext<TabsContextProps | null>(null);\n\nexport function useTabsContext() {\n const context = useContext(TabsContext);\n if (!context) {\n throw new Error(\n \"Tabs context required. Did you use `<Tabs.List />`, `<Tabs.Tab />`, or `<Tabs.Content />` outside of <Tabs/>?\",\n );\n }\n return context;\n}\n","import type { HTMLAttributes, ReactElement } from \"react\";\nimport { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { useTabsContext } from \"./context\";\n\nexport interface TabsContentsProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactElement<TabsContentProps> | ReactElement<TabsContentProps>[];\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const TabsContents = forwardRef<HTMLDivElement, TabsContentsProps>(\n ({ asChild, children, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component ref={ref} className={clsx(\"hds-tabs__contents\")} {...rest}>\n {children}\n </Component>\n );\n },\n);\nTabsContents.displayName = \"Tabs.Contents\";\n\nexport interface TabsContentProps extends HTMLAttributes<HTMLElement> {\n children: ReactElement<HTMLElement> | ReactElement<HTMLElement>[] | string;\n\n /**\n * Content for the referenced tabId\n */\n forTabId: string;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const TabsContent = forwardRef<HTMLDivElement, TabsContentProps>(\n ({ asChild, forTabId, children, ...rest }, ref) => {\n const context = useTabsContext();\n const Component = asChild ? Slot : \"div\";\n\n if (context.activeTabId === forTabId) {\n return (\n <Component {...rest} ref={ref}>\n {children}\n </Component>\n );\n }\n return null;\n },\n);\n\nTabsContent.displayName = \"Tabs.Content\";\n","import type { HTMLAttributes, ReactElement, MouseEvent } from \"react\";\nimport { forwardRef, useEffect, useRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { useResize, useHydrated, useMergeRefs } from \"../utils/utils\";\nimport { useTabsContext } from \"./context\";\n\nexport interface TabsListProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactElement<TabsTabProps> | ReactElement<TabsTabProps>[];\n\n /**\n * Direction of the tabs. Can either be vertical or horizontal.\n * Horizontal breaks on window width with fallback back to vertical\n *\n * @default \"horizontal\"\n */\n direction?: \"vertical\" | \"horizontal\";\n}\n\nexport const TabsList = forwardRef<HTMLDivElement, TabsListProps>(\n ({ children, direction = \"horizontal\", className, ...rest }, ref) => {\n const { activeTabId } = useTabsContext();\n const tabsListRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([tabsListRef, ref]);\n const { width: tabsWidth } = useResize(tabsListRef);\n\n const isClientSide = useHydrated();\n const { innerWidth } = isClientSide ? window : { innerWidth: 1000 };\n const wideEnough = innerWidth >= tabsWidth;\n\n const previousTabId = useRef(activeTabId);\n\n // Marker animation\n useEffect(() => {\n const tabList = tabsListRef.current;\n const activeTab = tabList?.querySelector(`[data-tabid=\"${activeTabId}\"]`);\n if (!activeTab || !tabList) return;\n\n const { offsetHeight: containerHeight, offsetWidth: containerWidth } = tabList;\n const { offsetHeight, offsetWidth, offsetTop, offsetLeft } = activeTab as HTMLElement;\n\n // Calculate the height and width of the marker relative to the container\n const height = offsetHeight / containerHeight;\n const width = offsetWidth / containerWidth;\n\n // NOTE: Doing a DOM manipulation here to set the CSS variables for the marker\n // Not really the react idomatic way, but as long as it works we are able to skip some intermidiate `useState`\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-height\", String(height));\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-width\", String(width));\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-top\", `${offsetTop}px`);\n tabsListRef.current.style.setProperty(\"--_hds-tabs-marker-left\", `${offsetLeft}px`);\n\n // Start with border fallback, then switch to the animated marker when the user changes tabs\n // This way the marker is placed immediately to the default tab, then animates smoothly to the next when selected\n if (previousTabId.current !== activeTabId) {\n tabsListRef.current.style.setProperty(\n \"--_hds-tabs-marker-animated-color\",\n \"var(--_hds-tabs-marker-color)\",\n );\n tabsListRef.current.style.setProperty(\n \"--_hds-tabs-marker-border-fallback-color\",\n \"transparent\",\n );\n }\n previousTabId.current = activeTabId;\n }, [activeTabId, innerWidth]);\n\n return (\n <div\n className={clsx(\n \"hds-tabs__list\",\n direction === \"horizontal\"\n ? {\n \"hds-tabs__list--horizontal\": wideEnough,\n \"hds-tabs__list--vertical\": !wideEnough,\n }\n : {\n \"hds-tabs__list--vertical\": true,\n },\n className as undefined,\n )}\n ref={mergedRef}\n role=\"tablist\"\n {...rest}\n >\n {children}\n </div>\n );\n },\n);\nTabsList.displayName = \"Tabs.List\";\n\nexport interface TabsTabProps extends HTMLAttributes<HTMLButtonElement> {\n children: ReactElement<HTMLElement> | string;\n\n /**\n * Identifier for the tab\n */\n tabId: string;\n}\n\nexport const TabsTab = forwardRef<HTMLButtonElement, TabsTabProps>(\n ({ children, tabId, className, onClick, ...rest }, ref) => {\n const context = useTabsContext();\n\n const toggleTab = (e: MouseEvent<HTMLButtonElement>) => {\n e.preventDefault();\n context.toggleActiveTabId(tabId);\n onClick?.(e);\n };\n return (\n <button\n className={clsx(\n \"hds-tabs__tab\",\n { \"hds-tabs__tab--active\": context.activeTabId === tabId },\n className as undefined,\n )}\n data-tabid={tabId}\n onClick={toggleTab}\n ref={ref}\n type=\"button\"\n role=\"tab\"\n {...rest}\n >\n {children}\n </button>\n );\n },\n);\nTabsTab.displayName = \"Tabs.Tab\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nfunction releaseFocusTrap(inertElements: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;AAChB,KAAK,UAAU;","names":["import_react","import_typed_classname","import_react_slot","import_react","import_react","import_typed_classname","import_react","import_jsx_runtime","import_jsx_runtime"]}
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  Tabs
3
- } from "../chunk-7UD72WOC.mjs";
4
- import "../chunk-4WQWU5TL.mjs";
3
+ } from "../chunk-QZZIOBF4.mjs";
4
+ import "../chunk-AXQCREUJ.mjs";
5
5
  import "../chunk-CCVZAHYA.mjs";
6
6
  import "../chunk-KQITCS3U.mjs";
7
- import "../chunk-DEX36MFK.mjs";
7
+ import "../chunk-TDXU2IC6.mjs";
8
8
  import "../chunk-R4SQKVDQ.mjs";
9
9
  export {
10
10
  Tabs
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-animate-height.d.ts","sourceRoot":"","sources":["../../src/utils/auto-animate-height.tsx"],"names":[],"mappings":";AAGA,MAAM,WAAW,sBAAuB,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAClF;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAEhD;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAE7B;;OAEG;IACH,eAAe,CAAC,EAAE,IAAI,GAAG,KAAK,GAAG,QAAQ,CAAC;IAC1C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,mHAqG7B,CAAC"}
@@ -56,7 +56,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
56
56
  ));
57
57
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
58
 
59
- // src/utilities/auto-animate-height.tsx
59
+ // src/utils/auto-animate-height.tsx
60
60
  var auto_animate_height_exports = {};
61
61
  __export(auto_animate_height_exports, {
62
62
  AutoAnimateHeight: () => AutoAnimateHeight
@@ -64,7 +64,7 @@ __export(auto_animate_height_exports, {
64
64
  module.exports = __toCommonJS(auto_animate_height_exports);
65
65
  var import_react2 = require("react");
66
66
 
67
- // src/utils.ts
67
+ // src/utils/utils.ts
68
68
  var React = __toESM(require("react"));
69
69
  var import_react = require("react");
70
70
  function useMergeRefs(refs) {
@@ -84,7 +84,7 @@ function useMergeRefs(refs) {
84
84
  }, refs);
85
85
  }
86
86
 
87
- // src/utilities/auto-animate-height.tsx
87
+ // src/utils/auto-animate-height.tsx
88
88
  var import_jsx_runtime = require("react/jsx-runtime");
89
89
  var AutoAnimateHeight = (0, import_react2.forwardRef)(
90
90
  (_a, ref) => {