etudes 5.0.0 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/components/Accordion.js +36 -63
  2. package/components/Accordion.js.map +1 -1
  3. package/components/BurgerButton.d.ts +15 -15
  4. package/components/BurgerButton.js +11 -35
  5. package/components/BurgerButton.js.map +1 -1
  6. package/components/Carousel.d.ts +2 -2
  7. package/components/Carousel.js +6 -31
  8. package/components/Carousel.js.map +1 -1
  9. package/components/Collection.js +7 -29
  10. package/components/Collection.js.map +1 -1
  11. package/components/Counter.d.ts +11 -11
  12. package/components/Counter.js +3 -28
  13. package/components/Counter.js.map +1 -1
  14. package/components/CoverImage.d.ts +6 -6
  15. package/components/CoverImage.js +10 -35
  16. package/components/CoverImage.js.map +1 -1
  17. package/components/CoverVideo.d.ts +6 -6
  18. package/components/CoverVideo.js +10 -35
  19. package/components/CoverVideo.js.map +1 -1
  20. package/components/DebugConsole.d.ts +8 -8
  21. package/components/DebugConsole.js +3 -28
  22. package/components/DebugConsole.js.map +1 -1
  23. package/components/Dial.d.ts +12 -12
  24. package/components/Dial.js +13 -39
  25. package/components/Dial.js.map +1 -1
  26. package/components/Dropdown.js +5 -32
  27. package/components/Dropdown.js.map +1 -1
  28. package/components/FlatSVG.d.ts +8 -8
  29. package/components/FlatSVG.js +3 -25
  30. package/components/FlatSVG.js.map +1 -1
  31. package/components/Image.d.ts +15 -15
  32. package/components/Image.js +3 -25
  33. package/components/Image.js.map +1 -1
  34. package/components/MasonryGrid.d.ts +2 -2
  35. package/components/MasonryGrid.js +3 -26
  36. package/components/MasonryGrid.js.map +1 -1
  37. package/components/Panorama.d.ts +2 -2
  38. package/components/Panorama.js +3 -26
  39. package/components/Panorama.js.map +1 -1
  40. package/components/PanoramaSlider.d.ts +11 -11
  41. package/components/PanoramaSlider.js +14 -43
  42. package/components/PanoramaSlider.js.map +1 -1
  43. package/components/RangeSlider.d.ts +16 -16
  44. package/components/RangeSlider.js +45 -74
  45. package/components/RangeSlider.js.map +1 -1
  46. package/components/RotatingGallery.d.ts +12 -12
  47. package/components/RotatingGallery.js +10 -33
  48. package/components/RotatingGallery.js.map +1 -1
  49. package/components/SelectableButton.d.ts +10 -10
  50. package/components/SelectableButton.js +3 -25
  51. package/components/SelectableButton.js.map +1 -1
  52. package/components/Slider.d.ts +20 -20
  53. package/components/Slider.js +32 -58
  54. package/components/Slider.js.map +1 -1
  55. package/components/StepwiseSlider.d.ts +22 -22
  56. package/components/StepwiseSlider.js +34 -60
  57. package/components/StepwiseSlider.js.map +1 -1
  58. package/components/SwipeContainer.d.ts +9 -9
  59. package/components/SwipeContainer.js +3 -25
  60. package/components/SwipeContainer.js.map +1 -1
  61. package/components/TextField.d.ts +11 -11
  62. package/components/TextField.js +3 -25
  63. package/components/TextField.js.map +1 -1
  64. package/components/Video.d.ts +18 -18
  65. package/components/Video.js +3 -26
  66. package/components/Video.js.map +1 -1
  67. package/components/WithTooltip.d.ts +2 -2
  68. package/components/WithTooltip.js +4 -27
  69. package/components/WithTooltip.js.map +1 -1
  70. package/hooks/useClickOutsideEffect.js +1 -2
  71. package/hooks/useClickOutsideEffect.js.map +1 -1
  72. package/hooks/useDragEffect.js +1 -2
  73. package/hooks/useDragEffect.js.map +1 -1
  74. package/hooks/useDragValueEffect.js +1 -2
  75. package/hooks/useDragValueEffect.js.map +1 -1
  76. package/hooks/useImageSize.js +1 -2
  77. package/hooks/useImageSize.js.map +1 -1
  78. package/hooks/useInterval.js +1 -2
  79. package/hooks/useInterval.js.map +1 -1
  80. package/hooks/useLoadImageEffect.js +1 -2
  81. package/hooks/useLoadImageEffect.js.map +1 -1
  82. package/hooks/useLoadVideoMetadataEffect.js +1 -2
  83. package/hooks/useLoadVideoMetadataEffect.js.map +1 -1
  84. package/hooks/useMounted.js +1 -2
  85. package/hooks/useMounted.js.map +1 -1
  86. package/hooks/usePrevious.js +1 -2
  87. package/hooks/usePrevious.js.map +1 -1
  88. package/hooks/useRect.js +1 -2
  89. package/hooks/useRect.js.map +1 -1
  90. package/hooks/useResizeEffect.js +1 -2
  91. package/hooks/useResizeEffect.js.map +1 -1
  92. package/hooks/useScrollPositionEffect.js +1 -2
  93. package/hooks/useScrollPositionEffect.js.map +1 -1
  94. package/hooks/useSearchParamState.js +1 -2
  95. package/hooks/useSearchParamState.js.map +1 -1
  96. package/hooks/useSize.js +1 -2
  97. package/hooks/useSize.js.map +1 -1
  98. package/hooks/useTimeout.js +1 -2
  99. package/hooks/useTimeout.js.map +1 -1
  100. package/hooks/useVideoSize.js +1 -2
  101. package/hooks/useVideoSize.js.map +1 -1
  102. package/hooks/useViewportSize.js +1 -2
  103. package/hooks/useViewportSize.js.map +1 -1
  104. package/operators/Conditional.d.ts +2 -2
  105. package/operators/Conditional.js +5 -9
  106. package/operators/Conditional.js.map +1 -1
  107. package/operators/Each.d.ts +2 -2
  108. package/operators/Each.js +8 -31
  109. package/operators/Each.js.map +1 -1
  110. package/operators/ExtractChild.d.ts +2 -2
  111. package/operators/ExtractChild.js +13 -35
  112. package/operators/ExtractChild.js.map +1 -1
  113. package/operators/ExtractChildren.d.ts +2 -2
  114. package/operators/ExtractChildren.js +11 -34
  115. package/operators/ExtractChildren.js.map +1 -1
  116. package/operators/Repeat.d.ts +2 -2
  117. package/operators/Repeat.js +7 -30
  118. package/operators/Repeat.js.map +1 -1
  119. package/package.json +33 -30
  120. package/providers/ScrollPositionProvider.d.ts +3 -3
  121. package/providers/ScrollPositionProvider.js +6 -28
  122. package/providers/ScrollPositionProvider.js.map +1 -1
  123. package/utils/asClassNameDict.js +1 -2
  124. package/utils/asClassNameDict.js.map +1 -1
  125. package/utils/asComponentDict.js +1 -2
  126. package/utils/asComponentDict.js.map +1 -1
  127. package/utils/asStyleDict.js +1 -2
  128. package/utils/asStyleDict.js.map +1 -1
  129. package/utils/cloneStyledElement.js +1 -2
  130. package/utils/cloneStyledElement.js.map +1 -1
  131. package/utils/styles.js +1 -2
  132. package/utils/styles.js.map +1 -1
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __read = (this && this.__read) || function (o, n) {
26
3
  var m = typeof Symbol === "function" && o[Symbol.iterator];
27
4
  if (!m) return o;
@@ -48,19 +25,19 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
48
25
  return to.concat(ar || Array.prototype.slice.call(from));
49
26
  };
