@postenbring/hedwig-react 0.0.71 → 0.0.73

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 (123) hide show
  1. package/dist/_tsup-dts-rollup.d.mts +99 -28
  2. package/dist/_tsup-dts-rollup.d.ts +99 -28
  3. package/dist/{breadcrumb/index.js → breadcrumbs/breadcrumbs.js} +12 -11
  4. package/dist/breadcrumbs/breadcrumbs.js.map +1 -0
  5. package/dist/{breadcrumb/breadcrumb.mjs → breadcrumbs/breadcrumbs.mjs} +2 -2
  6. package/dist/{breadcrumb/breadcrumb.js → breadcrumbs/index.js} +14 -9
  7. package/dist/breadcrumbs/index.js.map +1 -0
  8. package/dist/breadcrumbs/index.mjs +9 -0
  9. package/dist/button/button.js +1 -4
  10. package/dist/button/button.js.map +1 -1
  11. package/dist/button/button.mjs +1 -1
  12. package/dist/button/index.js +1 -4
  13. package/dist/button/index.js.map +1 -1
  14. package/dist/button/index.mjs +1 -1
  15. package/dist/chunk-3LYJRAOC.mjs +1 -0
  16. package/dist/{chunk-OUHO4LGN.mjs → chunk-BWFFP6BB.mjs} +2 -5
  17. package/dist/chunk-BWFFP6BB.mjs.map +1 -0
  18. package/dist/chunk-CFAH2LID.mjs +1 -0
  19. package/dist/{chunk-K2HG7WRK.mjs → chunk-CSAEHQ4R.mjs} +2 -2
  20. package/dist/{chunk-ZRFDCZ62.mjs → chunk-CSFSJGLY.mjs} +5 -5
  21. package/dist/chunk-E2RTLHMZ.mjs +54 -0
  22. package/dist/chunk-E2RTLHMZ.mjs.map +1 -0
  23. package/dist/chunk-EMI7NAO2.mjs +45 -0
  24. package/dist/chunk-EMI7NAO2.mjs.map +1 -0
  25. package/dist/chunk-GGEQEVZ4.mjs +22 -0
  26. package/dist/chunk-GGEQEVZ4.mjs.map +1 -0
  27. package/dist/chunk-HSIL53A5.mjs +118 -0
  28. package/dist/chunk-HSIL53A5.mjs.map +1 -0
  29. package/dist/chunk-ISAHCU7C.mjs +1 -0
  30. package/dist/chunk-ISAHCU7C.mjs.map +1 -0
  31. package/dist/chunk-JBWAZQKM.mjs +1 -0
  32. package/dist/chunk-JBWAZQKM.mjs.map +1 -0
  33. package/dist/{chunk-O32FZU7E.mjs → chunk-S3BGPCLK.mjs} +4 -4
  34. package/dist/{chunk-FOZSX44S.mjs → chunk-VM345XBI.mjs} +6 -6
  35. package/dist/chunk-Z753E3XF.mjs +33 -0
  36. package/dist/chunk-Z753E3XF.mjs.map +1 -0
  37. package/dist/description-list/description-list.d.mts +1 -1
  38. package/dist/description-list/description-list.d.ts +1 -1
  39. package/dist/description-list/description-list.js +19 -21
  40. package/dist/description-list/description-list.js.map +1 -1
  41. package/dist/description-list/description-list.mjs +1 -1
  42. package/dist/description-list/index.js +19 -21
  43. package/dist/description-list/index.js.map +1 -1
  44. package/dist/description-list/index.mjs +1 -1
  45. package/dist/footer/footer.js +1 -4
  46. package/dist/footer/footer.js.map +1 -1
  47. package/dist/footer/footer.mjs +2 -2
  48. package/dist/footer/index.js +1 -4
  49. package/dist/footer/index.js.map +1 -1
  50. package/dist/footer/index.mjs +3 -3
  51. package/dist/form/index.mjs +14 -14
  52. package/dist/help-text/help-text.d.mts +1 -0
  53. package/dist/help-text/help-text.d.ts +1 -0
  54. package/dist/help-text/help-text.js +186 -0
  55. package/dist/help-text/help-text.js.map +1 -0
  56. package/dist/help-text/help-text.mjs +10 -0
  57. package/dist/help-text/help-text.mjs.map +1 -0
  58. package/dist/help-text/index.d.mts +1 -0
  59. package/dist/help-text/index.d.ts +1 -0
  60. package/dist/help-text/index.js +188 -0
  61. package/dist/help-text/index.js.map +1 -0
  62. package/dist/help-text/index.mjs +11 -0
  63. package/dist/help-text/index.mjs.map +1 -0
  64. package/dist/index-no-css.d.mts +2 -0
  65. package/dist/index-no-css.d.ts +2 -0
  66. package/dist/index-no-css.js +414 -316
  67. package/dist/index-no-css.js.map +1 -1
  68. package/dist/index-no-css.mjs +112 -102
  69. package/dist/index.d.mts +2 -0
  70. package/dist/index.d.ts +2 -0
  71. package/dist/index.js +414 -316
  72. package/dist/index.js.map +1 -1
  73. package/dist/index.mjs +112 -102
  74. package/dist/index.mjs.map +1 -1
  75. package/dist/layout/index.mjs +6 -6
  76. package/dist/navbar/index.mjs +5 -5
  77. package/dist/show-more/index.js +91 -39
  78. package/dist/show-more/index.js.map +1 -1
  79. package/dist/show-more/index.mjs +2 -1
  80. package/dist/table/index.d.mts +1 -0
  81. package/dist/table/index.d.ts +1 -0
  82. package/dist/table/index.js +94 -0
  83. package/dist/table/index.js.map +1 -0
  84. package/dist/table/index.mjs +9 -0
  85. package/dist/table/index.mjs.map +1 -0
  86. package/dist/table/table.d.mts +1 -0
  87. package/dist/table/table.d.ts +1 -0
  88. package/dist/table/table.js +92 -0
  89. package/dist/table/table.js.map +1 -0
  90. package/dist/table/table.mjs +8 -0
  91. package/dist/table/table.mjs.map +1 -0
  92. package/dist/tabs/index.mjs +5 -5
  93. package/dist/utilities/auto-animate-height.js +89 -37
  94. package/dist/utilities/auto-animate-height.js.map +1 -1
  95. package/dist/utilities/auto-animate-height.mjs +2 -1
  96. package/dist/utilities/index.js +89 -37
  97. package/dist/utilities/index.js.map +1 -1
  98. package/dist/utilities/index.mjs +2 -1
  99. package/package.json +6 -5
  100. package/dist/breadcrumb/breadcrumb.js.map +0 -1
  101. package/dist/breadcrumb/index.js.map +0 -1
  102. package/dist/breadcrumb/index.mjs +0 -9
  103. package/dist/chunk-AKYK3XFN.mjs +0 -95
  104. package/dist/chunk-AKYK3XFN.mjs.map +0 -1
  105. package/dist/chunk-OUHO4LGN.mjs.map +0 -1
  106. package/dist/chunk-XMB45ILT.mjs +0 -35
  107. package/dist/chunk-XMB45ILT.mjs.map +0 -1
  108. package/dist/chunk-YKDKFWP2.mjs +0 -19
  109. package/dist/chunk-YKDKFWP2.mjs.map +0 -1
  110. package/dist/chunk-YWNVB7TY.mjs +0 -1
  111. package/dist/chunk-ZOCMUEOX.mjs +0 -1
  112. package/dist/{breadcrumb/breadcrumb.d.mts → breadcrumbs/breadcrumbs.d.mts} +1 -1
  113. package/dist/{breadcrumb/breadcrumb.d.ts → breadcrumbs/breadcrumbs.d.ts} +1 -1
  114. /package/dist/{breadcrumb/breadcrumb.mjs.map → breadcrumbs/breadcrumbs.mjs.map} +0 -0
  115. /package/dist/{breadcrumb → breadcrumbs}/index.d.mts +0 -0
  116. /package/dist/{breadcrumb → breadcrumbs}/index.d.ts +0 -0
  117. /package/dist/{breadcrumb → breadcrumbs}/index.mjs.map +0 -0
  118. /package/dist/{chunk-YWNVB7TY.mjs.map → chunk-3LYJRAOC.mjs.map} +0 -0
  119. /package/dist/{chunk-ZOCMUEOX.mjs.map → chunk-CFAH2LID.mjs.map} +0 -0
  120. /package/dist/{chunk-K2HG7WRK.mjs.map → chunk-CSAEHQ4R.mjs.map} +0 -0
  121. /package/dist/{chunk-ZRFDCZ62.mjs.map → chunk-CSFSJGLY.mjs.map} +0 -0
  122. /package/dist/{chunk-O32FZU7E.mjs.map → chunk-S3BGPCLK.mjs.map} +0 -0
  123. /package/dist/{chunk-FOZSX44S.mjs.map → chunk-VM345XBI.mjs.map} +0 -0
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __defProps = Object.defineProperties;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
7
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
8
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
8
10
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
11
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
12
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -44,6 +46,14 @@ var __copyProps = (to, from, except, desc) => {
44
46
  }
