@chayns-components/core 5.3.9 → 5.3.10

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 (47) hide show
  1. package/AGENTS.md +61 -2
  2. package/lib/cjs/components/masonry/Masonry.context.js +17 -0
  3. package/lib/cjs/components/masonry/Masonry.context.js.map +1 -0
  4. package/lib/cjs/components/masonry/Masonry.hooks.js +53 -0
  5. package/lib/cjs/components/masonry/Masonry.hooks.js.map +1 -0
  6. package/lib/cjs/components/masonry/Masonry.js +81 -0
  7. package/lib/cjs/components/masonry/Masonry.js.map +1 -0
  8. package/lib/cjs/components/masonry/Masonry.styles.js +16 -0
  9. package/lib/cjs/components/masonry/Masonry.styles.js.map +1 -0
  10. package/lib/cjs/components/masonry/Masonry.types.js +6 -0
  11. package/lib/cjs/components/masonry/Masonry.types.js.map +1 -0
  12. package/lib/cjs/components/masonry/Masonry.utils.js +121 -0
  13. package/lib/cjs/components/masonry/Masonry.utils.js.map +1 -0
  14. package/lib/cjs/components/masonry/masonry-item/MasonryItem.js +77 -0
  15. package/lib/cjs/components/masonry/masonry-item/MasonryItem.js.map +1 -0
  16. package/lib/cjs/components/masonry/masonry-item/MasonryItem.styles.js +17 -0
  17. package/lib/cjs/components/masonry/masonry-item/MasonryItem.styles.js.map +1 -0
  18. package/lib/cjs/index.js +7 -0
  19. package/lib/cjs/index.js.map +1 -1
  20. package/lib/esm/components/masonry/Masonry.context.js +10 -0
  21. package/lib/esm/components/masonry/Masonry.context.js.map +1 -0
  22. package/lib/esm/components/masonry/Masonry.hooks.js +44 -0
  23. package/lib/esm/components/masonry/Masonry.hooks.js.map +1 -0
  24. package/lib/esm/components/masonry/Masonry.js +74 -0
  25. package/lib/esm/components/masonry/Masonry.js.map +1 -0
  26. package/lib/esm/components/masonry/Masonry.styles.js +9 -0
  27. package/lib/esm/components/masonry/Masonry.styles.js.map +1 -0
  28. package/lib/esm/components/masonry/Masonry.types.js +2 -0
  29. package/lib/esm/components/masonry/Masonry.types.js.map +1 -0
  30. package/lib/esm/components/masonry/Masonry.utils.js +110 -0
  31. package/lib/esm/components/masonry/Masonry.utils.js.map +1 -0
  32. package/lib/esm/components/masonry/masonry-item/MasonryItem.js +69 -0
  33. package/lib/esm/components/masonry/masonry-item/MasonryItem.js.map +1 -0
  34. package/lib/esm/components/masonry/masonry-item/MasonryItem.styles.js +10 -0
  35. package/lib/esm/components/masonry/masonry-item/MasonryItem.styles.js.map +1 -0
  36. package/lib/esm/index.js +1 -0
  37. package/lib/esm/index.js.map +1 -1
  38. package/lib/types/components/masonry/Masonry.context.d.ts +3 -0
  39. package/lib/types/components/masonry/Masonry.d.ts +3 -0
  40. package/lib/types/components/masonry/Masonry.hooks.d.ts +22 -0
  41. package/lib/types/components/masonry/Masonry.styles.d.ts +5 -0
  42. package/lib/types/components/masonry/Masonry.types.d.ts +40 -0
  43. package/lib/types/components/masonry/Masonry.utils.d.ts +22 -0
  44. package/lib/types/components/masonry/masonry-item/MasonryItem.d.ts +5 -0
  45. package/lib/types/components/masonry/masonry-item/MasonryItem.styles.d.ts +5 -0
  46. package/lib/types/index.d.ts +1 -0
  47. package/package.json +2 -2
package/AGENTS.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @chayns-components/core
2
2
 
3
- React component package providing 45 documented components for chayns applications.
3
+ React component package providing 46 documented components for chayns applications.
4
4
 
5
- Documented components: `Accordion`, `AmountControl`, `AnimatedNumber`, `Badge`, `Button`, `Checkbox`, `ComboBox`, `ContentCard`, `ContextMenu`, `ExpandableContent`, `FileInput`, `FileList`, `FileSelect`, `Filter`, `FilterButtons`, `GridImage`, `GroupedImage`, `HighlightSlider`, `Icon`, `Input`, `List`, `MentionFinder`, `MultiActionButton`, `NumberInput`, `Popup`, `ProgressBar`, `RadioButton`, `ScrollView`, `SearchBox`, `SearchInput`, `SelectButton`, `SetupWizard`, `SetupWizardItem`, `SharingBar`, `SharingButton`, `Signature`, `Skeleton`, `Slider`, `SliderButton`, `SmallWaitCursor`, `TagInput`, `TextArea`, `Tooltip`, `Truncation`, `VerificationBadge`.
5
+ Documented components: `Accordion`, `AmountControl`, `AnimatedNumber`, `Badge`, `Button`, `Checkbox`, `ComboBox`, `ContentCard`, `ContextMenu`, `ExpandableContent`, `FileInput`, `FileList`, `FileSelect`, `Filter`, `FilterButtons`, `GridImage`, `GroupedImage`, `HighlightSlider`, `Icon`, `Input`, `List`, `Masonry`, `MentionFinder`, `MultiActionButton`, `NumberInput`, `Popup`, `ProgressBar`, `RadioButton`, `ScrollView`, `SearchBox`, `SearchInput`, `SelectButton`, `SetupWizard`, `SetupWizardItem`, `SharingBar`, `SharingButton`, `Signature`, `Skeleton`, `Slider`, `SliderButton`, `SmallWaitCursor`, `TagInput`, `TextArea`, `Tooltip`, `Truncation`, `VerificationBadge`.
6
6
 