50
27
  Object.defineProperty(exports, "__esModule", { value: true });
51
- exports.Repeat = void 0;
52
- var react_1 = __importStar(require("react"));
28
+ exports.Repeat = Repeat;
29
+ var jsx_runtime_1 = require("react/jsx-runtime");
30
+ var react_1 = require("react");
53
31
  /**
54
32
  * A tag-less component that repeats its children, automatically assigning each
55
33
  * a unique key.
56
34
  */
57
35
  function Repeat(_a) {
58
36
  var _b = _a.count, count = _b === void 0 ? 1 : _b, children = _a.children, render = _a.render;
59
- return (react_1.default.createElement(react_1.default.Fragment, null, __spreadArray([], __read(Array(count)), false).map(function (v, i) {
60
- var _a;
61
- return (react_1.default.createElement(react_1.Fragment, { key: "element-".concat(i) }, (_a = render === null || render === void 0 ? void 0 : render(i)) !== null && _a !== void 0 ? _a : (typeof children === 'function' ? children(i) : children)));
62
- })));
37
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: __spreadArray([], __read(Array(count)), false).map(function (v, i) {
38
+ var _a;
39
+ return ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: (_a = render === null || render === void 0 ? void 0 : render(i)) !== null && _a !== void 0 ? _a : (typeof children === 'function' ? children(i) : children) }, "element-".concat(i)));
40
+ }) }));
63
41
  }
64
- exports.Repeat = Repeat;
65
42
  Object.defineProperty(Repeat, 'displayName', { value: 'Repeat', writable: false });
66
43
  //# sourceMappingURL=Repeat.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Repeat.js","sourceRoot":"/","sources":["operators/Repeat.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAuD;AAQvD;;;GAGG;AACH,SAAgB,MAAM,CAAC,EAIC;QAHtB,aAAS,EAAT,KAAK,mBAAG,CAAC,KAAA,EACT,QAAQ,cAAA,EACR,MAAM,YAAA;IAEN,OAAO,CACL,8DACG,yBAAI,KAAK,CAAC,KAAK,CAAC,UAAE,GAAG,CAAC,UAAC,CAAC,EAAE,CAAC;;QAAK,OAAA,CAC/B,8BAAC,gBAAQ,IAAC,GAAG,EAAE,kBAAW,CAAC,CAAE,IAC1B,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,CAAC,CAAC,mCAAI,CAAC,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAChE,CACZ,CAAA;KAAA,CAAC,CACD,CACJ,CAAA;AACH,CAAC;AAdD,wBAcC;AAED,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA","sourcesContent":["import React, { Fragment, type ReactNode } from 'react'\n\nexport type RepeatProps = {\n children?: ReactNode | ((index: number) => ReactNode)\n count?: number\n render?: (index: number) => ReactNode\n}\n\n/**\n * A tag-less component that repeats its children, automatically assigning each\n * a unique key.\n */\nexport function Repeat({\n count = 1,\n children,\n render,\n}: Readonly<RepeatProps>) {\n return (\n <>\n {[...Array(count)].map((v, i) => (\n <Fragment key={`element-${i}`}>\n {render?.(i) ?? (typeof children === 'function' ? children(i) : children)}\n </Fragment>\n ))}\n </>\n )\n}\n\nObject.defineProperty(Repeat, 'displayName', { value: 'Repeat', writable: false })\n"]}
