unframer 2.0.1 → 2.1.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.
package/esm/framer.js CHANGED
@@ -8795,7 +8795,7 @@ var cancelSync = stepsOrder.reduce((acc, key7) => {
8795
8795
  acc[key7] = (process2) => cancelFrame(process2);
8796
8796
  return acc;
8797
8797
  }, {});
8798
- // https :https://app.framerstatic.com/framer.L736M3IJ.js
8798
+ // https :https://app.framerstatic.com/framer.PRO3WDEJ.js
8799
8799
  import { Component as Component2, } from 'react';
8800
8800
  import React12 from 'react';
8801
8801
  import { jsx as _jsx5, } from 'react/jsx-runtime';
@@ -8971,16 +8971,16 @@ import { jsx as jsx54, jsxs as jsxs18, } from 'react/jsx-runtime';
8971
8971
  import { jsx as jsx55, } from 'react/jsx-runtime';
8972
8972
  import { jsx as jsx56, } from 'react/jsx-runtime';
8973
8973
  import { jsx as jsx57, } from 'react/jsx-runtime';
8974
+ import React85 from 'react';
8974
8975
  import { jsx as jsx58, } from 'react/jsx-runtime';
8975
- import { useRef as useRef18, } from 'react';
8976
8976
  import { jsx as jsx59, } from 'react/jsx-runtime';
8977
- import { useRef as useRef19, } from 'react';
8978
- import { jsx as jsx60, } from 'react/jsx-runtime';
8979
- import React85 from 'react';
8980
- import { jsx as jsx61, jsxs as jsxs19, } from 'react/jsx-runtime';
8981
- import { Children as Children32, cloneElement as cloneElement32, forwardRef as forwardRef52, isValidElement as isValidElement32, useContext as useContext162, useInsertionEffect as useInsertionEffect42, useRef as useRef21, } from 'react';
8982
- import * as React86 from 'react';
8983
- import { useRef as useRef20, } from 'react';
8977
+ import React86 from 'react';
8978
+ import { jsx as jsx60, jsxs as jsxs19, } from 'react/jsx-runtime';
8979
+ import React87 from 'react';
8980
+ import { jsx as jsx61, jsxs as jsxs20, } from 'react/jsx-runtime';
8981
+ import { Children as Children32, cloneElement as cloneElement32, forwardRef as forwardRef52, isValidElement as isValidElement32, useContext as useContext162, useInsertionEffect as useInsertionEffect42, useRef as useRef19, } from 'react';
8982
+ import * as React88 from 'react';
8983
+ import { useRef as useRef18, } from 'react';
8984
8984
  import { jsx as jsx62, } from 'react/jsx-runtime';
8985
8985
  import { jsx as jsx63, } from 'react/jsx-runtime';
8986
8986
  import { useEffect as useEffect142, useState as useState22, } from 'react';
@@ -10146,12 +10146,13 @@ var require_fontfaceobserver_standalone = __commonJS({
10146
10146
  },
10147
10147
  });
10148
10148
  function renderPage(Page4, defaultPageStyle) {
10149
- return React12.isValidElement(Page4)
10150
- ? React12.cloneElement(Page4, { style: defaultPageStyle, })
10151
- : React12.createElement(Page4, { style: defaultPageStyle, });
10149
+ const style = { style: defaultPageStyle, };
10150
+ return React12.isValidElement(Page4) ? React12.cloneElement(Page4, style) : React12.createElement(Page4, style);
10152
10151
  }
10153
10152
  var NotFoundError = class extends Error {
10154
10153
  };
