@makeswift/runtime 0.1.5 → 0.1.8

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 (152) hide show
  1. package/dist/Box.cjs.js +4 -3
  2. package/dist/Box.cjs.js.map +1 -1
  3. package/dist/Box.es.js +5 -4
  4. package/dist/Box.es.js.map +1 -1
  5. package/dist/Button.cjs.js +5 -3
  6. package/dist/Button.cjs.js.map +1 -1
  7. package/dist/Button.es.js +16 -14
  8. package/dist/Button.es.js.map +1 -1
  9. package/dist/Carousel.cjs.js +4 -3
  10. package/dist/Carousel.cjs.js.map +1 -1
  11. package/dist/Carousel.es.js +5 -4
  12. package/dist/Carousel.es.js.map +1 -1
  13. package/dist/Countdown.cjs.js +4 -3
  14. package/dist/Countdown.cjs.js.map +1 -1
  15. package/dist/Countdown.es.js +5 -4
  16. package/dist/Countdown.es.js.map +1 -1
  17. package/dist/Divider.cjs.js +4 -3
  18. package/dist/Divider.cjs.js.map +1 -1
  19. package/dist/Divider.es.js +5 -4
  20. package/dist/Divider.es.js.map +1 -1
  21. package/dist/Embed.cjs.js +4 -3
  22. package/dist/Embed.cjs.js.map +1 -1
  23. package/dist/Embed.es.js +5 -4
  24. package/dist/Embed.es.js.map +1 -1
  25. package/dist/Form.cjs.js +7 -3
  26. package/dist/Form.cjs.js.map +1 -1
  27. package/dist/Form.es.js +9 -5
  28. package/dist/Form.es.js.map +1 -1
  29. package/dist/Image.cjs2.js +6 -4
  30. package/dist/Image.cjs2.js.map +1 -1
  31. package/dist/Image.es2.js +10 -8
  32. package/dist/Image.es2.js.map +1 -1
  33. package/dist/Navigation.cjs.js +4 -3
  34. package/dist/Navigation.cjs.js.map +1 -1
  35. package/dist/Navigation.es.js +5 -4
  36. package/dist/Navigation.es.js.map +1 -1
  37. package/dist/SocialLinks.cjs.js +3 -2
  38. package/dist/SocialLinks.cjs.js.map +1 -1
  39. package/dist/SocialLinks.es.js +4 -3
  40. package/dist/SocialLinks.es.js.map +1 -1
  41. package/dist/Text.cjs.js +7 -3
  42. package/dist/Text.cjs.js.map +1 -1
  43. package/dist/Text.es.js +9 -5
  44. package/dist/Text.es.js.map +1 -1
  45. package/dist/Video.cjs.js +4 -3
  46. package/dist/Video.cjs.js.map +1 -1
  47. package/dist/Video.es.js +5 -4
  48. package/dist/Video.es.js.map +1 -1
  49. package/dist/components.cjs.js +1 -1
  50. package/dist/components.es.js +1 -1
  51. package/dist/cssMediaRules.es.js +1 -1
  52. package/dist/index.cjs.js +10 -31
  53. package/dist/index.cjs.js.map +1 -1
  54. package/dist/index.cjs3.js +27 -11
  55. package/dist/index.cjs3.js.map +1 -1
  56. package/dist/index.es.js +11 -31
  57. package/dist/index.es.js.map +1 -1
  58. package/dist/index.es2.js +1 -1
  59. package/dist/index.es3.js +28 -12
  60. package/dist/index.es3.js.map +1 -1
  61. package/dist/next.es.js +1 -1
  62. package/dist/react-builder-preview.es.js +1 -1
  63. package/dist/types/components/builtin/Box/Box.d.ts +2 -2
  64. package/dist/types/components/builtin/Box/Box.d.ts.map +1 -1
  65. package/dist/types/components/builtin/Button/Button.d.ts +2 -1
  66. package/dist/types/components/builtin/Button/Button.d.ts.map +1 -1
  67. package/dist/types/components/builtin/Carousel/Carousel.d.ts +2 -2
  68. package/dist/types/components/builtin/Carousel/Carousel.d.ts.map +1 -1
  69. package/dist/types/components/builtin/Carousel/register.d.ts.map +1 -1
  70. package/dist/types/components/builtin/Countdown/Countdown.d.ts +2 -2
  71. package/dist/types/components/builtin/Countdown/Countdown.d.ts.map +1 -1
  72. package/dist/types/components/builtin/Countdown/register.d.ts.map +1 -1
  73. package/dist/types/components/builtin/Divider/Divider.d.ts +2 -2
  74. package/dist/types/components/builtin/Divider/Divider.d.ts.map +1 -1
  75. package/dist/types/components/builtin/Divider/register.d.ts.map +1 -1
  76. package/dist/types/components/builtin/Embed/Embed.d.ts +2 -2
  77. package/dist/types/components/builtin/Embed/Embed.d.ts.map +1 -1
  78. package/dist/types/components/builtin/Form/Form.d.ts +2 -2
  79. package/dist/types/components/builtin/Form/Form.d.ts.map +1 -1
  80. package/dist/types/components/builtin/Form/components/Placeholder/index.d.ts +2 -1
  81. package/dist/types/components/builtin/Form/components/Placeholder/index.d.ts.map +1 -1
  82. package/dist/types/components/builtin/Form/register.d.ts.map +1 -1
  83. package/dist/types/components/builtin/Image/Image.d.ts.map +1 -1
  84. package/dist/types/components/builtin/Navigation/Navigation.d.ts +2 -2
  85. package/dist/types/components/builtin/Navigation/Navigation.d.ts.map +1 -1
  86. package/dist/types/components/builtin/Navigation/register.d.ts.map +1 -1
  87. package/dist/types/components/builtin/SocialLinks/SocialLinks.d.ts +2 -2
  88. package/dist/types/components/builtin/SocialLinks/SocialLinks.d.ts.map +1 -1
  89. package/dist/types/components/builtin/SocialLinks/register.d.ts.map +1 -1
  90. package/dist/types/components/builtin/Text/Text.d.ts +2 -2
  91. package/dist/types/components/builtin/Text/Text.d.ts.map +1 -1
  92. package/dist/types/components/builtin/Text/components/RichTextEditor/index.d.ts.map +1 -1
  93. package/dist/types/components/builtin/Text/register.d.ts.map +1 -1
  94. package/dist/types/components/builtin/Video/Video.d.ts +2 -2
  95. package/dist/types/components/builtin/Video/Video.d.ts.map +1 -1
  96. package/dist/types/components/builtin/Video/register.d.ts.map +1 -1
  97. package/dist/types/components/shared/Link/index.d.ts.map +1 -1
  98. package/dist/useBoxShadow.es.js +1 -1
  99. package/dist/useMediaQuery.es.js +1 -1
  100. package/package.json +1 -1
  101. package/dist/Box2.cjs.js +0 -54
  102. package/dist/Box2.cjs.js.map +0 -1
  103. package/dist/Box2.es.js +0 -52
  104. package/dist/Box2.es.js.map +0 -1
  105. package/dist/grid-item.cjs.js +0 -594
  106. package/dist/grid-item.cjs.js.map +0 -1
  107. package/dist/grid-item.es.js +0 -585
  108. package/dist/grid-item.es.js.map +0 -1
  109. package/dist/slot.cjs.js +0 -130
  110. package/dist/slot.cjs.js.map +0 -1
  111. package/dist/slot.es.js +0 -123
  112. package/dist/slot.es.js.map +0 -1
  113. package/dist/types/components/builtin/Box/Box2.d.ts +0 -8
  114. package/dist/types/components/builtin/Box/Box2.d.ts.map +0 -1
  115. package/dist/types/components/experimental/box-placeholder.d.ts +0 -2
  116. package/dist/types/components/experimental/box-placeholder.d.ts.map +0 -1
  117. package/dist/types/components/experimental/box.d.ts +0 -9
  118. package/dist/types/components/experimental/box.d.ts.map +0 -1
  119. package/dist/types/components/experimental/index.d.ts +0 -2
  120. package/dist/types/components/experimental/index.d.ts.map +0 -1
  121. package/dist/types/components/hooks/useTable.d.ts +0 -66
  122. package/dist/types/components/hooks/useTable.d.ts.map +0 -1
  123. package/dist/types/components/shared/grid-item.d.ts +0 -17
  124. package/dist/types/components/shared/grid-item.d.ts.map +0 -1
  125. package/dist/types/controls/slot.d.ts +0 -42
  126. package/dist/types/controls/slot.d.ts.map +0 -1
  127. package/dist/types/css/border-radius.d.ts +0 -20
  128. package/dist/types/css/border-radius.d.ts.map +0 -1
  129. package/dist/types/css/border.d.ts +0 -31
  130. package/dist/types/css/border.d.ts.map +0 -1
  131. package/dist/types/css/box-shadow.d.ts +0 -19
  132. package/dist/types/css/box-shadow.d.ts.map +0 -1
  133. package/dist/types/css/color.d.ts +0 -5
  134. package/dist/types/css/color.d.ts.map +0 -1
  135. package/dist/types/css/length-percentage.d.ts +0 -10
  136. package/dist/types/css/length-percentage.d.ts.map +0 -1
  137. package/dist/types/css/length.d.ts +0 -14
  138. package/dist/types/css/length.d.ts.map +0 -1
  139. package/dist/types/css/margin.d.ts +0 -20
  140. package/dist/types/css/margin.d.ts.map +0 -1
  141. package/dist/types/css/padding.d.ts +0 -20
  142. package/dist/types/css/padding.d.ts.map +0 -1
  143. package/dist/types/runtimes/react/controls/slot.d.ts +0 -26
  144. package/dist/types/runtimes/react/controls/slot.d.ts.map +0 -1
  145. package/dist/types/runtimes/react/use-style.d.ts +0 -3
  146. package/dist/types/runtimes/react/use-style.d.ts.map +0 -1
  147. package/dist/types/use-global-style.d.ts +0 -3
  148. package/dist/types/use-global-style.d.ts.map +0 -1
  149. package/dist/types/use-grid-item-style.d.ts +0 -1
  150. package/dist/types/use-grid-item-style.d.ts.map +0 -1
  151. package/dist/types/use-style.d.ts +0 -3
  152. package/dist/types/use-style.d.ts.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"Box2.cjs.js","sources":["../src/components/builtin/Box/Box2.tsx"],"sourcesContent":["import { GridValue } from '../../../prop-controllers/descriptors'\nimport { Element } from '../../../runtimes/react'\n\ntype Props = {\n children?: GridValue\n}\n\nexport default function Box2({ children }: Props) {\n return (\n <div\n style={{\n display: 'flex',\n minHeight: 100,\n maxWidth: '100%',\n width: '100%',\n border: '1px solid black',\n }}\n >\n {children?.elements.map(element => (\n <div style={{ flex: 1 }}>\n <Element element={element} />\n {/* @ts-ignore */}\n {/* <Box2 {...element.props} /> */}\n </div>\n ))}\n </div>\n )\n}\n"],"names":["children","display","minHeight","maxWidth","width","border","elements","map","element","flex","Element"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAO6B,cAAA;AAAA,EAAEA;AAAAA,GAAmB;AAE9C,wCAAA,OAAA;AAAA,IACE,OAAO;AAAA,MACLC,SAAS;AAAA,MACTC,WAAW;AAAA,MACXC,UAAU;AAAA,MACVC,OAAO;AAAA,MACPC,QAAQ;AAAA,IANZ;AAAA,IAAA,UASGL,qCAAUM,SAASC,IAAIC,CAAAA,2CACtB,OAAA;AAAA,MAAK,OAAO;AAAA,QAAEC,MAAM;AAAA,MAApB;AAAA,MAAA,yCACGC,cAAD;AAAA,QAAS;AAAA,MAAA,CAAT;AAAA,IAAA,CAFH;AAAA,EAAA,CAVL;AAmBD;;"}
package/dist/Box2.es.js DELETED
@@ -1,52 +0,0 @@
1
- import { E as Element } from "./index.es.js";
2
- import { jsx } from "react/jsx-runtime";
3
- import "react";
4
- import "use-sync-external-store/shim/with-selector";
5
- import "./react-page.es.js";
6
- import "redux";
7
- import "redux-thunk";
8
- import "./actions.es.js";
9
- import "./descriptors.es.js";
10
- import "./style.es.js";
11
- import "./color.es.js";
12
- import "./image.es.js";
13
- import "next/dynamic";
14
- import "next/document";
15
- import "styled-components";
16
- import "slate";
17
- import "@emotion/server/create-instance";
18
- import "@emotion/css";
19
- import "@apollo/client";
20
- import "@apollo/client/link/batch-http";
21
- import "./graphql.es.js";
22
- import "./text-input.es.js";
23
- import "./shape.es.js";
24
- import "color";
25
- import "react-dom";
26
- import "html-react-parser";
27
- import "next/head";
28
- import "uuid/v4";
29
- import "corporate-ipsum";
30
- function Box2({
31
- children
32
- }) {
33
- return /* @__PURE__ */ jsx("div", {
34
- style: {
35
- display: "flex",
36
- minHeight: 100,
37
- maxWidth: "100%",
38
- width: "100%",
39
- border: "1px solid black"
40
- },
41
- children: children == null ? void 0 : children.elements.map((element) => /* @__PURE__ */ jsx("div", {
42
- style: {
43
- flex: 1
44
- },
45
- children: /* @__PURE__ */ jsx(Element, {
46
- element
47
- })
48
- }))
49
- });
50
- }
51
- export { Box2 as default };
52
- //# sourceMappingURL=Box2.es.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Box2.es.js","sources":["../src/components/builtin/Box/Box2.tsx"],"sourcesContent":["import { GridValue } from '../../../prop-controllers/descriptors'\nimport { Element } from '../../../runtimes/react'\n\ntype Props = {\n children?: GridValue\n}\n\nexport default function Box2({ children }: Props) {\n return (\n <div\n style={{\n display: 'flex',\n minHeight: 100,\n maxWidth: '100%',\n width: '100%',\n border: '1px solid black',\n }}\n >\n {children?.elements.map(element => (\n <div style={{ flex: 1 }}>\n <Element element={element} />\n {/* @ts-ignore */}\n {/* <Box2 {...element.props} /> */}\n </div>\n ))}\n </div>\n )\n}\n"],"names":["children","display","minHeight","maxWidth","width","border","elements","map","element","flex"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAO6B,cAAA;AAAA,EAAEA;AAAAA,GAAmB;AAE9C,6BAAA,OAAA;AAAA,IACE,OAAO;AAAA,MACLC,SAAS;AAAA,MACTC,WAAW;AAAA,MACXC,UAAU;AAAA,MACVC,OAAO;AAAA,MACPC,QAAQ;AAAA,IANZ;AAAA,IAAA,UASGL,qCAAUM,SAASC,IAAIC,CAAAA,gCACtB,OAAA;AAAA,MAAK,OAAO;AAAA,QAAEC,MAAM;AAAA,MAApB;AAAA,MAAA,8BACG,SAAD;AAAA,QAAS;AAAA,MAAA,CAAT;AAAA,IAAA,CAFH;AAAA,EAAA,CAVL;AAmBD;;"}
@@ -1,594 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
- var __spreadValues = (a, b) => {
10
- for (var prop in b || (b = {}))
11
- if (__hasOwnProp.call(b, prop))
12
- __defNormalProp(a, prop, b[prop]);
13
- if (__getOwnPropSymbols)
14
- for (var prop of __getOwnPropSymbols(b)) {
15
- if (__propIsEnum.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
17
- }
18
- return a;
19
- };
20
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
- var __objRest = (source, exclude) => {
22
- var target = {};
23
- for (var prop in source)
24
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
25
- target[prop] = source[prop];
26
- if (source != null && __getOwnPropSymbols)
27
- for (var prop of __getOwnPropSymbols(source)) {
28
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
29
- target[prop] = source[prop];
30
- }
31
- return target;
32
- };
33
- var css = require("@emotion/css");
34
- var framerMotion = require("framer-motion");
35
- var React = require("react");
36
- var next = require("./index.cjs.js");
37
- var NextImage = require("next/image");
38
- var jsxRuntime = require("react/jsx-runtime");
39
- var ReactPlayer = require("react-player");
40
- var styled = require("styled-components");
41
- function _interopDefaultLegacy(e) {
42
- return e && typeof e === "object" && "default" in e ? e : { "default": e };
43
- }
44
- var NextImage__default = /* @__PURE__ */ _interopDefaultLegacy(NextImage);
45
- var ReactPlayer__default = /* @__PURE__ */ _interopDefaultLegacy(ReactPlayer);
46
- var styled__default = /* @__PURE__ */ _interopDefaultLegacy(styled);
47
- function useBackgrounds(value) {
48
- const fileIds = value == null ? [] : value.map(({ value: backgrounds }) => backgrounds.map((background) => background.type === "image" && background.payload != null ? background.payload.imageId : null).filter(next.isNonNullable).reduce((a, b) => a.concat(b), [])).reduce((a, b) => a.concat(b), []);
49
- const swatchIds = value == null ? [] : value.map(({ value: backgrounds }) => backgrounds.map((background) => {
50
- if (background.type === "color" && background.payload != null) {
51
- return [background.payload.swatchId];
52
- }
53
- if (background.type === "gradient" && background.payload != null) {
54
- return background.payload.stops.map((stop) => stop.color && stop.color.swatchId).filter(next.isNonNullable);
55
- }
56
- if (background.type === "video" && background.payload != null) {
57
- return [background.payload.maskColor && background.payload.maskColor.swatchId];
58
- }
59
- return null;
60
- }).filter(next.isNonNullable).reduce((a, b) => a.concat(b), [])).reduce((a, b) => a.concat(b), []).filter(next.isNonNullable);
61
- const skip = value == null;
62
- const filesResult = next.useQuery(next.FILES_BY_ID, {
63
- skip: skip || fileIds.length === 0,
64
- variables: { ids: fileIds }
65
- });
66
- const swatchesResult = next.useQuery(next.SWATCHES_BY_ID, {
67
- skip: skip || swatchIds.length === 0,
68
- variables: { ids: swatchIds }
69
- });
70
- return React.useMemo(() => {
71
- const { data: filesData = {} } = filesResult;
72
- const { data: swatchesData = {} } = swatchesResult;
73
- if (value == null || filesResult.error != null || swatchesResult.error != null) {
74
- return null;
75
- }
76
- const { files = [] } = filesData;
77
- const { swatches = [] } = swatchesData;
78
- return value.map((_a) => {
79
- var _b = _a, { value: backgrounds } = _b, restOfValue = __objRest(_b, ["value"]);
80
- return __spreadProps(__spreadValues({}, restOfValue), {
81
- value: backgrounds.map((bg) => {
82
- if (bg.type === "image" && bg.payload != null && bg.payload.imageId != null) {
83
- const _a2 = bg.payload, { imageId } = _a2, restOfPayload = __objRest(_a2, ["imageId"]);
84
- const file = files.find((f) => f && f.id === imageId);
85
- return file && {
86
- id: bg.id,
87
- type: "image",
88
- payload: __spreadProps(__spreadValues({}, restOfPayload), {
89
- publicUrl: file.publicUrl,
90
- dimensions: file.dimensions
91
- })
92
- };
93
- }
94
- if (bg.type === "color" && bg.payload != null) {
95
- const { swatchId, alpha } = bg.payload;
96
- const swatch = swatches.find((s) => s && s.id === swatchId);
97
- return { id: bg.id, type: "color", payload: { swatch, alpha } };
98
- }
99
- if (bg.type === "gradient" && bg.payload != null && bg.payload.stops.length > 0) {
100
- return {
101
- id: bg.id,
102
- type: "gradient",
103
- payload: {
104
- angle: bg.payload.angle,
105
- isRadial: bg.payload.isRadial,
106
- stops: bg.payload.stops.map((_b2) => {
107
- var _c = _b2, { color } = _c, restOfStop = __objRest(_c, ["color"]);
108
- return __spreadProps(__spreadValues({}, restOfStop), {
109
- color: color && {
110
- swatch: swatches.find((s) => s && s.id === color.swatchId),
111
- alpha: color.alpha
112
- }
113
- });
114
- })
115
- }
116
- };
117
- }
118
- if (bg.type === "video" && bg.payload != null) {
119
- const _d = bg.payload, { maskColor } = _d, restOfPayload = __objRest(_d, ["maskColor"]);
120
- const swatch = maskColor && swatches.find((s) => s && s.id === maskColor.swatchId);
121
- return {
122
- id: bg.id,
123
- type: "video",
124
- payload: __spreadProps(__spreadValues({}, restOfPayload), {
125
- maskColor: swatch && maskColor && { swatch, alpha: maskColor.alpha }
126
- })
127
- };
128
- }
129
- return null;
130
- }).filter(Boolean)
131
- });
132
- });
133
- }, [filesResult, swatchesResult, value]);
134
- }
135
- const clamp = (min, val, max) => Math.min(Math.max(min, val), max);
136
- function isScrollable(element) {
137
- const {
138
- overflow,
139
- overflowY,
140
- overflowX
141
- } = element.ownerDocument.defaultView.getComputedStyle(element);
142
- return /(auto|scroll)/.test(overflow + overflowX + overflowY);
143
- }
144
- function getScrollParent(element) {
145
- const {
146
- parentElement
147
- } = element;
148
- if (!element || !parentElement)
149
- return element;
150
- if (isScrollable(element))
151
- return element;
152
- return getScrollParent(parentElement);
153
- }
154
- function Parallax(_a) {
155
- var _b = _a, {
156
- strength,
157
- children
158
- } = _b, rest = __objRest(_b, [
159
- "strength",
160
- "children"
161
- ]);
162
- const container = React.useRef(null);
163
- const [containerScrollTop, setContainerScrollTop] = React.useState(strength == null ? 0 : strength);
164
- const lastScrollParentScrollTop = React.useRef(0);
165
- next.useIsomorphicLayoutEffect(() => {
166
- if (!container.current || strength == null || strength === 0)
167
- return void 0;
168
- const containerDocument = container.current.ownerDocument;
169
- const scrollParent = getScrollParent(container.current);
170
- const eventTarget = containerDocument.documentElement === scrollParent ? containerDocument.defaultView : scrollParent;
171
- lastScrollParentScrollTop.current = scrollParent.scrollTop;
172
- setContainerScrollTop(strength);
173
- function handleScroll() {
174
- containerDocument.defaultView.requestAnimationFrame(() => {
175
- if (!container.current)
176
- return;
177
- const {
178
- top: containerTop,
179
- bottom: containerBottom
180
- } = container.current.getBoundingClientRect();
181
- const {
182
- top: scrollParentTop,
183
- bottom: scrollParentBottom
184
- } = scrollParent === containerDocument.documentElement ? {
185
- top: 0,
186
- bottom: containerDocument.defaultView.innerHeight
187
- } : scrollParent.getBoundingClientRect();
188
- const {
189
- scrollTop: scrollParentScrollTop
190
- } = scrollParent === containerDocument.documentElement ? {
191
- scrollTop: containerDocument.defaultView.pageYOffset
192
- } : scrollParent;
193
- const scrollParentHeight = scrollParentBottom - scrollParentTop;
194
- const scrollParentScrollDelta = scrollParentScrollTop - lastScrollParentScrollTop.current;
195
- lastScrollParentScrollTop.current = scrollParentScrollTop;
196
- setContainerScrollTop((scrollTop) => {
197
- const isContainerVisible = containerTop < scrollParentTop + scrollParentHeight && containerBottom > scrollParentTop;
198
- const containerScrollRemaining = scrollParentScrollDelta > 0 ? 2 * strength - scrollTop : scrollTop;
199
- const scrollParentScrollRemaining = scrollParentScrollDelta > 0 ? scrollParentTop + containerBottom : scrollParentHeight - containerTop;
200
- const parallaxRatio = containerScrollRemaining / scrollParentScrollRemaining;
201
- const containerScrollDelta = isContainerVisible ? parallaxRatio * scrollParentScrollDelta : 0;
202
- return clamp(0, scrollTop + containerScrollDelta, strength * 2);
203
- });
204
- });
205
- }
206
- eventTarget.addEventListener("scroll", handleScroll);
207
- return () => eventTarget.removeEventListener("scroll", handleScroll);
208
- }, [strength]);
209
- const getProps = React.useCallback((_a2) => {
210
- var _b2 = _a2, {
211
- style
212
- } = _b2, restOfChildrenProps = __objRest(_b2, [
213
- "style"
214
- ]);
215
- return __spreadProps(__spreadValues({}, restOfChildrenProps), {
216
- style: __spreadValues(__spreadProps(__spreadValues({}, style), {
217
- position: "absolute",
218
- left: 0,
219
- right: 0,
220
- top: 0,
221
- bottom: 0
222
- }), strength == null || strength === 0 ? {} : {
223
- top: -strength,
224
- bottom: -strength,
225
- transform: `translate3d(0, ${containerScrollTop - strength}px, 0)`
226
- })
227
- });
228
- }, [strength, containerScrollTop]);
229
- return /* @__PURE__ */ jsxRuntime.jsx("div", __spreadProps(__spreadValues({}, rest), {
230
- ref: container,
231
- style: {
232
- position: "absolute",
233
- top: 0,
234
- left: 0,
235
- right: 0,
236
- bottom: 0
237
- },
238
- children: children(getProps)
239
- }));
240
- }
241
- const Container = styled__default["default"].div`
242
- position: absolute;
243
- top: 0;
244
- left: 0;
245
- right: 0;
246
- bottom: 0;
247
- pointer-events: none;
248
- overflow: hidden;
249
- `;
250
- const Mask = styled__default["default"].div`
251
- position: absolute;
252
- top: 0;
253
- left: 0;
254
- right: 0;
255
- bottom: 0;
256
- background: ${(props) => props.backgroundColor};
257
- opacity: ${(props) => props.visible ? 1 : 0};
258
- transition: opacity 1s;
259
- `;
260
- const getScale = (element, aspectRatio, zoom) => {
261
- const {
262
- offsetWidth: width,
263
- offsetHeight: height
264
- } = element;
265
- const computedAspectRatio = width / height;
266
- return Math.max(aspectRatio / computedAspectRatio, computedAspectRatio / aspectRatio) * zoom;
267
- };
268
- function BackgroundVideo({
269
- url = "",
270
- aspectRatio = 16 / 9,
271
- zoom = 1,
272
- maskColor,
273
- opacity
274
- }) {
275
- var _a;
276
- const [ready, setReady] = React.useState(false);
277
- const [scale, setScale] = React.useState(1);
278
- const container = React.useRef(null);
279
- next.useIsomorphicLayoutEffect(() => {
280
- const {
281
- current: containerEl
282
- } = container;
283
- if (!containerEl)
284
- return void 0;
285
- const {
286
- defaultView
287
- } = containerEl.ownerDocument;
288
- const handleResize = () => setScale(getScale(containerEl, aspectRatio, zoom));
289
- handleResize();
290
- defaultView.addEventListener("resize", handleResize);
291
- return () => defaultView.removeEventListener("resize", handleResize);
292
- }, [aspectRatio, zoom]);
293
- if (!ReactPlayer__default["default"].canPlay(url))
294
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
295
- return /* @__PURE__ */ jsxRuntime.jsxs(Container, {
296
- ref: container,
297
- children: [container.current && /* @__PURE__ */ jsxRuntime.jsx(ReactPlayer__default["default"], {
298
- url,
299
- config: {
300
- vimeo: {
301
- playerOptions: {
302
- background: true
303
- }
304
- },
305
- youtube: {
306
- playerVars: {
307
- origin: (_a = container.current.ownerDocument.defaultView) == null ? void 0 : _a.location.origin
308
- }
309
- },
310
- wistia: {
311
- options: {
312
- endVideoBehavior: "loop",
313
- playbackRateControl: false,
314
- playbar: false,
315
- playButton: false,
316
- volumeControl: false,
317
- fullscreenButton: false,
318
- muted: true
319
- }
320
- }
321
- },
322
- playing: true,
323
- loop: true,
324
- muted: true,
325
- controls: false,
326
- onReady: () => setReady(true),
327
- style: {
328
- transform: `scale3d(${scale}, ${scale}, 1)`,
329
- opacity
330
- },
331
- width: "100%",
332
- height: "100%"
333
- }), /* @__PURE__ */ jsxRuntime.jsx(Mask, {
334
- backgroundColor: maskColor,
335
- visible: !ready
336
- })]
337
- });
338
- }
339
- function getColor(color) {
340
- if (color == null)
341
- return "black";
342
- if (color.swatch == null) {
343
- return next.colorToString(__spreadProps(__spreadValues({}, color), {
344
- swatch: {
345
- hue: 0,
346
- saturation: 0,
347
- lightness: 0
348
- }
349
- }));
350
- }
351
- return next.colorToString(color);
352
- }
353
- const getStopsStyle = (stops) => stops.map(({
354
- color,
355
- location
356
- }) => `${getColor(color)} ${location}%`).join(",");
357
- const absoluteFillStyle = {
358
- position: "absolute",
359
- top: 0,
360
- right: 0,
361
- bottom: 0,
362
- left: 0
363
- };
364
- const containerStyle = __spreadProps(__spreadValues({}, absoluteFillStyle), {
365
- borderRadius: "inherit"
366
- });
367
- function Backgrounds({
368
- backgrounds
369
- }) {
370
- if (backgrounds == null)
371
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
372
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
373
- children: backgrounds.map(({
374
- value,
375
- deviceId
376
- }) => {
377
- const visibility = backgrounds.map((v) => ({
378
- deviceId: v.deviceId,
379
- value: v.deviceId === deviceId
380
- }));
381
- return /* @__PURE__ */ jsxRuntime.jsx(BackgroundDeviceLayer, {
382
- layer: value,
383
- visibility
384
- }, deviceId);
385
- })
386
- });
387
- }
388
- function BackgroundDeviceLayer({
389
- layer,
390
- visibility
391
- }) {
392
- const visibilityStyle = next.responsiveStyle([visibility], ([v]) => ({
393
- display: v === true ? "block" : "none"
394
- }));
395
- return /* @__PURE__ */ jsxRuntime.jsx("div", {
396
- className: next.useStyle(__spreadProps(__spreadValues(__spreadValues({}, containerStyle), visibilityStyle), {
397
- overflow: "hidden"
398
- })),
399
- children: [...layer].reverse().map((bg) => {
400
- if (bg.type === "color") {
401
- return /* @__PURE__ */ jsxRuntime.jsx(ColorBackground, {
402
- color: getColor(bg.payload)
403
- }, bg.id);
404
- }
405
- if (bg.type === "image" && bg.payload) {
406
- return /* @__PURE__ */ React.createElement(ImageBackground, __spreadProps(__spreadValues({}, bg.payload), {
407
- key: bg.id
408
- }));
409
- }
410
- if (bg.type === "gradient" && bg.payload) {
411
- return /* @__PURE__ */ React.createElement(GradientBackground, __spreadProps(__spreadValues({}, bg.payload), {
412
- key: bg.id,
413
- gradient: getStopsStyle(bg.payload.stops)
414
- }));
415
- }
416
- if (bg.type === "video" && bg.payload) {
417
- return /* @__PURE__ */ React.createElement(VideoBackground, __spreadProps(__spreadValues({}, bg.payload), {
418
- key: bg.id,
419
- maskColor: getColor(bg.payload.maskColor)
420
- }));
421
- }
422
- return null;
423
- })
424
- });
425
- }
426
- function ColorBackground({
427
- color
428
- }) {
429
- return /* @__PURE__ */ jsxRuntime.jsx("div", {
430
- className: next.useStyle(__spreadProps(__spreadValues({}, containerStyle), {
431
- backgroundColor: color
432
- }))
433
- });
434
- }
435
- const ImageBackgroundRepeat = {
436
- NoRepeat: "no-repeat",
437
- RepeatX: "repeat-x",
438
- RepeatY: "repeat-y",
439
- Repeat: "repeat"
440
- };
441
- const ImageBackgroundSize = {
442
- Cover: "cover",
443
- Contain: "contain",
444
- Auto: "auto"
445
- };
446
- function ImageBackground({
447
- publicUrl,
448
- position,
449
- repeat = ImageBackgroundRepeat.NoRepeat,
450
- size = ImageBackgroundSize.Cover,
451
- opacity,
452
- parallax
453
- }) {
454
- const backgroundPosition = `${position.x}% ${position.y}%`;
455
- const containerClassName = next.useStyle(containerStyle);
456
- if (repeat === "no-repeat" && size !== "auto" && publicUrl != null) {
457
- return /* @__PURE__ */ jsxRuntime.jsx(Parallax, {
458
- strength: parallax,
459
- children: (getParallaxProps) => /* @__PURE__ */ jsxRuntime.jsx("div", __spreadProps(__spreadValues({}, getParallaxProps({
460
- style: {
461
- opacity,
462
- overflow: "hidden"
463
- }
464
- })), {
465
- children: /* @__PURE__ */ jsxRuntime.jsx(NextImage__default["default"], {
466
- src: publicUrl,
467
- layout: "fill",
468
- objectPosition: backgroundPosition,
469
- objectFit: size
470
- })
471
- }))
472
- });
473
- }
474
- return /* @__PURE__ */ jsxRuntime.jsx(Parallax, {
475
- strength: parallax,
476
- children: (getParallaxProps) => /* @__PURE__ */ jsxRuntime.jsx("div", __spreadValues({
477
- className: containerClassName
478
- }, getParallaxProps({
479
- style: {
480
- backgroundImage: publicUrl != null ? `url('${publicUrl}')` : void 0,
481
- backgroundPosition,
482
- backgroundRepeat: repeat,
483
- backgroundSize: size,
484
- opacity
485
- }
486
- })))
487
- });
488
- }
489
- function GradientBackground({
490
- gradient,
491
- isRadial,
492
- angle
493
- }) {
494
- return /* @__PURE__ */ jsxRuntime.jsx("div", {
495
- className: next.useStyle(__spreadProps(__spreadValues({}, containerStyle), {
496
- background: isRadial ? `radial-gradient(${gradient})` : `linear-gradient(${angle}rad, ${gradient})`
497
- }))
498
- });
499
- }
500
- function getAspectRatio(aspectRatio) {
501
- switch (aspectRatio) {
502
- case "wide":
503
- return 16 / 9;
504
- case "standard":
505
- return 4 / 3;
506
- default:
507
- return 16 / 9;
508
- }
509
- }
510
- function VideoBackground({
511
- url,
512
- aspectRatio,
513
- maskColor,
514
- zoom,
515
- opacity,
516
- parallax
517
- }) {
518
- return /* @__PURE__ */ jsxRuntime.jsx(Parallax, {
519
- strength: parallax,
520
- children: (getParallaxProps) => /* @__PURE__ */ jsxRuntime.jsx("div", __spreadProps(__spreadValues({}, getParallaxProps({
521
- className: next.useStyle(containerStyle)
522
- })), {
523
- children: /* @__PURE__ */ jsxRuntime.jsx(BackgroundVideo, {
524
- url,
525
- zoom,
526
- opacity,
527
- aspectRatio: getAspectRatio(aspectRatio),
528
- maskColor
529
- })
530
- }))
531
- });
532
- }
533
- var BackgroundsContainer = React.forwardRef(function BackgroundsContainer2(_c, ref) {
534
- var _d = _c, {
535
- backgrounds,
536
- children,
537
- className
538
- } = _d, restOfProps = __objRest(_d, [
539
- "backgrounds",
540
- "children",
541
- "className"
542
- ]);
543
- const [handle, setHandle] = React.useState(null);
544
- React.useImperativeHandle(ref, () => handle, [handle]);
545
- return /* @__PURE__ */ jsxRuntime.jsxs(framerMotion.motion.div, __spreadProps(__spreadValues({}, restOfProps), {
546
- ref: setHandle,
547
- className: css.cx(next.useStyle({
548
- position: "relative",
549
- width: "100%",
550
- margin: "0 auto",
551
- "> *": {
552
- borderRadius: "inherit",
553
- height: "inherit"
554
- },
555
- "> :last-child": {
556
- position: "relative"
557
- }
558
- }), className),
559
- children: [/* @__PURE__ */ jsxRuntime.jsx(Backgrounds, {
560
- backgrounds: useBackgrounds(backgrounds)
561
- }), React.Children.only(children)]
562
- }));
563
- });
564
- function GridItem(_e) {
565
- var _f = _e, {
566
- as,
567
- grid,
568
- index,
569
- columnGap,
570
- rowGap,
571
- className
572
- } = _f, restOfProps = __objRest(_f, [
573
- "as",
574
- "grid",
575
- "index",
576
- "columnGap",
577
- "rowGap",
578
- "className"
579
- ]);
580
- const gridItemClassName = next.useStyle(next.responsiveGridItem({
581
- grid,
582
- index,
583
- columnGap,
584
- rowGap
585
- }));
586
- const Component = as != null ? as : "div";
587
- return /* @__PURE__ */ jsxRuntime.jsx(Component, __spreadProps(__spreadValues({}, restOfProps), {
588
- className: css.cx(gridItemClassName, className)
589
- }));
590
- }
591
- exports.BackgroundsContainer = BackgroundsContainer;
592
- exports.GridItem = GridItem;
593
- exports.useBackgrounds = useBackgrounds;
594
- //# sourceMappingURL=grid-item.cjs.js.map