1
+ {"version":3,"file":"Repeat.js","sourceRoot":"/","sources":["operators/Repeat.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,wBAcC;;AA1BD,+BAAgD;AAQhD;;;GAGG;AACH,SAAgB,MAAM,CAAC,EAIC;QAHtB,aAAS,EAAT,KAAK,mBAAG,CAAC,KAAA,EACT,QAAQ,cAAA,EACR,MAAM,YAAA;IAEN,OAAO,CACL,2DACG,yBAAI,KAAK,CAAC,KAAK,CAAC,UAAE,GAAG,CAAC,UAAC,CAAC,EAAE,CAAC;;YAAK,OAAA,CAC/B,uBAAC,gBAAQ,cACN,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,CAAC,CAAC,mCAAI,CAAC,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAD5D,kBAAW,CAAC,CAAE,CAElB,CACZ,CAAA;SAAA,CAAC,GACD,CACJ,CAAA;AACH,CAAC;AAED,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA","sourcesContent":["import { Fragment, type ReactNode } from 'react'\n\nexport type RepeatProps = {\n children?: ReactNode | ((index: number) => ReactNode)\n count?: number\n render?: (index: number) => ReactNode\n}\n\n/**\n * A tag-less component that repeats its children, automatically assigning each\n * a unique key.\n */\nexport function Repeat({\n count = 1,\n children,\n render,\n}: Readonly<RepeatProps>) {\n return (\n <>\n {[...Array(count)].map((v, i) => (\n <Fragment key={`element-${i}`}>\n {render?.(i) ?? (typeof children === 'function' ? children(i) : children)}\n </Fragment>\n ))}\n </>\n )\n}\n\nObject.defineProperty(Repeat, 'displayName', { value: 'Repeat', writable: false })\n"]}
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "etudes",
3
- "version": "5.0.0",
3
+ "version": "5.2.0",
4
4
  "description": "A study of headless React components",
5
- "main": "lib",
6
5
  "scripts": {
7
6
  "clean": "rimraf lib",
8
7
  "prebuild": "npm run lint && npm run clean",
@@ -11,7 +10,7 @@
11
10
  "predemo": "npm run clean",
12
11
  "demo": "concurrently \"cross-env NODE_ENV=production tsc -w --diagnostics false\" \"wait-on lib && cross-env NODE_ENV=development webpack-cli serve --mode development --hot --config demo/config/build.conf.ts\"",
13
12
  "test": "echo \"No tests yet :)\"",
14
- "lint": "eslint --ext .ts --ext .tsx src demo",
13
+ "lint": "eslint",
15
14
  "lint:fix": "npm run lint -- --fix",
16
15
  "scan": "dotenv -- sh -c 'sonar-scanner -Dsonar.projectKey=$SONAR_PROJECT_KEY -Dsonar.sources=. -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.token=$SONAR_TOKEN'"
17
16
  },
@@ -35,55 +34,59 @@
35
34
  "utils"
36
35
  ],
37
36
  "devDependencies": {
38
- "@babel/core": "^7.24.4",
39
- "@babel/plugin-transform-runtime": "^7.24.3",
40
- "@babel/preset-env": "^7.24.4",
41
- "@babel/preset-react": "^7.24.1",
42
- "@babel/preset-typescript": "^7.24.1",
37
+ "@babel/core": "^7.24.7",
38
+ "@babel/plugin-transform-runtime": "^7.24.7",
39
+ "@babel/preset-env": "^7.24.7",
40
+ "@babel/preset-react": "^7.24.7",
41
+ "@babel/preset-typescript": "^7.24.7",
42
+ "@eslint/js": "^9.5.0",
43
+ "@semantic-release/changelog": "^6.0.3",
44
+ "@semantic-release/git": "^10.0.1",
45
+ "@stylistic/eslint-plugin": "^2.2.2",
43
46
  "@types/debug": "^4.1.12",
44
47
  "@types/html-webpack-plugin": "^3.2.9",
45
48
  "@types/node-polyglot": "^2.5.0",
46
- "@types/react": "^18.2.79",
47
- "@types/react-dom": "^18.2.25",
49
+ "@types/react": "^18.3.3",
50
+ "@types/react-dom": "^18.3.0",
48
51
  "@types/styled-components": "^5.1.34",
49
52
  "@types/webpack": "^5.28.5",
50
- "@types/webpack-env": "^1.18.4",
51
- "@typescript-eslint/eslint-plugin": "^7.7.0",
52
- "@typescript-eslint/parser": "^7.7.0",
53
+ "@types/webpack-env": "^1.18.5",
53
54
  "babel-loader": "^9.1.3",
54
55
  "babel-plugin-styled-components": "^2.1.4",
55
56
  "concurrently": "^8.2.2",
56
57
  "cross-env": "^7.0.3",
57
- "debug": "^4.3.4",
58
- "dotenv-cli": "^7.4.1",
59
- "eslint": "^8.56.0",
58
+ "debug": "^4.3.5",
59
+ "dotenv-cli": "^7.4.2",
60
+ "eslint": "^9.5.0",
60
61
  "html-webpack-plugin": "^5.6.0",
61
- "react": "^18.2.0",
62
- "react-dom": "^18.2.0",
63
- "react-router": "^6.22.3",
64
- "react-router-dom": "^6.22.3",
65
- "rimraf": "^5.0.5",
66
- "styled-components": "^6.1.8",
62
+ "react": "^18.3.1",
63
+ "react-dom": "^18.3.1",
64
+ "react-router": "^6.23.1",
65
+ "react-router-dom": "^6.23.1",
66
+ "rimraf": "^5.0.7",
67
+ "semantic-release": "^24.0.0",
68
+ "styled-components": "^6.1.11",
67
69
  "ts-node": "^10.9.2",
68
- "typescript": "^5.4.5",
70
+ "typescript": "^5.5.2",
71
+ "typescript-eslint": "^8.0.0-alpha.10",
69
72
  "wait-on": "^7.2.0",
70
- "webpack": "^5.91.0",
73
+ "webpack": "^5.92.1",
71
74
  "webpack-cli": "^5.1.4",
72
- "webpack-dev-server": "^4.15.1"
75
+ "webpack-dev-server": "^5.0.4"
73
76
  },
