@postenbring/hedwig-react 0.0.60 → 0.0.62

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 (110) hide show
  1. package/dist/_tsup-dts-rollup.d.mts +142 -96
  2. package/dist/_tsup-dts-rollup.d.ts +142 -96
  3. package/dist/badge/badge.js +1 -0
  4. package/dist/badge/badge.js.map +1 -1
  5. package/dist/badge/badge.mjs +1 -1
  6. package/dist/badge/index.js +1 -0
  7. package/dist/badge/index.js.map +1 -1
  8. package/dist/badge/index.mjs +1 -1
  9. package/dist/chunk-2KX7VFN2.mjs +1 -0
  10. package/dist/{chunk-MDA3MMNA.mjs → chunk-5QL53TR2.mjs} +2 -1
  11. package/dist/{chunk-MDA3MMNA.mjs.map → chunk-5QL53TR2.mjs.map} +1 -1
  12. package/dist/chunk-DZNH5JHY.mjs +1 -0
  13. package/dist/{chunk-ZUKLWHUR.mjs → chunk-GJDRW6PA.mjs} +3 -2
  14. package/dist/{chunk-ZUKLWHUR.mjs.map → chunk-GJDRW6PA.mjs.map} +1 -1
  15. package/dist/chunk-H4GIHEB2.mjs +1 -0
  16. package/dist/{chunk-44X6U32G.mjs → chunk-OYJQ5MAS.mjs} +2 -1
  17. package/dist/{chunk-44X6U32G.mjs.map → chunk-OYJQ5MAS.mjs.map} +1 -1
  18. package/dist/{chunk-PTANXZW6.mjs → chunk-PMLDK3VC.mjs} +2 -1
  19. package/dist/{chunk-PTANXZW6.mjs.map → chunk-PMLDK3VC.mjs.map} +1 -1
  20. package/dist/{chunk-3ADVRQ3D.mjs → chunk-Q6REETZD.mjs} +14 -8
  21. package/dist/chunk-Q6REETZD.mjs.map +1 -0
  22. package/dist/chunk-V4NGUB4I.mjs +34 -0
  23. package/dist/chunk-V4NGUB4I.mjs.map +1 -0
  24. package/dist/{chunk-Q3GMWURJ.mjs → chunk-VKRPPQ6F.mjs} +6 -6
  25. package/dist/{chunk-JDJQFQQ6.mjs → chunk-W3D4VR4Y.mjs} +2 -1
  26. package/dist/{chunk-JDJQFQQ6.mjs.map → chunk-W3D4VR4Y.mjs.map} +1 -1
  27. package/dist/chunk-WGVZWX5L.mjs +82 -0
  28. package/dist/chunk-WGVZWX5L.mjs.map +1 -0
  29. package/dist/form/index.d.mts +3 -0
  30. package/dist/form/index.d.ts +3 -0
  31. package/dist/form/index.js +65 -8
  32. package/dist/form/index.js.map +1 -1
  33. package/dist/form/index.mjs +7 -3
  34. package/dist/form/radiobutton/index.d.mts +3 -0
  35. package/dist/form/radiobutton/index.d.ts +3 -0
  36. package/dist/form/radiobutton/index.js +135 -8
  37. package/dist/form/radiobutton/index.js.map +1 -1
  38. package/dist/form/radiobutton/index.mjs +10 -2
  39. package/dist/form/radiobutton/radiobutton.js +133 -8
  40. package/dist/form/radiobutton/radiobutton.js.map +1 -1
  41. package/dist/form/radiobutton/radiobutton.mjs +6 -1
  42. package/dist/form/radiobutton/radiogroup.d.mts +3 -0
  43. package/dist/form/radiobutton/radiogroup.d.ts +3 -0
  44. package/dist/form/radiobutton/radiogroup.js +145 -0
  45. package/dist/form/radiobutton/radiogroup.js.map +1 -0
  46. package/dist/form/radiobutton/radiogroup.mjs +14 -0
  47. package/dist/form/radiobutton/radiogroup.mjs.map +1 -0
  48. package/dist/index-no-css.d.mts +3 -0
  49. package/dist/index-no-css.d.ts +3 -0
  50. package/dist/index-no-css.js +228 -160
  51. package/dist/index-no-css.js.map +1 -1
  52. package/dist/index-no-css.mjs +23 -18
  53. package/dist/index.d.mts +3 -0
  54. package/dist/index.d.ts +3 -0
  55. package/dist/index.js +228 -160
  56. package/dist/index.js.map +1 -1
  57. package/dist/index.mjs +23 -18
  58. package/dist/index.mjs.map +1 -1
  59. package/dist/link/index.js +1 -0
  60. package/dist/link/index.js.map +1 -1
  61. package/dist/link/index.mjs +1 -1
  62. package/dist/link/link.js +1 -0
  63. package/dist/link/link.js.map +1 -1
  64. package/dist/link/link.mjs +1 -1
  65. package/dist/list/index.js +2 -0
  66. package/dist/list/index.js.map +1 -1
  67. package/dist/list/index.mjs +2 -2
  68. package/dist/list/link-list.js +2 -0
  69. package/dist/list/link-list.js.map +1 -1
  70. package/dist/list/link-list.mjs +2 -2
  71. package/dist/list/list.js +1 -0
  72. package/dist/list/list.js.map +1 -1
  73. package/dist/list/list.mjs +1 -1
  74. package/dist/navbar/index.mjs +2 -2
  75. package/dist/show-more/index.d.mts +2 -2
  76. package/dist/show-more/index.d.ts +2 -2
  77. package/dist/show-more/index.js +13 -7
  78. package/dist/show-more/index.js.map +1 -1
  79. package/dist/show-more/index.mjs +3 -3
  80. package/dist/skeleton/index.js +1 -0
  81. package/dist/skeleton/index.js.map +1 -1
  82. package/dist/skeleton/index.mjs +1 -1
  83. package/dist/skeleton/skeleton.js +1 -0
  84. package/dist/skeleton/skeleton.js.map +1 -1
  85. package/dist/skeleton/skeleton.mjs +1 -1
  86. package/dist/utilities/auto-animate-height.d.mts +2 -0
  87. package/dist/utilities/auto-animate-height.d.ts +2 -0
  88. package/dist/{show-more → utilities}/auto-animate-height.js +13 -7
  89. package/dist/utilities/auto-animate-height.js.map +1 -0
  90. package/dist/{show-more → utilities}/auto-animate-height.mjs +1 -1
  91. package/dist/utilities/auto-animate-height.mjs.map +1 -0
  92. package/dist/utilities/index.d.mts +2 -0
  93. package/dist/utilities/index.d.ts +2 -0
  94. package/dist/utilities/index.js +143 -0
  95. package/dist/utilities/index.js.map +1 -0
  96. package/dist/utilities/index.mjs +9 -0
  97. package/dist/utilities/index.mjs.map +1 -0
  98. package/package.json +3 -3
  99. package/dist/chunk-3ADVRQ3D.mjs.map +0 -1
  100. package/dist/chunk-DY7LD3X3.mjs +0 -1
  101. package/dist/chunk-MQ3EEUTP.mjs +0 -1
  102. package/dist/chunk-SEKRICE4.mjs +0 -42
  103. package/dist/chunk-SEKRICE4.mjs.map +0 -1
  104. package/dist/show-more/auto-animate-height.d.mts +0 -2
  105. package/dist/show-more/auto-animate-height.d.ts +0 -2
  106. package/dist/show-more/auto-animate-height.js.map +0 -1
  107. /package/dist/{chunk-DY7LD3X3.mjs.map → chunk-2KX7VFN2.mjs.map} +0 -0
  108. /package/dist/{chunk-MQ3EEUTP.mjs.map → chunk-DZNH5JHY.mjs.map} +0 -0
  109. /package/dist/{show-more/auto-animate-height.mjs.map → chunk-H4GIHEB2.mjs.map} +0 -0
  110. /package/dist/{chunk-Q3GMWURJ.mjs.map → chunk-VKRPPQ6F.mjs.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,2 @@
1
+ export { AutoAnimateHeight_alias_4 as AutoAnimateHeight } from '../_tsup-dts-rollup';
2
+ export { AutoAnimateHeightProps_alias_4 as AutoAnimateHeightProps } from '../_tsup-dts-rollup';
@@ -0,0 +1,2 @@
1
+ export { AutoAnimateHeight_alias_4 as AutoAnimateHeight } from '../_tsup-dts-rollup';
2
+ export { AutoAnimateHeightProps_alias_4 as AutoAnimateHeightProps } from '../_tsup-dts-rollup';
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {}))
13
+ if (__hasOwnProp.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b)) {
17
+ if (__propIsEnum.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
+ var __objRest = (source, exclude) => {
24
+ var target = {};
25
+ for (var prop in source)
26
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
27
+ target[prop] = source[prop];
28
+ if (source != null && __getOwnPropSymbols)
29
+ for (var prop of __getOwnPropSymbols(source)) {
30
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
31
+ target[prop] = source[prop];
32
+ }
33
+ return target;
34
+ };
35
+ var __export = (target, all) => {
36
+ for (var name in all)
37
+ __defProp(target, name, { get: all[name], enumerable: true });
38
+ };
39
+ var __copyProps = (to, from, except, desc) => {
40
+ if (from && typeof from === "object" || typeof from === "function") {
41
+ for (let key of __getOwnPropNames(from))
42
+ if (!__hasOwnProp.call(to, key) && key !== except)
43
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
44
+ }
45
+ return to;
46
+ };
47
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
48
+
49
+ // src/utilities/index.ts
50
+ var utilities_exports = {};
51
+ __export(utilities_exports, {
52
+ AutoAnimateHeight: () => AutoAnimateHeight
53
+ });
54
+ module.exports = __toCommonJS(utilities_exports);
55
+
56
+ // src/utilities/auto-animate-height.tsx
57
+ var import_react = require("react");
58
+ var import_react_dom = require("react-dom");
59
+ 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)(
66
+ (_a, ref) => {
67
+ var _b = _a, {
68
+ as: Component = "div",
69
+ children,
70
+ style,
71
+ animationDuration = "quick",
72
+ animationEasing = "normal"
73
+ } = _b, rest = __objRest(_b, [
74
+ "as",
75
+ "children",
76
+ "style",
77
+ "animationDuration",
78
+ "animationEasing"
79
+ ]);
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 }), {})
85
+ );
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
+ }
105
+ }
106
+ }, [children]);
107
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
108
+ Component,
109
+ __spreadProps(__spreadValues({
110
+ ref,
111
+ style: __spreadValues({
112
+ overflow: "hidden",
113
+ height,
114
+ transitionProperty: "height",
115
+ transitionDuration: `var(--hds-micro-animation-duration-${animationDuration})`,
116
+ transitionTimingFunction: `var(--hds-micro-animation-easing-${animationEasing})`
117
+ }, style)
118
+ }, rest), {
119
+ children: [
120
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
121
+ "div",
122
+ {
123
+ "aria-hidden": true,
124
+ ref: measurementRef,
125
+ style: {
126
+ position: "absolute",
127
+ visibility: "hidden"
128
+ },
129
+ children
130
+ }
131
+ ),
132
+ clonedChildren
133
+ ]
134
+ })
135
+ );
136
+ }
137
+ );
138
+ AutoAnimateHeight.displayName = "AutoAnimateHeight";
139
+ // Annotate the CommonJS export names for ESM import in node:
140
+ 0 && (module.exports = {
141
+ AutoAnimateHeight
142
+ });
143
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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 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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ight
4
+ } from "../chunk-Q6REETZD.mjs";
5
+ import "../chunk-R4SQKVDQ.mjs";
6
+ export {
7
+ AutoAnimateHeight
8
+ };
9
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postenbring/hedwig-react",
3
- "version": "0.0.60",
3
+ "version": "0.0.62",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -19,8 +19,8 @@
19
19
  "react-dom": "18.2.0",