45
47
  return to;
46
48
  };
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
+ ));
47
57
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
48
58
 
49
59
  // src/utilities/index.ts
@@ -54,67 +64,109 @@ __export(utilities_exports, {
54
64
  module.exports = __toCommonJS(utilities_exports);
55
65
 
56
66
  // src/utilities/auto-animate-height.tsx
67
+ var import_react2 = require("react");
68
+
69
+ // src/utils.ts
70
+ var React = __toESM(require("react"));
57
71
  var import_react = require("react");
58
- var import_react_dom = require("react-dom");
72
+ function useMergeRefs(refs) {
73
+ return React.useMemo(() => {
74
+ if (refs.every((ref) => ref === null)) {
75
+ return null;
76
+ }
77
+ return (value) => {
78
+ refs.forEach((ref) => {
79
+ if (typeof ref === "function") {
80
+ ref(value);
81
+ } else if (ref !== null) {
82
+ ref.current = value;
83
+ }
84
+ });
85
+ };
86
+ }, refs);
87
+ }
88
+
89
+ // src/utilities/auto-animate-height.tsx
59
90
  var import_jsx_runtime = require("react/jsx-runtime");
60
- var animationDurationToValue = {
61
- quick: 100,
62
- normal: 300,
63
- slow: 700
64
- };
65
- var AutoAnimateHeight = (0, import_react.forwardRef)(
91
+ var AutoAnimateHeight = (0, import_react2.forwardRef)(
66
92
  (_a, ref) => {
67
93
  var _b = _a, {
68
94
  as: Component = "div",
69
95
  children,
70
96
  style,
71
97
  animationDuration = "quick",
72
- animationEasing = "normal"
98
+ animationEasing = "normal",
99
+ onTransitionEnd
73
100
  } = _b, rest = __objRest(_b, [
74
101
  "as",
75
102
  "children",
76
103
  "style",
77
104
  "animationDuration",
78
- "animationEasing"
105
+ "animationEasing",
106
+ "onTransitionEnd"
79
107
  ]);
80
- const timeoutRef = (0, import_react.useRef)(null);
81
- const measurementRef = (0, import_react.useRef)(null);
82
- const [height, setHeight] = (0, import_react.useState)(void 0);
83
- const [clonedChildren, setClonedChildren] = (0, import_react.useState)(
84
- () => (0, import_react.cloneElement)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children }), {})
108
+ var _a2, _b2;
109
+ const rootRef = (0, import_react2.useRef)(null);
110
+ const mergedRef = useMergeRefs([rootRef, ref]);
111
+ const measurementRef = (0, import_react2.useRef)(null);
112
+ const [height, setHeight] = (0, import_react2.useState)(
113
+ void 0
85
114
  );
86
- (0, import_react.useEffect)(() => {
87
- if (measurementRef.current) {
88
- const { height: newHeight } = measurementRef.current.getBoundingClientRect();
89
- if (timeoutRef.current) {
90
- clearTimeout(timeoutRef.current);
91
- }
92
- if (newHeight < (height != null ? height : 0)) {
93
- setTimeout(() => {
94
- (0, import_react_dom.flushSync)(() => {
95
- setHeight(newHeight);
96
- });
97
- timeoutRef.current = setTimeout(() => {
98
- setClonedChildren((0, import_react.cloneElement)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children }), {}));
99
- }, animationDurationToValue[animationDuration]);
100
- });
101
- } else {
102
- setHeight(newHeight);
103
- setClonedChildren((0, import_react.cloneElement)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children }), {}));
104
- }
115
+ const [clonedChildren, setClonedChildren] = (0, import_react2.useState)(
116
+ () => (0, import_react2.cloneElement)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children }), {})
117
+ );
118
+ (0, import_react2.useEffect)(() => {
119
+ var _a3;
120
+ if (!rootRef.current)
121
+ return;
122
+ if (!measurementRef.current)
123
+ return;
124
+ if (document.body.scrollHeight === 0)
125
+ return;
126
+ const currentMeasurement = measurementRef.current;
127
+ const { height: newHeight } = currentMeasurement.getBoundingClientRect();
128
+ let previouslyObservedHeight = newHeight;
129
+ const resizeObserver = new ResizeObserver(() => {
130
+ const { height: resizedHeight } = currentMeasurement.getBoundingClientRect();
131
+ if (resizedHeight === previouslyObservedHeight)
132
+ return;
133
+ previouslyObservedHeight = resizedHeight;
134
+ setHeight({ height: resizedHeight, shouldAnimate: false });
135
+ });
136
+ resizeObserver.observe(currentMeasurement);
137
+ setHeight({ height: newHeight, shouldAnimate: true });
138
+ const nextClonedChildren = (0, import_react2.cloneElement)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children }), {});
139
+ if (newHeight >= ((_a3 = height == null ? void 0 : height.height) != null ? _a3 : 0)) {
140
+ setClonedChildren(nextClonedChildren);
141
+ return () => {
142
+ resizeObserver.disconnect();
143
+ };
144
+ }
145
+ const currentRoot = rootRef.current;
146
+ function onTransitionEndHandler(e) {
147
+ if (e.propertyName !== "height")
148
+ return;
149
+ setClonedChildren(nextClonedChildren);
105
150
  }