74
77
  "dependencies": {
75
- "clsx": "^2.1.0",
78
+ "clsx": "^2.1.1",
76
79
  "fast-deep-equal": "^3.1.3",
77
- "fast-xml-parser": "^4.3.6",
80
+ "fast-xml-parser": "^4.4.0",
78
81
  "interactjs": "^1.10.27",
79
82
  "resize-observer-polyfill": "^1.5.1",
80
- "spase": "^7.1.0"
83
+ "spase": "^7.2.1"
81
84
  },
82
85
  "peerDependencies": {
83
86
  "react": "^18.2.0"
84
87
  },
85
88
  "optionalDependencies": {
86
- "react-router": "^6.22.3",
87
- "react-router-dom": "^6.22.3"
89
+ "react-router": "^6.23.1",
90
+ "react-router-dom": "^6.23.1"
88
91
  }
89
92
  }
@@ -1,4 +1,4 @@
1
- import React, { type PropsWithChildren, type RefObject } from 'react';
1
+ import { type PropsWithChildren, type RefObject } from 'react';
2
2
  import { Point } from 'spase';
3
3
  type ScrollPosition = {
4
4
  pos: Point;
@@ -9,7 +9,7 @@ type ScrollPositionContextValue = ScrollPosition & {
9
9
  maxPos: Point;
10
10
  };
11
11
  type ScrollPositionProviderProps = PropsWithChildren;
12
- export declare const ScrollPositionContext: React.Context<ScrollPositionContextValue | undefined>;
13
- export declare function ScrollPositionProvider({ children, }: Readonly<ScrollPositionProviderProps>): React.JSX.Element;
12
+ export declare const ScrollPositionContext: import("react").Context<ScrollPositionContextValue | undefined>;
13
+ export declare function ScrollPositionProvider({ children, }: Readonly<ScrollPositionProviderProps>): import("react/jsx-runtime").JSX.Element;
14
14
  export declare function useScrollPosition(targetRef?: RefObject<Element>): ScrollPosition;
15
15
  export {};
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __read = (this && this.__read) || function (o, n) {
26
3
  var m = typeof Symbol === "function" && o[Symbol.iterator];
27
4
  if (!m) return o;
@@ -39,8 +16,11 @@ var __read = (this && this.__read) || function (o, n) {
39
16
  return ar;
40
17
  };
41
18
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.useScrollPosition = exports.ScrollPositionProvider = exports.ScrollPositionContext = void 0;
43
- var react_1 = __importStar(require("react"));
19
+ exports.ScrollPositionContext = void 0;
20
+ exports.ScrollPositionProvider = ScrollPositionProvider;
21
+ exports.useScrollPosition = useScrollPosition;
22
+ var jsx_runtime_1 = require("react/jsx-runtime");
23
+ var react_1 = require("react");
44
24
  var spase_1 = require("spase");
45
25
  exports.ScrollPositionContext = (0, react_1.createContext)(undefined);
46
26
  function ScrollPositionProvider(_a) {
@@ -77,9 +57,8 @@ function ScrollPositionProvider(_a) {
77
57
  window.removeEventListener('orientationchange', updateScrollPosition);
78
58
  };
79
59
  }, []);
80
- return (react_1.default.createElement(exports.ScrollPositionContext.Provider, { value: value }, children));
60
+ return ((0, jsx_runtime_1.jsx)(exports.ScrollPositionContext.Provider, { value: value, children: children }));
81
61
  }
82
- exports.ScrollPositionProvider = ScrollPositionProvider;
83
62
  function useScrollPosition(targetRef) {
84
63
  var context = (0, react_1.useContext)(exports.ScrollPositionContext);
85
64
  if (!context)
@@ -108,5 +87,4 @@ function useScrollPosition(targetRef) {
108
87
  step: new spase_1.Point([stepX, stepY]),
109
88
  };
110
89
  }