7
7
  ## Import
8
8
 
@@ -39,6 +39,7 @@ import { Accordion, AmountControl, AnimatedNumber } from '@chayns-components/cor
39
39
  - `Icon`
40
40
  - `Input`
41
41
  - `List`
42
+ - `Masonry`
42
43
  - `MentionFinder`
43
44
  - `MultiActionButton`
44
45
  - `NumberInput`
@@ -3006,6 +3007,64 @@ No additional exported types documented.
3006
3007
 
3007
3008
  ### Anti Patterns
3008
3009
 
3010
+ - Avoid imports from internal paths such as `@chayns-components/core/src/...`; always use the public package export.
3011
+ ## Masonry
3012
+
3013
+ `Masonry` is exported by `@chayns-components/core` and should be imported from the public package entry point.
3014
+
3015
+ ### Import
3016
+
3017
+ ```ts
3018
+ import { Masonry } from '@chayns-components/core';
3019
+ ```
3020
+
3021
+ ### Examples
3022
+
3023
+ #### General
3024
+
3025
+ ```tsx
3026
+ <Masonry
3027
+ gap={16}
3028
+ columnWidth={160}
3029
+ rowHeight={80}
3030
+ />
3031
+ ```
3032
+
3033
+ #### Packed
3034
+
3035
+ ```tsx
3036
+ <Masonry
3037
+ gap={16}
3038
+ columnWidth={160}
3039
+ rowHeight={80}
3040
+ />
3041
+ ```
3042
+
3043
+ #### Dynamic
3044
+
3045
+ ```tsx
3046
+ <Masonry
3047
+ gap={16}
3048
+ columnWidth={160}
3049
+ rowHeight={80}
3050
+ />
3051
+ ```
3052
+
3053
+ ### Props
3054
+
3055
+ No prop documentation available.
3056
+
3057
+ ### Types
3058
+
3059
+ No additional exported types documented.
3060
+
3061
+ ### Usage Notes
3062
+
3063
+ - Import `Masonry` directly from `@chayns-components/core` instead of internal source paths.
3064
+ - Start with one of the documented Storybook examples and adapt the props incrementally for your use case.
3065
+
3066
+ ### Anti Patterns
3067
+
3009
3068
  - Avoid imports from internal paths such as `@chayns-components/core/src/...`; always use the public package export.
3010
3069
  ## MentionFinder
