@plasmicpkgs/plasmic-basic-components 0.0.191 → 0.0.192
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/dist/LoadingBoundary.d.ts +0 -2
- package/dist/Timer.d.ts +12 -0
- package/dist/common.d.ts +3 -0
- package/dist/index.d.ts +8 -6
- package/dist/plasmic-basic-components.cjs.development.js +283 -214
- package/dist/plasmic-basic-components.cjs.development.js.map +1 -1
- package/dist/plasmic-basic-components.cjs.production.min.js +1 -1
- package/dist/plasmic-basic-components.cjs.production.min.js.map +1 -1
- package/dist/plasmic-basic-components.esm.js +281 -214
- package/dist/plasmic-basic-components.esm.js.map +1 -1
- package/package.json +2 -2
|
@@ -5,8 +5,6 @@ interface LoadingBoundaryProps {
|
|
|
5
5
|
children?: React.ReactNode;
|
|
6
6
|
forceLoading?: boolean;
|
|
7
7
|
}
|
|
8
|
-
export declare const isBrowser: boolean;
|
|
9
|
-
export declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
|
|
10
8
|
export default function LoadingBoundary({ children, forceLoading, loadingState, }: LoadingBoundaryProps): React.JSX.Element | null;
|
|
11
9
|
export declare const loadingBoundaryMeta: ComponentMeta<LoadingBoundaryProps>;
|
|
12
10
|
export declare function registerLoadingBoundary(loader?: {
|
package/dist/Timer.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import registerComponent, { CodeComponentMeta } from "@plasmicapp/host/registerComponent";
|
|
2
|
+
export interface TimerProps {
|
|
3
|
+
onTick: () => void;
|
|
4
|
+
isRunning?: boolean;
|
|
5
|
+
intervalSeconds?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function useInterval(callback: () => void, delay: number | null): void;
|
|
8
|
+
export default function Timer({ intervalSeconds, isRunning, onTick, }: TimerProps): null;
|
|
9
|
+
export declare const timerMeta: CodeComponentMeta<TimerProps>;
|
|
10
|
+
export declare function registerTimer(loader?: {
|
|
11
|
+
registerComponent: typeof registerComponent;
|
|
12
|
+
}, customMeta?: CodeComponentMeta<TimerProps>): void;
|
package/dist/common.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
export declare const tuple: <T extends any[]>(...args: T) => T;
|
|
2
3
|
export declare function ensure<T>(x: T | null | undefined): T;
|
|
4
|
+
export declare const isBrowser: boolean;
|
|
5
|
+
export declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
+
export * from "./ConditionGuard";
|
|
2
|
+
export { default as ConditionGuard } from "./ConditionGuard";
|
|
1
3
|
export * from "./Data";
|
|
2
4
|
export * from "./Embed";
|
|
3
5
|
export { default as Embed } from "./Embed";
|
|
4
6
|
export * from "./Iframe";
|
|
5
7
|
export { default as Iframe } from "./Iframe";
|
|
8
|
+
export * from "./LoadingBoundary";
|
|
9
|
+
export { default as LoadingBoundary } from "./LoadingBoundary";
|
|
6
10
|
export * from "./Repeater";
|
|
7
11
|
export { default as Repeater } from "./Repeater";
|
|
8
12
|
export * from "./ScrollRevealer";
|
|
9
13
|
export { default as ScrollRevealer } from "./ScrollRevealer";
|
|
14
|
+
export * from "./SideEffect";
|
|
15
|
+
export { default as SideEffect } from "./SideEffect";
|
|
16
|
+
export * from "./Timer";
|
|
17
|
+
export { default as Timer } from "./Timer";
|
|
10
18
|
export * from "./Video";
|
|
11
19
|
export { default as Video } from "./Video";
|
|
12
|
-
export { default as LoadingBoundary } from "./LoadingBoundary";
|
|
13
|
-
export * from "./LoadingBoundary";
|
|
14
|
-
export { default as ConditionGuard } from "./ConditionGuard";
|
|
15
|
-
export * from "./ConditionGuard";
|
|
16
|
-
export { default as SideEffect } from "./SideEffect";
|
|
17
|
-
export * from "./SideEffect";
|
|
@@ -4,12 +4,92 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
6
|
|
|
7
|
-
var host = require('@plasmicapp/host');
|
|
8
7
|
var registerComponent = _interopDefault(require('@plasmicapp/host/registerComponent'));
|
|
9
8
|
var React = require('react');
|
|
10
9
|
var React__default = _interopDefault(React);
|
|
10
|
+
var host = require('@plasmicapp/host');
|
|
11
|
+
var registerGlobalContext = _interopDefault(require('@plasmicapp/host/registerGlobalContext'));
|
|
11
12
|
var plasmicQuery = require('@plasmicapp/query');
|
|
12
13
|
|
|
14
|
+
function ConditionGuardOnNotSatisfied(_ref) {
|
|
15
|
+
var onNotSatisfied = _ref.onNotSatisfied;
|
|
16
|
+
var ref = React__default.useRef(false);
|
|
17
|
+
React__default.useEffect(function () {
|
|
18
|
+
if (!ref.current) {
|
|
19
|
+
ref.current = true;
|
|
20
|
+
onNotSatisfied == null || onNotSatisfied();
|
|
21
|
+
}
|
|
22
|
+
}, [onNotSatisfied]);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
function isCurrentLocationInSkipPaths(skipPaths) {
|
|
26
|
+
var _globalThis$__PLASMIC;
|
|
27
|
+
var pathname = window.location.pathname;
|
|
28
|
+
// Ignore search params
|
|
29
|
+
var currentPath = window.location.origin + pathname;
|
|
30
|
+
var plasmicPathname = globalThis == null || (_globalThis$__PLASMIC = globalThis["__PLASMIC_STUDIO_PATH"]) == null ? void 0 : _globalThis$__PLASMIC.call(globalThis);
|
|
31
|
+
return skipPaths == null ? void 0 : skipPaths.some(function (_ref2) {
|
|
32
|
+
var path = _ref2.path;
|
|
33
|
+
return path === pathname || path === currentPath || path === plasmicPathname;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function ConditionGuard(_ref3) {
|
|
37
|
+
var condition = _ref3.condition,
|
|
38
|
+
onNotSatisfied = _ref3.onNotSatisfied,
|
|
39
|
+
children = _ref3.children,
|
|
40
|
+
skipPaths = _ref3.skipPaths;
|
|
41
|
+
if (!condition && !isCurrentLocationInSkipPaths(skipPaths)) {
|
|
42
|
+
return React__default.createElement(ConditionGuardOnNotSatisfied, {
|
|
43
|
+
onNotSatisfied: onNotSatisfied
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return React__default.createElement(React__default.Fragment, null, children);
|
|
47
|
+
}
|
|
48
|
+
var conditionGuardMeta = {
|
|
49
|
+
name: "hostless-condition-guard",
|
|
50
|
+
displayName: "Condition Guard",
|
|
51
|
+
description: "Ensure some condition, or else run an interaction. Examples: ensure all users have a database row, or require new users to setup a profile.",
|
|
52
|
+
importName: "ConditionGuard",
|
|
53
|
+
importPath: "@plasmicpkgs/plasmic-basic-components",
|
|
54
|
+
props: {
|
|
55
|
+
children: "slot",
|
|
56
|
+
condition: {
|
|
57
|
+
type: "boolean",
|
|
58
|
+
displayName: "Condition",
|
|
59
|
+
description: "The condition to guard against",
|
|
60
|
+
helpText: "Condition to check. Render contents only if true. Run interaction if false.",
|
|
61
|
+
defaultValue: true
|
|
62
|
+
},
|
|
63
|
+
onNotSatisfied: {
|
|
64
|
+
type: "eventHandler",
|
|
65
|
+
displayName: "On condition false",
|
|
66
|
+
description: "The action to run when the condition is not satisfied",
|
|
67
|
+
argTypes: []
|
|
68
|
+
},
|
|
69
|
+
skipPaths: {
|
|
70
|
+
type: "array",
|
|
71
|
+
displayName: "Skip Paths",
|
|
72
|
+
description: "Paths that the action should not run",
|
|
73
|
+
itemType: {
|
|
74
|
+
type: "object",
|
|
75
|
+
fields: {
|
|
76
|
+
path: "href"
|
|
77
|
+
},
|
|
78
|
+
nameFunc: function nameFunc(item) {
|
|
79
|
+
return item == null ? void 0 : item.path;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
function registerConditionGuard(loader, customConditionGuardMeta) {
|
|
86
|
+
if (loader) {
|
|
87
|
+
loader.registerComponent(ConditionGuard, customConditionGuardMeta != null ? customConditionGuardMeta : conditionGuardMeta);
|
|
88
|
+
} else {
|
|
89
|
+
registerComponent(ConditionGuard, customConditionGuardMeta != null ? customConditionGuardMeta : conditionGuardMeta);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
13
93
|
function _regeneratorRuntime() {
|
|
14
94
|
_regeneratorRuntime = function () {
|
|
15
95
|
return e;
|
|
@@ -599,6 +679,7 @@ function registerDynamicImage(loader, customDynamicImageMeta) {
|
|
|
599
679
|
}
|
|
600
680
|
}
|
|
601
681
|
|
|
682
|
+
console.log(typeof registerGlobalContext);
|
|
602
683
|
function ensure(x) {
|
|
603
684
|
if (x === null || x === undefined) {
|
|
604
685
|
debugger;
|
|
@@ -607,6 +688,8 @@ function ensure(x) {
|
|
|
607
688
|
return x;
|
|
608
689
|
}
|
|
609
690
|
}
|
|
691
|
+
var isBrowser = typeof window !== "undefined";
|
|
692
|
+
var useIsomorphicLayoutEffect = isBrowser ? React__default.useLayoutEffect : React__default.useEffect;
|
|
610
693
|
|
|
611
694
|
/**
|
|
612
695
|
* A common use case for embedding HTML snippets is loading/running script tags, so most of the logic here is for
|
|
@@ -788,6 +871,90 @@ function registerIframe(loader, customIframeMeta) {
|
|
|
788
871
|
}
|
|
789
872
|
}
|
|
790
873
|
|
|
874
|
+
var reactMajorVersion = + /*#__PURE__*/React__default.version.split(".")[0];
|
|
875
|
+
if (reactMajorVersion < 18) {
|
|
876
|
+
console.warn("The LoadingBoundary component only works with React 18+");
|
|
877
|
+
}
|
|
878
|
+
var enableLoadingBoundaryKey = "plasmicInternalEnableLoadingBoundary";
|
|
879
|
+
var hasLoadingBoundaryKey = "plasmicInternalHasLoadingBoundary";
|
|
880
|
+
function useIsClient() {
|
|
881
|
+
var _useState = React.useState(false),
|
|
882
|
+
loaded = _useState[0],
|
|
883
|
+
setLoaded = _useState[1];
|
|
884
|
+
useIsomorphicLayoutEffect(function () {
|
|
885
|
+
setLoaded(true);
|
|
886
|
+
}, []);
|
|
887
|
+
return loaded;
|
|
888
|
+
}
|
|
889
|
+
var hasWarnedDisabledLoadingBoundary = false;
|
|
890
|
+
function warnDisabledLoadingBoundary() {
|
|
891
|
+
if (!hasWarnedDisabledLoadingBoundary) {
|
|
892
|
+
hasWarnedDisabledLoadingBoundary = true;
|
|
893
|
+
console.warn("LoadingBoundary feature is not enabled. To use the LoadingBoundary component make sure to upgrade your @plasmicapp/* dependencies to the latest version and to wrap you App inside <PlasmicRootProvider />");
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
function LoadingBoundary(_ref) {
|
|
897
|
+
var _useDataEnv;
|
|
898
|
+
var children = _ref.children,
|
|
899
|
+
forceLoading = _ref.forceLoading,
|
|
900
|
+
loadingState = _ref.loadingState;
|
|
901
|
+
var isClient = useIsClient();
|
|
902
|
+
var enableLoadingBoundary = !!((_useDataEnv = host.useDataEnv()) != null && _useDataEnv[enableLoadingBoundaryKey]);
|
|
903
|
+
if (!isClient && !(plasmicQuery.isPlasmicPrepass != null && plasmicQuery.isPlasmicPrepass())) {
|
|
904
|
+
return null;
|
|
905
|
+
}
|
|
906
|
+
if (forceLoading) {
|
|
907
|
+
return React__default.createElement(React__default.Fragment, null, loadingState != null ? loadingState : null);
|
|
908
|
+
}
|
|
909
|
+
if (reactMajorVersion < 18) {
|
|
910
|
+
return React__default.createElement(React__default.Fragment, null, children != null ? children : null);
|
|
911
|
+
}
|
|
912
|
+
if (!enableLoadingBoundary) {
|
|
913
|
+
warnDisabledLoadingBoundary();
|
|
914
|
+
return React__default.createElement(React__default.Fragment, null, children != null ? children : null);
|
|
915
|
+
}
|
|
916
|
+
return React__default.createElement(React.Suspense, {
|
|
917
|
+
fallback: React__default.createElement(React__default.Fragment, null, loadingState != null ? loadingState : null)
|
|
918
|
+
}, React__default.createElement(host.DataProvider, {
|
|
919
|
+
hidden: true,
|
|
920
|
+
name: hasLoadingBoundaryKey,
|
|
921
|
+
data: true
|
|
922
|
+
}, children != null ? children : null));
|
|
923
|
+
}
|
|
924
|
+
var loadingBoundaryMeta = {
|
|
925
|
+
name: "hostless-loading-boundary",
|
|
926
|
+
displayName: "Loading Boundary",
|
|
927
|
+
importName: "LoadingBoundary",
|
|
928
|
+
importPath: "@plasmicpkgs/plasmic-basic-components",
|
|
929
|
+
props: {
|
|
930
|
+
children: "slot",
|
|
931
|
+
loadingState: {
|
|
932
|
+
type: "slot",
|
|
933
|
+
displayName: "Loading State",
|
|
934
|
+
defaultValue: {
|
|
935
|
+
type: "text",
|
|
936
|
+
value: "Loading..."
|
|
937
|
+
}
|
|
938
|
+
},
|
|
939
|
+
forceLoading: {
|
|
940
|
+
type: "boolean",
|
|
941
|
+
editOnly: true,
|
|
942
|
+
displayName: "Force Loading",
|
|
943
|
+
description: "Force rendering the 'Loading' state"
|
|
944
|
+
}
|
|
945
|
+
},
|
|
946
|
+
providesData: true,
|
|
947
|
+
styleSections: false,
|
|
948
|
+
description: "Handle the loading state of queries and integrations"
|
|
949
|
+
};
|
|
950
|
+
function registerLoadingBoundary(loader, customLoadingBoundaryMeta) {
|
|
951
|
+
if (loader) {
|
|
952
|
+
loader.registerComponent(LoadingBoundary, customLoadingBoundaryMeta != null ? customLoadingBoundaryMeta : loadingBoundaryMeta);
|
|
953
|
+
} else {
|
|
954
|
+
registerComponent(LoadingBoundary, customLoadingBoundaryMeta != null ? customLoadingBoundaryMeta : loadingBoundaryMeta);
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
|
|
791
958
|
var thisModule$1 = "@plasmicpkgs/plasmic-basic-components";
|
|
792
959
|
var defaultItemName = "currentItem";
|
|
793
960
|
var defaultIndexName = "currentIndex";
|
|
@@ -943,6 +1110,117 @@ function registerScrollRevealer(loader, customScrollRevealerMeta) {
|
|
|
943
1110
|
}
|
|
944
1111
|
}
|
|
945
1112
|
|
|
1113
|
+
function SideEffect(_ref) {
|
|
1114
|
+
var deps = _ref.deps,
|
|
1115
|
+
onMount = _ref.onMount,
|
|
1116
|
+
onUnmount = _ref.onUnmount;
|
|
1117
|
+
React__default.useEffect(function () {
|
|
1118
|
+
onMount == null || onMount();
|
|
1119
|
+
return function () {
|
|
1120
|
+
onUnmount == null || onUnmount();
|
|
1121
|
+
};
|
|
1122
|
+
}, deps != null ? deps : []);
|
|
1123
|
+
return null;
|
|
1124
|
+
}
|
|
1125
|
+
var sideEffectMeta = {
|
|
1126
|
+
name: "hostless-side-effect",
|
|
1127
|
+
displayName: "Side Effect",
|
|
1128
|
+
description: "Run actions on load, unload, and when data changes.",
|
|
1129
|
+
importName: "SideEffect",
|
|
1130
|
+
importPath: "@plasmicpkgs/plasmic-basic-components",
|
|
1131
|
+
props: {
|
|
1132
|
+
onMount: {
|
|
1133
|
+
type: "eventHandler",
|
|
1134
|
+
displayName: "On load",
|
|
1135
|
+
description: "Actions to run when this Side Effect component is mounted.",
|
|
1136
|
+
argTypes: []
|
|
1137
|
+
},
|
|
1138
|
+
onUnmount: {
|
|
1139
|
+
type: "eventHandler",
|
|
1140
|
+
displayName: "On unload",
|
|
1141
|
+
description: "Actions to run when this Side Effect component is unmounted.",
|
|
1142
|
+
argTypes: []
|
|
1143
|
+
},
|
|
1144
|
+
deps: {
|
|
1145
|
+
type: "array",
|
|
1146
|
+
displayName: "When data changes",
|
|
1147
|
+
description: "List of values which should trigger a re-run of the actions if changed."
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
};
|
|
1151
|
+
function registerSideEffect(loader, customMeta) {
|
|
1152
|
+
if (loader) {
|
|
1153
|
+
loader.registerComponent(SideEffect, customMeta != null ? customMeta : sideEffectMeta);
|
|
1154
|
+
} else {
|
|
1155
|
+
registerComponent(SideEffect, customMeta != null ? customMeta : sideEffectMeta);
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
function useInterval(callback, delay) {
|
|
1160
|
+
var savedCallback = React.useRef(callback);
|
|
1161
|
+
// Remember the latest callback if it changes.
|
|
1162
|
+
useIsomorphicLayoutEffect(function () {
|
|
1163
|
+
savedCallback.current = callback;
|
|
1164
|
+
}, [callback]);
|
|
1165
|
+
// Set up the interval.
|
|
1166
|
+
React.useEffect(function () {
|
|
1167
|
+
// Don't schedule if no delay is specified.
|
|
1168
|
+
// Note: 0 is a valid value for delay.
|
|
1169
|
+
if (!delay && delay !== 0) {
|
|
1170
|
+
return;
|
|
1171
|
+
}
|
|
1172
|
+
var id = setInterval(function () {
|
|
1173
|
+
return savedCallback.current();
|
|
1174
|
+
}, delay);
|
|
1175
|
+
return function () {
|
|
1176
|
+
return clearInterval(id);
|
|
1177
|
+
};
|
|
1178
|
+
}, [delay]);
|
|
1179
|
+
}
|
|
1180
|
+
function Timer(_ref) {
|
|
1181
|
+
var _ref$intervalSeconds = _ref.intervalSeconds,
|
|
1182
|
+
intervalSeconds = _ref$intervalSeconds === void 0 ? 1 : _ref$intervalSeconds,
|
|
1183
|
+
_ref$isRunning = _ref.isRunning,
|
|
1184
|
+
isRunning = _ref$isRunning === void 0 ? false : _ref$isRunning,
|
|
1185
|
+
_ref$onTick = _ref.onTick,
|
|
1186
|
+
onTick = _ref$onTick === void 0 ? function () {} : _ref$onTick;
|
|
1187
|
+
useInterval(onTick,
|
|
1188
|
+
// Delay in milliseconds or null to stop it
|
|
1189
|
+
isRunning ? intervalSeconds * 1000 : null);
|
|
1190
|
+
return null;
|
|
1191
|
+
}
|
|
1192
|
+
var timerMeta = {
|
|
1193
|
+
name: "hostless-timer",
|
|
1194
|
+
displayName: "Timer",
|
|
1195
|
+
description: "Run something periodically",
|
|
1196
|
+
importName: "Timer",
|
|
1197
|
+
importPath: "@plasmicpkgs/plasmic-basic-components",
|
|
1198
|
+
props: {
|
|
1199
|
+
onTick: {
|
|
1200
|
+
type: "eventHandler",
|
|
1201
|
+
displayName: "Run periodically",
|
|
1202
|
+
description: "Actions to run periodically",
|
|
1203
|
+
argTypes: []
|
|
1204
|
+
},
|
|
1205
|
+
isRunning: {
|
|
1206
|
+
type: "boolean",
|
|
1207
|
+
displayName: "Is Running?"
|
|
1208
|
+
},
|
|
1209
|
+
intervalSeconds: {
|
|
1210
|
+
type: "number",
|
|
1211
|
+
displayName: "Seconds",
|
|
1212
|
+
description: "Interval in seconds"
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
};
|
|
1216
|
+
function registerTimer(loader, customMeta) {
|
|
1217
|
+
if (loader) {
|
|
1218
|
+
loader.registerComponent(Timer, customMeta != null ? customMeta : timerMeta);
|
|
1219
|
+
} else {
|
|
1220
|
+
registerComponent(Timer, customMeta != null ? customMeta : timerMeta);
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
|
|
946
1224
|
var Video = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
947
1225
|
return React__default.createElement("video", Object.assign({
|
|
948
1226
|
ref: ref
|
|
@@ -1013,217 +1291,6 @@ function registerVideo(loader, customVideoMeta) {
|
|
|
1013
1291
|
}
|
|
1014
1292
|
}
|
|
1015
1293
|
|
|
1016
|
-
var reactMajorVersion = + /*#__PURE__*/React__default.version.split(".")[0];
|
|
1017
|
-
if (reactMajorVersion < 18) {
|
|
1018
|
-
console.warn("The LoadingBoundary component only works with React 18+");
|
|
1019
|
-
}
|
|
1020
|
-
var isBrowser = typeof window !== "undefined";
|
|
1021
|
-
var enableLoadingBoundaryKey = "plasmicInternalEnableLoadingBoundary";
|
|
1022
|
-
var hasLoadingBoundaryKey = "plasmicInternalHasLoadingBoundary";
|
|
1023
|
-
var useIsomorphicLayoutEffect = isBrowser ? React__default.useLayoutEffect : React__default.useEffect;
|
|
1024
|
-
function useIsClient() {
|
|
1025
|
-
var _useState = React.useState(false),
|
|
1026
|
-
loaded = _useState[0],
|
|
1027
|
-
setLoaded = _useState[1];
|
|
1028
|
-
useIsomorphicLayoutEffect(function () {
|
|
1029
|
-
setLoaded(true);
|
|
1030
|
-
}, []);
|
|
1031
|
-
return loaded;
|
|
1032
|
-
}
|
|
1033
|
-
var hasWarnedDisabledLoadingBoundary = false;
|
|
1034
|
-
function warnDisabledLoadingBoundary() {
|
|
1035
|
-
if (!hasWarnedDisabledLoadingBoundary) {
|
|
1036
|
-
hasWarnedDisabledLoadingBoundary = true;
|
|
1037
|
-
console.warn("LoadingBoundary feature is not enabled. To use the LoadingBoundary component make sure to upgrade your @plasmicapp/* dependencies to the latest version and to wrap you App inside <PlasmicRootProvider />");
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
function LoadingBoundary(_ref) {
|
|
1041
|
-
var _useDataEnv;
|
|
1042
|
-
var children = _ref.children,
|
|
1043
|
-
forceLoading = _ref.forceLoading,
|
|
1044
|
-
loadingState = _ref.loadingState;
|
|
1045
|
-
var isClient = useIsClient();
|
|
1046
|
-
var enableLoadingBoundary = !!((_useDataEnv = host.useDataEnv()) != null && _useDataEnv[enableLoadingBoundaryKey]);
|
|
1047
|
-
if (!isClient && !(plasmicQuery.isPlasmicPrepass != null && plasmicQuery.isPlasmicPrepass())) {
|
|
1048
|
-
return null;
|
|
1049
|
-
}
|
|
1050
|
-
if (forceLoading) {
|
|
1051
|
-
return React__default.createElement(React__default.Fragment, null, loadingState != null ? loadingState : null);
|
|
1052
|
-
}
|
|
1053
|
-
if (reactMajorVersion < 18) {
|
|
1054
|
-
return React__default.createElement(React__default.Fragment, null, children != null ? children : null);
|
|
1055
|
-
}
|
|
1056
|
-
if (!enableLoadingBoundary) {
|
|
1057
|
-
warnDisabledLoadingBoundary();
|
|
1058
|
-
return React__default.createElement(React__default.Fragment, null, children != null ? children : null);
|
|
1059
|
-
}
|
|
1060
|
-
return React__default.createElement(React.Suspense, {
|
|
1061
|
-
fallback: React__default.createElement(React__default.Fragment, null, loadingState != null ? loadingState : null)
|
|
1062
|
-
}, React__default.createElement(host.DataProvider, {
|
|
1063
|
-
hidden: true,
|
|
1064
|
-
name: hasLoadingBoundaryKey,
|
|
1065
|
-
data: true
|
|
1066
|
-
}, children != null ? children : null));
|
|
1067
|
-
}
|
|
1068
|
-
var loadingBoundaryMeta = {
|
|
1069
|
-
name: "hostless-loading-boundary",
|
|
1070
|
-
displayName: "Loading Boundary",
|
|
1071
|
-
importName: "LoadingBoundary",
|
|
1072
|
-
importPath: "@plasmicpkgs/plasmic-basic-components",
|
|
1073
|
-
props: {
|
|
1074
|
-
children: "slot",
|
|
1075
|
-
loadingState: {
|
|
1076
|
-
type: "slot",
|
|
1077
|
-
displayName: "Loading State",
|
|
1078
|
-
defaultValue: {
|
|
1079
|
-
type: "text",
|
|
1080
|
-
value: "Loading..."
|
|
1081
|
-
}
|
|
1082
|
-
},
|
|
1083
|
-
forceLoading: {
|
|
1084
|
-
type: "boolean",
|
|
1085
|
-
editOnly: true,
|
|
1086
|
-
displayName: "Force Loading",
|
|
1087
|
-
description: "Force rendering the 'Loading' state"
|
|
1088
|
-
}
|
|
1089
|
-
},
|
|
1090
|
-
providesData: true,
|
|
1091
|
-
styleSections: false,
|
|
1092
|
-
description: "Handle the loading state of queries and integrations"
|
|
1093
|
-
};
|
|
1094
|
-
function registerLoadingBoundary(loader, customLoadingBoundaryMeta) {
|
|
1095
|
-
if (loader) {
|
|
1096
|
-
loader.registerComponent(LoadingBoundary, customLoadingBoundaryMeta != null ? customLoadingBoundaryMeta : loadingBoundaryMeta);
|
|
1097
|
-
} else {
|
|
1098
|
-
registerComponent(LoadingBoundary, customLoadingBoundaryMeta != null ? customLoadingBoundaryMeta : loadingBoundaryMeta);
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
function ConditionGuardOnNotSatisfied(_ref) {
|
|
1103
|
-
var onNotSatisfied = _ref.onNotSatisfied;
|
|
1104
|
-
var ref = React__default.useRef(false);
|
|
1105
|
-
React__default.useEffect(function () {
|
|
1106
|
-
if (!ref.current) {
|
|
1107
|
-
ref.current = true;
|
|
1108
|
-
onNotSatisfied == null || onNotSatisfied();
|
|
1109
|
-
}
|
|
1110
|
-
}, [onNotSatisfied]);
|
|
1111
|
-
return null;
|
|
1112
|
-
}
|
|
1113
|
-
function isCurrentLocationInSkipPaths(skipPaths) {
|
|
1114
|
-
var _globalThis$__PLASMIC;
|
|
1115
|
-
var pathname = window.location.pathname;
|
|
1116
|
-
// Ignore search params
|
|
1117
|
-
var currentPath = window.location.origin + pathname;
|
|
1118
|
-
var plasmicPathname = globalThis == null || (_globalThis$__PLASMIC = globalThis["__PLASMIC_STUDIO_PATH"]) == null ? void 0 : _globalThis$__PLASMIC.call(globalThis);
|
|
1119
|
-
return skipPaths == null ? void 0 : skipPaths.some(function (_ref2) {
|
|
1120
|
-
var path = _ref2.path;
|
|
1121
|
-
return path === pathname || path === currentPath || path === plasmicPathname;
|
|
1122
|
-
});
|
|
1123
|
-
}
|
|
1124
|
-
function ConditionGuard(_ref3) {
|
|
1125
|
-
var condition = _ref3.condition,
|
|
1126
|
-
onNotSatisfied = _ref3.onNotSatisfied,
|
|
1127
|
-
children = _ref3.children,
|
|
1128
|
-
skipPaths = _ref3.skipPaths;
|
|
1129
|
-
if (!condition && !isCurrentLocationInSkipPaths(skipPaths)) {
|
|
1130
|
-
return React__default.createElement(ConditionGuardOnNotSatisfied, {
|
|
1131
|
-
onNotSatisfied: onNotSatisfied
|
|
1132
|
-
});
|
|
1133
|
-
}
|
|
1134
|
-
return React__default.createElement(React__default.Fragment, null, children);
|
|
1135
|
-
}
|
|
1136
|
-
var conditionGuardMeta = {
|
|
1137
|
-
name: "hostless-condition-guard",
|
|
1138
|
-
displayName: "Condition Guard",
|
|
1139
|
-
description: "Ensure some condition, or else run an interaction. Examples: ensure all users have a database row, or require new users to setup a profile.",
|
|
1140
|
-
importName: "ConditionGuard",
|
|
1141
|
-
importPath: "@plasmicpkgs/plasmic-basic-components",
|
|
1142
|
-
props: {
|
|
1143
|
-
children: "slot",
|
|
1144
|
-
condition: {
|
|
1145
|
-
type: "boolean",
|
|
1146
|
-
displayName: "Condition",
|
|
1147
|
-
description: "The condition to guard against",
|
|
1148
|
-
helpText: "Condition to check. Render contents only if true. Run interaction if false.",
|
|
1149
|
-
defaultValue: true
|
|
1150
|
-
},
|
|
1151
|
-
onNotSatisfied: {
|
|
1152
|
-
type: "eventHandler",
|
|
1153
|
-
displayName: "On condition false",
|
|
1154
|
-
description: "The action to run when the condition is not satisfied",
|
|
1155
|
-
argTypes: []
|
|
1156
|
-
},
|
|
1157
|
-
skipPaths: {
|
|
1158
|
-
type: "array",
|
|
1159
|
-
displayName: "Skip Paths",
|
|
1160
|
-
description: "Paths that the action should not run",
|
|
1161
|
-
itemType: {
|
|
1162
|
-
type: "object",
|
|
1163
|
-
fields: {
|
|
1164
|
-
path: "href"
|
|
1165
|
-
},
|
|
1166
|
-
nameFunc: function nameFunc(item) {
|
|
1167
|
-
return item == null ? void 0 : item.path;
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
};
|
|
1173
|
-
function registerConditionGuard(loader, customConditionGuardMeta) {
|
|
1174
|
-
if (loader) {
|
|
1175
|
-
loader.registerComponent(ConditionGuard, customConditionGuardMeta != null ? customConditionGuardMeta : conditionGuardMeta);
|
|
1176
|
-
} else {
|
|
1177
|
-
registerComponent(ConditionGuard, customConditionGuardMeta != null ? customConditionGuardMeta : conditionGuardMeta);
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
|
|
1181
|
-
function SideEffect(_ref) {
|
|
1182
|
-
var deps = _ref.deps,
|
|
1183
|
-
onMount = _ref.onMount,
|
|
1184
|
-
onUnmount = _ref.onUnmount;
|
|
1185
|
-
React__default.useEffect(function () {
|
|
1186
|
-
onMount == null || onMount();
|
|
1187
|
-
return function () {
|
|
1188
|
-
onUnmount == null || onUnmount();
|
|
1189
|
-
};
|
|
1190
|
-
}, deps != null ? deps : []);
|
|
1191
|
-
return null;
|
|
1192
|
-
}
|
|
1193
|
-
var sideEffectMeta = {
|
|
1194
|
-
name: "hostless-side-effect",
|
|
1195
|
-
displayName: "Side Effect",
|
|
1196
|
-
description: "Run actions on load, unload, and when data changes.",
|
|
1197
|
-
importName: "SideEffect",
|
|
1198
|
-
importPath: "@plasmicpkgs/plasmic-basic-components",
|
|
1199
|
-
props: {
|
|
1200
|
-
onMount: {
|
|
1201
|
-
type: "eventHandler",
|
|
1202
|
-
displayName: "On load",
|
|
1203
|
-
description: "Actions to run when this Side Effect component is mounted.",
|
|
1204
|
-
argTypes: []
|
|
1205
|
-
},
|
|
1206
|
-
onUnmount: {
|
|
1207
|
-
type: "eventHandler",
|
|
1208
|
-
displayName: "On unload",
|
|
1209
|
-
description: "Actions to run when this Side Effect component is unmounted.",
|
|
1210
|
-
argTypes: []
|
|
1211
|
-
},
|
|
1212
|
-
deps: {
|
|
1213
|
-
type: "array",
|
|
1214
|
-
displayName: "When data changes",
|
|
1215
|
-
description: "List of values which should trigger a re-run of the actions if changed."
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
};
|
|
1219
|
-
function registerSideEffect(loader, customMeta) {
|
|
1220
|
-
if (loader) {
|
|
1221
|
-
loader.registerComponent(SideEffect, customMeta != null ? customMeta : sideEffectMeta);
|
|
1222
|
-
} else {
|
|
1223
|
-
registerComponent(SideEffect, customMeta != null ? customMeta : sideEffectMeta);
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
1294
|
exports.ConditionGuard = ConditionGuard;
|
|
1228
1295
|
exports.DataProvider = DataProvider;
|
|
1229
1296
|
exports.DynamicElement = DynamicElement;
|
|
@@ -1236,6 +1303,7 @@ exports.LoadingBoundary = LoadingBoundary;
|
|
|
1236
1303
|
exports.Repeater = Repeater;
|
|
1237
1304
|
exports.ScrollRevealer = ScrollRevealer;
|
|
1238
1305
|
exports.SideEffect = SideEffect;
|
|
1306
|
+
exports.Timer = Timer;
|
|
1239
1307
|
exports.Video = Video;
|
|
1240
1308
|
exports.applySelector = applySelector;
|
|
1241
1309
|
exports.conditionGuardMeta = conditionGuardMeta;
|
|
@@ -1247,7 +1315,6 @@ exports.dynamicRepeaterProps = dynamicRepeaterProps;
|
|
|
1247
1315
|
exports.dynamicTextMeta = dynamicTextMeta;
|
|
1248
1316
|
exports.embedMeta = embedMeta;
|
|
1249
1317
|
exports.iframeMeta = iframeMeta;
|
|
1250
|
-
exports.isBrowser = isBrowser;
|
|
1251
1318
|
exports.loadingBoundaryMeta = loadingBoundaryMeta;
|
|
1252
1319
|
exports.registerConditionGuard = registerConditionGuard;
|
|
1253
1320
|
exports.registerDataProvider = registerDataProvider;
|
|
@@ -1261,13 +1328,15 @@ exports.registerLoadingBoundary = registerLoadingBoundary;
|
|
|
1261
1328
|
exports.registerRepeater = registerRepeater;
|
|
1262
1329
|
exports.registerScrollRevealer = registerScrollRevealer;
|
|
1263
1330
|
exports.registerSideEffect = registerSideEffect;
|
|
1331
|
+
exports.registerTimer = registerTimer;
|
|
1264
1332
|
exports.registerVideo = registerVideo;
|
|
1265
1333
|
exports.repeaterMeta = repeaterMeta;
|
|
1266
1334
|
exports.scrollRevealerMeta = scrollRevealerMeta;
|
|
1267
1335
|
exports.sideEffectMeta = sideEffectMeta;
|
|
1336
|
+
exports.timerMeta = timerMeta;
|
|
1268
1337
|
exports.useDataEnv = useDataEnv;
|
|
1269
1338
|
exports.useDirectionalIntersection = useDirectionalIntersection;
|
|
1270
|
-
exports.
|
|
1339
|
+
exports.useInterval = useInterval;
|
|
1271
1340
|
exports.useSelector = useSelector;
|
|
1272
1341
|
exports.useSelectors = useSelectors;
|
|
1273
1342
|
exports.videoMeta = videoMeta;
|