111
- exports.useScrollPosition = useScrollPosition;
112
90
  //# sourceMappingURL=ScrollPositionProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ScrollPositionProvider.js","sourceRoot":"/","sources":["providers/ScrollPositionProvider.tsx"],"names":[],"mappings":"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","sourcesContent":["import React, { createContext, useContext, useEffect, useState, type PropsWithChildren, type RefObject } from 'react'\nimport { Point, Rect } from 'spase'\n\ntype ScrollPosition = {\n pos: Point\n step: Point\n}\n\ntype ScrollPositionContextValue = ScrollPosition & {\n minPos: Point\n maxPos: Point\n}\n\ntype ScrollPositionProviderProps = PropsWithChildren\n\nexport const ScrollPositionContext = createContext<ScrollPositionContextValue | undefined>(undefined)\n\nexport function ScrollPositionProvider({\n children,\n}: Readonly<ScrollPositionProviderProps>) {\n const [value, setValue] = useState<ScrollPositionContextValue>({\n minPos: new Point(),\n maxPos: new Point(),\n pos: new Point(),\n step: new Point(),\n })\n\n useEffect(() => {\n const updateScrollPosition = () => {\n const refRect = Rect.fromViewport()\n const refRectMin = refRect.clone({ x: 0, y: 0 })\n const refRectFull = Rect.from(window, { overflow: true })\n\n if (!refRectFull) return\n\n const refRectMax = refRectMin.clone({ x: refRectFull.width - refRect.width, y: refRectFull.height - refRect.height })\n const step = new Point([refRect.left / refRectMax.left, refRect.top / refRectMax.top])\n\n setValue({\n minPos: new Point([refRectMin.left, refRectMin.top]),\n maxPos: new Point([refRectMax.left, refRectMax.top]),\n pos: new Point([refRect.left, refRect.top]),\n step,\n })\n }\n\n window.addEventListener('scroll', updateScrollPosition)\n window.addEventListener('resize', updateScrollPosition)\n window.addEventListener('orientationchange', updateScrollPosition)\n\n updateScrollPosition()\n\n return () => {\n window.removeEventListener('scroll', updateScrollPosition)\n window.removeEventListener('resize', updateScrollPosition)\n window.removeEventListener('orientationchange', updateScrollPosition)\n }\n }, [])\n\n return (\n <ScrollPositionContext.Provider value={value}>\n {children}\n </ScrollPositionContext.Provider>\n )\n}\n\nexport function useScrollPosition(targetRef?: RefObject<Element>): ScrollPosition {\n const context = useContext(ScrollPositionContext)\n if (!context) throw Error('Cannot fetch the current scroll position context, is the corresponding provider instated?')\n\n if (!targetRef) {\n return {\n pos: context.pos,\n step: context.step,\n }\n }\n\n const element = targetRef.current\n\n const refRect = Rect.fromViewport()\n const rect = Rect.from(element)\n\n if (!refRect || !rect) {\n return {\n pos: new Point(),\n step: new Point(),\n }\n }\n\n const posX = refRect.right - rect.left\n const posY = refRect.bottom - rect.top\n const stepX = posX / rect.width\n const stepY = posY / rect.height\n\n return {\n pos: new Point([posX, posY]),\n step: new Point([stepX, stepY]),\n }\n}\n"]}
1
+ {"version":3,"file":"ScrollPositionProvider.js","sourceRoot":"/","sources":["providers/ScrollPositionProvider.tsx"],"names":[],"mappings":"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","sourcesContent":["import { createContext, useContext, useEffect, useState, type PropsWithChildren, type RefObject } from 'react'\nimport { Point, Rect } from 'spase'\n\ntype ScrollPosition = {\n pos: Point\n step: Point\n}\n\ntype ScrollPositionContextValue = ScrollPosition & {\n minPos: Point\n maxPos: Point\n}\n\ntype ScrollPositionProviderProps = PropsWithChildren\n\nexport const ScrollPositionContext = createContext<ScrollPositionContextValue | undefined>(undefined)\n\nexport function ScrollPositionProvider({\n children,\n}: Readonly<ScrollPositionProviderProps>) {\n const [value, setValue] = useState<ScrollPositionContextValue>({\n minPos: new Point(),\n maxPos: new Point(),\n pos: new Point(),\n step: new Point(),\n })\n\n useEffect(() => {\n const updateScrollPosition = () => {\n const refRect = Rect.fromViewport()\n const refRectMin = refRect.clone({ x: 0, y: 0 })\n const refRectFull = Rect.from(window, { overflow: true })\n\n if (!refRectFull) return\n\n const refRectMax = refRectMin.clone({ x: refRectFull.width - refRect.width, y: refRectFull.height - refRect.height })\n const step = new Point([refRect.left / refRectMax.left, refRect.top / refRectMax.top])\n\n setValue({\n minPos: new Point([refRectMin.left, refRectMin.top]),\n maxPos: new Point([refRectMax.left, refRectMax.top]),\n pos: new Point([refRect.left, refRect.top]),\n step,\n })\n }\n\n window.addEventListener('scroll', updateScrollPosition)\n window.addEventListener('resize', updateScrollPosition)\n window.addEventListener('orientationchange', updateScrollPosition)\n\n updateScrollPosition()\n\n return () => {\n window.removeEventListener('scroll', updateScrollPosition)\n window.removeEventListener('resize', updateScrollPosition)\n window.removeEventListener('orientationchange', updateScrollPosition)\n }\n }, [])\n\n return (\n <ScrollPositionContext.Provider value={value}>\n {children}\n </ScrollPositionContext.Provider>\n )\n}\n\nexport function useScrollPosition(targetRef?: RefObject<Element>): ScrollPosition {\n const context = useContext(ScrollPositionContext)\n if (!context) throw Error('Cannot fetch the current scroll position context, is the corresponding provider instated?')\n\n if (!targetRef) {\n return {\n pos: context.pos,\n step: context.step,\n }\n }\n\n const element = targetRef.current\n\n const refRect = Rect.fromViewport()\n const rect = Rect.from(element)\n\n if (!refRect || !rect) {\n return {\n pos: new Point(),\n step: new Point(),\n }\n }\n\n const posX = refRect.right - rect.left\n const posY = refRect.bottom - rect.top\n const stepX = posX / rect.width\n const stepY = posY / rect.height\n\n return {\n pos: new Point([posX, posY]),\n step: new Point([stepX, stepY]),\n }\n}\n"]}
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.asClassNameDict = void 0;
3
+ exports.asClassNameDict = asClassNameDict;
4
4
  function asClassNameDict(dict) {
5
5
  return dict;
6
6
  }
7
- exports.asClassNameDict = asClassNameDict;
8
7
  //# sourceMappingURL=asClassNameDict.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"asClassNameDict.js","sourceRoot":"/","sources":["utils/asClassNameDict.ts"],"names":[],"mappings":";;;AAAA,SAAgB,eAAe,CAAI,IAAgC;IACjE,OAAO,IAAI,CAAA;AACb,CAAC;AAFD,0CAEC","sourcesContent":["export function asClassNameDict<T>(dict: { [K in keyof T]: string }) {\n return dict\n}\n"]}
