@superblocksteam/library 2.0.165-next.0 → 2.0.166-next.1

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.
@@ -1,5 +1,4 @@
1
1
  import { t as getTracer } from "./utils-DXaAwgS_.js";
2
- import { PropsCategory } from "@superblocksteam/library-shared/props";
3
2
  import { action, entries, isComputedProp, isObservableArray, isObservableMap, isObservableObject, makeAutoObservable, makeObservable, observable, observe, reaction, toJS, values } from "mobx";
4
3
  import { matchRoutes } from "react-router";
5
4
  import { URL_PARAMS, getQueryParams, pathStringToArray, toMobXPatch } from "@superblocksteam/library-shared";
@@ -14,324 +13,6 @@ import { NotificationPosition } from "@superblocksteam/library-shared/types";
14
13
  import { jsx } from "react/jsx-runtime";
15
14
  import { ROOT_CONTEXT, context, propagation, trace } from "@opentelemetry/api";
16
15
  import diff from "microdiff";
17
- //#region src/lib/user-facing/properties-panel/props-builder.ts
18
- var Section = class Section {
19
- props = {};
20
- propertiesPanelConfig = {};
21
- constructor(category) {
22
- this.category = category;
23
- }
24
- static category(category) {
25
- return new Section(category);
26
- }
27
- children(props) {
28
- if (props instanceof CompositeProp || props instanceof RecordProp) this.props = {
29
- ...this.props,
30
- ...props.getProps()
31
- };
32
- else if (props instanceof UnionProp) this.props = {
33
- ...this.props,
34
- ...props.getProps()
35
- };
36
- else this.props = {
37
- ...this.props,
38
- ...props
39
- };
40
- return this;
41
- }
42
- add = this.children;
43
- /** @deprecated Panel configuration is accepted for source compatibility and ignored. */
44
- propertiesPanel(_config) {
45
- return this;
46
- }
47
- get name() {
48
- switch (this.category) {
49
- case PropsCategory.Content: return "Content";
50
- case PropsCategory.Routing: return "Routing";
51
- case PropsCategory.Interaction: return "Interaction";
52
- case PropsCategory.Layout: return "Layout";
53
- case PropsCategory.Appearance: return "Appearance";
54
- case PropsCategory.Permissions: return "Permissions";
55
- case PropsCategory.EventHandlers: return "Actions";
56
- case PropsCategory.Styles: return "Styles";
57
- default: return "Uncategorized";
58
- }
59
- }
60
- };
61
- var Prop = class Prop {
62
- prop;
63
- constructor(typeString) {
64
- this.prop = {
65
- path: "",
66
- dataType: typeString
67
- };
68
- }
69
- static unset() {
70
- return new Prop("any");
71
- }
72
- static string() {
73
- return new Prop("string");
74
- }
75
- static number() {
76
- return new Prop("number");
77
- }
78
- static boolean() {
79
- return new Prop("boolean");
80
- }
81
- static array() {
82
- return new Prop("array");
83
- }
84
- static any() {
85
- return new Prop("any");
86
- }
87
- static jsx() {
88
- return new Prop("jsx");
89
- }
90
- static literal(value) {
91
- switch (typeof value) {
92
- case "string": return Prop.string().default(value);
93
- case "number": return Prop.number().default(value);
94
- case "boolean": return Prop.boolean().default(value);
95
- default: throw new Error(`Invalid literal value: ${value}`);
96
- }
97
- }
98
- static eventHandler() {
99
- return new Prop("eventHandler");
100
- }
101
- static function(implementation) {
102
- return new FunctionProp(implementation);
103
- }
104
- /**
105
- * Creates a composite property, which is a property that contains nested properties. For example,
106
- * the following composite property:
107
- *
108
- * ```ts
109
- * const prop = Prop.composite({
110
- * name: Prop.string(),
111
- * age: Prop.number(),
112
- * });
113
- * ```
114
- *
115
- * is equivalent to the following type:
116
- *
117
- * ```ts
118
- * type Prop = {
119
- * name: string;
120
- * age: number;
121
- * };
122
- * ```
123
- */
124
- static composite(props) {
125
- return new CompositeProp(props);
126
- }
127
- /**
128
- * Creates a record property, which is a record that maps string keys to the nestedproperties. For example,
129
- * the following record property:
130
- *
131
- * ```ts
132
- * const prop = Prop.record({
133
- * name: Prop.string(),
134
- * age: Prop.number(),
135
- * });
136
- * ```
137
- *
138
- * is equivalent to the following type:
139
- *
140
- * ```ts
141
- * type Prop = Record<string, {
142
- * name: string;
143
- * age: number;
144
- * }>;
145
- * ```
146
- */
147
- static record(props) {
148
- return new RecordProp(props);
149
- }
150
- static union(props) {
151
- return new UnionProp(props.shared, props.variants);
152
- }
153
- default(de) {
154
- this.prop.default = de;
155
- return this;
156
- }
157
- contextual(computedArgs) {
158
- this.prop.contextual = true;
159
- this.prop.computedArgs = computedArgs;
160
- return this;
161
- }
162
- setName(name) {
163
- this.prop.path = name;
164
- return this;
165
- }
166
- /** @deprecated Panel configuration is accepted for source compatibility and ignored. */
167
- propertiesPanel(_schema) {
168
- return this;
169
- }
170
- /** @deprecated Panel metadata is accepted for source compatibility and ignored. */
171
- setDisplayProperty(_property, _value) {
172
- return this;
173
- }
174
- /** @deprecated Panel relations are accepted for source compatibility and ignored. */
175
- dependsOn(_relations) {
176
- return this;
177
- }
178
- getRelations() {
179
- return [];
180
- }
181
- hasPropertiesPanelDisplay() {
182
- return false;
183
- }
184
- toDefinition(_props) {}
185
- docs(docs) {
186
- this.prop.docs = docs;
187
- return this;
188
- }
189
- build() {
190
- return this.prop;
191
- }
192
- get type() {
193
- return this.prop.dataType;
194
- }
195
- get path() {
196
- return this.prop.path;
197
- }
198
- };
199
- /**
200
- * See {@link Prop.composite}
201
- */
202
- var CompositeProp = class extends Prop {
203
- typeString = "composite";
204
- nestedProps;
205
- constructor(props) {
206
- super("composite");
207
- this.nestedProps = props;
208
- }
209
- getProps() {
210
- return this.nestedProps;
211
- }
212
- propertiesPanelChildrenDisplayMode() {}
213
- };
214
- /**
215
- * See {@link Prop.record}
216
- */
217
- var RecordProp = class extends Prop {
218
- typeString = "recordOf";
219
- nestedProps;
220
- constructor(props) {
221
- super("recordOf");
222
- this.nestedProps = props;
223
- }
224
- getProps() {
225
- return this.nestedProps;
226
- }
227
- };
228
- var FunctionProp = class extends Prop {
229
- typeString = "function";
230
- constructor(implementation) {
231
- super("function");
232
- this.default(implementation);
233
- }
234
- /** @deprecated Action panel metadata is accepted for source compatibility and ignored. */
235
- actionPanel(_panel) {
236
- return this;
237
- }
238
- getActionPanel() {}
239
- };
240
- var UnionProp = class extends Prop {
241
- typeString = "union";
242
- shared;
243
- variants;
244
- constructor(shared, variants) {
245
- super("any");
246
- this.shared = shared;
247
- this.variants = variants;
248
- }
249
- getProps() {
250
- const props = { ...this.shared };
251
- for (const variant of this.variants) for (const [key, prop] of Object.entries(variant)) if (!Object.hasOwn(props, key)) props[key] = prop;
252
- return props;
253
- }
254
- };
255
- function buildCompositeDefault(prop, name, parentDefault) {
256
- const defaultThroughParent = parentDefault?.[name];
257
- const selfDefault = prop.build().default;
258
- let propDefault = defaultThroughParent ?? selfDefault;
259
- if (!propDefault && typeof parentDefault === "function") propDefault = function getNestedDefault(s) {
260
- return parentDefault.call(this, s)?.[name];
261
- };
262
- return propDefault;
263
- }
264
- function buildPropLeafDefault(prop, name, parentDefault) {
265
- const defaultThroughParent = parentDefault?.[name];
266
- let propDefault = prop.build().default ?? defaultThroughParent;
267
- if (!propDefault && typeof parentDefault === "function") propDefault = function getNestedDefault(s) {
268
- return parentDefault.call(this, s)?.[name];
269
- };
270
- return propDefault;
271
- }
272
- /**
273
- * Core traversal function that walks through all properties in sections
274
- * and calls the provided callback for each leaf property.
275
- */
276
- function traverseProps(sections, onProp, parentPath = "") {
277
- const processProps = ({ props, parentPath, parentDefault }) => {
278
- for (const [name, prop] of Object.entries(props)) {
279
- if (!prop) continue;
280
- const fullPath = parentPath ? `${parentPath}.${name}` : name;
281
- if (prop instanceof CompositeProp) {
282
- const compositeDefault = buildCompositeDefault(prop, name, parentDefault);
283
- processProps({
284
- props: prop.nestedProps,
285
- parentPath: fullPath,
286
- parentDefault: compositeDefault
287
- });
288
- } else if (prop instanceof RecordProp) {
289
- const recordPath = `${fullPath}.*`;
290
- processProps({
291
- props: prop.nestedProps,
292
- parentPath: recordPath,
293
- parentDefault: prop.build().default
294
- });
295
- } else if (prop instanceof Section) processProps({
296
- props: prop.props,
297
- parentPath
298
- });
299
- else if (prop instanceof UnionProp) {
300
- const sharedKeys = Object.keys(prop.shared);
301
- processProps({
302
- props: prop.shared,
303
- parentPath: fullPath
304
- });
305
- for (const variant of prop.variants) processProps({
306
- props: Object.fromEntries(Object.entries(variant).filter(([key]) => !sharedKeys.includes(key))),
307
- parentPath: fullPath
308
- });
309
- } else if (prop instanceof Prop) onProp(prop, fullPath, name, parentDefault);
310
- else console.warn("Invalid prop type", {
311
- name,
312
- prop
313
- });
314
- }
315
- };
316
- for (const section of Object.values(sections)) processProps({
317
- props: section.props,
318
- parentPath,
319
- parentDefault: void 0
320
- });
321
- }
322
- function createManagedPropsList(sections, parentPath = "") {
323
- const managedPropsList = [];
324
- traverseProps(sections, (prop, fullPath, name, parentDefault) => {
325
- let configuredProp = prop.setName(fullPath);
326
- const propDefault = buildPropLeafDefault(prop, name, parentDefault);
327
- if (propDefault !== void 0) configuredProp = configuredProp.default(propDefault);
328
- const builtProp = configuredProp.build();
329
- if (builtProp.dataType === "internal") return;
330
- managedPropsList.push({ ...builtProp });
331
- }, parentPath);
332
- return managedPropsList;
333
- }
334
- //#endregion
335
16
  //#region src/lib/internal-details/is-edit-mode.ts