151
+ currentRoot.addEventListener("transitionend", onTransitionEndHandler);
152
+ return () => {
153
+ resizeObserver.disconnect();
154
+ currentRoot.removeEventListener("transitionend", onTransitionEndHandler);
155
+ };
106
156
  }, [children]);
107
157
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
108
158
  Component,
109
159
  __spreadProps(__spreadValues({
110
- ref,
160
+ ref: mergedRef,
161
+ onTransitionEnd,
111
162
  style: __spreadValues({
112
163
  position: "relative",
113
164
  overflow: "hidden",
114
- height,
115
- transitionProperty: "height",
165
+ height: (_b2 = height == null ? void 0 : height.height) != null ? _b2 : (_a2 = measurementRef.current) == null ? void 0 : _a2.getBoundingClientRect().height,
166
+ transitionProperty: (height == null ? void 0 : height.shouldAnimate) ? "height" : "none",
116
167
  transitionDuration: `var(--hds-micro-animation-duration-${animationDuration})`,
117
- transitionTimingFunction: `var(--hds-micro-animation-easing-${animationEasing})`
168
+ transitionTimingFunction: `var(--hds-micro-animation-easing-${animationEasing})`,
169
+ willChange: "height"
118
170
  }, style)
119
171
  }, rest), {
120
172
  children: [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/index.ts","../../src/utilities/auto-animate-height.tsx"],"sourcesContent":["export { AutoAnimateHeight } from \"./auto-animate-height\";\nexport type * from \"./auto-animate-height\";\n","import { cloneElement, forwardRef, useEffect, useRef, useState } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport type { OverridableComponent } from \"../utils\";\n\nconst animationDurationToValue = {\n quick: 100,\n normal: 300,\n slow: 700,\n};\n\nexport interface AutoAnimateHeightProps {\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 * 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: OverridableComponent<AutoAnimateHeightProps, HTMLDivElement> =\n forwardRef(\n (\n {\n as: Component = \"div\",\n children,\n style,\n animationDuration = \"quick\",\n animationEasing = \"normal\",\n ...rest\n },\n ref,\n ) => {\n const timeoutRef = useRef<NodeJS.Timeout | null>(null);\n const measurementRef = useRef<HTMLDivElement>(null);\n const [height, setHeight] = useState<number | undefined>(undefined);\n const [clonedChildren, setClonedChildren] = useState<React.ReactNode>(() =>\n cloneElement(<>{children}</>, {}),\n );\n useEffect(() => {\n if (measurementRef.current) {\n const { height: newHeight } = measurementRef.current.getBoundingClientRect();\n\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n if (newHeight < (height ?? 0)) {\n // If the children are shrinking, hold off on replacing until the animation is done\n // This way we don't get a sudden flash of empty content\n setTimeout(() => {\n flushSync(() => {\n setHeight(newHeight);\n });\n timeoutRef.current = setTimeout(() => {\n setClonedChildren(cloneElement(<>{children}</>, {}));\n }, animationDurationToValue[animationDuration]);\n });\n } else {\n setHeight(newHeight);\n setClonedChildren(cloneElement(<>{children}</>, {}));\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- I know better\n }, [children]);\n\n return (\n <Component\n ref={ref}\n style={{\n position: \"relative\",\n overflow: \"hidden\",\n height,\n transitionProperty: \"height\",\n transitionDuration: `var(--hds-micro-animation-duration-${animationDuration})`,\n transitionTimingFunction: `var(--hds-micro-animation-easing-${animationEasing})`,\n ...style,\n }}\n {...rest}\n >\n <div\n aria-hidden\n ref={measurementRef}\n style={{\n position: \"absolute\",\n visibility: \"hidden\",\n }}\n >\n {children}\n </div>\n {clonedChildren}\n </Component>\n );\n },\n );\nAutoAnimateHeight.displayName = \"AutoAnimateHeight\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAsE;AACtE,uBAA0B;AAoDL;AAjDrB,IAAM,2BAA2B;AAAA,EAC/B,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AACR;AA4BO,IAAM,wBACX;AAAA,EACE,CACE,IAQA,QACG;AATH,iBACE;AAAA,UAAI,YAAY;AAAA,MAChB;AAAA,MACA;AAAA,MACA,oBAAoB;AAAA,MACpB,kBAAkB;AAAA,IA5C1B,IAuCM,IAMK,iBANL,IAMK;AAAA,MALH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAKF,UAAM,iBAAa,qBAA8B,IAAI;AACrD,UAAM,qBAAiB,qBAAuB,IAAI;AAClD,UAAM,CAAC,QAAQ,SAAS,QAAI,uBAA6B,MAAS;AAClE,UAAM,CAAC,gBAAgB,iBAAiB,QAAI;AAAA,MAA0B,UACpE,2BAAa,2EAAG,UAAS,GAAK,CAAC,CAAC;AAAA,IAClC;AACA,gCAAU,MAAM;AACd,UAAI,eAAe,SAAS;AAC1B,cAAM,EAAE,QAAQ,UAAU,IAAI,eAAe,QAAQ,sBAAsB;AAE3E,YAAI,WAAW,SAAS;AACtB,uBAAa,WAAW,OAAO;AAAA,QACjC;AACA,YAAI,aAAa,0BAAU,IAAI;AAG7B,qBAAW,MAAM;AACf,4CAAU,MAAM;AACd,wBAAU,SAAS;AAAA,YACrB,CAAC;AACD,uBAAW,UAAU,WAAW,MAAM;AACpC,oCAAkB,2BAAa,2EAAG,UAAS,GAAK,CAAC,CAAC,CAAC;AAAA,YACrD,GAAG,yBAAyB,iBAAiB,CAAC;AAAA,UAChD,CAAC;AAAA,QACH,OAAO;AACL,oBAAU,SAAS;AACnB,gCAAkB,2BAAa,2EAAG,UAAS,GAAK,CAAC,CAAC,CAAC;AAAA,QACrD;AAAA,MACF;AAAA,IAEF,GAAG,CAAC,QAAQ,CAAC;AAEb,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,OAAO;AAAA,UACL,UAAU;AAAA,UACV,UAAU;AAAA,UACV;AAAA,UACA,oBAAoB;AAAA,UACpB,oBAAoB,sCAAsC,iBAAiB;AAAA,UAC3E,0BAA0B,oCAAoC,eAAe;AAAA,WAC1E;AAAA,SAED,OAXL;AAAA,QAaC;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,eAAW;AAAA,cACX,KAAK;AAAA,cACL,OAAO;AAAA,gBACL,UAAU;AAAA,gBACV,YAAY;AAAA,cACd;AAAA,cAEC;AAAA;AAAA,UACH;AAAA,UACC;AAAA;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACF,kBAAkB,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../src/utilities/index.ts","../../src/utilities/auto-animate-height.tsx","../../src/utils.ts"],"sourcesContent":["export { AutoAnimateHeight } from \"./auto-animate-height\";\nexport type * from \"./auto-animate-height\";\n","import { cloneElement, forwardRef, useEffect, useRef, useState } from \"react\";\nimport { useMergeRefs, type OverridableComponent } from \"../utils\";\n\nexport interface AutoAnimateHeightProps {\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: OverridableComponent<AutoAnimateHeightProps, HTMLDivElement> =\n forwardRef(\n (\n {\n as: Component = \"div\",\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 <Component\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 }}\n >\n {children}\n </div>\n {clonedChildren}\n </Component>\n );\n },\n );\nAutoAnimateHeight.displayName = \"AutoAnimateHeight\";\n","import type { ComponentPropsWithRef, ElementType, FC, RefAttributes } from \"react\";\nimport * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * OverridableComponent makes the `as` prop available,\n * to be used to override the html element being used for a component\n *\n * Taken from digdir design system: https://github.com/digdir/designsystem/blob/main/packages/react/src/types/OverridableComponent.ts\n */\nexport type OverridableComponent<ComponentProps, Element extends HTMLElement> = {\n (props: ComponentProps & RefAttributes<Element>): ReturnType<FC>;\n\n <As extends ElementType>(\n props: {\n /** Override html element */\n as?: As;\n } & ComponentProps &\n Omit<ComponentPropsWithRef<As>, keyof ComponentProps>,\n ): ReturnType<FC>;\n} & Pick<FC, \"displayName\">;\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"],"mappings":";;;;;;;;;;;;;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OAbL;AAAA,QAeC;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,eAAW;AAAA,cACX,KAAK;AAAA,cACL,OAAO;AAAA,gBACL,UAAU;AAAA,gBACV,YAAY;AAAA,cACd;AAAA,cAEC;AAAA;AAAA,UACH;AAAA,UACC;AAAA;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACF,kBAAkB,cAAc;","names":["import_react","_a","_b"]}
@@ -1,7 +1,8 @@
1
1
  import "../chunk-DZNH5JHY.mjs";
2
2
  import {
3
3
  AutoAnimateHeight
4
- } from "../chunk-AKYK3XFN.mjs";
4
+ } from "../chunk-HSIL53A5.mjs";
5
+ import "../chunk-ZL56N4UK.mjs";
5
6
  import "../chunk-R4SQKVDQ.mjs";