1
+ {"version":3,"file":"asClassNameDict.js","sourceRoot":"/","sources":["utils/asClassNameDict.ts"],"names":[],"mappings":";;AAAA,0CAEC;AAFD,SAAgB,eAAe,CAAI,IAAgC;IACjE,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["export function asClassNameDict<T>(dict: { [K in keyof T]: string }) {\n return dict\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.asComponentDict = void 0;
3
+ exports.asComponentDict = asComponentDict;
4
4
  var react_1 = require("react");
5
5
  function asComponentDict(children, typeDict) {
6
6
  if (typeDict === void 0) { typeDict = {}; }
@@ -20,5 +20,4 @@ function asComponentDict(children, typeDict) {
20
20
  });
21
21
  return components;
22
22
  }
23
- exports.asComponentDict = asComponentDict;
24
23
  //# sourceMappingURL=asComponentDict.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"asComponentDict.js","sourceRoot":"/","sources":["utils/asComponentDict.ts"],"names":[],"mappings":";;;AAAA,+BAA4F;AAM5F,SAAgB,eAAe,CAA8B,QAAoB,EAAE,QAAqB;IAArB,yBAAA,EAAA,WAAc,EAAO;IACtG,IAAM,IAAI,GAAgB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC/C,IAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACrC,IAAM,UAAU,GAAqC,EAAE,CAAA;IAEvD,gBAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAA,KAAK;QAC9B,IAAI,CAAC,IAAA,sBAAc,EAAC,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC,wBAAwB,CAAC,CAAA;QAEjE,IAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAW,CAAC,CAAA;QAC9C,IAAI,KAAK,GAAG,CAAC;YAAE,MAAM,KAAK,CAAC,sEAA+D,KAAK,CAAE,CAAC,CAAA;QAElG,IAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAA;QACvB,IAAI,UAAU,CAAC,GAAG,CAAC;YAAE,MAAM,KAAK,CAAC,mBAAY,KAAK,CAAC,KAAK,CAAC,gCAA6B,CAAC,CAAA;QAEvF,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;IACzB,CAAC,CAAC,CAAA;IAEF,OAAO,UAAU,CAAA;AACnB,CAAC;AAlBD,0CAkBC","sourcesContent":["import { Children, isValidElement, type JSXElementConstructor, type ReactNode } from 'react'\n\ntype ComponentTypeDict = Record<string, JSXElementConstructor<any>>\n\ntype ComponentElementDict<T extends ComponentTypeDict> = Record<keyof T, JSX.Element>\n\nexport function asComponentDict<T extends ComponentTypeDict>(children?: ReactNode, typeDict: T = {} as T): Partial<ComponentElementDict<T>> {\n const keys: (keyof T)[] = Object.keys(typeDict)\n const types = Object.values(typeDict)\n const components: Partial<ComponentElementDict<T>> = {}\n\n Children.forEach(children, child => {\n if (!isValidElement(child)) throw Error('Invalid child detected')\n\n const index = types.indexOf(child.type as any)\n if (index < 0) throw Error(`Unsupported child, only the following children are allowed: ${types}`)\n\n const key = keys[index]\n if (components[key]) throw Error(`Only one ${types[index]} can be provided as a child`)\n\n components[key] = child\n })\n\n return components\n}\n"]}
1
+ {"version":3,"file":"asComponentDict.js","sourceRoot":"/","sources":["utils/asComponentDict.ts"],"names":[],"mappings":";;AAMA,0CAkBC;AAxBD,+BAA4F;AAM5F,SAAgB,eAAe,CAA8B,QAAoB,EAAE,QAAqB;IAArB,yBAAA,EAAA,WAAc,EAAO;IACtG,IAAM,IAAI,GAAgB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC/C,IAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACrC,IAAM,UAAU,GAAqC,EAAE,CAAA;IAEvD,gBAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAA,KAAK;QAC9B,IAAI,CAAC,IAAA,sBAAc,EAAC,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC,wBAAwB,CAAC,CAAA;QAEjE,IAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAW,CAAC,CAAA;QAC9C,IAAI,KAAK,GAAG,CAAC;YAAE,MAAM,KAAK,CAAC,sEAA+D,KAAK,CAAE,CAAC,CAAA;QAElG,IAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAA;QACvB,IAAI,UAAU,CAAC,GAAG,CAAC;YAAE,MAAM,KAAK,CAAC,mBAAY,KAAK,CAAC,KAAK,CAAC,gCAA6B,CAAC,CAAA;QAEvF,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;IACzB,CAAC,CAAC,CAAA;IAEF,OAAO,UAAU,CAAA;AACnB,CAAC","sourcesContent":["import { Children, isValidElement, type JSXElementConstructor, type ReactNode } from 'react'\n\ntype ComponentTypeDict = Record<string, JSXElementConstructor<any>>\n\ntype ComponentElementDict<T extends ComponentTypeDict> = Record<keyof T, JSX.Element>\n\nexport function asComponentDict<T extends ComponentTypeDict>(children?: ReactNode, typeDict: T = {} as T): Partial<ComponentElementDict<T>> {\n const keys: (keyof T)[] = Object.keys(typeDict)\n const types = Object.values(typeDict)\n const components: Partial<ComponentElementDict<T>> = {}\n\n Children.forEach(children, child => {\n if (!isValidElement(child)) throw Error('Invalid child detected')\n\n const index = types.indexOf(child.type as any)\n if (index < 0) throw Error(`Unsupported child, only the following children are allowed: ${types}`)\n\n const key = keys[index]\n if (components[key]) throw Error(`Only one ${types[index]} can be provided as a child`)\n\n components[key] = child\n })\n\n return components\n}\n"]}
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.asStyleDict = void 0;
3
+ exports.asStyleDict = asStyleDict;
4
4
  function asStyleDict(dict) {
5
5
  return dict;
6
6
  }
7
- exports.asStyleDict = asStyleDict;
8
7
  //# sourceMappingURL=asStyleDict.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"asStyleDict.js","sourceRoot":"/","sources":["utils/asStyleDict.ts"],"names":[],"mappings":";;;AAEA,SAAgB,WAAW,CAAI,IAAuC;IACpE,OAAO,IAAI,CAAA;AACb,CAAC;AAFD,kCAEC","sourcesContent":["import { type CSSProperties } from 'react'\n\nexport function asStyleDict<T>(dict: { [K in keyof T]: CSSProperties }) {\n return dict\n}\n"]}
1
+ {"version":3,"file":"asStyleDict.js","sourceRoot":"/","sources":["utils/asStyleDict.ts"],"names":[],"mappings":";;AAEA,kCAEC;AAFD,SAAgB,WAAW,CAAI,IAAuC;IACpE,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { type CSSProperties } from 'react'\n\nexport function asStyleDict<T>(dict: { [K in keyof T]: CSSProperties }) {\n return dict\n}\n"]}
@@ -47,7 +47,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
47
47
  return to.concat(ar || Array.prototype.slice.call(from));
