@makeswift/runtime 0.28.8-canary.2 → 0.28.8-canary.3
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/cjs/api/graphql-api-client.js +1 -1
- package/dist/cjs/api/rest-api-client.js +1 -1
- package/dist/cjs/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/client/index.js +1 -1
- package/dist/cjs/runtimes/react/components/resolve-props.js +8 -1
- package/dist/cjs/runtimes/react/components/resolve-props.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-control-instances.js +39 -0
- package/dist/cjs/runtimes/react/hooks/use-control-instances.js.map +1 -0
- package/dist/cjs/runtimes/react/hooks/use-resolved-props.js +11 -28
- package/dist/cjs/runtimes/react/hooks/use-resolved-props.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-stylesheet-factory.js +3 -3
- package/dist/cjs/runtimes/react/hooks/use-stylesheet-factory.js.map +1 -1
- package/dist/cjs/runtimes/react/stylesheet-factory.js +17 -0
- package/dist/cjs/runtimes/react/stylesheet-factory.js.map +1 -0
- package/dist/esm/api/graphql-api-client.js +1 -1
- package/dist/esm/api/rest-api-client.js +1 -1
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/runtimes/react/components/resolve-props.js +8 -1
- package/dist/esm/runtimes/react/components/resolve-props.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-control-instances.js +15 -0
- package/dist/esm/runtimes/react/hooks/use-control-instances.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-resolved-props.js +10 -17
- package/dist/esm/runtimes/react/hooks/use-resolved-props.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-stylesheet-factory.js +3 -3
- package/dist/esm/runtimes/react/hooks/use-stylesheet-factory.js.map +1 -1
- package/dist/esm/runtimes/react/stylesheet-factory.js +1 -0
- package/dist/esm/runtimes/react/stylesheet-factory.js.map +1 -0
- package/dist/types/runtimes/react/components/resolve-props.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-control-instances.d.ts +3 -0
- package/dist/types/runtimes/react/hooks/use-control-instances.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/use-resolved-props.d.ts +7 -1
- package/dist/types/runtimes/react/hooks/use-resolved-props.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-stylesheet-factory.d.ts +1 -5
- package/dist/types/runtimes/react/hooks/use-stylesheet-factory.d.ts.map +1 -1
- package/dist/types/runtimes/react/stylesheet-factory.d.ts +6 -0
- package/dist/types/runtimes/react/stylesheet-factory.d.ts.map +1 -0
- package/package.json +3 -3
- package/dist/cjs/runtimes/react/controls/group.js +0 -45
- package/dist/cjs/runtimes/react/controls/group.js.map +0 -1
- package/dist/esm/runtimes/react/controls/group.js +0 -23
- package/dist/esm/runtimes/react/controls/group.js.map +0 -1
- package/dist/types/runtimes/react/controls/group.d.ts +0 -11
- package/dist/types/runtimes/react/controls/group.d.ts.map +0 -1
|
@@ -27,7 +27,7 @@ class MakeswiftGraphQLApiClient {
|
|
|
27
27
|
graphqlClient;
|
|
28
28
|
constructor({ endpoint }) {
|
|
29
29
|
this.graphqlClient = new import_client.GraphQLClient(endpoint, {
|
|
30
|
-
"makeswift-runtime-version": "0.28.8-canary.
|
|
30
|
+
"makeswift-runtime-version": "0.28.8-canary.3"
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
async createTableRecord(tableId, columns) {
|
|
@@ -147,7 +147,7 @@ class MakeswiftRestAPIClient {
|
|
|
147
147
|
const requestHeaders = new Headers({
|
|
148
148
|
"x-api-key": this.apiKey,
|
|
149
149
|
"makeswift-site-api-key": this.apiKey,
|
|
150
|
-
"makeswift-runtime-version": "0.28.8-canary.
|
|
150
|
+
"makeswift-runtime-version": "0.28.8-canary.3"
|
|
151
151
|
});
|
|
152
152
|
if (siteVersion?.token) {
|
|
153
153
|
requestUrl.searchParams.set("version", siteVersion.version);
|
|
@@ -28,7 +28,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
|
|
|
28
28
|
return import_request_response.ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
|
|
29
29
|
}
|
|
30
30
|
return import_request_response.ApiResponse.json({
|
|
31
|
-
version: "0.28.8-canary.
|
|
31
|
+
version: "0.28.8-canary.3",
|
|
32
32
|
interactionMode: true,
|
|
33
33
|
clientSideNavigation: false,
|
|
34
34
|
elementFromPoint: false,
|
package/dist/cjs/client/index.js
CHANGED
|
@@ -689,7 +689,7 @@ Received "${apiKey}" instead.`
|
|
|
689
689
|
headers: {
|
|
690
690
|
"x-api-key": this.apiKey,
|
|
691
691
|
"makeswift-site-api-key": this.apiKey,
|
|
692
|
-
"makeswift-runtime-version": "0.28.8-canary.
|
|
692
|
+
"makeswift-runtime-version": "0.28.8-canary.3",
|
|
693
693
|
"content-type": "application/json"
|
|
694
694
|
},
|
|
695
695
|
body: JSON.stringify({ token }),
|
|
@@ -23,13 +23,20 @@ __export(resolve_props_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(resolve_props_exports);
|
|
24
24
|
var import_use_control_defs = require("../hooks/use-control-defs");
|
|
25
25
|
var import_use_resolved_props = require("../hooks/use-resolved-props");
|
|
26
|
+
var import_use_stylesheet_factory = require("../hooks/use-stylesheet-factory");
|
|
26
27
|
var import_legacy_controls = require("../legacy-controls");
|
|
27
28
|
function ResolveProps({
|
|
28
29
|
element,
|
|
29
30
|
children: renderComponent
|
|
30
31
|
}) {
|
|
31
32
|
const [legacyDescriptors, definitions] = (0, import_use_control_defs.useControlDefs)({ elementType: element.type });
|
|
32
|
-
const
|
|
33
|
+
const stylesheetFactory = (0, import_use_stylesheet_factory.useStylesheetFactory)();
|
|
34
|
+
const resolvedProps = (0, import_use_resolved_props.useResolvedProps)({
|
|
35
|
+
propDefs: definitions,
|
|
36
|
+
propData: element.props,
|
|
37
|
+
elementKey: element.key,
|
|
38
|
+
stylesheetFactory
|
|
39
|
+
});
|
|
33
40
|
const renderFn = Object.entries(legacyDescriptors).reduceRight(
|
|
34
41
|
(renderFn2, [propName, descriptor]) => (props) => (0, import_legacy_controls.resolveLegacyDescriptorProp)(descriptor, propName, element.props[propName], props, renderFn2),
|
|
35
42
|
renderComponent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/components/resolve-props.tsx"],"sourcesContent":["import { type ReactNode } from 'react'\n\nimport { type ElementData } from '../../../state/read-only-state'\n\nimport { useControlDefs } from '../hooks/use-control-defs'\nimport { useResolvedProps } from '../hooks/use-resolved-props'\n\nimport { resolveLegacyDescriptorProp } from '../legacy-controls'\n\nexport function ResolveProps({\n element,\n children: renderComponent,\n}: {\n element: ElementData\n children: (props: Record<string, unknown>) => ReactNode\n}): ReactNode {\n const [legacyDescriptors, definitions] = useControlDefs({ elementType: element.type })\n\n const resolvedProps = useResolvedProps(definitions
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/components/resolve-props.tsx"],"sourcesContent":["import { type ReactNode } from 'react'\n\nimport { type ElementData } from '../../../state/read-only-state'\n\nimport { useControlDefs } from '../hooks/use-control-defs'\nimport { useResolvedProps } from '../hooks/use-resolved-props'\nimport { useStylesheetFactory } from '../hooks/use-stylesheet-factory'\n\nimport { resolveLegacyDescriptorProp } from '../legacy-controls'\n\nexport function ResolveProps({\n element,\n children: renderComponent,\n}: {\n element: ElementData\n children: (props: Record<string, unknown>) => ReactNode\n}): ReactNode {\n const [legacyDescriptors, definitions] = useControlDefs({ elementType: element.type })\n\n const stylesheetFactory = useStylesheetFactory()\n const resolvedProps = useResolvedProps({\n propDefs: definitions,\n propData: element.props,\n elementKey: element.key,\n stylesheetFactory,\n })\n\n const renderFn = Object.entries(legacyDescriptors).reduceRight(\n (renderFn, [propName, descriptor]) =>\n props =>\n resolveLegacyDescriptorProp(descriptor, propName, element.props[propName], props, renderFn),\n renderComponent,\n )\n\n return renderFn(resolvedProps)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,8BAA+B;AAC/B,gCAAiC;AACjC,oCAAqC;AAErC,6BAA4C;AAErC,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA,UAAU;AACZ,GAGc;AACZ,QAAM,CAAC,mBAAmB,WAAW,QAAI,wCAAe,EAAE,aAAa,QAAQ,KAAK,CAAC;AAErF,QAAM,wBAAoB,oDAAqB;AAC/C,QAAM,oBAAgB,4CAAiB;AAAA,IACrC,UAAU;AAAA,IACV,UAAU,QAAQ;AAAA,IAClB,YAAY,QAAQ;AAAA,IACpB;AAAA,EACF,CAAC;AAED,QAAM,WAAW,OAAO,QAAQ,iBAAiB,EAAE;AAAA,IACjD,CAACA,WAAU,CAAC,UAAU,UAAU,MAC9B,eACE,oDAA4B,YAAY,UAAU,QAAQ,MAAM,QAAQ,GAAG,OAAOA,SAAQ;AAAA,IAC9F;AAAA,EACF;AAEA,SAAO,SAAS,aAAa;AAC/B;","names":["renderFn"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var use_control_instances_exports = {};
|
|
20
|
+
__export(use_control_instances_exports, {
|
|
21
|
+
useControlInstances: () => useControlInstances
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(use_control_instances_exports);
|
|
24
|
+
var import_read_only_state = require("../../../state/read-only-state");
|
|
25
|
+
var import_use_document_context = require("./use-document-context");
|
|
26
|
+
var import_use_selector = require("./use-selector");
|
|
27
|
+
function useControlInstances(elementKey) {
|
|
28
|
+
const documentKey = (0, import_use_document_context.useDocumentKey)();
|
|
29
|
+
return (0, import_use_selector.useSelector)((state) => {
|
|
30
|
+
if (documentKey == null)
|
|
31
|
+
return null;
|
|
32
|
+
return (0, import_read_only_state.getPropControllers)(state, { documentKey, elementKey });
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
useControlInstances
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=use-control-instances.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-control-instances.ts"],"sourcesContent":["import { ControlInstance } from '@makeswift/controls'\n\nimport { getPropControllers } from '../../../state/read-only-state'\nimport { useDocumentKey } from './use-document-context'\nimport { useSelector } from './use-selector'\n\nexport function useControlInstances(elementKey: string): Record<string, ControlInstance> | null {\n const documentKey = useDocumentKey()\n\n return useSelector(state => {\n if (documentKey == null) return null\n\n return getPropControllers(state, { documentKey, elementKey })\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,6BAAmC;AACnC,kCAA+B;AAC/B,0BAA4B;AAErB,SAAS,oBAAoB,YAA4D;AAC9F,QAAM,kBAAc,4CAAe;AAEnC,aAAO,iCAAY,WAAS;AAC1B,QAAI,eAAe;AAAM,aAAO;AAEhC,eAAO,2CAAmB,OAAO,EAAE,aAAa,WAAW,CAAC;AAAA,EAC9D,CAAC;AACH;","names":[]}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var use_resolved_props_exports = {};
|
|
30
20
|
__export(use_resolved_props_exports, {
|
|
@@ -33,29 +23,22 @@ __export(use_resolved_props_exports, {
|
|
|
33
23
|
module.exports = __toCommonJS(use_resolved_props_exports);
|
|
34
24
|
var import_react = require("react");
|
|
35
25
|
var import_controls = require("@makeswift/controls");
|
|
36
|
-
var ReactPage = __toESM(require("../../../state/read-only-state"));
|
|
37
26
|
var import_use_resource_resolver = require("./use-resource-resolver");
|
|
38
|
-
var import_use_document_context = require("./use-document-context");
|
|
39
|
-
var import_use_selector = require("./use-selector");
|
|
40
|
-
var import_use_stylesheet_factory = require("./use-stylesheet-factory");
|
|
41
|
-
var import_use_resolvable_record = require("./use-resolvable-record");
|
|
42
27
|
var import_prop_error_handling_proxy = require("../utils/prop-error-handling-proxy");
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
function useResolvedProps(propDefs, elementData, elementKey) {
|
|
52
|
-
const stylesheetFactory = (0, import_use_stylesheet_factory.useStylesheetFactory)();
|
|
28
|
+
var import_use_control_instances = require("./use-control-instances");
|
|
29
|
+
var import_use_resolvable_record = require("./use-resolvable-record");
|
|
30
|
+
function useResolvedProps({
|
|
31
|
+
propDefs,
|
|
32
|
+
propData,
|
|
33
|
+
elementKey,
|
|
34
|
+
stylesheetFactory
|
|
35
|
+
}) {
|
|
53
36
|
const resourceResolver = (0, import_use_resource_resolver.useResourceResolver)();
|
|
54
|
-
const controls = useControlInstances(elementKey);
|
|
37
|
+
const controls = (0, import_use_control_instances.useControlInstances)(elementKey);
|
|
55
38
|
const cache = (0, import_react.useRef)({}).current;
|
|
56
39
|
const resolveProp = (0, import_react.useCallback)(
|
|
57
40
|
(def, propName) => {
|
|
58
|
-
const data =
|
|
41
|
+
const data = propData[propName];
|
|
59
42
|
const control = controls?.[propName];
|
|
60
43
|
if (cache[propName] != null && data === cache[propName].data && control === cache[propName].control) {
|
|
61
44
|
return cache[propName].resolvedValue;
|
|
@@ -69,7 +52,7 @@ function useResolvedProps(propDefs, elementData, elementKey) {
|
|
|
69
52
|
cache[propName] = { data, control, resolvedValue };
|
|
70
53
|
return resolvedValue;
|
|
71
54
|
},
|
|
72
|
-
[controls,
|
|
55
|
+
[controls, propData, resourceResolver, stylesheetFactory]
|
|
73
56
|
);
|
|
74
57
|
const resolvables = (0, import_react.useMemo)(
|
|
75
58
|
() => (0, import_controls.mapValues)(propDefs, (def, propName) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-resolved-props.ts"],"sourcesContent":["import { useMemo, useEffect, useRef, useSyncExternalStore, useCallback } from 'react'\nimport {\n ControlDefinition,\n ControlInstance,\n mapValues,\n type Data,\n type Resolvable,\n} from '@makeswift/controls'\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-resolved-props.ts"],"sourcesContent":["import { useMemo, useEffect, useRef, useSyncExternalStore, useCallback } from 'react'\nimport {\n ControlDefinition,\n ControlInstance,\n mapValues,\n type Data,\n type Resolvable,\n} from '@makeswift/controls'\n\nimport { useResourceResolver } from './use-resource-resolver'\n\nimport { type StylesheetFactory } from '../stylesheet-factory'\nimport { propErrorHandlingProxy } from '../utils/prop-error-handling-proxy'\n\nimport { useControlInstances } from './use-control-instances'\nimport { useResolvableRecord } from './use-resolvable-record'\n\ntype CacheItem = {\n data: Data\n control: ControlInstance | undefined\n resolvedValue: Resolvable<unknown>\n}\n\nexport function useResolvedProps({\n propDefs,\n propData,\n elementKey,\n stylesheetFactory,\n}: {\n propDefs: Record<string, ControlDefinition>\n propData: Record<string, Data>\n elementKey: string\n stylesheetFactory: StylesheetFactory\n}): Record<string, unknown> {\n const resourceResolver = useResourceResolver()\n const controls = useControlInstances(elementKey)\n\n const cache = useRef<Record<string, CacheItem>>({}).current\n const resolveProp = useCallback(\n (def: ControlDefinition, propName: string) => {\n const data = propData[propName]\n const control = controls?.[propName]\n\n if (\n cache[propName] != null &&\n data === cache[propName].data &&\n control === cache[propName].control\n ) {\n return cache[propName].resolvedValue\n }\n\n const resolvedValue = def.resolveValue(\n data,\n resourceResolver,\n stylesheetFactory.get(propName),\n control,\n )\n\n cache[propName] = { data, control, resolvedValue }\n return resolvedValue\n },\n [controls, propData, resourceResolver, stylesheetFactory],\n )\n\n const resolvables = useMemo<Record<string, Resolvable<unknown>>>(\n () =>\n mapValues(propDefs, (def, propName) => {\n const defaultValue = (def.config as any)?.defaultValue\n return propErrorHandlingProxy(resolveProp(def, propName), defaultValue, error => {\n console.warn(\n `Error reading value for prop \"${propName}\", falling back to \\`${defaultValue}\\`.`,\n { control: def, error },\n )\n })\n }),\n [propDefs, resolveProp],\n )\n\n const props = useResolvableRecord(resolvables)\n\n // no need to call `triggerResolve` on the server, all the resources should already be in\n // the host API client's cache (populated from the snapshot's cache)\n useEffect(() => {\n props.triggerResolve()\n }, [props])\n\n // the order is important here, the styles are defined in the process of the props resolution,\n // calling `useDefinedStyles` before the props are resolved would effectively be a noop\n const resolvedProps = useSyncExternalStore(props.subscribe, props.readStable, props.readStable)\n\n stylesheetFactory.useDefinedStyles()\n\n return resolvedProps\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8E;AAC9E,sBAMO;AAEP,mCAAoC;AAGpC,uCAAuC;AAEvC,mCAAoC;AACpC,mCAAoC;AAQ7B,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAK4B;AAC1B,QAAM,uBAAmB,kDAAoB;AAC7C,QAAM,eAAW,kDAAoB,UAAU;AAE/C,QAAM,YAAQ,qBAAkC,CAAC,CAAC,EAAE;AACpD,QAAM,kBAAc;AAAA,IAClB,CAAC,KAAwB,aAAqB;AAC5C,YAAM,OAAO,SAAS,QAAQ;AAC9B,YAAM,UAAU,WAAW,QAAQ;AAEnC,UACE,MAAM,QAAQ,KAAK,QACnB,SAAS,MAAM,QAAQ,EAAE,QACzB,YAAY,MAAM,QAAQ,EAAE,SAC5B;AACA,eAAO,MAAM,QAAQ,EAAE;AAAA,MACzB;AAEA,YAAM,gBAAgB,IAAI;AAAA,QACxB;AAAA,QACA;AAAA,QACA,kBAAkB,IAAI,QAAQ;AAAA,QAC9B;AAAA,MACF;AAEA,YAAM,QAAQ,IAAI,EAAE,MAAM,SAAS,cAAc;AACjD,aAAO;AAAA,IACT;AAAA,IACA,CAAC,UAAU,UAAU,kBAAkB,iBAAiB;AAAA,EAC1D;AAEA,QAAM,kBAAc;AAAA,IAClB,UACE,2BAAU,UAAU,CAAC,KAAK,aAAa;AACrC,YAAM,eAAgB,IAAI,QAAgB;AAC1C,iBAAO,yDAAuB,YAAY,KAAK,QAAQ,GAAG,cAAc,WAAS;AAC/E,gBAAQ;AAAA,UACN,iCAAiC,QAAQ,wBAAwB,YAAY;AAAA,UAC7E,EAAE,SAAS,KAAK,MAAM;AAAA,QACxB;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,IACH,CAAC,UAAU,WAAW;AAAA,EACxB;AAEA,QAAM,YAAQ,kDAAoB,WAAW;AAI7C,8BAAU,MAAM;AACd,UAAM,eAAe;AAAA,EACvB,GAAG,CAAC,KAAK,CAAC;AAIV,QAAM,oBAAgB,mCAAqB,MAAM,WAAW,MAAM,YAAY,MAAM,UAAU;AAE9F,oBAAkB,iBAAiB;AAEnC,SAAO;AACT;","names":[]}
|
|
@@ -24,12 +24,12 @@ module.exports = __toCommonJS(use_stylesheet_factory_exports);
|
|
|
24
24
|
var import_react = require("react");
|
|
25
25
|
var import_serialize = require("@emotion/serialize");
|
|
26
26
|
var import_controls = require("@makeswift/controls");
|
|
27
|
-
var import_root_style_registry = require("../root-style-registry");
|
|
28
27
|
var import_resolved_style_to_css = require("../lib/resolved-style-to-css");
|
|
28
|
+
var import_poll_box_model = require("../poll-box-model");
|
|
29
|
+
var import_root_style_registry = require("../root-style-registry");
|
|
30
|
+
var import_use_style = require("../use-style");
|
|
29
31
|
var import_use_breakpoints = require("./use-breakpoints");
|
|
30
32
|
var import_use_css_id = require("./use-css-id");
|
|
31
|
-
var import_use_style = require("../use-style");
|
|
32
|
-
var import_poll_box_model = require("../poll-box-model");
|
|
33
33
|
function useStylesheetFactory() {
|
|
34
34
|
const breakpoints = (0, import_use_breakpoints.useBreakpoints)();
|
|
35
35
|
const cache = (0, import_root_style_registry.useCache)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-stylesheet-factory.ts"],"sourcesContent":["import { useMemo, useEffect, useRef } from 'react'\nimport { serializeStyles } from '@emotion/serialize'\nimport { type EmotionCache } from '@emotion/cache'\nimport { type SerializedStyles } from '@emotion/utils'\n\nimport {\n type BoxDisplayModel,\n type Breakpoints,\n type Stylesheet,\n type ResolvedStyle,\n isNotNil,\n} from '@makeswift/controls'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-stylesheet-factory.ts"],"sourcesContent":["import { useMemo, useEffect, useRef } from 'react'\nimport { serializeStyles } from '@emotion/serialize'\nimport { type EmotionCache } from '@emotion/cache'\nimport { type SerializedStyles } from '@emotion/utils'\n\nimport {\n type BoxDisplayModel,\n type Breakpoints,\n type Stylesheet,\n type ResolvedStyle,\n isNotNil,\n} from '@makeswift/controls'\n\nimport { resolvedStyleToCss } from '../lib/resolved-style-to-css'\nimport { pollBoxModel } from '../poll-box-model'\nimport { useCache } from '../root-style-registry'\nimport { type StylesheetFactory } from '../stylesheet-factory'\nimport { useStyles, serializedStyleClassName } from '../use-style'\n\nimport { useBreakpoints } from './use-breakpoints'\nimport { useCssId } from './use-css-id'\n\nexport function useStylesheetFactory(): StylesheetFactory {\n const breakpoints = useBreakpoints()\n const cache = useCache()\n const componentUid = useCssId()\n\n const computedStyles = useRef<Record<string, SerializedStyles>>({}).current\n const boxModelCallbacks = useRef<Record<string, (boxModel: BoxDisplayModel | null) => void>>(\n {},\n ).current\n\n return useMemo(() => {\n const getStylesheet = (styleSheetId: string): Stylesheet => ({\n breakpoints(): Breakpoints {\n return breakpoints\n },\n\n defineStyle(\n style: ResolvedStyle,\n onBoxModelChange?: (boxModel: BoxDisplayModel | null) => void,\n ): string {\n const serialized = serializeStyle(breakpoints, style, cache)\n const uid = `u-${componentUid}-${styleSheetId}`\n computedStyles[uid] = serialized\n\n const className = serializedStyleClassName(cache, serialized)\n if (!onBoxModelChange) return className\n\n boxModelCallbacks[uid] = onBoxModelChange\n return `${className} ${uid}`\n },\n\n child(id: string): Stylesheet {\n return getStylesheet(`${styleSheetId}-${id}`)\n },\n })\n\n return {\n get(propName: string): Stylesheet {\n return getStylesheet(propName)\n },\n\n useDefinedStyles() {\n useStyles(cache, Object.values(computedStyles))\n\n useEffect(() => {\n const unsubscribes = Object.entries(boxModelCallbacks)\n .map(([uid, callback]) =>\n callback != null\n ? pollBoxModel({\n element: document.querySelector(`.${uid}`),\n onBoxModelChange: callback,\n })\n : undefined,\n )\n .filter(isNotNil)\n\n return () => unsubscribes.forEach(fn => fn())\n }, [Object.keys(boxModelCallbacks).join(' ')])\n },\n }\n }, [breakpoints, cache, componentUid])\n}\n\nfunction serializeStyle(\n breakpoints: Breakpoints,\n style: ResolvedStyle,\n cache: EmotionCache,\n): SerializedStyles {\n const css = resolvedStyleToCss(breakpoints, style)\n return serializeStyles([css], cache.registered)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2C;AAC3C,uBAAgC;AAIhC,sBAMO;AAEP,mCAAmC;AACnC,4BAA6B;AAC7B,iCAAyB;AAEzB,uBAAoD;AAEpD,6BAA+B;AAC/B,wBAAyB;AAElB,SAAS,uBAA0C;AACxD,QAAM,kBAAc,uCAAe;AACnC,QAAM,YAAQ,qCAAS;AACvB,QAAM,mBAAe,4BAAS;AAE9B,QAAM,qBAAiB,qBAAyC,CAAC,CAAC,EAAE;AACpE,QAAM,wBAAoB;AAAA,IACxB,CAAC;AAAA,EACH,EAAE;AAEF,aAAO,sBAAQ,MAAM;AACnB,UAAM,gBAAgB,CAAC,kBAAsC;AAAA,MAC3D,cAA2B;AACzB,eAAO;AAAA,MACT;AAAA,MAEA,YACE,OACA,kBACQ;AACR,cAAM,aAAa,eAAe,aAAa,OAAO,KAAK;AAC3D,cAAM,MAAM,KAAK,YAAY,IAAI,YAAY;AAC7C,uBAAe,GAAG,IAAI;AAEtB,cAAM,gBAAY,2CAAyB,OAAO,UAAU;AAC5D,YAAI,CAAC;AAAkB,iBAAO;AAE9B,0BAAkB,GAAG,IAAI;AACzB,eAAO,GAAG,SAAS,IAAI,GAAG;AAAA,MAC5B;AAAA,MAEA,MAAM,IAAwB;AAC5B,eAAO,cAAc,GAAG,YAAY,IAAI,EAAE,EAAE;AAAA,MAC9C;AAAA,IACF;AAEA,WAAO;AAAA,MACL,IAAI,UAA8B;AAChC,eAAO,cAAc,QAAQ;AAAA,MAC/B;AAAA,MAEA,mBAAmB;AACjB,wCAAU,OAAO,OAAO,OAAO,cAAc,CAAC;AAE9C,oCAAU,MAAM;AACd,gBAAM,eAAe,OAAO,QAAQ,iBAAiB,EAClD;AAAA,YAAI,CAAC,CAAC,KAAK,QAAQ,MAClB,YAAY,WACR,oCAAa;AAAA,cACX,SAAS,SAAS,cAAc,IAAI,GAAG,EAAE;AAAA,cACzC,kBAAkB;AAAA,YACpB,CAAC,IACD;AAAA,UACN,EACC,OAAO,wBAAQ;AAElB,iBAAO,MAAM,aAAa,QAAQ,QAAM,GAAG,CAAC;AAAA,QAC9C,GAAG,CAAC,OAAO,KAAK,iBAAiB,EAAE,KAAK,GAAG,CAAC,CAAC;AAAA,MAC/C;AAAA,IACF;AAAA,EACF,GAAG,CAAC,aAAa,OAAO,YAAY,CAAC;AACvC;AAEA,SAAS,eACP,aACA,OACA,OACkB;AAClB,QAAM,UAAM,iDAAmB,aAAa,KAAK;AACjD,aAAO,kCAAgB,CAAC,GAAG,GAAG,MAAM,UAAU;AAChD;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var stylesheet_factory_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(stylesheet_factory_exports);
|
|
17
|
+
//# sourceMappingURL=stylesheet-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/runtimes/react/stylesheet-factory.ts"],"sourcesContent":["import { type Stylesheet } from '@makeswift/controls'\n\nexport type StylesheetFactory = {\n get(propName: string): Stylesheet\n useDefinedStyles(): void\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -9,7 +9,7 @@ class MakeswiftGraphQLApiClient {
|
|
|
9
9
|
graphqlClient;
|
|
10
10
|
constructor({ endpoint }) {
|
|
11
11
|
this.graphqlClient = new GraphQLClient(endpoint, {
|
|
12
|
-
"makeswift-runtime-version": "0.28.8-canary.
|
|
12
|
+
"makeswift-runtime-version": "0.28.8-canary.3"
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
async createTableRecord(tableId, columns) {
|
|
@@ -113,7 +113,7 @@ class MakeswiftRestAPIClient {
|
|
|
113
113
|
const requestHeaders = new Headers({
|
|
114
114
|
"x-api-key": this.apiKey,
|
|
115
115
|
"makeswift-site-api-key": this.apiKey,
|
|
116
|
-
"makeswift-runtime-version": "0.28.8-canary.
|
|
116
|
+
"makeswift-runtime-version": "0.28.8-canary.3"
|
|
117
117
|
});
|
|
118
118
|
if (siteVersion?.token) {
|
|
119
119
|
requestUrl.searchParams.set("version", siteVersion.version);
|
|
@@ -8,7 +8,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
|
|
|
8
8
|
return ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
|
|
9
9
|
}
|
|
10
10
|
return ApiResponse.json({
|
|
11
|
-
version: "0.28.8-canary.
|
|
11
|
+
version: "0.28.8-canary.3",
|
|
12
12
|
interactionMode: true,
|
|
13
13
|
clientSideNavigation: false,
|
|
14
14
|
elementFromPoint: false,
|
package/dist/esm/client/index.js
CHANGED
|
@@ -669,7 +669,7 @@ Received "${apiKey}" instead.`
|
|
|
669
669
|
headers: {
|
|
670
670
|
"x-api-key": this.apiKey,
|
|
671
671
|
"makeswift-site-api-key": this.apiKey,
|
|
672
|
-
"makeswift-runtime-version": "0.28.8-canary.
|
|
672
|
+
"makeswift-runtime-version": "0.28.8-canary.3",
|
|
673
673
|
"content-type": "application/json"
|
|
674
674
|
},
|
|
675
675
|
body: JSON.stringify({ token }),
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { useControlDefs } from "../hooks/use-control-defs";
|
|
2
2
|
import { useResolvedProps } from "../hooks/use-resolved-props";
|
|
3
|
+
import { useStylesheetFactory } from "../hooks/use-stylesheet-factory";
|
|
3
4
|
import { resolveLegacyDescriptorProp } from "../legacy-controls";
|
|
4
5
|
function ResolveProps({
|
|
5
6
|
element,
|
|
6
7
|
children: renderComponent
|
|
7
8
|
}) {
|
|
8
9
|
const [legacyDescriptors, definitions] = useControlDefs({ elementType: element.type });
|
|
9
|
-
const
|
|
10
|
+
const stylesheetFactory = useStylesheetFactory();
|
|
11
|
+
const resolvedProps = useResolvedProps({
|
|
12
|
+
propDefs: definitions,
|
|
13
|
+
propData: element.props,
|
|
14
|
+
elementKey: element.key,
|
|
15
|
+
stylesheetFactory
|
|
16
|
+
});
|
|
10
17
|
const renderFn = Object.entries(legacyDescriptors).reduceRight(
|
|
11
18
|
(renderFn2, [propName, descriptor]) => (props) => resolveLegacyDescriptorProp(descriptor, propName, element.props[propName], props, renderFn2),
|
|
12
19
|
renderComponent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/components/resolve-props.tsx"],"sourcesContent":["import { type ReactNode } from 'react'\n\nimport { type ElementData } from '../../../state/read-only-state'\n\nimport { useControlDefs } from '../hooks/use-control-defs'\nimport { useResolvedProps } from '../hooks/use-resolved-props'\n\nimport { resolveLegacyDescriptorProp } from '../legacy-controls'\n\nexport function ResolveProps({\n element,\n children: renderComponent,\n}: {\n element: ElementData\n children: (props: Record<string, unknown>) => ReactNode\n}): ReactNode {\n const [legacyDescriptors, definitions] = useControlDefs({ elementType: element.type })\n\n const resolvedProps = useResolvedProps(definitions
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/components/resolve-props.tsx"],"sourcesContent":["import { type ReactNode } from 'react'\n\nimport { type ElementData } from '../../../state/read-only-state'\n\nimport { useControlDefs } from '../hooks/use-control-defs'\nimport { useResolvedProps } from '../hooks/use-resolved-props'\nimport { useStylesheetFactory } from '../hooks/use-stylesheet-factory'\n\nimport { resolveLegacyDescriptorProp } from '../legacy-controls'\n\nexport function ResolveProps({\n element,\n children: renderComponent,\n}: {\n element: ElementData\n children: (props: Record<string, unknown>) => ReactNode\n}): ReactNode {\n const [legacyDescriptors, definitions] = useControlDefs({ elementType: element.type })\n\n const stylesheetFactory = useStylesheetFactory()\n const resolvedProps = useResolvedProps({\n propDefs: definitions,\n propData: element.props,\n elementKey: element.key,\n stylesheetFactory,\n })\n\n const renderFn = Object.entries(legacyDescriptors).reduceRight(\n (renderFn, [propName, descriptor]) =>\n props =>\n resolveLegacyDescriptorProp(descriptor, propName, element.props[propName], props, renderFn),\n renderComponent,\n )\n\n return renderFn(resolvedProps)\n}\n"],"mappings":"AAIA,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AAErC,SAAS,mCAAmC;AAErC,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA,UAAU;AACZ,GAGc;AACZ,QAAM,CAAC,mBAAmB,WAAW,IAAI,eAAe,EAAE,aAAa,QAAQ,KAAK,CAAC;AAErF,QAAM,oBAAoB,qBAAqB;AAC/C,QAAM,gBAAgB,iBAAiB;AAAA,IACrC,UAAU;AAAA,IACV,UAAU,QAAQ;AAAA,IAClB,YAAY,QAAQ;AAAA,IACpB;AAAA,EACF,CAAC;AAED,QAAM,WAAW,OAAO,QAAQ,iBAAiB,EAAE;AAAA,IACjD,CAACA,WAAU,CAAC,UAAU,UAAU,MAC9B,WACE,4BAA4B,YAAY,UAAU,QAAQ,MAAM,QAAQ,GAAG,OAAOA,SAAQ;AAAA,IAC9F;AAAA,EACF;AAEA,SAAO,SAAS,aAAa;AAC/B;","names":["renderFn"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getPropControllers } from "../../../state/read-only-state";
|
|
2
|
+
import { useDocumentKey } from "./use-document-context";
|
|
3
|
+
import { useSelector } from "./use-selector";
|
|
4
|
+
function useControlInstances(elementKey) {
|
|
5
|
+
const documentKey = useDocumentKey();
|
|
6
|
+
return useSelector((state) => {
|
|
7
|
+
if (documentKey == null)
|
|
8
|
+
return null;
|
|
9
|
+
return getPropControllers(state, { documentKey, elementKey });
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
useControlInstances
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=use-control-instances.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-control-instances.ts"],"sourcesContent":["import { ControlInstance } from '@makeswift/controls'\n\nimport { getPropControllers } from '../../../state/read-only-state'\nimport { useDocumentKey } from './use-document-context'\nimport { useSelector } from './use-selector'\n\nexport function useControlInstances(elementKey: string): Record<string, ControlInstance> | null {\n const documentKey = useDocumentKey()\n\n return useSelector(state => {\n if (documentKey == null) return null\n\n return getPropControllers(state, { documentKey, elementKey })\n })\n}\n"],"mappings":"AAEA,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAErB,SAAS,oBAAoB,YAA4D;AAC9F,QAAM,cAAc,eAAe;AAEnC,SAAO,YAAY,WAAS;AAC1B,QAAI,eAAe;AAAM,aAAO;AAEhC,WAAO,mBAAmB,OAAO,EAAE,aAAa,WAAW,CAAC;AAAA,EAC9D,CAAC;AACH;","names":[]}
|
|
@@ -2,29 +2,22 @@ import { useMemo, useEffect, useRef, useSyncExternalStore, useCallback } from "r
|
|
|
2
2
|
import {
|
|
3
3
|
mapValues
|
|
4
4
|
} from "@makeswift/controls";
|
|
5
|
-
import * as ReactPage from "../../../state/read-only-state";
|
|
6
5
|
import { useResourceResolver } from "./use-resource-resolver";
|
|
7
|
-
import { useDocumentKey } from "./use-document-context";
|
|
8
|
-
import { useSelector } from "./use-selector";
|
|
9
|
-
import { useStylesheetFactory } from "./use-stylesheet-factory";
|
|
10
|
-
import { useResolvableRecord } from "./use-resolvable-record";
|
|
11
6
|
import { propErrorHandlingProxy } from "../utils/prop-error-handling-proxy";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
function useResolvedProps(propDefs, elementData, elementKey) {
|
|
21
|
-
const stylesheetFactory = useStylesheetFactory();
|
|
7
|
+
import { useControlInstances } from "./use-control-instances";
|
|
8
|
+
import { useResolvableRecord } from "./use-resolvable-record";
|
|
9
|
+
function useResolvedProps({
|
|
10
|
+
propDefs,
|
|
11
|
+
propData,
|
|
12
|
+
elementKey,
|
|
13
|
+
stylesheetFactory
|
|
14
|
+
}) {
|
|
22
15
|
const resourceResolver = useResourceResolver();
|
|
23
16
|
const controls = useControlInstances(elementKey);
|
|
24
17
|
const cache = useRef({}).current;
|
|
25
18
|
const resolveProp = useCallback(
|
|
26
19
|
(def, propName) => {
|
|
27
|
-
const data =
|
|
20
|
+
const data = propData[propName];
|
|
28
21
|
const control = controls?.[propName];
|
|
29
22
|
if (cache[propName] != null && data === cache[propName].data && control === cache[propName].control) {
|
|
30
23
|
return cache[propName].resolvedValue;
|
|
@@ -38,7 +31,7 @@ function useResolvedProps(propDefs, elementData, elementKey) {
|
|
|
38
31
|
cache[propName] = { data, control, resolvedValue };
|
|
39
32
|
return resolvedValue;
|
|
40
33
|
},
|
|
41
|
-
[controls,
|
|
34
|
+
[controls, propData, resourceResolver, stylesheetFactory]
|
|
42
35
|
);
|
|
43
36
|
const resolvables = useMemo(
|
|
44
37
|
() => mapValues(propDefs, (def, propName) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-resolved-props.ts"],"sourcesContent":["import { useMemo, useEffect, useRef, useSyncExternalStore, useCallback } from 'react'\nimport {\n ControlDefinition,\n ControlInstance,\n mapValues,\n type Data,\n type Resolvable,\n} from '@makeswift/controls'\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-resolved-props.ts"],"sourcesContent":["import { useMemo, useEffect, useRef, useSyncExternalStore, useCallback } from 'react'\nimport {\n ControlDefinition,\n ControlInstance,\n mapValues,\n type Data,\n type Resolvable,\n} from '@makeswift/controls'\n\nimport { useResourceResolver } from './use-resource-resolver'\n\nimport { type StylesheetFactory } from '../stylesheet-factory'\nimport { propErrorHandlingProxy } from '../utils/prop-error-handling-proxy'\n\nimport { useControlInstances } from './use-control-instances'\nimport { useResolvableRecord } from './use-resolvable-record'\n\ntype CacheItem = {\n data: Data\n control: ControlInstance | undefined\n resolvedValue: Resolvable<unknown>\n}\n\nexport function useResolvedProps({\n propDefs,\n propData,\n elementKey,\n stylesheetFactory,\n}: {\n propDefs: Record<string, ControlDefinition>\n propData: Record<string, Data>\n elementKey: string\n stylesheetFactory: StylesheetFactory\n}): Record<string, unknown> {\n const resourceResolver = useResourceResolver()\n const controls = useControlInstances(elementKey)\n\n const cache = useRef<Record<string, CacheItem>>({}).current\n const resolveProp = useCallback(\n (def: ControlDefinition, propName: string) => {\n const data = propData[propName]\n const control = controls?.[propName]\n\n if (\n cache[propName] != null &&\n data === cache[propName].data &&\n control === cache[propName].control\n ) {\n return cache[propName].resolvedValue\n }\n\n const resolvedValue = def.resolveValue(\n data,\n resourceResolver,\n stylesheetFactory.get(propName),\n control,\n )\n\n cache[propName] = { data, control, resolvedValue }\n return resolvedValue\n },\n [controls, propData, resourceResolver, stylesheetFactory],\n )\n\n const resolvables = useMemo<Record<string, Resolvable<unknown>>>(\n () =>\n mapValues(propDefs, (def, propName) => {\n const defaultValue = (def.config as any)?.defaultValue\n return propErrorHandlingProxy(resolveProp(def, propName), defaultValue, error => {\n console.warn(\n `Error reading value for prop \"${propName}\", falling back to \\`${defaultValue}\\`.`,\n { control: def, error },\n )\n })\n }),\n [propDefs, resolveProp],\n )\n\n const props = useResolvableRecord(resolvables)\n\n // no need to call `triggerResolve` on the server, all the resources should already be in\n // the host API client's cache (populated from the snapshot's cache)\n useEffect(() => {\n props.triggerResolve()\n }, [props])\n\n // the order is important here, the styles are defined in the process of the props resolution,\n // calling `useDefinedStyles` before the props are resolved would effectively be a noop\n const resolvedProps = useSyncExternalStore(props.subscribe, props.readStable, props.readStable)\n\n stylesheetFactory.useDefinedStyles()\n\n return resolvedProps\n}\n"],"mappings":"AAAA,SAAS,SAAS,WAAW,QAAQ,sBAAsB,mBAAmB;AAC9E;AAAA,EAGE;AAAA,OAGK;AAEP,SAAS,2BAA2B;AAGpC,SAAS,8BAA8B;AAEvC,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AAQ7B,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAK4B;AAC1B,QAAM,mBAAmB,oBAAoB;AAC7C,QAAM,WAAW,oBAAoB,UAAU;AAE/C,QAAM,QAAQ,OAAkC,CAAC,CAAC,EAAE;AACpD,QAAM,cAAc;AAAA,IAClB,CAAC,KAAwB,aAAqB;AAC5C,YAAM,OAAO,SAAS,QAAQ;AAC9B,YAAM,UAAU,WAAW,QAAQ;AAEnC,UACE,MAAM,QAAQ,KAAK,QACnB,SAAS,MAAM,QAAQ,EAAE,QACzB,YAAY,MAAM,QAAQ,EAAE,SAC5B;AACA,eAAO,MAAM,QAAQ,EAAE;AAAA,MACzB;AAEA,YAAM,gBAAgB,IAAI;AAAA,QACxB;AAAA,QACA;AAAA,QACA,kBAAkB,IAAI,QAAQ;AAAA,QAC9B;AAAA,MACF;AAEA,YAAM,QAAQ,IAAI,EAAE,MAAM,SAAS,cAAc;AACjD,aAAO;AAAA,IACT;AAAA,IACA,CAAC,UAAU,UAAU,kBAAkB,iBAAiB;AAAA,EAC1D;AAEA,QAAM,cAAc;AAAA,IAClB,MACE,UAAU,UAAU,CAAC,KAAK,aAAa;AACrC,YAAM,eAAgB,IAAI,QAAgB;AAC1C,aAAO,uBAAuB,YAAY,KAAK,QAAQ,GAAG,cAAc,WAAS;AAC/E,gBAAQ;AAAA,UACN,iCAAiC,QAAQ,wBAAwB,YAAY;AAAA,UAC7E,EAAE,SAAS,KAAK,MAAM;AAAA,QACxB;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,IACH,CAAC,UAAU,WAAW;AAAA,EACxB;AAEA,QAAM,QAAQ,oBAAoB,WAAW;AAI7C,YAAU,MAAM;AACd,UAAM,eAAe;AAAA,EACvB,GAAG,CAAC,KAAK,CAAC;AAIV,QAAM,gBAAgB,qBAAqB,MAAM,WAAW,MAAM,YAAY,MAAM,UAAU;AAE9F,oBAAkB,iBAAiB;AAEnC,SAAO;AACT;","names":[]}
|
|
@@ -3,12 +3,12 @@ import { serializeStyles } from "@emotion/serialize";
|
|
|
3
3
|
import {
|
|
4
4
|
isNotNil
|
|
5
5
|
} from "@makeswift/controls";
|
|
6
|
-
import { useCache } from "../root-style-registry";
|
|
7
6
|
import { resolvedStyleToCss } from "../lib/resolved-style-to-css";
|
|
7
|
+
import { pollBoxModel } from "../poll-box-model";
|
|
8
|
+
import { useCache } from "../root-style-registry";
|
|
9
|
+
import { useStyles, serializedStyleClassName } from "../use-style";
|
|
8
10
|
import { useBreakpoints } from "./use-breakpoints";
|
|
9
11
|
import { useCssId } from "./use-css-id";
|
|
10
|
-
import { useStyles, serializedStyleClassName } from "../use-style";
|
|
11
|
-
import { pollBoxModel } from "../poll-box-model";
|
|
12
12
|
function useStylesheetFactory() {
|
|
13
13
|
const breakpoints = useBreakpoints();
|
|
14
14
|
const cache = useCache();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-stylesheet-factory.ts"],"sourcesContent":["import { useMemo, useEffect, useRef } from 'react'\nimport { serializeStyles } from '@emotion/serialize'\nimport { type EmotionCache } from '@emotion/cache'\nimport { type SerializedStyles } from '@emotion/utils'\n\nimport {\n type BoxDisplayModel,\n type Breakpoints,\n type Stylesheet,\n type ResolvedStyle,\n isNotNil,\n} from '@makeswift/controls'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-stylesheet-factory.ts"],"sourcesContent":["import { useMemo, useEffect, useRef } from 'react'\nimport { serializeStyles } from '@emotion/serialize'\nimport { type EmotionCache } from '@emotion/cache'\nimport { type SerializedStyles } from '@emotion/utils'\n\nimport {\n type BoxDisplayModel,\n type Breakpoints,\n type Stylesheet,\n type ResolvedStyle,\n isNotNil,\n} from '@makeswift/controls'\n\nimport { resolvedStyleToCss } from '../lib/resolved-style-to-css'\nimport { pollBoxModel } from '../poll-box-model'\nimport { useCache } from '../root-style-registry'\nimport { type StylesheetFactory } from '../stylesheet-factory'\nimport { useStyles, serializedStyleClassName } from '../use-style'\n\nimport { useBreakpoints } from './use-breakpoints'\nimport { useCssId } from './use-css-id'\n\nexport function useStylesheetFactory(): StylesheetFactory {\n const breakpoints = useBreakpoints()\n const cache = useCache()\n const componentUid = useCssId()\n\n const computedStyles = useRef<Record<string, SerializedStyles>>({}).current\n const boxModelCallbacks = useRef<Record<string, (boxModel: BoxDisplayModel | null) => void>>(\n {},\n ).current\n\n return useMemo(() => {\n const getStylesheet = (styleSheetId: string): Stylesheet => ({\n breakpoints(): Breakpoints {\n return breakpoints\n },\n\n defineStyle(\n style: ResolvedStyle,\n onBoxModelChange?: (boxModel: BoxDisplayModel | null) => void,\n ): string {\n const serialized = serializeStyle(breakpoints, style, cache)\n const uid = `u-${componentUid}-${styleSheetId}`\n computedStyles[uid] = serialized\n\n const className = serializedStyleClassName(cache, serialized)\n if (!onBoxModelChange) return className\n\n boxModelCallbacks[uid] = onBoxModelChange\n return `${className} ${uid}`\n },\n\n child(id: string): Stylesheet {\n return getStylesheet(`${styleSheetId}-${id}`)\n },\n })\n\n return {\n get(propName: string): Stylesheet {\n return getStylesheet(propName)\n },\n\n useDefinedStyles() {\n useStyles(cache, Object.values(computedStyles))\n\n useEffect(() => {\n const unsubscribes = Object.entries(boxModelCallbacks)\n .map(([uid, callback]) =>\n callback != null\n ? pollBoxModel({\n element: document.querySelector(`.${uid}`),\n onBoxModelChange: callback,\n })\n : undefined,\n )\n .filter(isNotNil)\n\n return () => unsubscribes.forEach(fn => fn())\n }, [Object.keys(boxModelCallbacks).join(' ')])\n },\n }\n }, [breakpoints, cache, componentUid])\n}\n\nfunction serializeStyle(\n breakpoints: Breakpoints,\n style: ResolvedStyle,\n cache: EmotionCache,\n): SerializedStyles {\n const css = resolvedStyleToCss(breakpoints, style)\n return serializeStyles([css], cache.registered)\n}\n"],"mappings":"AAAA,SAAS,SAAS,WAAW,cAAc;AAC3C,SAAS,uBAAuB;AAIhC;AAAA,EAKE;AAAA,OACK;AAEP,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AAEzB,SAAS,WAAW,gCAAgC;AAEpD,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AAElB,SAAS,uBAA0C;AACxD,QAAM,cAAc,eAAe;AACnC,QAAM,QAAQ,SAAS;AACvB,QAAM,eAAe,SAAS;AAE9B,QAAM,iBAAiB,OAAyC,CAAC,CAAC,EAAE;AACpE,QAAM,oBAAoB;AAAA,IACxB,CAAC;AAAA,EACH,EAAE;AAEF,SAAO,QAAQ,MAAM;AACnB,UAAM,gBAAgB,CAAC,kBAAsC;AAAA,MAC3D,cAA2B;AACzB,eAAO;AAAA,MACT;AAAA,MAEA,YACE,OACA,kBACQ;AACR,cAAM,aAAa,eAAe,aAAa,OAAO,KAAK;AAC3D,cAAM,MAAM,KAAK,YAAY,IAAI,YAAY;AAC7C,uBAAe,GAAG,IAAI;AAEtB,cAAM,YAAY,yBAAyB,OAAO,UAAU;AAC5D,YAAI,CAAC;AAAkB,iBAAO;AAE9B,0BAAkB,GAAG,IAAI;AACzB,eAAO,GAAG,SAAS,IAAI,GAAG;AAAA,MAC5B;AAAA,MAEA,MAAM,IAAwB;AAC5B,eAAO,cAAc,GAAG,YAAY,IAAI,EAAE,EAAE;AAAA,MAC9C;AAAA,IACF;AAEA,WAAO;AAAA,MACL,IAAI,UAA8B;AAChC,eAAO,cAAc,QAAQ;AAAA,MAC/B;AAAA,MAEA,mBAAmB;AACjB,kBAAU,OAAO,OAAO,OAAO,cAAc,CAAC;AAE9C,kBAAU,MAAM;AACd,gBAAM,eAAe,OAAO,QAAQ,iBAAiB,EAClD;AAAA,YAAI,CAAC,CAAC,KAAK,QAAQ,MAClB,YAAY,OACR,aAAa;AAAA,cACX,SAAS,SAAS,cAAc,IAAI,GAAG,EAAE;AAAA,cACzC,kBAAkB;AAAA,YACpB,CAAC,IACD;AAAA,UACN,EACC,OAAO,QAAQ;AAElB,iBAAO,MAAM,aAAa,QAAQ,QAAM,GAAG,CAAC;AAAA,QAC9C,GAAG,CAAC,OAAO,KAAK,iBAAiB,EAAE,KAAK,GAAG,CAAC,CAAC;AAAA,MAC/C;AAAA,IACF;AAAA,EACF,GAAG,CAAC,aAAa,OAAO,YAAY,CAAC;AACvC;AAEA,SAAS,eACP,aACA,OACA,OACkB;AAClB,QAAM,MAAM,mBAAmB,aAAa,KAAK;AACjD,SAAO,gBAAgB,CAAC,GAAG,GAAG,MAAM,UAAU;AAChD;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=stylesheet-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-props.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/components/resolve-props.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"resolve-props.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/components/resolve-props.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAQjE,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,QAAQ,EAAE,eAAe,GAC1B,EAAE;IACD,OAAO,EAAE,WAAW,CAAA;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,SAAS,CAAA;CACxD,GAAG,SAAS,CAmBZ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-control-instances.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/hooks/use-control-instances.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAMrD,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,IAAI,CAQ9F"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { ControlDefinition, type Data } from '@makeswift/controls';
|
|
2
|
-
|
|
2
|
+
import { type StylesheetFactory } from '../stylesheet-factory';
|
|
3
|
+
export declare function useResolvedProps({ propDefs, propData, elementKey, stylesheetFactory, }: {
|
|
4
|
+
propDefs: Record<string, ControlDefinition>;
|
|
5
|
+
propData: Record<string, Data>;
|
|
6
|
+
elementKey: string;
|
|
7
|
+
stylesheetFactory: StylesheetFactory;
|
|
8
|
+
}): Record<string, unknown>;
|
|
3
9
|
//# sourceMappingURL=use-resolved-props.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-resolved-props.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/hooks/use-resolved-props.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EAGjB,KAAK,IAAI,EAEV,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"use-resolved-props.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/hooks/use-resolved-props.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EAGjB,KAAK,IAAI,EAEV,MAAM,qBAAqB,CAAA;AAI5B,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAY9D,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,iBAAiB,GAClB,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;IAC3C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,iBAAiB,EAAE,iBAAiB,CAAA;CACrC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA4D1B"}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export type StylesheetFactory = {
|
|
3
|
-
get(propName: string): Stylesheet;
|
|
4
|
-
useDefinedStyles(): void;
|
|
5
|
-
};
|
|
1
|
+
import { type StylesheetFactory } from '../stylesheet-factory';
|
|
6
2
|
export declare function useStylesheetFactory(): StylesheetFactory;
|
|
7
3
|
//# sourceMappingURL=use-stylesheet-factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-stylesheet-factory.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/hooks/use-stylesheet-factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-stylesheet-factory.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/hooks/use-stylesheet-factory.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAM9D,wBAAgB,oBAAoB,IAAI,iBAAiB,CA6DxD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stylesheet-factory.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/react/stylesheet-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAErD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAA;IACjC,gBAAgB,IAAI,IAAI,CAAA;CACzB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@makeswift/runtime",
|
|
3
|
-
"version": "0.28.8-canary.
|
|
3
|
+
"version": "0.28.8-canary.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "makeswift/makeswift",
|
|
@@ -238,9 +238,9 @@
|
|
|
238
238
|
"use-sync-external-store": "^1.5.0",
|
|
239
239
|
"uuid": "^9.0.0",
|
|
240
240
|
"zod": "^3.21.4",
|
|
241
|
-
"@makeswift/controls": "0.1.
|
|
241
|
+
"@makeswift/controls": "0.1.21-canary.0",
|
|
242
242
|
"@makeswift/next-plugin": "0.6.1",
|
|
243
|
-
"@makeswift/prop-controllers": "0.4.
|
|
243
|
+
"@makeswift/prop-controllers": "0.4.15-canary.0"
|
|
244
244
|
},
|
|
245
245
|
"devDependencies": {
|
|
246
246
|
"@emotion/jest": "^11.11.0",
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var group_exports = {};
|
|
20
|
-
__export(group_exports, {
|
|
21
|
-
GroupControlValue: () => GroupControlValue
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(group_exports);
|
|
24
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
-
var import_controls = require("@makeswift/controls");
|
|
26
|
-
var import_control = require("./control");
|
|
27
|
-
function GroupControlValue({ definition, data, children, control }) {
|
|
28
|
-
return Object.entries(definition.config.props).reduceRight(
|
|
29
|
-
(renderFn, [key, controlDefinition]) => (shapeControlValue) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
30
|
-
import_control.ControlValue,
|
|
31
|
-
{
|
|
32
|
-
definition: controlDefinition,
|
|
33
|
-
data: data != null ? import_controls.GroupDefinition.propsData(data)[key] : void 0,
|
|
34
|
-
control: control?.child(key),
|
|
35
|
-
children: (value) => renderFn({ ...shapeControlValue, [key]: value })
|
|
36
|
-
}
|
|
37
|
-
),
|
|
38
|
-
children
|
|
39
|
-
)({});
|
|
40
|
-
}
|
|
41
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
-
0 && (module.exports = {
|
|
43
|
-
GroupControlValue
|
|
44
|
-
});
|
|
45
|
-
//# sourceMappingURL=group.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/controls/group.tsx"],"sourcesContent":["import { ReactNode } from 'react'\nimport {\n GroupControl,\n GroupDefinition,\n type DataType,\n type ResolvedValueType,\n} from '@makeswift/controls'\n\nimport { ControlValue } from './control'\n\ntype GroupControlValueProps = {\n definition: GroupDefinition\n data: DataType<GroupDefinition> | undefined\n children(value: ResolvedValueType<GroupDefinition>): ReactNode\n control: GroupControl\n}\n\nexport function GroupControlValue({ definition, data, children, control }: GroupControlValueProps) {\n return Object.entries(definition.config.props).reduceRight(\n (renderFn, [key, controlDefinition]) =>\n shapeControlValue => (\n <ControlValue\n definition={controlDefinition}\n data={data != null ? GroupDefinition.propsData(data)[key] : undefined}\n control={control?.child(key)}\n >\n {value => renderFn({ ...shapeControlValue, [key]: value })}\n </ControlValue>\n ),\n children,\n )({} as ResolvedValueType<GroupDefinition>)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBQ;AApBR,sBAKO;AAEP,qBAA6B;AAStB,SAAS,kBAAkB,EAAE,YAAY,MAAM,UAAU,QAAQ,GAA2B;AACjG,SAAO,OAAO,QAAQ,WAAW,OAAO,KAAK,EAAE;AAAA,IAC7C,CAAC,UAAU,CAAC,KAAK,iBAAiB,MAChC,uBACE;AAAA,MAAC;AAAA;AAAA,QACC,YAAY;AAAA,QACZ,MAAM,QAAQ,OAAO,gCAAgB,UAAU,IAAI,EAAE,GAAG,IAAI;AAAA,QAC5D,SAAS,SAAS,MAAM,GAAG;AAAA,QAE1B,qBAAS,SAAS,EAAE,GAAG,mBAAmB,CAAC,GAAG,GAAG,MAAM,CAAC;AAAA;AAAA,IAC3D;AAAA,IAEJ;AAAA,EACF,EAAE,CAAC,CAAuC;AAC5C;","names":[]}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
GroupDefinition
|
|
4
|
-
} from "@makeswift/controls";
|
|
5
|
-
import { ControlValue } from "./control";
|
|
6
|
-
function GroupControlValue({ definition, data, children, control }) {
|
|
7
|
-
return Object.entries(definition.config.props).reduceRight(
|
|
8
|
-
(renderFn, [key, controlDefinition]) => (shapeControlValue) => /* @__PURE__ */ jsx(
|
|
9
|
-
ControlValue,
|
|
10
|
-
{
|
|
11
|
-
definition: controlDefinition,
|
|
12
|
-
data: data != null ? GroupDefinition.propsData(data)[key] : void 0,
|
|
13
|
-
control: control?.child(key),
|
|
14
|
-
children: (value) => renderFn({ ...shapeControlValue, [key]: value })
|
|
15
|
-
}
|
|
16
|
-
),
|
|
17
|
-
children
|
|
18
|
-
)({});
|
|
19
|
-
}
|
|
20
|
-
export {
|
|
21
|
-
GroupControlValue
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=group.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/controls/group.tsx"],"sourcesContent":["import { ReactNode } from 'react'\nimport {\n GroupControl,\n GroupDefinition,\n type DataType,\n type ResolvedValueType,\n} from '@makeswift/controls'\n\nimport { ControlValue } from './control'\n\ntype GroupControlValueProps = {\n definition: GroupDefinition\n data: DataType<GroupDefinition> | undefined\n children(value: ResolvedValueType<GroupDefinition>): ReactNode\n control: GroupControl\n}\n\nexport function GroupControlValue({ definition, data, children, control }: GroupControlValueProps) {\n return Object.entries(definition.config.props).reduceRight(\n (renderFn, [key, controlDefinition]) =>\n shapeControlValue => (\n <ControlValue\n definition={controlDefinition}\n data={data != null ? GroupDefinition.propsData(data)[key] : undefined}\n control={control?.child(key)}\n >\n {value => renderFn({ ...shapeControlValue, [key]: value })}\n </ControlValue>\n ),\n children,\n )({} as ResolvedValueType<GroupDefinition>)\n}\n"],"mappings":"AAqBQ;AApBR;AAAA,EAEE;AAAA,OAGK;AAEP,SAAS,oBAAoB;AAStB,SAAS,kBAAkB,EAAE,YAAY,MAAM,UAAU,QAAQ,GAA2B;AACjG,SAAO,OAAO,QAAQ,WAAW,OAAO,KAAK,EAAE;AAAA,IAC7C,CAAC,UAAU,CAAC,KAAK,iBAAiB,MAChC,uBACE;AAAA,MAAC;AAAA;AAAA,QACC,YAAY;AAAA,QACZ,MAAM,QAAQ,OAAO,gBAAgB,UAAU,IAAI,EAAE,GAAG,IAAI;AAAA,QAC5D,SAAS,SAAS,MAAM,GAAG;AAAA,QAE1B,qBAAS,SAAS,EAAE,GAAG,mBAAmB,CAAC,GAAG,GAAG,MAAM,CAAC;AAAA;AAAA,IAC3D;AAAA,IAEJ;AAAA,EACF,EAAE,CAAC,CAAuC;AAC5C;","names":[]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { GroupControl, GroupDefinition, type DataType, type ResolvedValueType } from '@makeswift/controls';
|
|
3
|
-
type GroupControlValueProps = {
|
|
4
|
-
definition: GroupDefinition;
|
|
5
|
-
data: DataType<GroupDefinition> | undefined;
|
|
6
|
-
children(value: ResolvedValueType<GroupDefinition>): ReactNode;
|
|
7
|
-
control: GroupControl;
|
|
8
|
-
};
|
|
9
|
-
export declare function GroupControlValue({ definition, data, children, control }: GroupControlValueProps): ReactNode;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=group.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/controls/group.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EACL,YAAY,EACZ,eAAe,EACf,KAAK,QAAQ,EACb,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAA;AAI5B,KAAK,sBAAsB,GAAG;IAC5B,UAAU,EAAE,eAAe,CAAA;IAC3B,IAAI,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,SAAS,CAAA;IAC3C,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC,eAAe,CAAC,GAAG,SAAS,CAAA;IAC9D,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,wBAAgB,iBAAiB,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,sBAAsB,aAchG"}
|