6
7
  export {
7
8
  AutoAnimateHeight
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postenbring/hedwig-react",
3
- "version": "0.0.71",
3
+ "version": "0.0.73",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -13,14 +13,14 @@
13
13
  ],
14
14
  "devDependencies": {
15
15
  "@microsoft/api-extractor": "7.43.1",
16
- "@types/react": "^18.2.78",
16
+ "@types/react": "^18.2.79",
17
17
  "@types/react-dom": "^18.2.25",
18
18
  "react": "^18.2.0",
19
19
  "react-dom": "18.2.0",
20
20
  "tsup": "^8.0.1",
21
21
  "typescript": "^5.4.5",
22
- "hedwig-tsconfig": "0.0.0",
23
- "eslint-config-custom": "0.0.1"
22
+ "eslint-config-custom": "0.0.1",
23
+ "hedwig-tsconfig": "0.0.0"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "@types/react": "^17.0.0 || ^18.0.0",
@@ -29,9 +29,10 @@
29
29
  "react-dom": "^17.0.0 || ^18.0.0"
30
30
  },
31
31
  "dependencies": {
32
+ "@radix-ui/react-popover": "1.0.7",
32
33
  "@radix-ui/react-slot": "1.0.2",
33
34
  "focus-trap-react": "10.2.3",
34
- "@postenbring/hedwig-css": "0.0.62"
35
+ "@postenbring/hedwig-css": "0.0.64"
35
36
  },