48
48
  };
49
49
  Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.cloneStyledElement = void 0;
50
+ exports.cloneStyledElement = cloneStyledElement;
51
51
  var react_1 = require("react");
52
52
  function cloneStyledElement(element, props) {
53
53
  if (props === void 0) { props = {}; }
@@ -59,5 +59,4 @@ function cloneStyledElement(element, props) {
59
59
  var _b = element.props, elementClassName = _b.className, elementStyle = _b.style, otherElementProps = __rest(_b, ["className", "style"]);
60
60
  return react_1.cloneElement.apply(void 0, __spreadArray([element, __assign(__assign({ className: "".concat(elementClassName !== null && elementClassName !== void 0 ? elementClassName : '', " ").concat(className !== null && className !== void 0 ? className : '').split(' ').filter(Boolean).join(' '), style: __assign(__assign({}, elementStyle !== null && elementStyle !== void 0 ? elementStyle : {}), style !== null && style !== void 0 ? style : {}) }, otherElementProps), otherProps)], __read(children), false));
61
61
  }
62
- exports.cloneStyledElement = cloneStyledElement;
63
62
  //# sourceMappingURL=cloneStyledElement.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cloneStyledElement.js","sourceRoot":"/","sources":["utils/cloneStyledElement.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAiM;AAkBjM,SAAS,kBAAkB,CACzB,OAAuE,EACvE,KAAqE;IAArE,sBAAA,EAAA,UAAqE;IACrE,kBAAwB;SAAxB,UAAwB,EAAxB,qBAAwB,EAAxB,IAAwB;QAAxB,iCAAwB;;IAExB,IAAM,KAAsC,KAAY,EAAhD,SAAS,eAAA,EAAE,KAAK,WAAA,EAAK,UAAU,cAAjC,sBAAmC,CAAe,CAAA;IACxD,IAAM,KAA6E,OAAO,CAAC,KAAY,EAApF,gBAAgB,eAAA,EAAS,YAAY,WAAA,EAAK,iBAAiB,cAAxE,sBAA0E,CAAuB,CAAA;IAEvG,OAAO,oBAAY,8BAAC,OAAO,sBACzB,SAAS,EAAE,UAAG,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,EAAE,cAAI,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAC9F,KAAK,wBACA,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,GAClB,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,KAEb,iBAAiB,GACjB,UAAU,WACT,QAAQ,WAAC;AACjB,CAAC;AAEQ,gDAAkB","sourcesContent":["import { cloneElement, type Attributes, type CElement, type ClassAttributes, type Component, type ComponentState, type FunctionComponentElement, type ReactElement, type ReactNode } from 'react'\n\n/**\n * Wrapper for {@link cloneElement} but instead of overwriting `className` and\n * `style` of the cloned element with the values specified in the `props`\n * argument, they are merged.\n *\n * @param element The target element to clone.\n * @param props The props to apply to the cloned element. Overlapping props are\n * overwritten with the exception of `className` and `style`, which\n * are merged.\n * @param children Optional child elements add into the cloned element.\n *\n * @returns The cloned element.\n */\nfunction cloneStyledElement<P>(element: FunctionComponentElement<P>, props?: Partial<P> & Attributes, ...children: ReactNode[]): FunctionComponentElement<P>\nfunction cloneStyledElement<P, T extends Component<P, ComponentState>>(element: CElement<P, T>, props?: Partial<P> & ClassAttributes<T>, ...children: ReactNode[]): CElement<P, T>\nfunction cloneStyledElement<P>(element: ReactElement<P>, props?: Partial<P> & Attributes, ...children: ReactNode[]): ReactElement<P>\nfunction cloneStyledElement<P, T extends Component<P, ComponentState> = never>(\n element: FunctionComponentElement<P> | CElement<P, T> | ReactElement<P>,\n props: Partial<P> & Attributes | Partial<P> & ClassAttributes<T> = {},\n ...children: ReactNode[]\n) {\n const { className, style, ...otherProps } = props as any\n const { className: elementClassName, style: elementStyle, ...otherElementProps } = element.props as any\n\n return cloneElement(element, {\n className: `${elementClassName ?? ''} ${className ?? ''}`.split(' ').filter(Boolean).join(' '),\n style: {\n ...elementStyle ?? {},\n ...style ?? {},\n },\n ...otherElementProps,\n ...otherProps,\n }, ...children)\n}\n\nexport { cloneStyledElement }\n"]}
1
+ {"version":3,"file":"cloneStyledElement.js","sourceRoot":"/","sources":["utils/cloneStyledElement.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCS,gDAAkB;AArC3B,+BAAiM;AAkBjM,SAAS,kBAAkB,CACzB,OAAuE,EACvE,KAAqE;IAArE,sBAAA,EAAA,UAAqE;IACrE,kBAAwB;SAAxB,UAAwB,EAAxB,qBAAwB,EAAxB,IAAwB;QAAxB,iCAAwB;;IAExB,IAAM,KAAsC,KAAY,EAAhD,SAAS,eAAA,EAAE,KAAK,WAAA,EAAK,UAAU,cAAjC,sBAAmC,CAAe,CAAA;IACxD,IAAM,KAA6E,OAAO,CAAC,KAAY,EAApF,gBAAgB,eAAA,EAAS,YAAY,WAAA,EAAK,iBAAiB,cAAxE,sBAA0E,CAAuB,CAAA;IAEvG,OAAO,oBAAY,8BAAC,OAAO,sBACzB,SAAS,EAAE,UAAG,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,EAAE,cAAI,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAC9F,KAAK,wBACA,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,GAClB,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,KAEb,iBAAiB,GACjB,UAAU,WACT,QAAQ,WAAC;AACjB,CAAC","sourcesContent":["import { cloneElement, type Attributes, type CElement, type ClassAttributes, type Component, type ComponentState, type FunctionComponentElement, type ReactElement, type ReactNode } from 'react'\n\n/**\n * Wrapper for {@link cloneElement} but instead of overwriting `className` and\n * `style` of the cloned element with the values specified in the `props`\n * argument, they are merged.\n *\n * @param element The target element to clone.\n * @param props The props to apply to the cloned element. Overlapping props are\n * overwritten with the exception of `className` and `style`, which\n * are merged.\n * @param children Optional child elements add into the cloned element.\n *\n * @returns The cloned element.\n */\nfunction cloneStyledElement<P>(element: FunctionComponentElement<P>, props?: Partial<P> & Attributes, ...children: ReactNode[]): FunctionComponentElement<P>\nfunction cloneStyledElement<P, T extends Component<P, ComponentState>>(element: CElement<P, T>, props?: Partial<P> & ClassAttributes<T>, ...children: ReactNode[]): CElement<P, T>\nfunction cloneStyledElement<P>(element: ReactElement<P>, props?: Partial<P> & Attributes, ...children: ReactNode[]): ReactElement<P>\nfunction cloneStyledElement<P, T extends Component<P, ComponentState> = never>(\n element: FunctionComponentElement<P> | CElement<P, T> | ReactElement<P>,\n props: Partial<P> & Attributes | Partial<P> & ClassAttributes<T> = {},\n ...children: ReactNode[]\n) {\n const { className, style, ...otherProps } = props as any\n const { className: elementClassName, style: elementStyle, ...otherElementProps } = element.props as any\n\n return cloneElement(element, {\n className: `${elementClassName ?? ''} ${className ?? ''}`.split(' ').filter(Boolean).join(' '),\n style: {\n ...elementStyle ?? {},\n ...style ?? {},\n },\n ...otherElementProps,\n ...otherProps,\n }, ...children)\n}\n\nexport { cloneStyledElement }\n"]}
package/utils/styles.js CHANGED
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.styles = void 0;
14
+ exports.styles = styles;
15
15
  function styles() {
16
16
  var args = [];
17
17
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -19,5 +19,4 @@ function styles() {
19
19
  }
20
20
  return args.reduce(function (out, curr) { return (__assign(__assign({}, out), curr || {})); }, {});
21
21
  }
22
- exports.styles = styles;
23
22
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","sourceRoot":"/","sources":["utils/styles.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,SAAgB,MAAM;IAAC,cAA8C;SAA9C,UAA8C,EAA9C,qBAA8C,EAA9C,IAA8C;QAA9C,yBAA8C;;IACnE,OAAO,IAAI,CAAC,MAAM,CAAgB,UAAC,GAAG,EAAE,IAAI,IAAK,OAAA,uBAC5C,GAAG,GACH,IAAI,IAAI,EAAE,EACb,EAH+C,CAG/C,EAAE,EAAE,CAAC,CAAA;AACT,CAAC;AALD,wBAKC","sourcesContent":["import { type CSSProperties } from 'react'\n\nexport function styles(...args: (CSSProperties | undefined | false)[]): CSSProperties {\n return args.reduce<CSSProperties>((out, curr) => ({\n ...out,\n ...curr || {},\n }), {})\n}\n"]}
1
+ {"version":3,"file":"styles.js","sourceRoot":"/","sources":["utils/styles.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAEA,wBAKC;AALD,SAAgB,MAAM;IAAC,cAA8C;SAA9C,UAA8C,EAA9C,qBAA8C,EAA9C,IAA8C;QAA9C,yBAA8C;;IACnE,OAAO,IAAI,CAAC,MAAM,CAAgB,UAAC,GAAG,EAAE,IAAI,IAAK,OAAA,uBAC5C,GAAG,GACH,IAAI,IAAI,EAAE,EACb,EAH+C,CAG/C,EAAE,EAAE,CAAC,CAAA;AACT,CAAC","sourcesContent":["import { type CSSProperties } from 'react'\n\nexport function styles(...args: (CSSProperties | undefined | false)[]): CSSProperties {\n return args.reduce<CSSProperties>((out, curr) => ({\n ...out,\n ...curr || {},\n }), {})\n}\n"]}