10154
+ var ErrorBoundaryCaughtError = class extends Error {
10155
+ };
10155
10156
  var ErrorBoundary = class extends Component2 {
10156
10157
  constructor(props) {
10157
10158
  super(props);
@@ -10178,7 +10179,9 @@ var ErrorBoundary = class extends Component2 {
10178
10179
  return this.props.children;
10179
10180
  }
10180
10181
  if (!(this.state.error instanceof NotFoundError)) {
10181
- throw this.state.error;
10182
+ const error = new ErrorBoundaryCaughtError();
10183
+ error.cause = this.state.error;
10184
+ throw error;
10182
10185
  }
10183
10186
  const { notFoundPage, defaultPageStyle, } = this.props;
10184
10187
  if (!notFoundPage) {
@@ -11046,17 +11049,17 @@ function RoutesProvider({ routes, children, }) {
11046
11049
  return _jsx2(RouterContext.Provider, { value: { getRoute, }, children, });
11047
11050
  }
11048
11051
  var SuspenseErrorBoundary = class extends Component22 {
11049
- constructor(props) {
11050
- super(props);
11052
+ constructor() {
11053
+ super(...arguments);
11051
11054
  this.state = { error: void 0, };
11052
11055
  }
11053
11056
  static getDerivedStateFromError(error) {
11054
- console.error('Error in SuspenseErrorBoundary (getDerivedStateFromError).', error);
11057
+ console.error('Derived error in SuspenseErrorBoundary', error);
11055
11058
  return { error, };
11056
11059
  }
11057
11060
  componentDidCatch(error, errorInfo) {
11058
11061
  var _a;
11059
- console.error('Caught error in in SuspenseErrorBoundary.', error, errorInfo);
11062
+ console.error('Caught error in SuspenseErrorBoundary', error, errorInfo);
11060
11063
  (_a = window.__framer_events) === null || _a === void 0 ? void 0 : _a.push([
11061
11064
  'published_site_load_recoverable_error',
11062
11065
  {
@@ -11069,6 +11072,9 @@ var SuspenseErrorBoundary = class extends Component22 {
11069
11072
  if (this.state.error === void 0) {
11070
11073
  return this.props.children;
11071
11074
  }
11075
+ if (this.state.error instanceof ErrorBoundaryCaughtError) {
11076
+ throw this.state.error.cause;
11077
+ }
11072
11078
  return _jsx3(Suspense, { children: this.props.fallbackChildren, });
11073
11079
  }
11074
11080
  };
@@ -16550,6 +16556,7 @@ var hideScrollbars = [
16550
16556
  `[data-hide-scrollbars="true"]::-webkit-scrollbar { width: 0px; height: 0px; }`,
16551
16557
  `[data-hide-scrollbars="true"]::-webkit-scrollbar-thumb { background: transparent; }`,
16552
16558
  ];
16559
+ var formInputRules = [`[data-framer-component-type="Form"] input { padding: var(--input-padding); }`,];
16553
16560
  var frameCSSRules = (isPreview) => {
16554
16561
  return isPreview ? frameCSS : [];
16555
16562
  };
@@ -16571,6 +16578,7 @@ var combineCSSRules = (isPreview) => [
16571
16578
  ...svgCSSRules,
16572
16579
  ...resetCSS,
16573
16580
  ...hideScrollbars,
16581
+ ...formInputRules,
16574
16582
  ];
16575
16583
  export var combinedCSSRules = combineCSSRules(false);
16576
16584
  var combinedCSSRulesForPreview = combineCSSRules(true);
@@ -20067,7 +20075,7 @@ function hasDataFramerName(props) {
20067
20075
  return 'data-framer-name' in props;
20068
20076
  }
20069
20077
  var VisibleFrame = /* @__PURE__ */ forwardRef4(function VisibleFrame2(props, forwardedRef) {
20070
- var _f;
20078
+ var _f, _j;
20071
20079
  const { name, center, border, _border, __portal, } = props;
20072
20080
  const { props: propsWithOverrides, children, } = processOverrideForwarding(props);
20073
20081
  const motionProps = getMotionProps(propsWithOverrides);
@@ -20076,7 +20084,7 @@ var VisibleFrame = /* @__PURE__ */ forwardRef4(function VisibleFrame2(props, for
20076
20084
  const fallbackRef = useRef62(null);
20077
20085
  const ref = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : fallbackRef;
20078
20086
  const dataProps = {
20079
- 'data-framer-component-type': 'Frame',
20087
+ 'data-framer-component-type': (_f = props.componentType) !== null && _f !== void 0 ? _f : 'Frame',
20080
20088
  'data-framer-cursor': cursor,
20081
20089
  'data-framer-highlight': cursor === 'pointer' ? true : void 0,
20082
20090
  'data-layoutid': layoutId,
@@ -20106,7 +20114,7 @@ var VisibleFrame = /* @__PURE__ */ forwardRef4(function VisibleFrame2(props, for
20106
20114
  children: [
20107
20115
  backgroundImage
20108
20116
  ? /* @__PURE__ */ jsx10(BackgroundImageComponent, {
20109
- alt: (_f = props.alt) !== null && _f !== void 0 ? _f : '',
20117
+ alt: (_j = props.alt) !== null && _j !== void 0 ? _j : '',
20110
20118
  image: backgroundImage,
20111
20119
  containerSize: rect !== null && rect !== void 0 ? rect : void 0,
20112
20120
  nodeId: props.id && nodeIdFromString(props.id),
@@ -23700,6 +23708,9 @@ function paddingFromProps(props) {
23700
23708
  };
23701
23709
  }
23702
23710
  function makePaddingString({ top, left, bottom, right, }) {
23711
+ if (top === right && right === bottom && bottom === left) {
23712
+ return `${top}px`;
23713
+ }
23703
23714
  return `${top}px ${right}px ${bottom}px ${left}px`;
23704
23715
  }
23705
23716
  function triggerStackReflow(element, display) {
@@ -26962,6 +26973,9 @@ function useStyleTransform({ transformTrigger, styleTransformEffectEnabled, tran
26962
26973
  if (pageInputRange.length !== outputRange[key7].length) {
26963
26974
  continue;
26964
26975
  }
26976
+ if (outputRange[key7][0] === void 0) {
26977
+ continue;
26978
+ }
26965
26979
  effect.values[key7].set(transform(scrollY.progress, pageInputRange, outputRange[key7]));
26966
26980
  }
26967
26981
  }, transformTrigger === 'onInView'
@@ -26987,6 +27001,9 @@ function useStyleTransform({ transformTrigger, styleTransformEffectEnabled, tran
26987
27001
  if (scrollYInputRange.length !== effectKeyOutputRange[key7].length) {
26988
27002
  continue;
26989
27003
  }
27004
+ if (effectKeyOutputRange[key7][0] === void 0) {
27005
+ continue;
27006
+ }
26990
27007
  effect.values[key7].set(transform(scrollY.current, scrollYInputRange, effectKeyOutputRange[key7]));
26991
27008
  }
26992
27009
  });
@@ -35664,53 +35681,97 @@ var localPackageFallbackIdentifier = '|local|';
35664
35681
  function CustomProperties({ children, customProperties, }) {
35665
35682
  return /* @__PURE__ */ jsx57('div', { style: customProperties, children, });
35666
35683
  }
35667
- var FormContainer = (props) => {
35668
- return /* @__PURE__ */ jsx58(FrameWithMotion, Object.assign(Object.assign({}, props), { as: 'form' }));
35669
- };
35670
- var FormButton = (props) => {
35684
+ var FormButton = /* @__PURE__ */ React85.forwardRef(function FormButon(props, ref) {
35671
35685
  var _f;
35672
- const { __fromCanvasComponent, style: baseStyle2, } = props;
35673
- const layoutId = useLayoutId2(props);
35674
- const ref = useRef18(null);
35686
+ const [submitting, setSubmitting,] = React85.useState(false);
35687
+ const { style: baseStyle2, } = props;
35675
35688
  const style = mergeWithDefaultStyle(baseStyle2 !== null && baseStyle2 !== void 0 ? baseStyle2 : {});
35676
- const dataProps = {
35677
- 'data-layoutid': layoutId,
35678
- };
35679
- const isDisabled = Boolean(__fromCanvasComponent);
35680
- useMeasureLayout(props, ref);
35681
- return /* @__PURE__ */ jsx59(motion.input, Object.assign(Object.assign({ type: props.type, disabled: isDisabled }, dataProps), { layoutId,
35682
- ref, style: Object.assign(Object.assign({}, baseStyle2), style), value: (_f = props.value) !== null && _f !== void 0 ? _f : 'Submit' }));
35683
- };
35689
+ const onSubmit = () => {
35690
+ setSubmitting(true);
35691
+ setTimeout(() => {
35692
+ setSubmitting(false);
35693
+ }, 500);
35694
+ };
35695
+ return /* @__PURE__ */ jsx58(motion.input, {
35696
+ type: props.type,
35697
+ 'data-submitting': submitting,
35698
+ disabled: props.isDisabled || submitting,
35699
+ ref,
35700
+ style,
35701
+ value: submitting ? 'Submitting' : (_f = props.value) !== null && _f !== void 0 ? _f : 'Submit',
35702
+ onClick: onSubmit,
35703
+ });
35704
+ });
35684
35705
  function mergeWithDefaultStyle(style) {
35685
- return Object.assign({ display: 'block', padding: '12px', width: '100%', background: '#222', color: '#fff', borderRadius: '10px', border: '1px solid rgba(0,0,0,0.05)' }, style);
35706
+ return Object.assign({ display: 'block', padding: '12px', fontSize: '14px', width: '100%', fontWeight: 'bold', cursor: 'pointer', background: '#222', color: '#fff', borderRadius: '10px', border: '1px solid rgba(0,0,0,0.05)' }, style);
35686
35707
  }
35687
- var FormPlainTextInput = (props) => {
35688
- const { __fromCanvasComponent, } = props;
35689
- const layoutId = useLayoutId2(props);
35690
- const ref = useRef19(null);
35691
- const dataProps = {
35692
- 'data-layoutid': layoutId,
35693
- };
35694
- const isDisabled = Boolean(__fromCanvasComponent);
35695
- useMeasureLayout(props, ref);
35708
+ var FormContainer = (_f) => {
35709
+ var { action: _, formId } = _f, props = __rest(_f, ["action", "formId"]);
35710
+ const handleSubmit = (event) => __awaiter(void 0, void 0, void 0, function* () {
35711
+ event.preventDefault();
35712
+ const data2 = new URLSearchParams();
35713
+ for (const [key7, value,] of new FormData(event.currentTarget)) {
35714
+ data2.append(key7, value);
35715
+ }
35716
+ yield fetch('https://hooks.zapier.com/hooks/catch/8935032/3pzgf76/', {
35717
+ body: new URLSearchParams(data2),
35718
+ method: 'POST',
35719
+ });
35720
+ });
35721
+ return /* @__PURE__ */ jsx59(motion.form, Object.assign(Object.assign({}, props), { 'data-formid': formId, onSubmit: handleSubmit, children: props.children }));
35722
+ };
35723
+ var passwordManagerIgnoreDataProps = {
35724
+ // 1Password
35725
+ 'data-1p-ignore': true,
35726
+ // LastPass
35727
+ 'data-lpignore': true,
35728
+ };
35729
+ var sensibleInputDefaults = {
35730
+ autocomplete: 'off',
35731
+ };
35732
+ var labelStyles = {
35733
+ display: 'block',
35734
+ marginBottom: 8,
35735
+ fontSize: 12,
35736
+ color: '#000',
35737
+ width: '100%',
35738
+ fontWeight: 'bold',
35739
+ textTransform: 'capitalize',
35740
+ };
35741
+ var FormPlainTextInput = /* @__PURE__ */ React86.forwardRef(function FormPlainTextInput2(props, ref) {
35742
+ const dataProps = Object.assign(Object.assign({}, sensibleInputDefaults), passwordManagerIgnoreDataProps);
35696
35743
  const baseStyle2 = {
35697
- padding: '12px',
35744
+ fontSize: '14px',
35698
35745
  width: '100%',
35699
35746
  background: '#f5f5f5',
35700
35747
  borderRadius: '10px',
35701
35748
  border: '1px solid rgba(0,0,0,0.05)',
35702
35749
  };
35703
- return /* @__PURE__ */ jsx60(motion.input, Object.assign(Object.assign({ disabled: isDisabled }, dataProps), { layoutId,
35704
- ref, style: Object.assign(Object.assign({}, baseStyle2), props.style), placeholder: props.placeholder }));
35705
- };
35706
- var Image2 = /* @__PURE__ */ React85.forwardRef(function Image3(props, ref) {
35750
+ const input = /* @__PURE__ */ jsx60(motion.input, Object.assign(Object.assign({ id: props.inputName, disabled: props.isDisabled }, dataProps), { type: props.type, required: props.required, autoFocus: props.autoFocus, name: props.inputName, style: baseStyle2, placeholder: props.placeholder }));
35751
+ if (props.label) {
35752
+ return /* @__PURE__ */ jsx60('div', {
35753
+ ref,
35754
+ style: { width: '100%', },
35755
+ children: /* @__PURE__ */ jsxs19('label', {
35756
+ style: { width: '100%', },
35757
+ htmlFor: props.inputName,
35758
+ children: [
35759
+ /* @__PURE__ */ jsx60('span', { style: labelStyles, children: props.label, }),
35760
+ input,
35761
+ ],
35762
+ }),
35763
+ });
35764
+ }
35765
+ return /* @__PURE__ */ jsx60('div', { ref, style: { width: '100%', }, children: input, });
35766
+ });
35767
+ var Image2 = /* @__PURE__ */ React87.forwardRef(function Image3(props, ref) {
35707
35768
  const { background, children, alt } = props, rest = __rest(props, ["background", "children", "alt"]);
35708
35769
  const style = Object.assign({}, rest.style);
35709
35770
  if (background) {
35710
35771
  delete style.background;
35711
35772
  }
35712
35773
  const MotionComponent = htmlElementAsMotionComponent(props.as);
35713
- return /* @__PURE__ */ jsxs19(MotionComponent, Object.assign(Object.assign({}, rest), { style,
35774
+ return /* @__PURE__ */ jsxs20(MotionComponent, Object.assign(Object.assign({}, rest), { style,
35714
35775
  ref, children: [
35715
35776
  background && /* @__PURE__ */ jsx61(BackgroundImageComponent, { image: background, alt, }),
35716
35777
  children,
@@ -35802,18 +35863,18 @@ function escapeHTML2(str) {
35802
35863
  }
35803
35864
  var deprecatedRichTextPlaceholder = '{{ text-placeholder }}';
35804
35865
  var richTextWrapperClassName = 'rich-text-wrapper';
35805
- var DeprecatedRichText = /* @__PURE__ */ React86.forwardRef(function Text3(props, forwardedRef) {
35866
+ var DeprecatedRichText = /* @__PURE__ */ React88.forwardRef(function Text3(props, forwardedRef) {
35806
35867
  var _f, _j;
35807
35868
  const { id: id3, name, html, htmlFromDesign, text, textFromDesign, fonts = [], width, height, left, right, top, bottom, center, className, stylesPresetsClassName, visible = true, opacity, rotation = 0, verticalAlignment = 'top', isEditable = false, willChangeTransform, environment: environment2 = RenderTarget.current, withExternalLayout = false, positionSticky, positionStickyTop, positionStickyRight, positionStickyBottom, positionStickyLeft, __htmlStructure, __fromCanvasComponent = false, _forwardedOverrideId, _forwardedOverrides, _usesDOMRect, children } = props, rest = __rest(props, ["id", "name", "html", "htmlFromDesign", "text", "textFromDesign", "fonts", "width", "height", "left", "right", "top", "bottom", "center", "className", "stylesPresetsClassName", "visible", "opacity", "rotation", "verticalAlignment", "isEditable", "willChangeTransform", "environment", "withExternalLayout", "positionSticky", "positionStickyTop", "positionStickyRight", "positionStickyBottom", "positionStickyLeft", "__htmlStructure", "__fromCanvasComponent", "_forwardedOverrideId", "_forwardedOverrides", "_usesDOMRect", "children"]);
35808
35869
  const parentSize = useParentSize();
35809
35870
  const layoutId = useLayoutId2(props);
35810
- const fallbackLayoutRef = useRef20(null);
35871
+ const fallbackLayoutRef = useRef18(null);
35811
35872
  const layoutRef = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : fallbackLayoutRef;
35812
35873
  const { navigate, getRoute, } = useRouter();
35813
35874
  const currentRoute = useCurrentRoute();
35814
35875
  useRoutePreloader((_f = props.preload) !== null && _f !== void 0 ? _f : []);
35815
35876
  useMeasureLayout(props, layoutRef);
35816
- const inCodeComponent = React86.useContext(ComponentContainerContext);
35877
+ const inCodeComponent = React88.useContext(ComponentContainerContext);
35817
35878
  const isOnCanvas = useIsOnFramerCanvas();
35818
35879
  let textOrOverride = text;
35819
35880
  const forwardedOverrideId = _forwardedOverrideId !== null && _forwardedOverrideId !== void 0 ? _forwardedOverrideId : id3;
@@ -35839,13 +35900,13 @@ var DeprecatedRichText = /* @__PURE__ */ React86.forwardRef(function Text3(props
35839
35900
  innerHTML = htmlFromDesign;
35840
35901
  }
35841
35902
  const implicitPathVariables = useImplicitPathVariables();
35842
- const innerHTMLWithReplacedFramerPageLinks = React86.useMemo(() => {
35903
+ const innerHTMLWithReplacedFramerPageLinks = React88.useMemo(() => {
35843
35904
  if (isOnCanvas || !getRoute || !currentRoute) {
35844
35905
  return innerHTML;
35845
35906
  }
35846
35907
  return replaceFramerPageLinks(innerHTML, getRoute, currentRoute, implicitPathVariables);
35847
35908
  }, [isOnCanvas, innerHTML, getRoute, currentRoute, implicitPathVariables,]);
35848
- React86.useEffect(() => {
35909
+ React88.useEffect(() => {
35849
35910
  const container = layoutRef.current;
35850
35911
  if (container === null) {
35851
35912
  return;
@@ -35866,7 +35927,7 @@ var DeprecatedRichText = /* @__PURE__ */ React86.forwardRef(function Text3(props
35866
35927
  };
35867
35928
  }, [navigate, implicitPathVariables,]);
35868
35929
  useLoadFonts(fonts, __fromCanvasComponent, layoutRef);
35869
- React86.useInsertionEffect(() => {
35930
+ React88.useInsertionEffect(() => {
35870
35931
  injectComponentCSSRules();
35871
35932
  }, []);
35872
35933
  if (!visible) {
@@ -35938,7 +35999,7 @@ function convertVerticalAlignment2(verticalAlignment) {
35938
35999
  }
35939
36000
  }
35940
36001
  function useLoadFonts(fonts, fromCanvasComponent, containerRef) {
35941
- const prevFontsRef = useRef20([]);
36002
+ const prevFontsRef = useRef18([]);
35942
36003
  if (!isShallowEqualArray(prevFontsRef.current, fonts)) {
35943
36004
  prevFontsRef.current = fonts;
35944
36005
  fontStore.loadFonts(fonts).then(({ newlyLoadedFontCount, }) => {
@@ -35969,7 +36030,7 @@ var RichTextContainer = /* @__PURE__ */ forwardRef52((props, ref) => {
35969
36030
  const isOnCanvas = useIsOnFramerCanvas();
35970
36031
  const inCodeComponent = useContext162(ComponentContainerContext);
35971
36032
  const layoutId = useLayoutId2(props);
35972
- const fallbackRef = useRef21(null);
36033
+ const fallbackRef = useRef19(null);
35973
36034
  const containerRef = ref !== null && ref !== void 0 ? ref : fallbackRef;
35974
36035
  useMeasureLayout(props, containerRef);
35975
36036
  useLoadFonts(fonts, __fromCanvasComponent, containerRef);
@@ -36488,7 +36549,9 @@ var package_default = {
36488
36549
  scripts: {
36489
36550
  prepublishOnly: 'make build',
36490
36551
  coverage: 'yarn :jest --coverage',
36491
- lint: 'yarn :eslint ./src --ext .ts,.tsx --format codeframe --quiet',
36552
+ lint: 'yarn format-check:ts && yarn :eslint ./src --ext .ts,.tsx --format codeframe --quiet',
36553
+ 'format:ts': 'yarn :format "src/**/*.{ts,tsx}"',
36554
+ 'format-check:ts': 'yarn :format-check "src/**/*.{ts,tsx}"',
36492
36555
  'lint:fix': 'yarn lint --fix --cache',
36493
36556
  test: 'yarn :jest',
36494
36557
  watch: 'yarn :jest --watch',