20
20
  "tsup": "^8.0.1",
21
21
  "typescript": "^5.4.3",
22
- "eslint-config-custom": "0.0.1",
23
- "hedwig-tsconfig": "0.0.0"
22
+ "hedwig-tsconfig": "0.0.0",
23
+ "eslint-config-custom": "0.0.1"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "@types/react": "^17.0.0 || ^18.0.0",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/show-more/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 \"normal\"\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 = \"normal\",\n animationEasing = \"normal\",\n ...rest\n },\n ref,\n ) => {\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 (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 flushSync(() => {\n setHeight(newHeight);\n });\n setTimeout(() => {\n setClonedChildren(cloneElement(<>{children}</>, {}));\n }, animationDurationToValue[animationDuration]);\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 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;AAmDL,wBAwBb,YAxBa;AAhDrB,IAAM,2BAA2B;AAAA,EAC/B,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AACR;AA4BO,IAAM,oBACX;AAAA,EACE,CACE,IAQA,QACG;AATH,iBACE;AAAA,UAAI,YAAY;AAAA,MAChB;AAA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,cAAc;","names":[]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-DY7LD3X3.mjs.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-MQ3EEUTP.mjs.map
@@ -1,42 +0,0 @@
1
- import {
2
- __objRest,
3
- __spreadProps,
4
- __spreadValues
5
- } from "./chunk-R4SQKVDQ.mjs";
6
-
7
- // src/form/radiobutton/radiobutton.tsx
8
- import { forwardRef } from "react";
9
- import { clsx } from "@postenbring/hedwig-css/typed-classname";
10
- import { jsx, jsxs } from "react/jsx-runtime";
11
- var Radiobutton = forwardRef(
12
- (_a, ref) => {
13
- var _b = _a, { variant = "plain", hasError, title, children, className } = _b, rest = __objRest(_b, ["variant", "hasError", "title", "children", "className"]);
14
- return /* @__PURE__ */ jsxs(
15
- "div",
16
- {
17
- className: clsx(
18
- "hds-radiobutton",
19
- {
20
- [`hds-radiobutton--${variant}`]: variant === "bounding-box",
21
- "hds-radiobutton--error": hasError
22
- },
23
- className
24
- ),
25
- children: [
26
- /* @__PURE__ */ jsxs("label", { children: [
27
- /* @__PURE__ */ jsx("input", __spreadProps(__spreadValues({}, rest), { ref, type: "radio" })),
28
- /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "hds-radiobutton__checkmark" }),
29
- title ? /* @__PURE__ */ jsx("p", { className: "hds-radiobutton__title", children: title }) : children
30
- ] }),
31
- title ? children : null
32
- ]
33
- }
34
- );
35
- }
36
- );
37
- Radiobutton.displayName = "Radiobutton";
38
-
39
- export {
40
- Radiobutton
41
- };
42
- //# sourceMappingURL=chunk-SEKRICE4.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/form/radiobutton/radiobutton.tsx"],"sourcesContent":["import type { InputHTMLAttributes } from \"react\";\nimport React, { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\n\nexport interface RadiobuttonProps\n extends Omit<InputHTMLAttributes<HTMLInputElement>, \"defaultValue\"> {\n variant?: \"plain\" | \"bounding-box\";\n hasError?: boolean;\n title?: string;\n}\n\nexport const Radiobutton = forwardRef<HTMLInputElement, RadiobuttonProps>(\n ({ variant = \"plain\", hasError, title, children, className, ...rest }, ref) => {\n return (\n <div\n className={clsx(\n \"hds-radiobutton\",\n {\n [`hds-radiobutton--${variant}`]: variant === \"bounding-box\",\n \"hds-radiobutton--error\": hasError,\n },\n className as undefined,\n )}\n >\n <label>\n <input {...rest} ref={ref} type=\"radio\" />\n <span aria-hidden className=\"hds-radiobutton__checkmark\" />\n {title ? <p className=\"hds-radiobutton__title\">{title}</p> : children}\n </label>\n {title ? children : null}\n </div>\n );\n },\n);\nRadiobutton.displayName = \"Radiobutton\";\n"],"mappings":";;;;;;;AACA,SAAgB,kBAAkB;AAClC,SAAS,YAAY;AAsBb,SACE,KADF;AAbD,IAAM,cAAc;AAAA,EACzB,CAAC,IAAsE,QAAQ;AAA9E,iBAAE,YAAU,SAAS,UAAU,OAAO,UAAU,UAZnD,IAYG,IAA8D,iBAA9D,IAA8D,CAA5D,WAAmB,YAAU,SAAO,YAAU;AAC/C,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAW;AAAA,UACT;AAAA,UACA;AAAA,YACE,CAAC,oBAAoB,OAAO,EAAE,GAAG,YAAY;AAAA,YAC7C,0BAA0B;AAAA,UAC5B;AAAA,UACA;AAAA,QACF;AAAA,QAEA;AAAA,+BAAC,WACC;AAAA,gCAAC,0CAAU,OAAV,EAAgB,KAAU,MAAK,UAAQ;AAAA,YACxC,oBAAC,UAAK,eAAW,MAAC,WAAU,8BAA6B;AAAA,YACxD,QAAQ,oBAAC,OAAE,WAAU,0BAA0B,iBAAM,IAAO;AAAA,aAC/D;AAAA,UACC,QAAQ,WAAW;AAAA;AAAA;AAAA,IACtB;AAAA,EAEJ;AACF;AACA,YAAY,cAAc;","names":[]}
@@ -1,2 +0,0 @@
1
- export { AutoAnimateHeightProps_alias_2 as AutoAnimateHeightProps } from '../_tsup-dts-rollup';
2
- export { AutoAnimateHeight_alias_2 as AutoAnimateHeight } from '../_tsup-dts-rollup';
@@ -1,2 +0,0 @@
1
- export { AutoAnimateHeightProps_alias_2 as AutoAnimateHeightProps } from '../_tsup-dts-rollup';
2
- export { AutoAnimateHeight_alias_2 as AutoAnimateHeight } from '../_tsup-dts-rollup';
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/show-more/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 \"normal\"\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 = \"normal\",\n animationEasing = \"normal\",\n ...rest\n },\n ref,\n ) => {\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 (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 flushSync(() => {\n setHeight(newHeight);\n });\n setTimeout(() => {\n setClonedChildren(cloneElement(<>{children}</>, {}));\n }, animationDurationToValue[animationDuration]);\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 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;AAAA,mBAAsE;AACtE,uBAA0B;AAmDL;AAhDrB,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,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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