336
17
  const getIsEditMode = () => {
337
18
  return window._SB_VIEW_MODE === "dev";
@@ -2668,7 +2349,7 @@ var ApiManager = class {
2668
2349
  }
2669
2350
  if (!entryPoint && this.rootStore.sdkApiEnabled) try {
2670
2351
  const rediscoveryT0 = performance.now();
2671
- const { discoverAndRegisterSdkApis } = await import("./sdk-api-discovery-DdbqEI70.js").then((n) => n.n);
2352
+ const { discoverAndRegisterSdkApis } = await import("./sdk-api-discovery-DvvsdT1z.js").then((n) => n.n);
2672
2353
  await discoverAndRegisterSdkApis();
2673
2354
  const rediscoveryMs = Math.round(performance.now() - rediscoveryT0);
2674
2355
  discoveryMs += rediscoveryMs;
@@ -3183,9 +2864,6 @@ const analyzePropertyType = (propData, prop) => {
3183
2864
  var ComponentRegistry = class {
3184
2865
  _componentRegistry = /* @__PURE__ */ new Map();
3185
2866
  _componentToType = /* @__PURE__ */ new WeakMap();
3186
- _defaultContainerType;
3187
- _defaultButtonType;
3188
- _defaultTextType;
3189
2867
  constructor(rootStore) {
3190
2868
  this.rootStore = rootStore;
3191
2869
  makeAutoObservable(this);
@@ -3193,8 +2871,6 @@ var ComponentRegistry = class {
3193
2871
  store: this,
3194
2872
  storeId: "component-registry",
3195
2873
  keys: {
3196
- customComponentList: true,
3197
- libraryComponentCatalogs: true,
3198
2874
  libraryComponentEditorConfigs: true,
3199
2875
  entityDefinitions: true
3200
2876
  }
@@ -3207,8 +2883,6 @@ var ComponentRegistry = class {
3207
2883
  type,
3208
2884
  propertiesDefinition: {},
3209
2885
  managedProps: [],
3210
- internalProps: [],
3211
- editorTemplates: [],
3212
2886
  editorConfig: void 0
3213
2887
  };
3214
2888
  this._componentRegistry.set(type, metadata);
@@ -3235,39 +2909,14 @@ var ComponentRegistry = class {
3235
2909
  const metadata = this.getOrCreateMetadata(type);
3236
2910
  metadata.managedProps = props;
3237
2911
  }
3238
- deleteManagedProps(type) {
3239
- const metadata = this.getOrCreateMetadata(type);
3240
- metadata.managedProps = [];
3241
- }
3242
- addEditorTemplate(type, template) {
3243
- const metadata = this.getOrCreateMetadata(type);
3244
- const existingTemplates = metadata.editorTemplates;
3245
- if (existingTemplates.some((t) => t.catalog?.displayName === template.catalog?.displayName && t.catalog?.category === template.catalog?.category)) return;
3246
- metadata.editorTemplates = [...existingTemplates, template];
3247
- }
3248
- getEditorTemplates(type) {
3249
- return this._componentRegistry.get(type)?.editorTemplates;
3250
- }
3251
2912
  getEditorConfigFromComponentType(type) {
3252
2913
  const componentStrType = this.getTypeForComponent(type);
3253
2914
  return componentStrType ? this.getEditorConfig(componentStrType) : void 0;
3254
2915
  }
3255
2916
  addEditorConfig(type, config) {
3256
- if (config.useAs) {
3257
- if (config.useAs.defaultContainer) this._defaultContainerType = type;
3258
- if (config.useAs.defaultButton) this._defaultButtonType = type;
3259
- if (config.useAs.defaultText) this._defaultTextType = type;
3260
- }
3261
2917
  const metadata = this.getOrCreateMetadata(type);
3262
2918
  metadata.editorConfig = config;
3263
2919
  }
3264
- addInternalProps(type, props) {
3265
- const metadata = this.getOrCreateMetadata(type);
3266
- metadata.internalProps = props;
3267
- }
3268
- getInternalProps(type) {
3269
- return this._componentRegistry.get(type)?.internalProps ?? [];
3270
- }
3271
2920
  getEditorConfig(type) {
3272
2921
  return this._componentRegistry.get(type)?.editorConfig;
3273
2922
  }
@@ -3299,43 +2948,11 @@ var ComponentRegistry = class {
3299
2948
  }
3300
2949
  return entityDefinitions;
3301
2950
  }
3302
- get libraryComponentCatalogs() {
3303
- const catalogs = [];
3304
- for (const [componentType, metadata] of this._componentRegistry.entries()) for (const template of metadata.editorTemplates) {
3305
- const catalog = template.catalog;
3306
- if (catalog) catalogs.push({
3307
- ...catalog,
3308
- componentType
3309
- });
3310
- }
3311
- return catalogs;
3312
- }
3313
2951
  get libraryComponentEditorConfigs() {
3314
2952
  const configs = {};
3315
2953
  for (const [componentType, metadata] of this._componentRegistry.entries()) if (metadata.editorConfig) configs[componentType] = metadata.editorConfig;
3316
2954
  return configs;
3317
2955
  }
3318
- get customComponentList() {
3319
- return Array.from(this._componentRegistry.keys());
3320
- }
3321
- get containerTypes() {
3322
- return new Set([this.defaultTagNames.container]);
3323
- }
3324
- get defaultTagNames() {
3325
- if (!this._defaultContainerType) console.warn("No default container registered - defaulting to 'Container'.");
3326
- if (!this._defaultButtonType) console.warn("No default button registered - defaulting to 'Button'.");
3327
- if (!this._defaultTextType) console.warn("No default text registered - defaulting to 'Text'.");
3328
- return {
3329
- container: this._defaultContainerType ?? "Container",
3330
- button: this._defaultButtonType ?? "Button",
3331
- text: this._defaultTextType ?? "Text"
3332
- };
3333
- }
3334
- get managedPropsRegistry() {
3335
- const registry = /* @__PURE__ */ new Map();
3336
- for (const [type, metadata] of this._componentRegistry.entries()) registry.set(type, metadata.managedProps);
3337
- return registry;
3338
- }
3339
2956
  getManagedProps(type) {
3340
2957
  return this._componentRegistry.get(type)?.managedProps ?? [];
3341
2958
  }
@@ -3355,22 +2972,6 @@ var ComponentRegistry = class {
3355
2972
  if (typeof component === "string") return this._componentRegistry.has(component);
3356
2973
  return this._componentToType.has(component);
3357
2974
  }
3358
- /**
3359
- * Get the property path with the record identifier if it exists. For example,
3360
- * `columns.columnName.label` becomes `columns.*.label`, for record properties.
3361
- */
3362
- getPropertyWithRecordIdentifier(type, path) {
3363
- const managedProps = this.getManagedProps(type);
3364
- const splitPath = path.split(".");
3365
- if (splitPath.length === 1) return path;
3366
- const [parentKey, _maybeTheRecordKey, ...rest] = splitPath;
3367
- for (const prop of managedProps) if (prop.path.startsWith(parentKey) && prop.path.includes("*") && rest.length > 0 && prop.path.endsWith(rest.join("."))) return [
3368
- parentKey,
3369
- "*",
3370
- rest.join(".")
3371
- ].join(".");
3372
- return path;
3373
- }
3374
2975
  };
3375
2976
  //#endregion
3376
2977
  //#region src/lib/internal-details/lib/root-store.ts
@@ -3582,6 +3183,6 @@ var RootStore = class {
3582
3183
  };
3583
3184
  var root_store_default = new RootStore();
3584
3185
  //#endregion
3585
- export { Section as A, iframeMessageHandler as C, createManagedPropsList as D, isEditMode as E, Prop as O, getParentOrigin as S, sendMessageImmediately as T, generateId as _, tracker as a, editorBridge as b, resolveById as c, useSuperblocksContext as d, useSuperblocksDataTags as f, embedStore as g, useSuperblocksUser as h, getContextFromTraceHeaders as i, PropsCategory as k, SuperblocksContextProvider as l, useSuperblocksProfiles as m, root_store_default as n, addNewPromise as o, useSuperblocksGroups as p, createIframeSpan as r, rejectById as s, ORCHESTRATOR_EXECUTE_RESPONSE_SIZE_LIMIT_FLAG as t, getAppMode as u, sendNotification as v, isEmbeddedBySuperblocksFirstParty as w, getEditStore as x, colors as y };
3186
+ export { iframeMessageHandler as C, isEditMode as E, getParentOrigin as S, sendMessageImmediately as T, generateId as _, tracker as a, editorBridge as b, resolveById as c, useSuperblocksContext as d, useSuperblocksDataTags as f, embedStore as g, useSuperblocksUser as h, getContextFromTraceHeaders as i, SuperblocksContextProvider as l, useSuperblocksProfiles as m, root_store_default as n, addNewPromise as o, useSuperblocksGroups as p, createIframeSpan as r, rejectById as s, ORCHESTRATOR_EXECUTE_RESPONSE_SIZE_LIMIT_FLAG as t, getAppMode as u, sendNotification as v, isEmbeddedBySuperblocksFirstParty as w, getEditStore as x, colors as y };
3586
3187
 
3587
- //# sourceMappingURL=root-store-CtsStoaR.js.map
3188
+ //# sourceMappingURL=root-store-BYYXPQRA.js.map