@makeswift/runtime 0.28.8-canary.20 → 0.28.8-canary.21
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/controls/slot.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/slot/index.js +29 -0
- package/dist/cjs/runtimes/react/controls/slot/index.js.map +1 -0
- package/dist/cjs/runtimes/react/controls/slot/render-slot.js +37 -0
- package/dist/cjs/runtimes/react/controls/slot/render-slot.js.map +1 -0
- package/dist/cjs/runtimes/react/controls/{slot.js → slot/slot-value.js} +24 -26
- package/dist/cjs/runtimes/react/controls/slot/slot-value.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/controls/slot.js.map +1 -1
- package/dist/esm/runtimes/react/controls/slot/index.js +5 -0
- package/dist/esm/runtimes/react/controls/slot/index.js.map +1 -0
- package/dist/esm/runtimes/react/controls/slot/render-slot.js +13 -0
- package/dist/esm/runtimes/react/controls/slot/render-slot.js.map +1 -0
- package/dist/esm/runtimes/react/controls/{slot.js → slot/slot-value.js} +27 -23
- package/dist/esm/runtimes/react/controls/slot/slot-value.js.map +1 -0
- package/dist/types/controls/slot.d.ts +1 -1
- package/dist/types/controls/slot.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/slot/index.d.ts +2 -0
- package/dist/types/runtimes/react/controls/slot/index.d.ts.map +1 -0
- package/dist/types/runtimes/react/controls/slot/render-slot.d.ts +9 -0
- package/dist/types/runtimes/react/controls/slot/render-slot.d.ts.map +1 -0
- package/dist/types/runtimes/react/controls/{slot.d.ts → slot/slot-value.d.ts} +7 -7
- package/dist/types/runtimes/react/controls/slot/slot-value.d.ts.map +1 -0
- package/package.json +3 -3
- package/dist/cjs/runtimes/react/controls/slot.js.map +0 -1
- package/dist/esm/runtimes/react/controls/slot.js.map +0 -1
- package/dist/types/runtimes/react/controls/slot.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.21"
|
|
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.21"
|
|
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.21",
|
|
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.21",
|
|
693
693
|
"content-type": "application/json"
|
|
694
694
|
},
|
|
695
695
|
body: JSON.stringify({ token }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/controls/slot.ts"],"sourcesContent":["import { ReactNode } from 'react'\nimport {\n SlotDefinition as BaseSlotDefinition,\n SlotControl,\n StableValue,\n type DeserializedRecord,\n type ResourceResolver,\n type Stylesheet,\n type Resolvable,\n type DataType,\n} from '@makeswift/controls'\n\nimport { renderSlot } from '../runtimes/react/controls/slot'\n\nexport type SlotPlaceholderConfig = {\n builderOnly?: boolean\n height?: number\n text?: string\n}\n\n// TODO: We need to make a decision on how we want to allow users to configure\n// the Slot placeholder. Some considerations (not exhaustive):\n// - Inline vs block slot placeholders\n// - Slots that shouldn't occupy space when they are empty\n// - Slots that are only shown when you engage drop & drop in the builder\n// - Which of these behaviors should be configurable vs. hardcoded\n// - Addressing the builtin box\n//\n// For now, this initial config allows us to experiment with some initial\n// customization. This is subject to change.\nexport type SlotConfig = {\n unstable_placeholder?: SlotPlaceholderConfig\n}\n\nabstract class BaseDefinition extends BaseSlotDefinition<ReactNode, SlotConfig> {}\n\nexport class SlotDefinition extends BaseDefinition {\n static deserialize(data: DeserializedRecord): SlotDefinition {\n if (data.type !== SlotDefinition.type) {\n throw new Error(`Slot: expected type ${SlotDefinition.type}, got ${data.type}`)\n }\n\n return Slot(data.config ?? {})\n }\n\n constructor(config: SlotConfig = {}) {\n super(config)\n }\n\n resolveValue(\n data: DataType<BaseDefinition> | undefined,\n _resolver: ResourceResolver,\n _stylesheet: Stylesheet,\n control?: SlotControl,\n ): Resolvable<ReactNode | undefined> {\n const stableValue = StableValue({\n name: SlotDefinition.type,\n read: () => renderSlot({ data, control: control ?? null, config: this.config }),\n })\n\n return {\n ...stableValue,\n triggerResolve: async () => {},\n }\n }\n}\n\nexport function Slot(config: SlotConfig = {}): SlotDefinition {\n return new SlotDefinition(config)\n}\n\nexport { SlotControl }\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBASO;AAEP,kBAA2B;AAsB3B,MAAe,uBAAuB,gBAAAA,eAA0C;AAAC;AAE1E,MAAM,uBAAuB,eAAe;AAAA,EACjD,OAAO,YAAY,MAA0C;AAC3D,QAAI,KAAK,SAAS,eAAe,MAAM;AACrC,YAAM,IAAI,MAAM,uBAAuB,eAAe,IAAI,SAAS,KAAK,IAAI,EAAE;AAAA,IAChF;AAEA,WAAO,KAAK,KAAK,UAAU,CAAC,CAAC;AAAA,EAC/B;AAAA,EAEA,YAAY,SAAqB,CAAC,GAAG;AACnC,UAAM,MAAM;AAAA,EACd;AAAA,EAEA,aACE,MACA,WACA,aACA,SACmC;AACnC,UAAM,kBAAc,6BAAY;AAAA,MAC9B,MAAM,eAAe;AAAA,MACrB,MAAM,UAAM,wBAAW,EAAE,MAAM,SAAS,WAAW,MAAM,QAAQ,KAAK,OAAO,CAAC;AAAA,IAChF,CAAC;AAED,WAAO;AAAA,MACL,GAAG;AAAA,MACH,gBAAgB,YAAY;AAAA,MAAC;AAAA,IAC/B;AAAA,EACF;AACF;AAEO,SAAS,KAAK,SAAqB,CAAC,GAAmB;AAC5D,SAAO,IAAI,eAAe,MAAM;AAClC;","names":["BaseSlotDefinition"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/controls/slot.ts"],"sourcesContent":["import { type ReactNode } from 'react'\nimport {\n SlotDefinition as BaseSlotDefinition,\n SlotControl,\n StableValue,\n type DeserializedRecord,\n type ResourceResolver,\n type Stylesheet,\n type Resolvable,\n type DataType,\n} from '@makeswift/controls'\n\nimport { renderSlot } from '../runtimes/react/controls/slot'\n\nexport type SlotPlaceholderConfig = {\n builderOnly?: boolean\n height?: number\n text?: string\n}\n\n// TODO: We need to make a decision on how we want to allow users to configure\n// the Slot placeholder. Some considerations (not exhaustive):\n// - Inline vs block slot placeholders\n// - Slots that shouldn't occupy space when they are empty\n// - Slots that are only shown when you engage drop & drop in the builder\n// - Which of these behaviors should be configurable vs. hardcoded\n// - Addressing the builtin box\n//\n// For now, this initial config allows us to experiment with some initial\n// customization. This is subject to change.\nexport type SlotConfig = {\n unstable_placeholder?: SlotPlaceholderConfig\n}\n\nabstract class BaseDefinition extends BaseSlotDefinition<ReactNode, SlotConfig> {}\n\nexport class SlotDefinition extends BaseDefinition {\n static deserialize(data: DeserializedRecord): SlotDefinition {\n if (data.type !== SlotDefinition.type) {\n throw new Error(`Slot: expected type ${SlotDefinition.type}, got ${data.type}`)\n }\n\n return Slot(data.config ?? {})\n }\n\n constructor(config: SlotConfig = {}) {\n super(config)\n }\n\n resolveValue(\n data: DataType<BaseDefinition> | undefined,\n _resolver: ResourceResolver,\n _stylesheet: Stylesheet,\n control?: SlotControl,\n ): Resolvable<ReactNode | undefined> {\n const stableValue = StableValue({\n name: SlotDefinition.type,\n read: () => renderSlot({ data, control: control ?? null, config: this.config }),\n })\n\n return {\n ...stableValue,\n triggerResolve: async () => {},\n }\n }\n}\n\nexport function Slot(config: SlotConfig = {}): SlotDefinition {\n return new SlotDefinition(config)\n}\n\nexport { SlotControl }\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBASO;AAEP,kBAA2B;AAsB3B,MAAe,uBAAuB,gBAAAA,eAA0C;AAAC;AAE1E,MAAM,uBAAuB,eAAe;AAAA,EACjD,OAAO,YAAY,MAA0C;AAC3D,QAAI,KAAK,SAAS,eAAe,MAAM;AACrC,YAAM,IAAI,MAAM,uBAAuB,eAAe,IAAI,SAAS,KAAK,IAAI,EAAE;AAAA,IAChF;AAEA,WAAO,KAAK,KAAK,UAAU,CAAC,CAAC;AAAA,EAC/B;AAAA,EAEA,YAAY,SAAqB,CAAC,GAAG;AACnC,UAAM,MAAM;AAAA,EACd;AAAA,EAEA,aACE,MACA,WACA,aACA,SACmC;AACnC,UAAM,kBAAc,6BAAY;AAAA,MAC9B,MAAM,eAAe;AAAA,MACrB,MAAM,UAAM,wBAAW,EAAE,MAAM,SAAS,WAAW,MAAM,QAAQ,KAAK,OAAO,CAAC;AAAA,IAChF,CAAC;AAED,WAAO;AAAA,MACL,GAAG;AAAA,MACH,gBAAgB,YAAY;AAAA,MAAC;AAAA,IAC/B;AAAA,EACF;AACF;AAEO,SAAS,KAAK,SAAqB,CAAC,GAAmB;AAC5D,SAAO,IAAI,eAAe,MAAM;AAClC;","names":["BaseSlotDefinition"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 slot_exports = {};
|
|
20
|
+
__export(slot_exports, {
|
|
21
|
+
renderSlot: () => import_render_slot.renderSlot
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(slot_exports);
|
|
24
|
+
var import_render_slot = require("./render-slot");
|
|
25
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
+
0 && (module.exports = {
|
|
27
|
+
renderSlot
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/controls/slot/index.ts"],"sourcesContent":["export { renderSlot } from './render-slot'\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA2B;","names":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 render_slot_exports = {};
|
|
20
|
+
__export(render_slot_exports, {
|
|
21
|
+
renderSlot: () => renderSlot
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(render_slot_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_slot_value = require("./slot-value");
|
|
26
|
+
function renderSlot({
|
|
27
|
+
data,
|
|
28
|
+
control,
|
|
29
|
+
config
|
|
30
|
+
}) {
|
|
31
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_slot_value.SlotValue, { data, instanceKey: control?.instanceKey, config });
|
|
32
|
+
}
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
renderSlot
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=render-slot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/controls/slot/render-slot.tsx"],"sourcesContent":["import { type ReactNode } from 'react'\nimport { SlotDefinition, SlotControl, type DataType } from '@makeswift/controls'\n\nimport { type SlotConfig } from '../../../../controls/slot'\n\nimport { SlotValue } from './slot-value'\n\nexport function renderSlot({\n data,\n control,\n config,\n}: {\n data: DataType<SlotDefinition<ReactNode>> | undefined\n control: SlotControl | null\n config: SlotConfig\n}): ReactNode {\n // To make `SlotValue` interactive in the builder after it has been rendered as part of an\n // RSC component's server output and hydrated on the client, we need some way to connect\n // it to the corresponding control instance. Handling this purely client-side isn't an\n // option, as by itself the rendered slot has no identity we could use to look up its control\n // instance. Instantiating the instance on the server and simply passing it as a prop is\n // also not an option, as class instances like `SlotControl` can't cross the RSC server-client\n // serialization boundary. We can, however, pass the control's `instanceKey` instead, and use\n // it to look up the corresponding client-side control instance in `SlotValue` via\n // `useControlInstance`, and it works equally well for purely client-side rendering.\n return <SlotValue data={data} instanceKey={control?.instanceKey} config={config} />\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBS;AApBT,wBAA0B;AAEnB,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AACF,GAIc;AAUZ,SAAO,4CAAC,+BAAU,MAAY,aAAa,SAAS,aAAa,QAAgB;AACnF;","names":[]}
|
|
@@ -17,36 +17,34 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
var
|
|
21
|
-
__export(
|
|
20
|
+
var slot_value_exports = {};
|
|
21
|
+
__export(slot_value_exports, {
|
|
22
22
|
Slot: () => Slot,
|
|
23
|
-
|
|
23
|
+
SlotValue: () => SlotValue
|
|
24
24
|
});
|
|
25
|
-
module.exports = __toCommonJS(
|
|
25
|
+
module.exports = __toCommonJS(slot_value_exports);
|
|
26
26
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
27
27
|
var import_react = require("react");
|
|
28
28
|
var import_css = require("@emotion/css");
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var import_columns = require("
|
|
32
|
-
var import_responsive_style = require("
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Slot.Placeholder, { control, placeholder: config.unstable_placeholder });
|
|
46
|
-
}
|
|
47
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Slot, { control, children: data.elements.map((element, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Slot.Item, { control, grid: data.columns, index: i, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Element.Element, { element }) }, element.key)) });
|
|
29
|
+
var import_controls = require("@makeswift/controls");
|
|
30
|
+
var import_Element = require("../../components/Element");
|
|
31
|
+
var import_columns = require("../../../../components/utils/columns");
|
|
32
|
+
var import_responsive_style = require("../../../../components/utils/responsive-style");
|
|
33
|
+
var import_use_is_in_builder = require("../../hooks/use-is-in-builder");
|
|
34
|
+
var import_use_control_instance = require("../../hooks/use-control-instance");
|
|
35
|
+
var import_use_style = require("../../use-style");
|
|
36
|
+
var import_poll_box_model = require("../../poll-box-model");
|
|
37
|
+
const SlotValue = (0, import_react.memo)(function SlotValue2({
|
|
38
|
+
data,
|
|
39
|
+
instanceKey,
|
|
40
|
+
config
|
|
41
|
+
}) {
|
|
42
|
+
const control = (0, import_use_control_instance.useControlInstance)(instanceKey, import_controls.SlotControl);
|
|
43
|
+
if (data == null || data.elements.length === 0) {
|
|
44
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Slot.Placeholder, { control, placeholder: config.unstable_placeholder });
|
|
48
45
|
}
|
|
49
|
-
);
|
|
46
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Slot, { control, children: data.elements.map((element, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Slot.Item, { control, grid: data.columns, index: i, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Element.Element, { element }) }, element.key)) });
|
|
47
|
+
});
|
|
50
48
|
function Slot({
|
|
51
49
|
as,
|
|
52
50
|
control,
|
|
@@ -178,6 +176,6 @@ function SlotPlaceholder({ control, placeholder }) {
|
|
|
178
176
|
// Annotate the CommonJS export names for ESM import in node:
|
|
179
177
|
0 && (module.exports = {
|
|
180
178
|
Slot,
|
|
181
|
-
|
|
179
|
+
SlotValue
|
|
182
180
|
});
|
|
183
|
-
//# sourceMappingURL=slot.js.map
|
|
181
|
+
//# sourceMappingURL=slot-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/controls/slot/slot-value.tsx"],"sourcesContent":["'use client'\n\nimport {\n type ComponentPropsWithoutRef,\n type ElementType,\n type ReactNode,\n useEffect,\n useState,\n memo,\n} from 'react'\nimport { cx } from '@emotion/css'\n\nimport {\n SlotDefinition,\n SlotControl,\n type DataType,\n type ControlInstanceKey,\n} from '@makeswift/controls'\n\nimport { type SlotConfig, type SlotPlaceholderConfig } from '../../../../controls/slot'\n\nimport { Element } from '../../components/Element'\nimport { getIndexes } from '../../../../components/utils/columns'\nimport { useResponsiveStyle } from '../../../../components/utils/responsive-style'\n\nimport { useIsInBuilder } from '../../hooks/use-is-in-builder'\nimport { useControlInstance } from '../../hooks/use-control-instance'\n\nimport { useStyle } from '../../use-style'\nimport { pollBoxModel } from '../../poll-box-model'\n\nexport const SlotValue = memo(function SlotValue({\n data,\n instanceKey,\n config,\n}: {\n data: DataType<SlotDefinition<ReactNode>> | undefined\n instanceKey: ControlInstanceKey | undefined\n config: SlotConfig\n}): ReactNode {\n const control = useControlInstance(instanceKey, SlotControl)\n\n // TODO(miguel): While the UI shouldn't allow the state, we should probably check that at least\n // one element is visible.\n if (data == null || data.elements.length === 0) {\n return <Slot.Placeholder control={control} placeholder={config.unstable_placeholder} />\n }\n\n return (\n <Slot control={control}>\n {data.elements.map((element, i) => (\n <Slot.Item key={element.key} control={control} grid={data.columns} index={i}>\n <Element element={element} />\n </Slot.Item>\n ))}\n </Slot>\n )\n})\n\ntype SlotProps<T extends ElementType> = {\n as?: T\n control: SlotControl | null\n children?: ReactNode\n className?: string\n}\n\nexport function Slot<T extends ElementType = 'div'>({\n as,\n control,\n children,\n className,\n ...restOfProps\n}: SlotProps<T> & Omit<ComponentPropsWithoutRef<T>, keyof SlotProps<T>>) {\n const As = as ?? 'div'\n const [element, setElement] = useState<Element | null>(null)\n const baseClassName = useStyle({\n display: 'flex',\n flexWrap: 'wrap',\n width: '100%',\n })\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeContainerBoxModel(boxModel),\n })\n }, [element, control])\n\n return (\n <As {...restOfProps} ref={setElement} className={cx(baseClassName, className)}>\n {children}\n </As>\n )\n}\n\nSlot.Placeholder = SlotPlaceholder\n\nSlot.Item = SlotItem\n\ntype SlotItemProps<T extends ElementType> = {\n as?: T\n control: SlotControl | null\n // @arvin: review for correctness\n grid: DataType<SlotDefinition<ReactNode>> extends undefined\n ? undefined\n : NonNullable<DataType<SlotDefinition<ReactNode>>>['columns']\n index: number\n children?: ReactNode\n className?: string\n}\n\nfunction SlotItem<T extends ElementType = 'div'>({\n as,\n control,\n grid,\n index,\n children,\n className,\n ...restOfProps\n}: SlotItemProps<T> & Omit<ComponentPropsWithoutRef<T>, keyof SlotItemProps<T>>): ReactNode {\n const As = as ?? 'div'\n const [element, setElement] = useState<Element | null>(null)\n const baseClassName = useStyle({\n display: 'flex',\n ...useResponsiveStyle([grid], ([{ count = 12, spans = [[12]] } = {}]) => {\n const [rowIndex, columnIndex] = getIndexes(spans, index)\n const span = spans[rowIndex][columnIndex]\n const flexBasis = `calc(100% * ${(span / count).toFixed(5)})`\n\n return span === 0 ? { display: 'none' } : { flexBasis, minWidth: flexBasis }\n }),\n })\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeItemBoxModel(index, boxModel),\n })\n }, [element, control, index])\n\n return (\n <As {...restOfProps} ref={setElement} className={cx(baseClassName, className)}>\n {children}\n </As>\n )\n}\n\ntype SlotPlaceholderProps = {\n control: SlotControl | null\n placeholder?: SlotPlaceholderConfig\n}\n\nconst DEFAULT_SHOW_PLACEHOLDER_IN_BUILDER_ONLY = false\nconst DEFAULT_PLACEHOLDER_HEIGHT_PX = 80\n\nfunction SlotPlaceholder({ control, placeholder }: SlotPlaceholderProps): ReactNode {\n const isInBuilder = useIsInBuilder()\n const [element, setElement] = useState<Element | null>(null)\n\n // TODO: When ready, we can default to only showing the slot placeholder in\n // the builder\n const showInBuilderOnly = placeholder?.builderOnly ?? DEFAULT_SHOW_PLACEHOLDER_IN_BUILDER_ONLY\n const placeholderHeight = placeholder?.height ?? DEFAULT_PLACEHOLDER_HEIGHT_PX\n const text = placeholder?.text\n\n const hidePlaceholder = showInBuilderOnly && !isInBuilder\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeContainerBoxModel(boxModel),\n })\n }, [element, control])\n\n return (\n <div\n ref={setElement}\n className={useStyle({\n width: '100%',\n background: 'rgba(161, 168, 194, 0.18)',\n })}\n style={{\n height: hidePlaceholder ? 0 : placeholderHeight,\n visibility: hidePlaceholder ? 'hidden' : undefined,\n }}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"100%\"\n height=\"100%\"\n className={useStyle({ overflow: 'visible', padding: 8 })}\n >\n <rect\n x={0}\n y={0}\n width=\"100%\"\n height=\"100%\"\n strokeWidth={2}\n strokeDasharray=\"4 2\"\n fill=\"none\"\n stroke=\"rgba(161, 168, 194, 0.40)\"\n rx=\"4\"\n ry=\"4\"\n />\n {text != null && (\n <text\n x=\"50%\"\n y=\"50%\"\n dominantBaseline=\"central\"\n textAnchor=\"middle\"\n fill=\"rgba(161, 168, 194, 0.80)\"\n fontSize=\"14px\"\n fontFamily=\"sans-serif\"\n style={{ userSelect: 'none' }}\n >\n {text}\n </text>\n )}\n </svg>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6CW;AA3CX,mBAOO;AACP,iBAAmB;AAEnB,sBAKO;AAIP,qBAAwB;AACxB,qBAA2B;AAC3B,8BAAmC;AAEnC,+BAA+B;AAC/B,kCAAmC;AAEnC,uBAAyB;AACzB,4BAA6B;AAEtB,MAAM,gBAAY,mBAAK,SAASA,WAAU;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AACF,GAIc;AACZ,QAAM,cAAU,gDAAmB,aAAa,2BAAW;AAI3D,MAAI,QAAQ,QAAQ,KAAK,SAAS,WAAW,GAAG;AAC9C,WAAO,4CAAC,KAAK,aAAL,EAAiB,SAAkB,aAAa,OAAO,sBAAsB;AAAA,EACvF;AAEA,SACE,4CAAC,QAAK,SACH,eAAK,SAAS,IAAI,CAAC,SAAS,MAC3B,4CAAC,KAAK,MAAL,EAA4B,SAAkB,MAAM,KAAK,SAAS,OAAO,GACxE,sDAAC,0BAAQ,SAAkB,KADb,QAAQ,GAExB,CACD,GACH;AAEJ,CAAC;AASM,SAAS,KAAoC;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AAAA,EACA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AChB,MAAK;AAAA,gBACL,QAAO;AAAA,gBACP,IAAG;AAAA,gBACH,IAAG;AAAA;AAAA,YACL;AAAA,YACC,QAAQ,QACP;AAAA,cAAC;AAAA;AAAA,gBACC,GAAE;AAAA,gBACF,GAAE;AAAA,gBACF,kBAAiB;AAAA,gBACjB,YAAW;AAAA,gBACX,MAAK;AAAA,gBACL,UAAS;AAAA,gBACT,YAAW;AAAA,gBACX,OAAO,EAAE,YAAY,OAAO;AAAA,gBAE3B;AAAA;AAAA,YACH;AAAA;AAAA;AAAA,MAEJ;AAAA;AAAA,EACF;AAEJ;","names":["SlotValue"]}
|
|
@@ -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.21"
|
|
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.21"
|
|
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.21",
|
|
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.21",
|
|
673
673
|
"content-type": "application/json"
|
|
674
674
|
},
|
|
675
675
|
body: JSON.stringify({ token }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/controls/slot.ts"],"sourcesContent":["import { ReactNode } from 'react'\nimport {\n SlotDefinition as BaseSlotDefinition,\n SlotControl,\n StableValue,\n type DeserializedRecord,\n type ResourceResolver,\n type Stylesheet,\n type Resolvable,\n type DataType,\n} from '@makeswift/controls'\n\nimport { renderSlot } from '../runtimes/react/controls/slot'\n\nexport type SlotPlaceholderConfig = {\n builderOnly?: boolean\n height?: number\n text?: string\n}\n\n// TODO: We need to make a decision on how we want to allow users to configure\n// the Slot placeholder. Some considerations (not exhaustive):\n// - Inline vs block slot placeholders\n// - Slots that shouldn't occupy space when they are empty\n// - Slots that are only shown when you engage drop & drop in the builder\n// - Which of these behaviors should be configurable vs. hardcoded\n// - Addressing the builtin box\n//\n// For now, this initial config allows us to experiment with some initial\n// customization. This is subject to change.\nexport type SlotConfig = {\n unstable_placeholder?: SlotPlaceholderConfig\n}\n\nabstract class BaseDefinition extends BaseSlotDefinition<ReactNode, SlotConfig> {}\n\nexport class SlotDefinition extends BaseDefinition {\n static deserialize(data: DeserializedRecord): SlotDefinition {\n if (data.type !== SlotDefinition.type) {\n throw new Error(`Slot: expected type ${SlotDefinition.type}, got ${data.type}`)\n }\n\n return Slot(data.config ?? {})\n }\n\n constructor(config: SlotConfig = {}) {\n super(config)\n }\n\n resolveValue(\n data: DataType<BaseDefinition> | undefined,\n _resolver: ResourceResolver,\n _stylesheet: Stylesheet,\n control?: SlotControl,\n ): Resolvable<ReactNode | undefined> {\n const stableValue = StableValue({\n name: SlotDefinition.type,\n read: () => renderSlot({ data, control: control ?? null, config: this.config }),\n })\n\n return {\n ...stableValue,\n triggerResolve: async () => {},\n }\n }\n}\n\nexport function Slot(config: SlotConfig = {}): SlotDefinition {\n return new SlotDefinition(config)\n}\n\nexport { SlotControl }\n"],"mappings":"AACA;AAAA,EACE,kBAAkB;AAAA,EAClB;AAAA,EACA;AAAA,OAMK;AAEP,SAAS,kBAAkB;AAsB3B,MAAe,uBAAuB,mBAA0C;AAAC;AAE1E,MAAM,uBAAuB,eAAe;AAAA,EACjD,OAAO,YAAY,MAA0C;AAC3D,QAAI,KAAK,SAAS,eAAe,MAAM;AACrC,YAAM,IAAI,MAAM,uBAAuB,eAAe,IAAI,SAAS,KAAK,IAAI,EAAE;AAAA,IAChF;AAEA,WAAO,KAAK,KAAK,UAAU,CAAC,CAAC;AAAA,EAC/B;AAAA,EAEA,YAAY,SAAqB,CAAC,GAAG;AACnC,UAAM,MAAM;AAAA,EACd;AAAA,EAEA,aACE,MACA,WACA,aACA,SACmC;AACnC,UAAM,cAAc,YAAY;AAAA,MAC9B,MAAM,eAAe;AAAA,MACrB,MAAM,MAAM,WAAW,EAAE,MAAM,SAAS,WAAW,MAAM,QAAQ,KAAK,OAAO,CAAC;AAAA,IAChF,CAAC;AAED,WAAO;AAAA,MACL,GAAG;AAAA,MACH,gBAAgB,YAAY;AAAA,MAAC;AAAA,IAC/B;AAAA,EACF;AACF;AAEO,SAAS,KAAK,SAAqB,CAAC,GAAmB;AAC5D,SAAO,IAAI,eAAe,MAAM;AAClC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/controls/slot.ts"],"sourcesContent":["import { type ReactNode } from 'react'\nimport {\n SlotDefinition as BaseSlotDefinition,\n SlotControl,\n StableValue,\n type DeserializedRecord,\n type ResourceResolver,\n type Stylesheet,\n type Resolvable,\n type DataType,\n} from '@makeswift/controls'\n\nimport { renderSlot } from '../runtimes/react/controls/slot'\n\nexport type SlotPlaceholderConfig = {\n builderOnly?: boolean\n height?: number\n text?: string\n}\n\n// TODO: We need to make a decision on how we want to allow users to configure\n// the Slot placeholder. Some considerations (not exhaustive):\n// - Inline vs block slot placeholders\n// - Slots that shouldn't occupy space when they are empty\n// - Slots that are only shown when you engage drop & drop in the builder\n// - Which of these behaviors should be configurable vs. hardcoded\n// - Addressing the builtin box\n//\n// For now, this initial config allows us to experiment with some initial\n// customization. This is subject to change.\nexport type SlotConfig = {\n unstable_placeholder?: SlotPlaceholderConfig\n}\n\nabstract class BaseDefinition extends BaseSlotDefinition<ReactNode, SlotConfig> {}\n\nexport class SlotDefinition extends BaseDefinition {\n static deserialize(data: DeserializedRecord): SlotDefinition {\n if (data.type !== SlotDefinition.type) {\n throw new Error(`Slot: expected type ${SlotDefinition.type}, got ${data.type}`)\n }\n\n return Slot(data.config ?? {})\n }\n\n constructor(config: SlotConfig = {}) {\n super(config)\n }\n\n resolveValue(\n data: DataType<BaseDefinition> | undefined,\n _resolver: ResourceResolver,\n _stylesheet: Stylesheet,\n control?: SlotControl,\n ): Resolvable<ReactNode | undefined> {\n const stableValue = StableValue({\n name: SlotDefinition.type,\n read: () => renderSlot({ data, control: control ?? null, config: this.config }),\n })\n\n return {\n ...stableValue,\n triggerResolve: async () => {},\n }\n }\n}\n\nexport function Slot(config: SlotConfig = {}): SlotDefinition {\n return new SlotDefinition(config)\n}\n\nexport { SlotControl }\n"],"mappings":"AACA;AAAA,EACE,kBAAkB;AAAA,EAClB;AAAA,EACA;AAAA,OAMK;AAEP,SAAS,kBAAkB;AAsB3B,MAAe,uBAAuB,mBAA0C;AAAC;AAE1E,MAAM,uBAAuB,eAAe;AAAA,EACjD,OAAO,YAAY,MAA0C;AAC3D,QAAI,KAAK,SAAS,eAAe,MAAM;AACrC,YAAM,IAAI,MAAM,uBAAuB,eAAe,IAAI,SAAS,KAAK,IAAI,EAAE;AAAA,IAChF;AAEA,WAAO,KAAK,KAAK,UAAU,CAAC,CAAC;AAAA,EAC/B;AAAA,EAEA,YAAY,SAAqB,CAAC,GAAG;AACnC,UAAM,MAAM;AAAA,EACd;AAAA,EAEA,aACE,MACA,WACA,aACA,SACmC;AACnC,UAAM,cAAc,YAAY;AAAA,MAC9B,MAAM,eAAe;AAAA,MACrB,MAAM,MAAM,WAAW,EAAE,MAAM,SAAS,WAAW,MAAM,QAAQ,KAAK,OAAO,CAAC;AAAA,IAChF,CAAC;AAED,WAAO;AAAA,MACL,GAAG;AAAA,MACH,gBAAgB,YAAY;AAAA,MAAC;AAAA,IAC/B;AAAA,EACF;AACF;AAEO,SAAS,KAAK,SAAqB,CAAC,GAAmB;AAC5D,SAAO,IAAI,eAAe,MAAM;AAClC;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/controls/slot/index.ts"],"sourcesContent":["export { renderSlot } from './render-slot'\n"],"mappings":"AAAA,SAAS,kBAAkB;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { SlotValue } from "./slot-value";
|
|
3
|
+
function renderSlot({
|
|
4
|
+
data,
|
|
5
|
+
control,
|
|
6
|
+
config
|
|
7
|
+
}) {
|
|
8
|
+
return /* @__PURE__ */ jsx(SlotValue, { data, instanceKey: control?.instanceKey, config });
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
renderSlot
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=render-slot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/controls/slot/render-slot.tsx"],"sourcesContent":["import { type ReactNode } from 'react'\nimport { SlotDefinition, SlotControl, type DataType } from '@makeswift/controls'\n\nimport { type SlotConfig } from '../../../../controls/slot'\n\nimport { SlotValue } from './slot-value'\n\nexport function renderSlot({\n data,\n control,\n config,\n}: {\n data: DataType<SlotDefinition<ReactNode>> | undefined\n control: SlotControl | null\n config: SlotConfig\n}): ReactNode {\n // To make `SlotValue` interactive in the builder after it has been rendered as part of an\n // RSC component's server output and hydrated on the client, we need some way to connect\n // it to the corresponding control instance. Handling this purely client-side isn't an\n // option, as by itself the rendered slot has no identity we could use to look up its control\n // instance. Instantiating the instance on the server and simply passing it as a prop is\n // also not an option, as class instances like `SlotControl` can't cross the RSC server-client\n // serialization boundary. We can, however, pass the control's `instanceKey` instead, and use\n // it to look up the corresponding client-side control instance in `SlotValue` via\n // `useControlInstance`, and it works equally well for purely client-side rendering.\n return <SlotValue data={data} instanceKey={control?.instanceKey} config={config} />\n}\n"],"mappings":"AAyBS;AApBT,SAAS,iBAAiB;AAEnB,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AACF,GAIc;AAUZ,SAAO,oBAAC,aAAU,MAAY,aAAa,SAAS,aAAa,QAAgB;AACnF;","names":[]}
|
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
useEffect,
|
|
5
|
+
useState,
|
|
6
|
+
memo
|
|
7
|
+
} from "react";
|
|
4
8
|
import { cx } from "@emotion/css";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
return /* @__PURE__ */ jsx(Slot, { control, children: data.elements.map((element, i) => /* @__PURE__ */ jsx(Slot.Item, { control, grid: data.columns, index: i, children: /* @__PURE__ */ jsx(Element, { element }) }, element.key)) });
|
|
9
|
+
import {
|
|
10
|
+
SlotControl
|
|
11
|
+
} from "@makeswift/controls";
|
|
12
|
+
import { Element } from "../../components/Element";
|
|
13
|
+
import { getIndexes } from "../../../../components/utils/columns";
|
|
14
|
+
import { useResponsiveStyle } from "../../../../components/utils/responsive-style";
|
|
15
|
+
import { useIsInBuilder } from "../../hooks/use-is-in-builder";
|
|
16
|
+
import { useControlInstance } from "../../hooks/use-control-instance";
|
|
17
|
+
import { useStyle } from "../../use-style";
|
|
18
|
+
import { pollBoxModel } from "../../poll-box-model";
|
|
19
|
+
const SlotValue = memo(function SlotValue2({
|
|
20
|
+
data,
|
|
21
|
+
instanceKey,
|
|
22
|
+
config
|
|
23
|
+
}) {
|
|
24
|
+
const control = useControlInstance(instanceKey, SlotControl);
|
|
25
|
+
if (data == null || data.elements.length === 0) {
|
|
26
|
+
return /* @__PURE__ */ jsx(Slot.Placeholder, { control, placeholder: config.unstable_placeholder });
|
|
24
27
|
}
|
|
25
|
-
);
|
|
28
|
+
return /* @__PURE__ */ jsx(Slot, { control, children: data.elements.map((element, i) => /* @__PURE__ */ jsx(Slot.Item, { control, grid: data.columns, index: i, children: /* @__PURE__ */ jsx(Element, { element }) }, element.key)) });
|
|
29
|
+
});
|
|
26
30
|
function Slot({
|
|
27
31
|
as,
|
|
28
32
|
control,
|
|
@@ -153,6 +157,6 @@ function SlotPlaceholder({ control, placeholder }) {
|
|
|
153
157
|
}
|
|
154
158
|
export {
|
|
155
159
|
Slot,
|
|
156
|
-
|
|
160
|
+
SlotValue
|
|
157
161
|
};
|
|
158
|
-
//# sourceMappingURL=slot.js.map
|
|
162
|
+
//# sourceMappingURL=slot-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/controls/slot/slot-value.tsx"],"sourcesContent":["'use client'\n\nimport {\n type ComponentPropsWithoutRef,\n type ElementType,\n type ReactNode,\n useEffect,\n useState,\n memo,\n} from 'react'\nimport { cx } from '@emotion/css'\n\nimport {\n SlotDefinition,\n SlotControl,\n type DataType,\n type ControlInstanceKey,\n} from '@makeswift/controls'\n\nimport { type SlotConfig, type SlotPlaceholderConfig } from '../../../../controls/slot'\n\nimport { Element } from '../../components/Element'\nimport { getIndexes } from '../../../../components/utils/columns'\nimport { useResponsiveStyle } from '../../../../components/utils/responsive-style'\n\nimport { useIsInBuilder } from '../../hooks/use-is-in-builder'\nimport { useControlInstance } from '../../hooks/use-control-instance'\n\nimport { useStyle } from '../../use-style'\nimport { pollBoxModel } from '../../poll-box-model'\n\nexport const SlotValue = memo(function SlotValue({\n data,\n instanceKey,\n config,\n}: {\n data: DataType<SlotDefinition<ReactNode>> | undefined\n instanceKey: ControlInstanceKey | undefined\n config: SlotConfig\n}): ReactNode {\n const control = useControlInstance(instanceKey, SlotControl)\n\n // TODO(miguel): While the UI shouldn't allow the state, we should probably check that at least\n // one element is visible.\n if (data == null || data.elements.length === 0) {\n return <Slot.Placeholder control={control} placeholder={config.unstable_placeholder} />\n }\n\n return (\n <Slot control={control}>\n {data.elements.map((element, i) => (\n <Slot.Item key={element.key} control={control} grid={data.columns} index={i}>\n <Element element={element} />\n </Slot.Item>\n ))}\n </Slot>\n )\n})\n\ntype SlotProps<T extends ElementType> = {\n as?: T\n control: SlotControl | null\n children?: ReactNode\n className?: string\n}\n\nexport function Slot<T extends ElementType = 'div'>({\n as,\n control,\n children,\n className,\n ...restOfProps\n}: SlotProps<T> & Omit<ComponentPropsWithoutRef<T>, keyof SlotProps<T>>) {\n const As = as ?? 'div'\n const [element, setElement] = useState<Element | null>(null)\n const baseClassName = useStyle({\n display: 'flex',\n flexWrap: 'wrap',\n width: '100%',\n })\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeContainerBoxModel(boxModel),\n })\n }, [element, control])\n\n return (\n <As {...restOfProps} ref={setElement} className={cx(baseClassName, className)}>\n {children}\n </As>\n )\n}\n\nSlot.Placeholder = SlotPlaceholder\n\nSlot.Item = SlotItem\n\ntype SlotItemProps<T extends ElementType> = {\n as?: T\n control: SlotControl | null\n // @arvin: review for correctness\n grid: DataType<SlotDefinition<ReactNode>> extends undefined\n ? undefined\n : NonNullable<DataType<SlotDefinition<ReactNode>>>['columns']\n index: number\n children?: ReactNode\n className?: string\n}\n\nfunction SlotItem<T extends ElementType = 'div'>({\n as,\n control,\n grid,\n index,\n children,\n className,\n ...restOfProps\n}: SlotItemProps<T> & Omit<ComponentPropsWithoutRef<T>, keyof SlotItemProps<T>>): ReactNode {\n const As = as ?? 'div'\n const [element, setElement] = useState<Element | null>(null)\n const baseClassName = useStyle({\n display: 'flex',\n ...useResponsiveStyle([grid], ([{ count = 12, spans = [[12]] } = {}]) => {\n const [rowIndex, columnIndex] = getIndexes(spans, index)\n const span = spans[rowIndex][columnIndex]\n const flexBasis = `calc(100% * ${(span / count).toFixed(5)})`\n\n return span === 0 ? { display: 'none' } : { flexBasis, minWidth: flexBasis }\n }),\n })\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeItemBoxModel(index, boxModel),\n })\n }, [element, control, index])\n\n return (\n <As {...restOfProps} ref={setElement} className={cx(baseClassName, className)}>\n {children}\n </As>\n )\n}\n\ntype SlotPlaceholderProps = {\n control: SlotControl | null\n placeholder?: SlotPlaceholderConfig\n}\n\nconst DEFAULT_SHOW_PLACEHOLDER_IN_BUILDER_ONLY = false\nconst DEFAULT_PLACEHOLDER_HEIGHT_PX = 80\n\nfunction SlotPlaceholder({ control, placeholder }: SlotPlaceholderProps): ReactNode {\n const isInBuilder = useIsInBuilder()\n const [element, setElement] = useState<Element | null>(null)\n\n // TODO: When ready, we can default to only showing the slot placeholder in\n // the builder\n const showInBuilderOnly = placeholder?.builderOnly ?? DEFAULT_SHOW_PLACEHOLDER_IN_BUILDER_ONLY\n const placeholderHeight = placeholder?.height ?? DEFAULT_PLACEHOLDER_HEIGHT_PX\n const text = placeholder?.text\n\n const hidePlaceholder = showInBuilderOnly && !isInBuilder\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeContainerBoxModel(boxModel),\n })\n }, [element, control])\n\n return (\n <div\n ref={setElement}\n className={useStyle({\n width: '100%',\n background: 'rgba(161, 168, 194, 0.18)',\n })}\n style={{\n height: hidePlaceholder ? 0 : placeholderHeight,\n visibility: hidePlaceholder ? 'hidden' : undefined,\n }}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"100%\"\n height=\"100%\"\n className={useStyle({ overflow: 'visible', padding: 8 })}\n >\n <rect\n x={0}\n y={0}\n width=\"100%\"\n height=\"100%\"\n strokeWidth={2}\n strokeDasharray=\"4 2\"\n fill=\"none\"\n stroke=\"rgba(161, 168, 194, 0.40)\"\n rx=\"4\"\n ry=\"4\"\n />\n {text != null && (\n <text\n x=\"50%\"\n y=\"50%\"\n dominantBaseline=\"central\"\n textAnchor=\"middle\"\n fill=\"rgba(161, 168, 194, 0.80)\"\n fontSize=\"14px\"\n fontFamily=\"sans-serif\"\n style={{ userSelect: 'none' }}\n >\n {text}\n </text>\n )}\n </svg>\n </div>\n )\n}\n"],"mappings":";AA6CW,cAmJL,YAnJK;AA3CX;AAAA,EAIE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAU;AAEnB;AAAA,EAEE;AAAA,OAGK;AAIP,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAC3B,SAAS,0BAA0B;AAEnC,SAAS,sBAAsB;AAC/B,SAAS,0BAA0B;AAEnC,SAAS,gBAAgB;AACzB,SAAS,oBAAoB;AAEtB,MAAM,YAAY,KAAK,SAASA,WAAU;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AACF,GAIc;AACZ,QAAM,UAAU,mBAAmB,aAAa,WAAW;AAI3D,MAAI,QAAQ,QAAQ,KAAK,SAAS,WAAW,GAAG;AAC9C,WAAO,oBAAC,KAAK,aAAL,EAAiB,SAAkB,aAAa,OAAO,sBAAsB;AAAA,EACvF;AAEA,SACE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ACN,QAAO;AAAA,UACP,WAAW,SAAS,EAAE,UAAU,WAAW,SAAS,EAAE,CAAC;AAAA,UAEvD;AAAA;AAAA,cAAC;AAAA;AAAA,gBACC,GAAG;AAAA,gBACH,GAAG;AAAA,gBACH,OAAM;AAAA,gBACN,QAAO;AAAA,gBACP,aAAa;AAAA,gBACb,iBAAgB;AAAA,gBAChB,MAAK;AAAA,gBACL,QAAO;AAAA,gBACP,IAAG;AAAA,gBACH,IAAG;AAAA;AAAA,YACL;AAAA,YACC,QAAQ,QACP;AAAA,cAAC;AAAA;AAAA,gBACC,GAAE;AAAA,gBACF,GAAE;AAAA,gBACF,kBAAiB;AAAA,gBACjB,YAAW;AAAA,gBACX,MAAK;AAAA,gBACL,UAAS;AAAA,gBACT,YAAW;AAAA,gBACX,OAAO,EAAE,YAAY,OAAO;AAAA,gBAE3B;AAAA;AAAA,YACH;AAAA;AAAA;AAAA,MAEJ;AAAA;AAAA,EACF;AAEJ;","names":["SlotValue"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
2
|
import { SlotDefinition as BaseSlotDefinition, SlotControl, type DeserializedRecord, type ResourceResolver, type Stylesheet, type Resolvable, type DataType } from '@makeswift/controls';
|
|
3
3
|
export type SlotPlaceholderConfig = {
|
|
4
4
|
builderOnly?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot.d.ts","sourceRoot":"","sources":["../../../src/controls/slot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"slot.d.ts","sourceRoot":"","sources":["../../../src/controls/slot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EACL,cAAc,IAAI,kBAAkB,EACpC,WAAW,EAEX,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,QAAQ,EACd,MAAM,qBAAqB,CAAA;AAI5B,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAYD,MAAM,MAAM,UAAU,GAAG;IACvB,oBAAoB,CAAC,EAAE,qBAAqB,CAAA;CAC7C,CAAA;AAED,uBAAe,cAAe,SAAQ,kBAAkB,CAAC,SAAS,EAAE,UAAU,CAAC;CAAG;AAElF,qBAAa,cAAe,SAAQ,cAAc;IAChD,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,cAAc;gBAQhD,MAAM,GAAE,UAAe;IAInC,YAAY,CACV,IAAI,EAAE,QAAQ,CAAC,cAAc,CAAC,GAAG,SAAS,EAC1C,SAAS,EAAE,gBAAgB,EAC3B,WAAW,EAAE,UAAU,EACvB,OAAO,CAAC,EAAE,WAAW,GACpB,UAAU,CAAC,SAAS,GAAG,SAAS,CAAC;CAWrC;AAED,wBAAgB,IAAI,CAAC,MAAM,GAAE,UAAe,GAAG,cAAc,CAE5D;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/runtimes/react/controls/slot/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { SlotDefinition, SlotControl, type DataType } from '@makeswift/controls';
|
|
3
|
+
import { type SlotConfig } from '../../../../controls/slot';
|
|
4
|
+
export declare function renderSlot({ data, control, config, }: {
|
|
5
|
+
data: DataType<SlotDefinition<ReactNode>> | undefined;
|
|
6
|
+
control: SlotControl | null;
|
|
7
|
+
config: SlotConfig;
|
|
8
|
+
}): ReactNode;
|
|
9
|
+
//# sourceMappingURL=render-slot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-slot.d.ts","sourceRoot":"","sources":["../../../../../../src/runtimes/react/controls/slot/render-slot.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAEhF,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAI3D,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,OAAO,EACP,MAAM,GACP,EAAE;IACD,IAAI,EAAE,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,GAAG,SAAS,CAAA;IACrD,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;IAC3B,MAAM,EAAE,UAAU,CAAA;CACnB,GAAG,SAAS,CAWZ"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef, ElementType, ReactNode } from 'react';
|
|
2
|
-
import { SlotDefinition, SlotControl, type DataType } from '@makeswift/controls';
|
|
3
|
-
import { type SlotConfig, type SlotPlaceholderConfig } from '
|
|
4
|
-
export declare
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ElementType, type ReactNode } from 'react';
|
|
2
|
+
import { SlotDefinition, SlotControl, type DataType, type ControlInstanceKey } from '@makeswift/controls';
|
|
3
|
+
import { type SlotConfig, type SlotPlaceholderConfig } from '../../../../controls/slot';
|
|
4
|
+
export declare const SlotValue: import("react").NamedExoticComponent<{
|
|
5
5
|
data: DataType<SlotDefinition<ReactNode>> | undefined;
|
|
6
|
-
|
|
6
|
+
instanceKey: ControlInstanceKey | undefined;
|
|
7
7
|
config: SlotConfig;
|
|
8
|
-
}
|
|
8
|
+
}>;
|
|
9
9
|
type SlotProps<T extends ElementType> = {
|
|
10
10
|
as?: T;
|
|
11
11
|
control: SlotControl | null;
|
|
@@ -32,4 +32,4 @@ type SlotPlaceholderProps = {
|
|
|
32
32
|
};
|
|
33
33
|
declare function SlotPlaceholder({ control, placeholder }: SlotPlaceholderProps): ReactNode;
|
|
34
34
|
export {};
|
|
35
|
-
//# sourceMappingURL=slot.d.ts.map
|
|
35
|
+
//# sourceMappingURL=slot-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slot-value.d.ts","sourceRoot":"","sources":["../../../../../../src/runtimes/react/controls/slot/slot-value.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,WAAW,EAChB,KAAK,SAAS,EAIf,MAAM,OAAO,CAAA;AAGd,OAAO,EACL,cAAc,EACd,WAAW,EACX,KAAK,QAAQ,EACb,KAAK,kBAAkB,EACxB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAYvF,eAAO,MAAM,SAAS;UAKd,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,GAAG,SAAS;iBACxC,kBAAkB,GAAG,SAAS;YACnC,UAAU;EAmBlB,CAAA;AAEF,KAAK,SAAS,CAAC,CAAC,SAAS,WAAW,IAAI;IACtC,EAAE,CAAC,EAAE,CAAC,CAAA;IACN,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;IAC3B,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,IAAI,CAAC,CAAC,SAAS,WAAW,GAAG,KAAK,EAAE,EAClD,EAAE,EACF,OAAO,EACP,QAAQ,EACR,SAAS,EACT,GAAG,WAAW,EACf,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,MAAM,SAAS,CAAC,CAAC,CAAC,CAAC,2CAuBtE;yBA7Be,IAAI;;;;AAmCpB,KAAK,aAAa,CAAC,CAAC,SAAS,WAAW,IAAI;IAC1C,EAAE,CAAC,EAAE,CAAC,CAAA;IACN,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;IAE3B,IAAI,EAAE,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,SAAS,SAAS,GACvD,SAAS,GACT,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IAC/D,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,iBAAS,QAAQ,CAAC,CAAC,SAAS,WAAW,GAAG,KAAK,EAAE,EAC/C,EAAE,EACF,OAAO,EACP,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,SAAS,EACT,GAAG,WAAW,EACf,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,MAAM,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CA4B1F;AAED,KAAK,oBAAoB,GAAG;IAC1B,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;IAC3B,WAAW,CAAC,EAAE,qBAAqB,CAAA;CACpC,CAAA;AAKD,iBAAS,eAAe,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,oBAAoB,GAAG,SAAS,CAoElF"}
|
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.21",
|
|
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.21-canary.10",
|
|
242
241
|
"@makeswift/next-plugin": "0.6.1",
|
|
243
|
-
"@makeswift/prop-controllers": "0.4.15-canary.10"
|
|
242
|
+
"@makeswift/prop-controllers": "0.4.15-canary.10",
|
|
243
|
+
"@makeswift/controls": "0.1.21-canary.10"
|
|
244
244
|
},
|
|
245
245
|
"devDependencies": {
|
|
246
246
|
"@emotion/jest": "^11.11.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/controls/slot.tsx"],"sourcesContent":["'use client'\n\nimport { ComponentPropsWithoutRef, ElementType, ReactNode, useEffect, useState, memo } from 'react'\nimport { cx } from '@emotion/css'\n\nimport { SlotDefinition, SlotControl, type DataType } from '@makeswift/controls'\n\nimport { type SlotConfig, type SlotPlaceholderConfig } from '../../../controls/slot'\nimport { Element } from '../components/Element'\nimport { useIsInBuilder } from '../hooks/use-is-in-builder'\nimport { getIndexes } from '../../../components/utils/columns'\nimport { useResponsiveStyle } from '../../../components/utils/responsive-style'\nimport { useStyle } from '../use-style'\nimport { pollBoxModel } from '../poll-box-model'\n\nexport function renderSlot(props: {\n data: DataType<SlotDefinition<ReactNode>> | undefined\n control: SlotControl | null\n config: SlotConfig\n}): ReactNode {\n return <SlotValue {...props} />\n}\n\nconst SlotValue = memo(\n ({\n data,\n control,\n config,\n }: {\n data: DataType<SlotDefinition<ReactNode>> | undefined\n control: SlotControl | null\n config: SlotConfig\n }): ReactNode => {\n // TODO(miguel): While the UI shouldn't allow the state, we should probably check that at least\n // one element is visible.\n if (data == null || data.elements.length === 0) {\n return <Slot.Placeholder control={control} placeholder={config.unstable_placeholder} />\n }\n\n return (\n <Slot control={control}>\n {data.elements.map((element, i) => (\n <Slot.Item key={element.key} control={control} grid={data.columns} index={i}>\n <Element element={element} />\n </Slot.Item>\n ))}\n </Slot>\n )\n },\n)\n\ntype SlotProps<T extends ElementType> = {\n as?: T\n control: SlotControl | null\n children?: ReactNode\n className?: string\n}\n\nexport function Slot<T extends ElementType = 'div'>({\n as,\n control,\n children,\n className,\n ...restOfProps\n}: SlotProps<T> & Omit<ComponentPropsWithoutRef<T>, keyof SlotProps<T>>) {\n const As = as ?? 'div'\n const [element, setElement] = useState<Element | null>(null)\n const baseClassName = useStyle({\n display: 'flex',\n flexWrap: 'wrap',\n width: '100%',\n })\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeContainerBoxModel(boxModel),\n })\n }, [element, control])\n\n return (\n <As {...restOfProps} ref={setElement} className={cx(baseClassName, className)}>\n {children}\n </As>\n )\n}\n\nSlot.Placeholder = SlotPlaceholder\n\nSlot.Item = SlotItem\n\ntype SlotItemProps<T extends ElementType> = {\n as?: T\n control: SlotControl | null\n // @arvin: review for correctness\n grid: DataType<SlotDefinition<ReactNode>> extends undefined\n ? undefined\n : NonNullable<DataType<SlotDefinition<ReactNode>>>['columns']\n index: number\n children?: ReactNode\n className?: string\n}\n\nfunction SlotItem<T extends ElementType = 'div'>({\n as,\n control,\n grid,\n index,\n children,\n className,\n ...restOfProps\n}: SlotItemProps<T> & Omit<ComponentPropsWithoutRef<T>, keyof SlotItemProps<T>>): ReactNode {\n const As = as ?? 'div'\n const [element, setElement] = useState<Element | null>(null)\n const baseClassName = useStyle({\n display: 'flex',\n ...useResponsiveStyle([grid], ([{ count = 12, spans = [[12]] } = {}]) => {\n const [rowIndex, columnIndex] = getIndexes(spans, index)\n const span = spans[rowIndex][columnIndex]\n const flexBasis = `calc(100% * ${(span / count).toFixed(5)})`\n\n return span === 0 ? { display: 'none' } : { flexBasis, minWidth: flexBasis }\n }),\n })\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeItemBoxModel(index, boxModel),\n })\n }, [element, control, index])\n\n return (\n <As {...restOfProps} ref={setElement} className={cx(baseClassName, className)}>\n {children}\n </As>\n )\n}\n\ntype SlotPlaceholderProps = {\n control: SlotControl | null\n placeholder?: SlotPlaceholderConfig\n}\n\nconst DEFAULT_SHOW_PLACEHOLDER_IN_BUILDER_ONLY = false\nconst DEFAULT_PLACEHOLDER_HEIGHT_PX = 80\n\nfunction SlotPlaceholder({ control, placeholder }: SlotPlaceholderProps): ReactNode {\n const isInBuilder = useIsInBuilder()\n const [element, setElement] = useState<Element | null>(null)\n\n // TODO: When ready, we can default to only showing the slot placeholder in\n // the builder\n const showInBuilderOnly = placeholder?.builderOnly ?? DEFAULT_SHOW_PLACEHOLDER_IN_BUILDER_ONLY\n const placeholderHeight = placeholder?.height ?? DEFAULT_PLACEHOLDER_HEIGHT_PX\n const text = placeholder?.text\n\n const hidePlaceholder = showInBuilderOnly && !isInBuilder\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeContainerBoxModel(boxModel),\n })\n }, [element, control])\n\n return (\n <div\n ref={setElement}\n className={useStyle({\n width: '100%',\n background: 'rgba(161, 168, 194, 0.18)',\n })}\n style={{\n height: hidePlaceholder ? 0 : placeholderHeight,\n visibility: hidePlaceholder ? 'hidden' : undefined,\n }}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"100%\"\n height=\"100%\"\n className={useStyle({ overflow: 'visible', padding: 8 })}\n >\n <rect\n x={0}\n y={0}\n width=\"100%\"\n height=\"100%\"\n strokeWidth={2}\n strokeDasharray=\"4 2\"\n fill=\"none\"\n stroke=\"rgba(161, 168, 194, 0.40)\"\n rx=\"4\"\n ry=\"4\"\n />\n {text != null && (\n <text\n x=\"50%\"\n y=\"50%\"\n dominantBaseline=\"central\"\n textAnchor=\"middle\"\n fill=\"rgba(161, 168, 194, 0.80)\"\n fontSize=\"14px\"\n fontFamily=\"sans-serif\"\n style={{ userSelect: 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es/react/controls/slot.tsx"],"sourcesContent":["'use client'\n\nimport { ComponentPropsWithoutRef, ElementType, ReactNode, useEffect, useState, memo } from 'react'\nimport { cx } from '@emotion/css'\n\nimport { SlotDefinition, SlotControl, type DataType } from '@makeswift/controls'\n\nimport { type SlotConfig, type SlotPlaceholderConfig } from '../../../controls/slot'\nimport { Element } from '../components/Element'\nimport { useIsInBuilder } from '../hooks/use-is-in-builder'\nimport { getIndexes } from '../../../components/utils/columns'\nimport { useResponsiveStyle } from '../../../components/utils/responsive-style'\nimport { useStyle } from '../use-style'\nimport { pollBoxModel } from '../poll-box-model'\n\nexport function renderSlot(props: {\n data: DataType<SlotDefinition<ReactNode>> | undefined\n control: SlotControl | null\n config: SlotConfig\n}): ReactNode {\n return <SlotValue {...props} />\n}\n\nconst SlotValue = memo(\n ({\n data,\n control,\n config,\n }: {\n data: DataType<SlotDefinition<ReactNode>> | undefined\n control: SlotControl | null\n config: SlotConfig\n }): ReactNode => {\n // TODO(miguel): While the UI shouldn't allow the state, we should probably check that at least\n // one element is visible.\n if (data == null || data.elements.length === 0) {\n return <Slot.Placeholder control={control} placeholder={config.unstable_placeholder} />\n }\n\n return (\n <Slot control={control}>\n {data.elements.map((element, i) => (\n <Slot.Item key={element.key} control={control} grid={data.columns} index={i}>\n <Element element={element} />\n </Slot.Item>\n ))}\n </Slot>\n )\n },\n)\n\ntype SlotProps<T extends ElementType> = {\n as?: T\n control: SlotControl | null\n children?: ReactNode\n className?: string\n}\n\nexport function Slot<T extends ElementType = 'div'>({\n as,\n control,\n children,\n className,\n ...restOfProps\n}: SlotProps<T> & Omit<ComponentPropsWithoutRef<T>, keyof SlotProps<T>>) {\n const As = as ?? 'div'\n const [element, setElement] = useState<Element | null>(null)\n const baseClassName = useStyle({\n display: 'flex',\n flexWrap: 'wrap',\n width: '100%',\n })\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeContainerBoxModel(boxModel),\n })\n }, [element, control])\n\n return (\n <As {...restOfProps} ref={setElement} className={cx(baseClassName, className)}>\n {children}\n </As>\n )\n}\n\nSlot.Placeholder = SlotPlaceholder\n\nSlot.Item = SlotItem\n\ntype SlotItemProps<T extends ElementType> = {\n as?: T\n control: SlotControl | null\n // @arvin: review for correctness\n grid: DataType<SlotDefinition<ReactNode>> extends undefined\n ? undefined\n : NonNullable<DataType<SlotDefinition<ReactNode>>>['columns']\n index: number\n children?: ReactNode\n className?: string\n}\n\nfunction SlotItem<T extends ElementType = 'div'>({\n as,\n control,\n grid,\n index,\n children,\n className,\n ...restOfProps\n}: SlotItemProps<T> & Omit<ComponentPropsWithoutRef<T>, keyof SlotItemProps<T>>): ReactNode {\n const As = as ?? 'div'\n const [element, setElement] = useState<Element | null>(null)\n const baseClassName = useStyle({\n display: 'flex',\n ...useResponsiveStyle([grid], ([{ count = 12, spans = [[12]] } = {}]) => {\n const [rowIndex, columnIndex] = getIndexes(spans, index)\n const span = spans[rowIndex][columnIndex]\n const flexBasis = `calc(100% * ${(span / count).toFixed(5)})`\n\n return span === 0 ? { display: 'none' } : { flexBasis, minWidth: flexBasis }\n }),\n })\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeItemBoxModel(index, boxModel),\n })\n }, [element, control, index])\n\n return (\n <As {...restOfProps} ref={setElement} className={cx(baseClassName, className)}>\n {children}\n </As>\n )\n}\n\ntype SlotPlaceholderProps = {\n control: SlotControl | null\n placeholder?: SlotPlaceholderConfig\n}\n\nconst DEFAULT_SHOW_PLACEHOLDER_IN_BUILDER_ONLY = false\nconst DEFAULT_PLACEHOLDER_HEIGHT_PX = 80\n\nfunction SlotPlaceholder({ control, placeholder }: SlotPlaceholderProps): ReactNode {\n const isInBuilder = useIsInBuilder()\n const [element, setElement] = useState<Element | null>(null)\n\n // TODO: When ready, we can default to only showing the slot placeholder in\n // the builder\n const showInBuilderOnly = placeholder?.builderOnly ?? DEFAULT_SHOW_PLACEHOLDER_IN_BUILDER_ONLY\n const placeholderHeight = placeholder?.height ?? DEFAULT_PLACEHOLDER_HEIGHT_PX\n const text = placeholder?.text\n\n const hidePlaceholder = showInBuilderOnly && !isInBuilder\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeContainerBoxModel(boxModel),\n })\n }, [element, control])\n\n return (\n <div\n ref={setElement}\n className={useStyle({\n width: '100%',\n background: 'rgba(161, 168, 194, 0.18)',\n })}\n style={{\n height: hidePlaceholder ? 0 : placeholderHeight,\n visibility: hidePlaceholder ? 'hidden' : undefined,\n }}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"100%\"\n height=\"100%\"\n className={useStyle({ overflow: 'visible', padding: 8 })}\n >\n <rect\n x={0}\n y={0}\n width=\"100%\"\n height=\"100%\"\n strokeWidth={2}\n strokeDasharray=\"4 2\"\n fill=\"none\"\n stroke=\"rgba(161, 168, 194, 0.40)\"\n rx=\"4\"\n ry=\"4\"\n />\n {text != null && (\n <text\n x=\"50%\"\n y=\"50%\"\n dominantBaseline=\"central\"\n textAnchor=\"middle\"\n fill=\"rgba(161, 168, 194, 0.80)\"\n fontSize=\"14px\"\n fontFamily=\"sans-serif\"\n style={{ userSelect: 'none' }}\n >\n {text}\n </text>\n )}\n </svg>\n </div>\n )\n}\n"],"mappings":";AAoBS,cAoKH,YApKG;AAlBT,SAA2D,WAAW,UAAU,YAAY;AAC5F,SAAS,UAAU;AAKnB,SAAS,eAAe;AACxB,SAAS,sBAAsB;AAC/B,SAAS,kBAAkB;AAC3B,SAAS,0BAA0B;AACnC,SAAS,gBAAgB;AACzB,SAAS,oBAAoB;AAEtB,SAAS,WAAW,OAIb;AACZ,SAAO,oBAAC,aAAW,GAAG,OAAO;AAC/B;AAEA,MAAM,YAAY;AAAA,EAChB,CAAC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACF,MAIiB;AAGf,QAAI,QAAQ,QA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