36
37
  "publishConfig": {
37
38
  "access": "public"
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/breadcrumb/breadcrumb.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactElement } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\n\nexport interface BreadcrumbsProps extends HTMLAttributes<HTMLOListElement> {\n children: ReactElement<HTMLLIElement> | ReactElement<HTMLLIElement>[];\n\n /**\n * Props passed to the `ol` html element\n */\n olProps?: HTMLAttributes<HTMLElement>;\n}\n\n/**\n * A breadcrumbs navigation menu\n *\n * **Usage**\n *\n * ```tsx\n * <Breadcrumbs data-testid=\"breadcrumbs\">\n * <li><Link href=\"../\">Previous page</Link></li>\n * <li aria-current=\"page\">Current page</li>\n * </Breadcrumbs>\n * ```\n *\n * Outputs this html structure\n *\n * ```html\n * <nav data-testid=\"breadcrumbs\">\n * <ol>\n * <li><a href=\"../\">Previous page</a></li>\n * <li aria-current=\"page\">Current page</li>\n * </ol>\n * </nav>\n * ```\n */\nexport function Breadcrumbs({ olProps, children, ...rest }: BreadcrumbsProps) {\n return (\n <nav {...rest}>\n <ol {...olProps} className={clsx(\"hds-breadcrumbs\", olProps?.className as undefined)}>\n {children}\n </ol>\n </nav>\n );\n}\n\nBreadcrumbs.displayName = \"Breadcrumbs\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,6BAAqB;AAqCf;AAHC,SAAS,YAAY,IAAkD;AAAlD,eAAE,WAAS,SAnCvC,IAmC4B,IAAwB,iBAAxB,IAAwB,CAAtB,WAAS;AACrC,SACE,4CAAC,wCAAQ,OAAR,EACC,sDAAC,uCAAO,UAAP,EAAgB,eAAW,6BAAK,mBAAmB,mCAAS,SAAsB,GAChF,WACH,IACF;AAEJ;AAEA,YAAY,cAAc;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/breadcrumb/index.tsx","../../src/breadcrumb/breadcrumb.tsx"],"sourcesContent":["export { Breadcrumbs } from \"./breadcrumb\";\n\nexport type * from \"./breadcrumb\";\n","import type { HTMLAttributes, ReactElement } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\n\nexport interface BreadcrumbsProps extends HTMLAttributes<HTMLOListElement> {\n children: ReactElement<HTMLLIElement> | ReactElement<HTMLLIElement>[];\n\n /**\n * Props passed to the `ol` html element\n */\n olProps?: HTMLAttributes<HTMLElement>;\n}\n\n/**\n * A breadcrumbs navigation menu\n *\n * **Usage**\n *\n * ```tsx\n * <Breadcrumbs data-testid=\"breadcrumbs\">\n * <li><Link href=\"../\">Previous page</Link></li>\n * <li aria-current=\"page\">Current page</li>\n * </Breadcrumbs>\n * ```\n *\n * Outputs this html structure\n *\n * ```html\n * <nav data-testid=\"breadcrumbs\">\n * <ol>\n * <li><a href=\"../\">Previous page</a></li>\n * <li aria-current=\"page\">Current page</li>\n * </ol>\n * </nav>\n * ```\n */\nexport function Breadcrumbs({ olProps, children, ...rest }: BreadcrumbsProps) {\n return (\n <nav {...rest}>\n <ol {...olProps} className={clsx(\"hds-breadcrumbs\", olProps?.className as undefined)}>\n {children}\n </ol>\n </nav>\n );\n}\n\nBreadcrumbs.displayName = \"Breadcrumbs\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,6BAAqB;AAqCf;AAHC,SAAS,YAAY,IAAkD;AAAlD,eAAE,WAAS,SAnCvC,IAmC4B,IAAwB,iBAAxB,IAAwB,CAAtB,WAAS;AACrC,SACE,4CAAC,wCAAQ,OAAR,EACC,sDAAC,uCAAO,UAAP,EAAgB,eAAW,6BAAK,mBAAmB,mCAAS,SAAsB,GAChF,WACH,IACF;AAEJ;AAEA,YAAY,cAAc;","names":[]}
@@ -1,9 +0,0 @@
1
- import "../chunk-ZOCMUEOX.mjs";
2
- import {
3
- Breadcrumbs
4
- } from "../chunk-YKDKFWP2.mjs";
5
- import "../chunk-R4SQKVDQ.mjs";
6
- export {
7
- Breadcrumbs
8
- };
9
- //# sourceMappingURL=index.mjs.map
@@ -1,95 +0,0 @@
1
- import {
2
- __objRest,
3
- __spreadProps,
4
- __spreadValues
5
- } from "./chunk-R4SQKVDQ.mjs";
6
-
7
- // src/utilities/auto-animate-height.tsx
8
- import { cloneElement, forwardRef, useEffect, useRef, useState } from "react";
9
- import { flushSync } from "react-dom";
10
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
- var animationDurationToValue = {
12
- quick: 100,
13
- normal: 300,
14
- slow: 700
15
- };
16
- var AutoAnimateHeight = forwardRef(
17
- (_a, ref) => {
18
- var _b = _a, {
19
- as: Component = "div",
20
- children,
21
- style,
22
- animationDuration = "quick",
23
- animationEasing = "normal"
24
- } = _b, rest = __objRest(_b, [
25
- "as",
26
- "children",
27
- "style",
28
- "animationDuration",
29
- "animationEasing"
30
- ]);
31
- const timeoutRef = useRef(null);
32
- const measurementRef = useRef(null);
33
- const [height, setHeight] = useState(void 0);
34
- const [clonedChildren, setClonedChildren] = useState(
35
- () => cloneElement(/* @__PURE__ */ jsx(Fragment, { children }), {})
36
- );
37
- useEffect(() => {
38
- if (measurementRef.current) {
39
- const { height: newHeight } = measurementRef.current.getBoundingClientRect();
40
- if (timeoutRef.current) {
41
- clearTimeout(timeoutRef.current);
42
- }
43
- if (newHeight < (height != null ? height : 0)) {
44
- setTimeout(() => {
45
- flushSync(() => {
46
- setHeight(newHeight);
47
- });
48
- timeoutRef.current = setTimeout(() => {
49
- setClonedChildren(cloneElement(/* @__PURE__ */ jsx(Fragment, { children }), {}));
50
- }, animationDurationToValue[animationDuration]);
51
- });
52
- } else {
53
- setHeight(newHeight);
54
- setClonedChildren(cloneElement(/* @__PURE__ */ jsx(Fragment, { children }), {}));
55
- }
56
- }
57
- }, [children]);
58
- return /* @__PURE__ */ jsxs(
59
- Component,
60
- __spreadProps(__spreadValues({
61
- ref,
62
- style: __spreadValues({
63
- position: "relative",
64
- overflow: "hidden",
65
- height,
66
- transitionProperty: "height",
67
- transitionDuration: `var(--hds-micro-animation-duration-${animationDuration})`,
68
- transitionTimingFunction: `var(--hds-micro-animation-easing-${animationEasing})`
69
- }, style)
70
- }, rest), {
71
- children: [
72
- /* @__PURE__ */ jsx(
73
- "div",
74
- {
75
- "aria-hidden": true,
76
- ref: measurementRef,
77
- style: {
78
- position: "absolute",
79
- visibility: "hidden"
80
- },
81
- children
82
- }
83
- ),
84
- clonedChildren
85
- ]
86
- })
87
- );
88
- }
89
- );
90
- AutoAnimateHeight.displayName = "AutoAnimateHeight";
91
-
92
- export {
93
- AutoAnimateHeight
94
- };
95
- //# sourceMappingURL=chunk-AKYK3XFN.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utilities/auto-animate-height.tsx"],"sourcesContent":["import { cloneElement, forwardRef, useEffect, useRef, useState } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport type { OverridableComponent } from \"../utils\";\n\nconst animationDurationToValue = {\n quick: 100,\n normal: 300,\n slow: 700,\n};\n\nexport interface AutoAnimateHeightProps {\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 * 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: OverridableComponent<AutoAnimateHeightProps, HTMLDivElement> =\n forwardRef(\n (\n {\n as: Component = \"div\",\n children,\n style,\n animationDuration = \"quick\",\n animationEasing = \"normal\",\n ...rest\n },\n ref,\n ) => {\n const timeoutRef = useRef<NodeJS.Timeout | null>(null);\n const measurementRef = useRef<HTMLDivElement>(null);\n const [height, setHeight] = useState<number | undefined>(undefined);\n const [clonedChildren, setClonedChildren] = useState<React.ReactNode>(() =>\n cloneElement(<>{children}</>, {}),\n );\n useEffect(() => {\n if (measurementRef.current) {\n const { height: newHeight } = measurementRef.current.getBoundingClientRect();\n\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n if (newHeight < (height ?? 0)) {\n // If the children are shrinking, hold off on replacing until the animation is done\n // This way we don't get a sudden flash of empty content\n setTimeout(() => {\n flushSync(() => {\n setHeight(newHeight);\n });\n timeoutRef.current = setTimeout(() => {\n setClonedChildren(cloneElement(<>{children}</>, {}));\n }, animationDurationToValue[animationDuration]);\n });\n } else {\n setHeight(newHeight);\n setClonedChildren(cloneElement(<>{children}</>, {}));\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- I know better\n }, [children]);\n\n return (\n <Component\n ref={ref}\n style={{\n position: \"relative\",\n overflow: \"hidden\",\n height,\n transitionProperty: \"height\",\n transitionDuration: `var(--hds-micro-animation-duration-${animationDuration})`,\n transitionTimingFunction: `var(--hds-micro-animation-easing-${animationEasing})`,\n ...style,\n }}\n {...rest}\n >\n <div\n aria-hidden\n ref={measurementRef}\n style={{\n position: \"absolute\",\n visibility: \"hidden\",\n }}\n >\n {children}\n </div>\n {clonedChildren}\n </Component>\n );\n },\n );\nAutoAnimateHeight.displayName = \"AutoAnimateHeight\";\n"],"mappings":";;;;;;;AAAA,SAAS,cAAc,YAAY,WAAW,QAAQ,gBAAgB;AACtE,SAAS,iBAAiB;AAoDL,wBA6Bb,YA7Ba;AAjDrB,IAAM,2BAA2B;AAAA,EAC/B,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AACR;AA4BO,IAAM,oBACX;AAAA,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,QAaC;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,eAAW;AAAA,cACX,KAAK;AAAA,cACL,OAAO;AAAA,gBACL,UAAU;AAAA,gBACV,YAAY;AAAA,cACd;AAAA,cAEC;AAAA;AAAA,UACH;AAAA,UACC;AAAA;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACF,kBAAkB,cAAc;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/button/button.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport type { OverridableComponent } from \"../utils\";\n\ninterface ButtonPropsInternal extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * The height, font size and padding of the button\n */\n size?: \"small\" | \"medium\" | \"large\";\n\n /**\n * Make the button use 100% width available.\n * Using the \"mobile\" it only stretch to full width on smaller screens\n */\n fullWidth?: boolean | \"mobile\";\n\n /**\n * Use an icon inside the button\n */\n icon?: React.ReactNode;\n\n children?: React.ReactNode;\n}\n\nexport type ButtonProps = ButtonPropsInternal &\n (\n | {\n /**\n * The background fill of the button\n */\n fill?: \"contained\" | \"outline\";\n }\n | {\n /**\n * @deprecated use `fill='outline'` instead\n */\n fill?: \"outlined\";\n }\n );\n\nexport const BaseButton: OverridableComponent<\n ButtonProps & { variant: \"primary\" | \"secondary\" },\n HTMLButtonElement\n> = forwardRef(\n (\n {\n as: Component = \"button\",\n children,\n variant,\n size = \"medium\",\n fullWidth = false,\n fill = \"contained\",\n icon,\n className,\n ...rest\n },\n ref,\n ) => {\n // TODO: Remove deprecated fill value name at some point\n // Deprecated at 10. march 2024\n if (fill === \"outlined\") {\n // eslint-disable-next-line no-console -- Deprecation warning\n console.warn(\"The `fill` value `outlined` is deprecated, use `fill='outline'` instead\");\n }\n return (\n <Component\n className={clsx(\n \"hds-button\",\n `hds-button--${size}`,\n {\n [`hds-button--${variant}`]: fill === \"contained\",\n [`hds-button--outline-${variant}`]: fill === \"outline\" || fill === \"outlined\",\n \"hds-button--full\": fullWidth === true,\n \"hds-button--mobile-full\": fullWidth === \"mobile\",\n \"hds-button--icon-only\": icon && !children,\n },\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {icon && !children ? icon : null}\n {children}\n </Component>\n );\n },\n);\nBaseButton.displayName = \"BaseButton\";\n\n/**\n * ## TODO\n *\n * - [x] Handle links that looks like buttons\n * - [ ] Revisit how to handle outline\n * - [ ] Figure out outline-white\n */\n\nexport const PrimaryButton: OverridableComponent<ButtonProps, HTMLButtonElement> = forwardRef(\n (props, ref) => {\n return <BaseButton {...props} ref={ref} variant=\"primary\" />;\n },\n);\n\nPrimaryButton.displayName = \"PrimaryButton\";\n\nexport const SecondaryButton: OverridableComponent<ButtonProps, HTMLButtonElement> = forwardRef(\n (props, ref) => {\n return <BaseButton {...props} ref={ref} variant=\"secondary\" />;\n },\n);\n\nSecondaryButton.displayName = \"SecondaryButton\";\n"],"mappings":";;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AAgEf,SAkCK,KAlCL;AAzBC,IAAM,aAGT;AAAA,EACF,CACE,IAWA,QACG;AAZH,iBACE;AAAA,UAAI,YAAY;AAAA,MAChB;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP,YAAY;AAAA,MACZ,OAAO;AAAA,MACP;AAAA,MACA;AAAA,IArDN,IA6CI,IASK,iBATL,IASK;AAAA,MARH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAOF,QAAI,SAAS,YAAY;AAEvB,cAAQ,KAAK,yEAAyE;AAAA,IACxF;AACA,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAW;AAAA,UACT;AAAA,UACA,eAAe,IAAI;AAAA,UACnB;AAAA,YACE,CAAC,eAAe,OAAO,EAAE,GAAG,SAAS;AAAA,YACrC,CAAC,uBAAuB,OAAO,EAAE,GAAG,SAAS,aAAa,SAAS;AAAA,YACnE,oBAAoB,cAAc;AAAA,YAClC,2BAA2B,cAAc;AAAA,YACzC,yBAAyB,QAAQ,CAAC;AAAA,UACpC;AAAA,UACA;AAAA,QACF;AAAA,QACA;AAAA,SACI,OAdL;AAAA,QAgBE;AAAA,kBAAQ,CAAC,WAAW,OAAO;AAAA,UAC3B;AAAA;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,WAAW,cAAc;AAUlB,IAAM,gBAAsE;AAAA,EACjF,CAAC,OAAO,QAAQ;AACd,WAAO,oBAAC,6CAAe,QAAf,EAAsB,KAAU,SAAQ,YAAU;AAAA,EAC5D;AACF;AAEA,cAAc,cAAc;AAErB,IAAM,kBAAwE;AAAA,EACnF,CAAC,OAAO,QAAQ;AACd,WAAO,oBAAC,6CAAe,QAAf,EAAsB,KAAU,SAAQ,cAAY;AAAA,EAC9D;AACF;AAEA,gBAAgB,cAAc;","names":[]}
@@ -1,35 +0,0 @@
1
- import {
2
- __objRest,
3
- __spreadValues
4
- } from "./chunk-R4SQKVDQ.mjs";
5
-
6
- // src/description-list/description-list.tsx
7
- import { clsx } from "@postenbring/hedwig-css/typed-classname";
8
- import { jsx } from "react/jsx-runtime";
9
- function DescriptionList(_a) {
10
- var _b = _a, {
11
- variant = "vertical",
12
- className
13
- } = _b, rest = __objRest(_b, [
14
- "variant",
15
- "className"
16
- ]);
17
- return /* @__PURE__ */ jsx(
18
- "dl",
19
- __spreadValues({
20
- className: clsx(
21
- "hds-description-list",
22
- {
23
- "hds-description-list--horizontal": variant === "horizontal"
24
- },
25
- className
26
- )
27
- }, rest)
28
- );
29
- }
30
- DescriptionList.displayName = "DescriptionList";
31
-
32
- export {
33
- DescriptionList
34
- };
35
- //# sourceMappingURL=chunk-XMB45ILT.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/description-list/description-list.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\n\nexport interface DescriptionListProps extends HTMLAttributes<HTMLDListElement> {\n /**\n * Either `DescriptionDetails` or `DescriptionTerm` elements\n */\n children?: ReactNode;\n /**\n * Direction of the description list\n */\n variant?: \"vertical\" | \"horizontal\";\n}\n\n/**\n * Uses the HTML5 `<dl>` element\n *\n * Pass in corresponding `<dt>` and `<dd>` elements as children\n *\n * ```tsx\n * <DescriptionList>\n * <dt>Vekt</dt>\n * <dd>12 kg</dd>\n * <dt>Antall kolli</dt>\n * <dd>2</dd>\n * </DescriptionList>\n * ```\n *\n * Optionally wrap them in `<div>` elements as allowed by the HTML5 spec\n *\n * ```tsx\n * <DescriptionList>\n * <div>\n * <dt>Vekt</dt>\n * <dd>12 kg</dd>\n * </div>\n * <div>\n * <dt>Antall kolli</dt>\n * <dd>2</dd>\n * </div>\n * </DescriptionList>\n * ```\n */\nexport function DescriptionList({\n variant = \"vertical\",\n className,\n ...rest\n}: DescriptionListProps) {\n return (\n <dl\n className={clsx(\n \"hds-description-list\",\n {\n \"hds-description-list--horizontal\": variant === \"horizontal\",\n },\n className as undefined,\n )}\n {...rest}\n />\n );\n}\nDescriptionList.displayName = \"DescriptionList\";\n"],"mappings":";;;;;;AACA,SAAS,YAAY;AAgDjB;AANG,SAAS,gBAAgB,IAIP;AAJO,eAC9B;AAAA,cAAU;AAAA,IACV;AAAA,EA7CF,IA2CgC,IAG3B,iBAH2B,IAG3B;AAAA,IAFH;AAAA,IACA;AAAA;AAGA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA;AAAA,UACE,oCAAoC,YAAY;AAAA,QAClD;AAAA,QACA;AAAA,MACF;AAAA,OACI;AAAA,EACN;AAEJ;AACA,gBAAgB,cAAc;","names":[]}
@@ -1,19 +0,0 @@
1
- import {
2
- __objRest,
3
- __spreadProps,
4
- __spreadValues
5
- } from "./chunk-R4SQKVDQ.mjs";
6
-
7
- // src/breadcrumb/breadcrumb.tsx
8
- import { clsx } from "@postenbring/hedwig-css/typed-classname";
9
- import { jsx } from "react/jsx-runtime";
10
- function Breadcrumbs(_a) {
11
- var _b = _a, { olProps, children } = _b, rest = __objRest(_b, ["olProps", "children"]);
12
- return /* @__PURE__ */ jsx("nav", __spreadProps(__spreadValues({}, rest), { children: /* @__PURE__ */ jsx("ol", __spreadProps(__spreadValues({}, olProps), { className: clsx("hds-breadcrumbs", olProps == null ? void 0 : olProps.className), children })) }));
13
- }
14
- Breadcrumbs.displayName = "Breadcrumbs";
15
-
16
- export {
17
- Breadcrumbs
18
- };
19
- //# sourceMappingURL=chunk-YKDKFWP2.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/breadcrumb/breadcrumb.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactElement } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\n\nexport interface BreadcrumbsProps extends HTMLAttributes<HTMLOListElement> {\n children: ReactElement<HTMLLIElement> | ReactElement<HTMLLIElement>[];\n\n /**\n * Props passed to the `ol` html element\n */\n olProps?: HTMLAttributes<HTMLElement>;\n}\n\n/**\n * A breadcrumbs navigation menu\n *\n * **Usage**\n *\n * ```tsx\n * <Breadcrumbs data-testid=\"breadcrumbs\">\n * <li><Link href=\"../\">Previous page</Link></li>\n * <li aria-current=\"page\">Current page</li>\n * </Breadcrumbs>\n * ```\n *\n * Outputs this html structure\n *\n * ```html\n * <nav data-testid=\"breadcrumbs\">\n * <ol>\n * <li><a href=\"../\">Previous page</a></li>\n * <li aria-current=\"page\">Current page</li>\n * </ol>\n * </nav>\n * ```\n */\nexport function Breadcrumbs({ olProps, children, ...rest }: BreadcrumbsProps) {\n return (\n <nav {...rest}>\n <ol {...olProps} className={clsx(\"hds-breadcrumbs\", olProps?.className as undefined)}>\n {children}\n </ol>\n </nav>\n );\n}\n\nBreadcrumbs.displayName = \"Breadcrumbs\";\n"],"mappings":";;;;;;;AACA,SAAS,YAAY;AAqCf;AAHC,SAAS,YAAY,IAAkD;AAAlD,eAAE,WAAS,SAnCvC,IAmC4B,IAAwB,iBAAxB,IAAwB,CAAtB,WAAS;AACrC,SACE,oBAAC,wCAAQ,OAAR,EACC,8BAAC,uCAAO,UAAP,EAAgB,WAAW,KAAK,mBAAmB,mCAAS,SAAsB,GAChF,WACH,IACF;AAEJ;AAEA,YAAY,cAAc;","names":[]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-YWNVB7TY.mjs.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-ZOCMUEOX.mjs.map
@@ -1,2 +1,2 @@
1
- export { Breadcrumbs_alias_2 as Breadcrumbs } from '../_tsup-dts-rollup';
2
1
  export { BreadcrumbsProps_alias_2 as BreadcrumbsProps } from '../_tsup-dts-rollup';
2
+ export { Breadcrumbs_alias_2 as Breadcrumbs } from '../_tsup-dts-rollup';
@@ -1,2 +1,2 @@
1
- export { Breadcrumbs_alias_2 as Breadcrumbs } from '../_tsup-dts-rollup';
2
1
  export { BreadcrumbsProps_alias_2 as BreadcrumbsProps } from '../_tsup-dts-rollup';
2
+ export { Breadcrumbs_alias_2 as Breadcrumbs } from '../_tsup-dts-rollup';
File without changes
File without changes
File without changes