3011
3070
 
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useMasonryContext = exports.MasonryContext = void 0;
7
+ var _react = require("react");
8
+ const MasonryContext = exports.MasonryContext = /*#__PURE__*/(0, _react.createContext)(undefined);
9
+ const useMasonryContext = () => {
10
+ const context = (0, _react.useContext)(MasonryContext);
11
+ if (!context) {
12
+ throw new Error('Masonry.Item must be used inside Masonry.');
13
+ }
14
+ return context;
15
+ };
16
+ exports.useMasonryContext = useMasonryContext;
17
+ //# sourceMappingURL=Masonry.context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Masonry.context.js","names":["_react","require","MasonryContext","exports","createContext","undefined","useMasonryContext","context","useContext","Error"],"sources":["../../../../src/components/masonry/Masonry.context.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport { MasonryContextValue } from './Masonry.types';\n\nexport const MasonryContext = createContext<MasonryContextValue | undefined>(undefined);\n\nexport const useMasonryContext = () => {\n const context = useContext(MasonryContext);\n\n if (!context) {\n throw new Error('Masonry.Item must be used inside Masonry.');\n }\n\n return context;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAMC,cAAc,GAAAC,OAAA,CAAAD,cAAA,gBAAG,IAAAE,oBAAa,EAAkCC,SAAS,CAAC;AAEhF,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;EACnC,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAACN,cAAc,CAAC;EAE1C,IAAI,CAACK,OAAO,EAAE;IACV,MAAM,IAAIE,KAAK,CAAC,2CAA2C,CAAC;EAChE;EAEA,OAAOF,OAAO;AAClB,CAAC;AAACJ,OAAA,CAAAG,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useMasonryLayout = exports.useMasonryItems = exports.useMasonryColumnCount = void 0;
7
+ var _react = require("react");
8
+ var _Masonry = require("./Masonry.utils");
9
+ const useMasonryItems = ({
10
+ children
11
+ }) => (0, _react.useMemo)(() => _react.Children.toArray(children), [children]);
12
+ exports.useMasonryItems = useMasonryItems;
13
+ const useMasonryLayout = ({
14
+ items,
15
+ itemHeights,
16
+ columnCount,
17
+ columnWidth,
18
+ rowHeight,
19
+ gap
20
+ }) => (0, _react.useMemo)(() => {
21
+ const layoutItems = items.map((item, index) => {
22
+ const key = (0, _Masonry.getMasonryItemKey)(item, index);
23
+ const height = itemHeights[key] ?? rowHeight;
24
+ return {
25
+ key,
26
+ columns: item.props.columns ?? 1,
27
+ rows: (0, _Masonry.calculateRowSpan)({
28
+ height,
29
+ rowHeight,
30
+ gap
31
+ })
32
+ };
33
+ });
34
+ return (0, _Masonry.packMasonryGrid)({
35
+ items: layoutItems,
36
+ columnCount,
37
+ columnWidth,
38
+ rowHeight,
39
+ gap
40
+ });
41
+ }, [items, itemHeights, columnCount, columnWidth, rowHeight, gap]);
42
+ exports.useMasonryLayout = useMasonryLayout;
43
+ const useMasonryColumnCount = ({
44
+ containerWidth,
45
+ columnWidth,
46
+ gap
47
+ }) => (0, _react.useMemo)(() => (0, _Masonry.calculateColumnCount)({
48
+ containerWidth,
49
+ columnWidth,
50
+ gap
51
+ }), [containerWidth, columnWidth, gap]);
52
+ exports.useMasonryColumnCount = useMasonryColumnCount;
53
+ //# sourceMappingURL=Masonry.hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Masonry.hooks.js","names":["_react","require","_Masonry","useMasonryItems","children","useMemo","Children","toArray","exports","useMasonryLayout","items","itemHeights","columnCount","columnWidth","rowHeight","gap","layoutItems","map","item","index","key","getMasonryItemKey","height","columns","props","rows","calculateRowSpan","packMasonryGrid","useMasonryColumnCount","containerWidth","calculateColumnCount"],"sources":["../../../../src/components/masonry/Masonry.hooks.ts"],"sourcesContent":["import { Children, ReactNode, useMemo } from 'react';\nimport { MasonryChild, MasonryItemProps, MasonryLayoutItem } from './Masonry.types';\nimport {\n calculateColumnCount,\n calculateRowSpan,\n getMasonryItemKey,\n packMasonryGrid,\n} from './Masonry.utils';\n\ninterface UseMasonryItemsParams {\n children: ReactNode;\n}\n\nexport const useMasonryItems = ({ children }: UseMasonryItemsParams) =>\n useMemo(() => Children.toArray(children) as MasonryChild[], [children]);\n\ninterface UseMasonryLayoutParams {\n items: MasonryChild[];\n itemHeights: Record<string, number>;\n columnCount: number;\n columnWidth: number;\n rowHeight: number;\n gap: number;\n}\n\nexport const useMasonryLayout = ({\n items,\n itemHeights,\n columnCount,\n columnWidth,\n rowHeight,\n gap,\n}: UseMasonryLayoutParams) =>\n useMemo(() => {\n const layoutItems: MasonryLayoutItem[] = items.map((item, index) => {\n const key = getMasonryItemKey(item as React.ReactElement<MasonryItemProps>, index);\n\n const height = itemHeights[key] ?? rowHeight;\n\n return {\n key,\n columns: item.props.columns ?? 1,\n rows: calculateRowSpan({\n height,\n rowHeight,\n gap,\n }),\n };\n });\n\n return packMasonryGrid({\n items: layoutItems,\n columnCount,\n columnWidth,\n rowHeight,\n gap,\n });\n }, [items, itemHeights, columnCount, columnWidth, rowHeight, gap]);\n\ninterface UseMasonryColumnCountParams {\n containerWidth: number;\n columnWidth: number;\n gap: number;\n}\n\nexport const useMasonryColumnCount = ({\n containerWidth,\n columnWidth,\n gap,\n}: UseMasonryColumnCountParams) =>\n useMemo(\n () =>\n calculateColumnCount({\n containerWidth,\n columnWidth,\n gap,\n }),\n [containerWidth, columnWidth, gap],\n );\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAWO,MAAME,eAAe,GAAGA,CAAC;EAAEC;AAAgC,CAAC,KAC/D,IAAAC,cAAO,EAAC,MAAMC,eAAQ,CAACC,OAAO,CAACH,QAAQ,CAAmB,EAAE,CAACA,QAAQ,CAAC,CAAC;AAACI,OAAA,CAAAL,eAAA,GAAAA,eAAA;AAWrE,MAAMM,gBAAgB,GAAGA,CAAC;EAC7BC,KAAK;EACLC,WAAW;EACXC,WAAW;EACXC,WAAW;EACXC,SAAS;EACTC;AACoB,CAAC,KACrB,IAAAV,cAAO,EAAC,MAAM;EACV,MAAMW,WAAgC,GAAGN,KAAK,CAACO,GAAG,CAAC,CAACC,IAAI,EAAEC,KAAK,KAAK;IAChE,MAAMC,GAAG,GAAG,IAAAC,0BAAiB,EAACH,IAAI,EAA0CC,KAAK,CAAC;IAElF,MAAMG,MAAM,GAAGX,WAAW,CAACS,GAAG,CAAC,IAAIN,SAAS;IAE5C,OAAO;MACHM,GAAG;MACHG,OAAO,EAAEL,IAAI,CAACM,KAAK,CAACD,OAAO,IAAI,CAAC;MAChCE,IAAI,EAAE,IAAAC,yBAAgB,EAAC;QACnBJ,MAAM;QACNR,SAAS;QACTC;MACJ,CAAC;IACL,CAAC;EACL,CAAC,CAAC;EAEF,OAAO,IAAAY,wBAAe,EAAC;IACnBjB,KAAK,EAAEM,WAAW;IAClBJ,WAAW;IACXC,WAAW;IACXC,SAAS;IACTC;EACJ,CAAC,CAAC;AACN,CAAC,EAAE,CAACL,KAAK,EAAEC,WAAW,EAAEC,WAAW,EAAEC,WAAW,EAAEC,SAAS,EAAEC,GAAG,CAAC,CAAC;AAACP,OAAA,CAAAC,gBAAA,GAAAA,gBAAA;AAQhE,MAAMmB,qBAAqB,GAAGA,CAAC;EAClCC,cAAc;EACdhB,WAAW;EACXE;AACyB,CAAC,KAC1B,IAAAV,cAAO,EACH,MACI,IAAAyB,6BAAoB,EAAC;EACjBD,cAAc;EACdhB,WAAW;EACXE;AACJ,CAAC,CAAC,EACN,CAACc,cAAc,EAAEhB,WAAW,EAAEE,GAAG,CACrC,CAAC;AAACP,OAAA,CAAAoB,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _react2 = require("motion/react");
9
+ var _element = require("../../hooks/element");
10
+ var _Masonry = require("./Masonry.context");
11
+ var _Masonry2 = require("./Masonry.styles");
12
+ var _Masonry3 = require("./Masonry.hooks");
13
+ var _Masonry4 = require("./Masonry.utils");
14
+ var _MasonryItem = _interopRequireWildcard(require("./masonry-item/MasonryItem"));
15
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
16
+ const MasonryBase = ({
17
+ children,
18
+ gap = 8,
19
+ columnWidth = 80,
20
+ rowHeight = 80
21
+ }) => {
22
+ const ref = (0, _react.useRef)(null);
23
+ const size = (0, _element.useElementSize)(ref);
24
+ const containerWidth = (size === null || size === void 0 ? void 0 : size.width) ?? 0;
25
+ const [itemHeights, setItemHeights] = (0, _react.useState)({});
26
+ const items = (0, _Masonry3.useMasonryItems)({
27
+ children
28
+ });
29
+ const columnCount = (0, _Masonry3.useMasonryColumnCount)({
30
+ containerWidth,
31
+ columnWidth,
32
+ gap
33
+ });
34
+ const layout = (0, _Masonry3.useMasonryLayout)({
35
+ items,
36
+ itemHeights,
37
+ columnCount,
38
+ columnWidth,
39
+ rowHeight,
40
+ gap
41
+ });
42
+ const registerItem = (0, _react.useCallback)((key, height) => {
43
+ setItemHeights(currentHeights => {
44
+ if (currentHeights[key] === height) {
45
+ return currentHeights;
46
+ }
47
+ return {
48
+ ...currentHeights,
49
+ [key]: height
50
+ };
51
+ });
52
+ }, []);
53
+ const contextValue = (0, _react.useMemo)(() => ({
54
+ registerItem
55
+ }), [registerItem]);
56
+ return /*#__PURE__*/_react.default.createElement(_Masonry.MasonryContext.Provider, {
57
+ value: contextValue
58
+ }, /*#__PURE__*/_react.default.createElement(_Masonry2.StyledMasonry, {
59
+ ref: ref,
60
+ $height: layout.height
61
+ }, /*#__PURE__*/_react.default.createElement(_react2.AnimatePresence, null, items.map((item, index) => {
62
+ const key = (0, _Masonry4.getMasonryItemKey)(item, index);
63
+ const packedItem = layout.items[key];
64
+ if (!packedItem) {
65
+ return null;
66
+ }
67
+ return /*#__PURE__*/_react.default.createElement(_MasonryItem.InternalMasonryItem, {
68
+ key: key,
69
+ itemKey: key,
70
+ x: packedItem.x,
71
+ y: packedItem.y,
72
+ width: packedItem.width
73
+ }, item.props.children);
74
+ }))));
75
+ };
76
+ MasonryBase.displayName = 'Masonry';
77
+ const Masonry = Object.assign(MasonryBase, {
78
+ Item: _MasonryItem.default
79
+ });
80
+ var _default = exports.default = Masonry;
81
+ //# sourceMappingURL=Masonry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Masonry.js","names":["_react","_interopRequireWildcard","require","_react2","_element","_Masonry","_Masonry2","_Masonry3","_Masonry4","_MasonryItem","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","MasonryBase","children","gap","columnWidth","rowHeight","ref","useRef","size","useElementSize","containerWidth","width","itemHeights","setItemHeights","useState","items","useMasonryItems","columnCount","useMasonryColumnCount","layout","useMasonryLayout","registerItem","useCallback","key","height","currentHeights","contextValue","useMemo","createElement","MasonryContext","Provider","value","StyledMasonry","$height","AnimatePresence","map","item","index","getMasonryItemKey","packedItem","InternalMasonryItem","itemKey","x","y","props","displayName","Masonry","assign","Item","MasonryItem","_default","exports"],"sources":["../../../../src/components/masonry/Masonry.tsx"],"sourcesContent":["import React, { FC, useCallback, useMemo, useRef, useState } from 'react';\nimport { AnimatePresence } from 'motion/react';\nimport { useElementSize } from '../../hooks/element';\nimport { MasonryComponent, MasonryItemProps, MasonryProps } from './Masonry.types';\nimport { MasonryContext } from './Masonry.context';\nimport { StyledMasonry } from './Masonry.styles';\nimport { useMasonryColumnCount, useMasonryItems, useMasonryLayout } from './Masonry.hooks';\nimport { getMasonryItemKey } from './Masonry.utils';\nimport MasonryItem, { InternalMasonryItem } from './masonry-item/MasonryItem';\n\nconst MasonryBase: FC<MasonryProps> = ({ children, gap = 8, columnWidth = 80, rowHeight = 80 }) => {\n const ref = useRef<HTMLDivElement | null>(null);\n const size = useElementSize(ref);\n\n const containerWidth = size?.width ?? 0;\n\n const [itemHeights, setItemHeights] = useState<Record<string, number>>({});\n\n const items = useMasonryItems({ children });\n\n const columnCount = useMasonryColumnCount({\n containerWidth,\n columnWidth,\n gap,\n });\n\n const layout = useMasonryLayout({\n items,\n itemHeights,\n columnCount,\n columnWidth,\n rowHeight,\n gap,\n });\n\n const registerItem = useCallback((key: string, height: number) => {\n setItemHeights((currentHeights) => {\n if (currentHeights[key] === height) {\n return currentHeights;\n }\n\n return {\n ...currentHeights,\n [key]: height,\n };\n });\n }, []);\n\n const contextValue = useMemo(\n () => ({\n registerItem,\n }),\n [registerItem],\n );\n\n return (\n <MasonryContext.Provider value={contextValue}>\n <StyledMasonry ref={ref} $height={layout.height}>\n <AnimatePresence>\n {items.map((item, index) => {\n const key = getMasonryItemKey(\n item as React.ReactElement<MasonryItemProps>,\n index,\n );\n\n const packedItem = layout.items[key];\n\n if (!packedItem) {\n return null;\n }\n\n return (\n <InternalMasonryItem\n key={key}\n itemKey={key}\n x={packedItem.x}\n y={packedItem.y}\n width={packedItem.width}\n >\n {item.props.children}\n </InternalMasonryItem>\n );\n })}\n </AnimatePresence>\n </StyledMasonry>\n </MasonryContext.Provider>\n );\n};\n\nMasonryBase.displayName = 'Masonry';\n\nconst Masonry = Object.assign(MasonryBase, {\n Item: MasonryItem,\n}) as MasonryComponent;\n\nexport default Masonry;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAR,uBAAA,CAAAC,OAAA;AAA8E,SAAAD,wBAAAS,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAX,uBAAA,YAAAA,CAAAS,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAA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AC;EAE9B,CAAC,CACY,CACN,CACM,CAAC;AAElC,CAAC;AAEDD,WAAW,CAAC4C,WAAW,GAAG,SAAS;AAEnC,MAAMC,OAAO,GAAGhD,MAAM,CAACiD,MAAM,CAAC9C,WAAW,EAAE;EACvC+C,IAAI,EAAEC;AACV,CAAC,CAAqB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA3D,OAAA,GAERsD,OAAO","ignoreList":[]}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.StyledMasonry = void 0;
7
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ const StyledMasonry = exports.StyledMasonry = _styledComponents.default.div`
10
+ position: relative;
11
+ width: 100%;
12
+ height: ${({
13
+ $height
14
+ }) => $height}px;
15
+ `;
16
+ //# sourceMappingURL=Masonry.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Masonry.styles.js","names":["_styledComponents","_interopRequireDefault","require","e","__esModule","default","StyledMasonry","exports","styled","div","$height"],"sources":["../../../../src/components/masonry/Masonry.styles.ts"],"sourcesContent":["import styled from 'styled-components';\n\nexport const StyledMasonry = styled.div<{ $height: number }>`\n position: relative;\n width: 100%;\n height: ${({ $height }) => $height}px;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEhC,MAAMG,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAGE,yBAAM,CAACC,GAAwB;AAC5D;AACA;AACA,cAAc,CAAC;EAAEC;AAAQ,CAAC,KAAKA,OAAO;AACtC,CAAC","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=Masonry.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Masonry.types.js","names":[],"sources":["../../../../src/components/masonry/Masonry.types.ts"],"sourcesContent":["import { ReactElement, ReactNode } from 'react';\n\nexport interface MasonryProps {\n children: ReactNode;\n gap?: number;\n columnWidth?: number;\n rowHeight?: number;\n}\n\nexport interface MasonryItemProps {\n children: ReactNode;\n columns?: number;\n}\n\nexport interface MasonryContextValue {\n registerItem: (key: string, height: number) => void;\n}\n\nexport interface MasonryLayoutItem {\n key: string;\n columns: number;\n rows: number;\n}\n\nexport interface PackedMasonryItem {\n key: string;\n x: number;\n y: number;\n width: number;\n}\n\nexport interface PackedMasonryGrid {\n items: Record<string, PackedMasonryItem>;\n height: number;\n}\n\nexport interface InternalMasonryItemProps {\n children: ReactNode;\n itemKey: string;\n x: number;\n y: number;\n width: number;\n}\n\nexport type MasonryChild = ReactElement<MasonryItemProps>;\n\nexport type MasonryComponent = React.FC<MasonryProps> & {\n Item: React.FC<MasonryItemProps>;\n};\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.packMasonryGrid = exports.getMasonryItemKey = exports.calculateRowSpan = exports.calculateColumnCount = void 0;
7
+ const getMasonryItemKey = (item, index) => item.key != null ? String(item.key) : String(index);
8
+ exports.getMasonryItemKey = getMasonryItemKey;
9
+ const isAreaFree = ({
10
+ grid,
11
+ startColumn,
12
+ startRow,
13
+ columns,
14
+ rows,
15
+ columnCount
16
+ }) => {
17
+ if (startColumn + columns > columnCount) {
18
+ return false;
19
+ }
20
+ for (let row = startRow; row < startRow + rows; row += 1) {
21
+ for (let column = startColumn; column < startColumn + columns; column += 1) {
22
+ var _grid$row;
23
+ if ((_grid$row = grid[row]) !== null && _grid$row !== void 0 && _grid$row[column]) {
24
+ return false;
25
+ }
26
+ }
27
+ }
28
+ return true;
29
+ };
30
+ const occupyArea = ({
31
+ grid,
32
+ startColumn,
33
+ startRow,
34
+ columns,
35
+ rows
36
+ }) => {
37
+ for (let row = startRow; row < startRow + rows; row += 1) {
38
+ if (!grid[row]) {
39
+ // eslint-disable-next-line no-param-reassign
40
+ grid[row] = [];
41
+ }
42
+ for (let column = startColumn; column < startColumn + columns; column += 1) {
43
+ // eslint-disable-next-line no-param-reassign
44
+ grid[row][column] = true;
45
+ }
46
+ }
47
+ };
48
+ const packMasonryGrid = ({
49
+ items,
50
+ columnCount,
51
+ columnWidth,
52
+ rowHeight,
53
+ gap
54
+ }) => {
55
+ const grid = [];
56
+ const packedItems = {};
57
+ let maxRow = 0;
58
+ items.forEach(item => {
59
+ const columns = Math.min(Math.max(item.columns, 1), columnCount);
60
+ const rows = Math.max(item.rows, 1);
61
+ let placed = false;
62
+ let row = 0;
63
+ while (!placed) {
64
+ for (let column = 0; column < columnCount; column += 1) {
65
+ const canPlaceItem = isAreaFree({
66
+ grid,
67
+ startColumn: column,
68
+ startRow: row,
69
+ columns,
70
+ rows,
71
+ columnCount
72
+ });
73
+ if (!canPlaceItem) {
74
+ continue;
75
+ }
76
+ occupyArea({
77
+ grid,
78
+ startColumn: column,
79
+ startRow: row,
80
+ columns,
81
+ rows
82
+ });
83
+ packedItems[item.key] = {
84
+ key: item.key,
85
+ x: column * (columnWidth + gap),
86
+ y: row * (rowHeight + gap),
87
+ width: columns * columnWidth + (columns - 1) * gap
88
+ };
89
+ maxRow = Math.max(maxRow, row + rows);
90
+ placed = true;
91
+ break;
92
+ }
93
+ if (!placed) {
94
+ row += 1;
95
+ }
96
+ }
97
+ });
98
+ return {
99
+ items: packedItems,
100
+ height: maxRow * rowHeight + Math.max(0, maxRow - 1) * gap
101
+ };
102
+ };
103
+ exports.packMasonryGrid = packMasonryGrid;
104
+ const calculateColumnCount = ({
105
+ containerWidth,
106
+ columnWidth,
107
+ gap
108
+ }) => {
109
+ if (!containerWidth) {
110
+ return 1;
111
+ }
112
+ return Math.max(1, Math.floor((containerWidth + gap) / (columnWidth + gap)));
113
+ };
114
+ exports.calculateColumnCount = calculateColumnCount;
115
+ const calculateRowSpan = ({
116
+ height,
117
+ rowHeight,
118
+ gap
119
+ }) => Math.max(1, Math.ceil((height + gap) / (rowHeight + gap)));
120
+ exports.calculateRowSpan = calculateRowSpan;
121
+ //# sourceMappingURL=Masonry.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Masonry.utils.js","names":["getMasonryItemKey","item","index","key","String","exports","isAreaFree","grid","startColumn","startRow","columns","rows","columnCount","row","column","_grid$row","occupyArea","packMasonryGrid","items","columnWidth","rowHeight","gap","packedItems","maxRow","forEach","Math","min","max","placed","canPlaceItem","x","y","width","height","calculateColumnCount","containerWidth","floor","calculateRowSpan","ceil"],"sources":["../../../../src/components/masonry/Masonry.utils.ts"],"sourcesContent":["import { ReactElement } from 'react';\nimport {\n MasonryItemProps,\n MasonryLayoutItem,\n PackedMasonryGrid,\n PackedMasonryItem,\n} from './Masonry.types';\n\nexport const getMasonryItemKey = (item: ReactElement<MasonryItemProps>, index: number) =>\n item.key != null ? String(item.key) : String(index);\n\ninterface IsAreaFreeParams {\n grid: boolean[][];\n startColumn: number;\n startRow: number;\n columns: number;\n rows: number;\n columnCount: number;\n}\n\nconst isAreaFree = ({\n grid,\n startColumn,\n startRow,\n columns,\n rows,\n columnCount,\n}: IsAreaFreeParams) => {\n if (startColumn + columns > columnCount) {\n return false;\n }\n\n for (let row = startRow; row < startRow + rows; row += 1) {\n for (let column = startColumn; column < startColumn + columns; column += 1) {\n if (grid[row]?.[column]) {\n return false;\n }\n }\n }\n\n return true;\n};\n\ninterface OccupyAreaParams {\n grid: boolean[][];\n startColumn: number;\n startRow: number;\n columns: number;\n rows: number;\n}\n\nconst occupyArea = ({ grid, startColumn, startRow, columns, rows }: OccupyAreaParams) => {\n for (let row = startRow; row < startRow + rows; row += 1) {\n if (!grid[row]) {\n // eslint-disable-next-line no-param-reassign\n grid[row] = [];\n }\n\n for (let column = startColumn; column < startColumn + columns; column += 1) {\n // eslint-disable-next-line no-param-reassign\n (grid[row] as boolean[])[column] = true;\n }\n }\n};\n\ninterface PackMasonryGridParams {\n items: MasonryLayoutItem[];\n columnCount: number;\n columnWidth: number;\n rowHeight: number;\n gap: number;\n}\n\nexport const packMasonryGrid = ({\n items,\n columnCount,\n columnWidth,\n rowHeight,\n gap,\n}: PackMasonryGridParams): PackedMasonryGrid => {\n const grid: boolean[][] = [];\n const packedItems: Record<string, PackedMasonryItem> = {};\n\n let maxRow = 0;\n\n items.forEach((item) => {\n const columns = Math.min(Math.max(item.columns, 1), columnCount);\n const rows = Math.max(item.rows, 1);\n\n let placed = false;\n let row = 0;\n\n while (!placed) {\n for (let column = 0; column < columnCount; column += 1) {\n const canPlaceItem = isAreaFree({\n grid,\n startColumn: column,\n startRow: row,\n columns,\n rows,\n columnCount,\n });\n\n if (!canPlaceItem) {\n continue;\n }\n\n occupyArea({\n grid,\n startColumn: column,\n startRow: row,\n columns,\n rows,\n });\n\n packedItems[item.key] = {\n key: item.key,\n x: column * (columnWidth + gap),\n y: row * (rowHeight + gap),\n width: columns * columnWidth + (columns - 1) * gap,\n };\n\n maxRow = Math.max(maxRow, row + rows);\n placed = true;\n break;\n }\n\n if (!placed) {\n row += 1;\n }\n }\n });\n\n return {\n items: packedItems,\n height: maxRow * rowHeight + Math.max(0, maxRow - 1) * gap,\n };\n};\n\nexport const calculateColumnCount = ({\n containerWidth,\n columnWidth,\n gap,\n}: {\n containerWidth: number;\n columnWidth: number;\n gap: number;\n}) => {\n if (!containerWidth) {\n return 1;\n }\n\n return Math.max(1, Math.floor((containerWidth + gap) / (columnWidth + gap)));\n};\n\nexport const calculateRowSpan = ({\n height,\n rowHeight,\n gap,\n}: {\n height: number;\n rowHeight: number;\n gap: number;\n}) => Math.max(1, Math.ceil((height + gap) / (rowHeight + gap)));\n"],"mappings":";;;;;;AAQO,MAAMA,iBAAiB,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ineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.InternalMasonryItem = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _Masonry = require("../Masonry.context");
9
+ var _MasonryItem = require("./MasonryItem.styles");
10
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
11
+ const MasonryItem = ({
12
+ children
13
+ }) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
14
+ const InternalMasonryItem = ({
15
+ children,
16
+ itemKey,
17
+ x,
18
+ y,
19
+ width
20
+ }) => {
21
+ const ref = (0, _react.useRef)(null);
22
+ const {
23
+ registerItem
24
+ } = (0, _Masonry.useMasonryContext)();
25
+ (0, _react.useEffect)(() => {
26
+ const element = ref.current;
27
+ if (!element) {
28
+ return undefined;
29
+ }
30
+ let frameId;
31
+ const updateHeight = () => {
32
+ if (frameId) {
33
+ window.cancelAnimationFrame(frameId);
34
+ }
35
+ frameId = window.requestAnimationFrame(() => {
36
+ registerItem(itemKey, element.getBoundingClientRect().height);
37
+ });
38
+ };
39
+ updateHeight();
40
+ const observer = new ResizeObserver(updateHeight);
41
+ observer.observe(element);
42
+ return () => {
43
+ if (frameId) {
44
+ window.cancelAnimationFrame(frameId);
45
+ }
46
+ observer.disconnect();
47
+ };
48
+ }, [itemKey, registerItem, width]);
49
+ return /*#__PURE__*/_react.default.createElement(_MasonryItem.StyledMasonryItem, {
50
+ ref: ref,
51
+ initial: {
52
+ opacity: 0,
53
+ scale: 0.96
54
+ },
55
+ animate: {
56
+ opacity: 1,
57
+ scale: 1,
58
+ x,
59
+ y,
60
+ width
61
+ },
62
+ exit: {
63
+ opacity: 0,
64
+ scale: 0.96
65
+ },
66
+ transition: {
67
+ type: 'spring',
68
+ stiffness: 320,
69
+ damping: 34,
70
+ mass: 0.85
71
+ }
72
+ }, children);
73
+ };
74
+ exports.InternalMasonryItem = InternalMasonryItem;
75
+ MasonryItem.displayName = 'Masonry.Item';
76
+ var _default = exports.default = MasonryItem;
77
+ //# sourceMappingURL=MasonryItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MasonryItem.js","names":["_react","_interopRequireWildcard","require","_Masonry","_MasonryItem","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","MasonryItem","children","createElement","Fragment","InternalMasonryItem","itemKey","x","y","width","ref","useRef","registerItem","useMasonryContext","useEffect","element","current","undefined","frameId","updateHeight","window","cancelAnimationFrame","requestAnimationFrame","getBoundingClientRect","height","observer","ResizeObserver","observe","disconnect","StyledMasonryItem","initial","opacity","scale","animate","exit","transition","type","stiffness","damping","mass","exports","displayName","_default"],"sources":["../../../../../src/components/masonry/masonry-item/MasonryItem.tsx"],"sourcesContent":["import React, { FC, useEffect, useRef } from 'react';\nimport { InternalMasonryItemProps, MasonryItemProps } from '../Masonry.types';\nimport { useMasonryContext } from '../Masonry.context';\nimport { StyledMasonryItem } from './MasonryItem.styles';\n\nconst MasonryItem: FC<MasonryItemProps> = ({ children }) => <>{children}</>;\n\nexport const InternalMasonryItem: FC<InternalMasonryItemProps> = ({\n children,\n itemKey,\n x,\n y,\n width,\n}) => {\n const ref = useRef<HTMLDivElement | null>(null);\n const { registerItem } = useMasonryContext();\n\n useEffect(() => {\n const element = ref.current;\n\n if (!element) {\n return undefined;\n }\n\n let frameId: number | undefined;\n\n const updateHeight = () => {\n if (frameId) {\n window.cancelAnimationFrame(frameId);\n }\n\n frameId = window.requestAnimationFrame(() => {\n registerItem(itemKey, element.getBoundingClientRect().height);\n });\n };\n\n updateHeight();\n\n const observer = new ResizeObserver(updateHeight);\n\n observer.observe(element);\n\n return () => {\n if (frameId) {\n window.cancelAnimationFrame(frameId);\n }\n\n observer.disconnect();\n };\n }, [itemKey, registerItem, width]);\n\n return (\n <StyledMasonryItem\n ref={ref}\n initial={{\n opacity: 0,\n scale: 0.96,\n }}\n animate={{\n opacity: 1,\n scale: 1,\n x,\n y,\n width,\n }}\n exit={{\n opacity: 0,\n scale: 0.96,\n }}\n transition={{\n type: 'spring',\n stiffness: 320,\n damping: 34,\n mass: 0.85,\n }}\n >\n {children}\n </StyledMasonryItem>\n );\n};\n\nMasonryItem.displayName = 'Masonry.Item';\n\nexport default MasonryItem;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAAyD,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAA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CAAC;IAEjDM,QAAQ,CAACE,OAAO,CAACZ,OAAO,CAAC;IAEzB,OAAO,MAAM;MACT,IAAIG,OAAO,EAAE;QACTE,MAAM,CAACC,oBAAoB,CAACH,OAAO,CAAC;MACxC;MAEAO,QAAQ,CAACG,UAAU,CAAC,CAAC;IACzB,CAAC;EACL,CAAC,EAAE,CAACtB,OAAO,EAAEM,YAAY,EAAEH,KAAK,CAAC,CAAC;EAElC,oBACIhC,MAAA,CAAAe,OAAA,CAAAW,aAAA,CAACtB,YAAA,CAAAgD,iBAAiB;IACdnB,GAAG,EAAEA,GAAI;IACToB,OAAO,EAAE;MACLC,OAAO,EAAE,CAAC;MACVC,KAAK,EAAE;IACX,CAAE;IACFC,OAAO,EAAE;MACLF,OAAO,EAAE,CAAC;MACVC,KAAK,EAAE,CAAC;MACRzB,CAAC;MACDC,CAAC;MACDC;IACJ,CAAE;IACFyB,IAAI,EAAE;MACFH,OAAO,EAAE,CAAC;MACVC,KAAK,EAAE;IACX,CAAE;IACFG,UAAU,EAAE;MACRC,IAAI,EAAE,QAAQ;MACdC,SAAS,EAAE,GAAG;MACdC,OAAO,EAAE,EAAE;MACXC,IAAI,EAAE;IACV;EAAE,GAEDrC,QACc,CAAC;AAE5B,CAAC;AAACsC,OAAA,CAAAnC,mBAAA,GAAAA,mBAAA;AAEFJ,WAAW,CAACwC,WAAW,GAAG,cAAc;AAAC,IAAAC,QAAA,GAAAF,OAAA,CAAAhD,OAAA,GAE1BS,WAAW","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.StyledMasonryItem = void 0;
7
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
8
+ var _react = require("motion/react");
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ const StyledMasonryItem = exports.StyledMasonryItem = (0, _styledComponents.default)(_react.motion.div)`
11
+ position: absolute;
12
+ top: 0;
13
+ left: 0;
14
+ overflow: hidden;
15
+ will-change: transform, width;
16
+ `;
17
+ //# sourceMappingURL=MasonryItem.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MasonryItem.styles.js","names":["_styledComponents","_interopRequireDefault","require","_react","e","__esModule","default","StyledMasonryItem","exports","styled","motion","div"],"sources":["../../../../../src/components/masonry/masonry-item/MasonryItem.styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { motion } from 'motion/react';\n\nexport const StyledMasonryItem = styled(motion.div)`\n position: absolute;\n top: 0;\n left: 0;\n overflow: hidden;\n will-change: transform, width;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAAsC,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE/B,MAAMG,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,IAAAE,yBAAM,EAACC,aAAM,CAACC,GAAG,CAAC;AACnD;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
package/lib/cjs/index.js CHANGED
@@ -267,6 +267,12 @@ Object.defineProperty(exports, "ListItemContent", {
267
267
  return _ListItemContent.default;
268
268
  }
269
269
  });
270
+ Object.defineProperty(exports, "Masonry", {
271
+ enumerable: true,
272
+ get: function () {
273
+ return _Masonry.default;
274
+ }
275
+ });
270
276
  Object.defineProperty(exports, "MentionFinder", {
271
277
  enumerable: true,
272
278
  get: function () {
@@ -659,6 +665,7 @@ var _uploadFile = require("./utils/uploadFile");
659
665
  var _ComboBox2 = require("./components/combobox/ComboBox.types");
660
666
  var _skeleton = _interopRequireDefault(require("./components/skeleton"));
661
667
  var _types = require("./components/skeleton/types");
668
+ var _Masonry = _interopRequireDefault(require("./components/masonry/Masonry"));
662
669
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
663
670
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
664
671
  //# sourceMappingURL=index.js.map