sculpted 0.3.2 → 0.3.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.
@@ -171,6 +171,7 @@ type RuntimeStyleEvidence = {
171
171
  readonly bounds?: RuntimeElementBounds;
172
172
  readonly ancestors?: readonly string[];
173
173
  readonly componentLayers?: readonly RuntimeComponentLayer[];
174
+ readonly inheritedStyleSources?: readonly RuntimeInheritedStyleSource[];
174
175
  };
175
176
  type RuntimeCssDeclaration = {
176
177
  readonly property: string;
@@ -198,6 +199,14 @@ type RuntimeComponentLayerElement = {
198
199
  readonly element?: Element;
199
200
  readonly inspected?: boolean;
200
201
  };
202
+ type RuntimeInheritedStyleSource = {
203
+ readonly target: PandaCssSourceTarget;
204
+ readonly depth: number;
205
+ readonly tagName: string;
206
+ readonly source?: string;
207
+ readonly component?: string;
208
+ readonly computedStyles: readonly RuntimeCssDeclaration[];
209
+ };
201
210
  type RuntimeAttribute = {
202
211
  readonly name: string;
203
212
  readonly value: string;
@@ -235,6 +244,7 @@ type InlineCssSourceCreateRequest = {
235
244
  readonly editId: string;
236
245
  readonly kind: 'panda-css-inline-source';
237
246
  readonly jsxSource: string;
247
+ readonly edits?: readonly StyleEdit[];
238
248
  readonly options?: Pick<StyleEditOptions, 'write' | 'format'>;
239
249
  };
240
250
  type StyleModuleSourceCreateRequest = {
@@ -378,4 +388,4 @@ type PreviewStyleSheet = {
378
388
  readonly rules: readonly PreviewStyleRule[];
379
389
  };
380
390
  //#endregion
381
- export { StyleModuleEditRequest as $, RuntimeAttribute as A, SourcePosition as B, OpenSourceLocationRequest as C, PreviewStyleCondition as D, PandaStyleObject as E, RuntimePropertyContext as F, StyleEdit as G, SourceTarget as H, RuntimeStyleEvidence as I, StyleEditError as J, StyleEditBatchRequest as K, SelectedElementInfo as L, RuntimeComponentLayerElement as M, RuntimeCssDeclaration as N, PreviewStyleRule as O, RuntimeElementBounds as P, StyleEditResponse as Q, SelectedElementState as R, OpenSourceLocationErrorCode as S, PandaCssSourceTarget as T, SourceTargetBase as U, SourceRange as V, SourceTargetKind as W, StyleEditOptions as X, StyleEditErrorCode as Y, StyleEditRequest as Z, InspectorManifest as _, EditorColorTokenMetadata as a, TokenConfigEditResponse as at, JsonValue as b, EditorMetadataUnavailableReason as c, EditorPropertyMetadata as d, StyleModuleSourceAttachRequest as et, EditorTokenSourceSection as f, InspectorEditorMetadata as g, InlineCssSourceCreateRequest as h, DynamicSourceTarget as i, TokenConfigEditRequest as it, RuntimeComponentLayer as j, PreviewStyleSheet as k, EditorMetadataUpdateEvent as l, ExternalSourceTarget as m, ComponentStyleModuleSource as n, StyleModuleSourceDetachRequest as nt, EditorFontTokenMetadata as o, UnsupportedReason as ot, EditorTokenSourceTarget as p, StyleEditBatchResponse as q, Confidence as r, StyleValueSource as rt, EditorMetadataSection as s, UnsupportedSourceTarget as st, ComponentStyleModuleResponse as t, StyleModuleSourceCreateRequest as tt, EditorPropertyCategory as u, InspectorManifestEntry as v, OpenSourceLocationResponse as w, ManifestUpdateEvent as x, JsonPrimitive as y, SourceLocation as z };
391
+ export { StyleEditResponse as $, RuntimeAttribute as A, SourceLocation as B, OpenSourceLocationRequest as C, PreviewStyleCondition as D, PandaStyleObject as E, RuntimeInheritedStyleSource as F, SourceTargetKind as G, SourceRange as H, RuntimePropertyContext as I, StyleEditBatchResponse as J, StyleEdit as K, RuntimeStyleEvidence as L, RuntimeComponentLayerElement as M, RuntimeCssDeclaration as N, PreviewStyleRule as O, RuntimeElementBounds as P, StyleEditRequest as Q, SelectedElementInfo as R, OpenSourceLocationErrorCode as S, PandaCssSourceTarget as T, SourceTarget as U, SourcePosition as V, SourceTargetBase as W, StyleEditErrorCode as X, StyleEditError as Y, StyleEditOptions as Z, InspectorManifest as _, EditorColorTokenMetadata as a, TokenConfigEditRequest as at, JsonValue as b, EditorMetadataUnavailableReason as c, UnsupportedSourceTarget as ct, EditorPropertyMetadata as d, StyleModuleEditRequest as et, EditorTokenSourceSection as f, InspectorEditorMetadata as g, InlineCssSourceCreateRequest as h, DynamicSourceTarget as i, StyleValueSource as it, RuntimeComponentLayer as j, PreviewStyleSheet as k, EditorMetadataUpdateEvent as l, ExternalSourceTarget as m, ComponentStyleModuleSource as n, StyleModuleSourceCreateRequest as nt, EditorFontTokenMetadata as o, TokenConfigEditResponse as ot, EditorTokenSourceTarget as p, StyleEditBatchRequest as q, Confidence as r, StyleModuleSourceDetachRequest as rt, EditorMetadataSection as s, UnsupportedReason as st, ComponentStyleModuleResponse as t, StyleModuleSourceAttachRequest as tt, EditorPropertyCategory as u, InspectorManifestEntry as v, OpenSourceLocationResponse as w, ManifestUpdateEvent as x, JsonPrimitive as y, SelectedElementState as z };
package/dist/ui.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as RuntimePropertyContext, L as SelectedElementInfo, N as RuntimeCssDeclaration, j as RuntimeComponentLayer } from "./types-CdByW0ji.mjs";
2
- import { r as SculptedRuntime } from "./runtime-C1gUOAc9.mjs";
1
+ import { I as RuntimePropertyContext, N as RuntimeCssDeclaration, R as SelectedElementInfo, j as RuntimeComponentLayer } from "./types-0a4hNfAF.mjs";
2
+ import { r as SculptedRuntime } from "./runtime-Cpxddehp.mjs";
3
3
 
4
4
  //#region src/ui/inspectorPanel.d.ts
5
5
  type ReadonlyInspectorPanelOptions = {
@@ -17,6 +17,7 @@ type ReadonlyInspectorPanelView = {
17
17
  readonly editable: boolean;
18
18
  readonly styleRows: readonly ReadonlyInspectorPanelRow[];
19
19
  readonly editableTargets: readonly ReadonlyInspectorPanelTarget[];
20
+ readonly inheritedTargets: readonly ReadonlyInspectorPanelInheritedTarget[];
20
21
  readonly inlineSourceCreate?: ReadonlyInspectorPanelInlineSourceCreate;
21
22
  readonly inspectedJsxSource?: string;
22
23
  readonly inspectedComponentSource?: string;
@@ -44,6 +45,10 @@ type ReadonlyInspectorPanelTarget = {
44
45
  readonly jsxSourceAliases?: readonly string[];
45
46
  readonly styleRows: readonly ReadonlyInspectorPanelRow[];
46
47
  };
48
+ type ReadonlyInspectorPanelInheritedTarget = ReadonlyInspectorPanelTarget & {
49
+ readonly depth: number;
50
+ readonly inheritedFrom: string;
51
+ };
47
52
  type ReadonlyInspectorPanelReadonlyTarget = {
48
53
  readonly id: string;
49
54
  readonly kind: string;
package/dist/ui.mjs CHANGED
@@ -7257,6 +7257,7 @@ function selectedElementPanelView(info) {
7257
7257
  editable: false,
7258
7258
  styleRows: [],
7259
7259
  editableTargets: [],
7260
+ inheritedTargets: [],
7260
7261
  inlineSourceCreate: void 0,
7261
7262
  inspectedJsxSource: void 0,
7262
7263
  inspectedComponentSource: void 0,
@@ -7286,6 +7287,7 @@ function selectedElementPanelView(info) {
7286
7287
  const editable = editableTargets.length > 0;
7287
7288
  const styleRows = editableTargets.flatMap((editableTarget) => editableTarget.styleRows);
7288
7289
  const editableComputedProperties = editableComputedPropertySet(editableTargets);
7290
+ const inheritedTargets = inheritedEditableTargets(info.evidence?.inheritedStyleSources ?? [], info.evidence?.computedStyles ?? [], editableComputedProperties);
7289
7291
  const inspectedJsxSource = inspectedComponentLayerSource(info.evidence?.componentLayers ?? []);
7290
7292
  const inspectedComponentSource = inspectedComponentSourceLocation(info.evidence?.componentLayers ?? []);
7291
7293
  const hasInlineEditableSource = editableTargets.some((editableTarget) => editableTarget.attribute === "class" || editableTarget.attribute === "className");
@@ -7296,6 +7298,7 @@ function selectedElementPanelView(info) {
7296
7298
  editable,
7297
7299
  styleRows,
7298
7300
  editableTargets,
7301
+ inheritedTargets,
7299
7302
  inlineSourceCreate: inspectedJsxSource && !hasInlineEditableSource ? { jsxSource: inspectedJsxSource } : void 0,
7300
7303
  inspectedJsxSource,
7301
7304
  inspectedComponentSource,
@@ -7361,6 +7364,52 @@ function previewInputValue(value, path) {
7361
7364
  function visibleComputedRows(computedStyles, editableComputedProperties = /* @__PURE__ */ new Set()) {
7362
7365
  return computedStyles.filter((row) => !isKnownInitialComputedValue(row) && !editableComputedProperties.has(row.property.toLowerCase())).slice(0, 16);
7363
7366
  }
7367
+ function inheritedEditableTargets(sources, inspectedComputedStyles, ownComputedProperties) {
7368
+ if (sources.length === 0 || inspectedComputedStyles.length === 0) return [];
7369
+ const inspectedComputed = declarationValueMap(inspectedComputedStyles);
7370
+ const claimedProperties = /* @__PURE__ */ new Set();
7371
+ const inheritedTargets = [];
7372
+ for (const source of sources) {
7373
+ const ancestorComputed = declarationValueMap(source.computedStyles);
7374
+ const inheritedRows = [];
7375
+ const targetRows = styleObjectRows(source.target.styleObject);
7376
+ for (const row of targetRows) {
7377
+ if (row.previewValue === void 0) continue;
7378
+ const inheritedProperties = previewDeclarationsForPandaInput(row.path.split("."), row.previewValue).flatMap((declaration) => expandedComputedProperties(declaration.property)).filter((property) => INHERITED_COMPUTED_PROPERTIES.has(property));
7379
+ if (inheritedProperties.length === 0) continue;
7380
+ const matchingProperties = inheritedProperties.filter((property) => {
7381
+ if (ownComputedProperties.has(property) || claimedProperties.has(property)) return false;
7382
+ const inspectedValue = inspectedComputed.get(property);
7383
+ if (!inspectedValue) return false;
7384
+ return inspectedValue === ancestorComputed.get(property);
7385
+ });
7386
+ if (matchingProperties.length === 0) continue;
7387
+ inheritedRows.push(row);
7388
+ matchingProperties.forEach((property) => {
7389
+ claimedProperties.add(property);
7390
+ });
7391
+ }
7392
+ if (inheritedRows.length === 0) continue;
7393
+ inheritedTargets.push({
7394
+ id: source.target.id,
7395
+ name: source.target.name,
7396
+ source: source.target.file,
7397
+ sourceLocation: sourceLocationLabel(source.target.file, source.target.loc),
7398
+ attribute: source.target.attribute,
7399
+ jsxSource: source.target.jsxSource,
7400
+ jsxSourceAliases: source.target.jsxSourceAliases,
7401
+ styleRows: inheritedRows,
7402
+ depth: source.depth,
7403
+ inheritedFrom: source.component ?? source.source ?? `${source.tagName}${source.depth === 1 ? " parent" : ` ancestor ${source.depth}`}`
7404
+ });
7405
+ }
7406
+ return inheritedTargets;
7407
+ }
7408
+ function declarationValueMap(declarations) {
7409
+ const values = /* @__PURE__ */ new Map();
7410
+ for (const declaration of declarations) values.set(declaration.property.toLowerCase(), declaration.value.trim());
7411
+ return values;
7412
+ }
7364
7413
  function editableComputedPropertySet(targets) {
7365
7414
  const properties = /* @__PURE__ */ new Set();
7366
7415
  for (const target of targets) for (const row of target.styleRows) {
@@ -7412,6 +7461,21 @@ const KNOWN_COMPUTED_INITIAL_VALUES = {
7412
7461
  "z-index": "auto"
7413
7462
  };
7414
7463
  const COMPUTED_PROPERTY_EXPANSIONS = {
7464
+ font: [
7465
+ "font-family",
7466
+ "font-size",
7467
+ "font-stretch",
7468
+ "font-style",
7469
+ "font-variant",
7470
+ "font-weight",
7471
+ "line-height"
7472
+ ],
7473
+ "list-style": [
7474
+ "list-style-image",
7475
+ "list-style-position",
7476
+ "list-style-type"
7477
+ ],
7478
+ text: ["color"],
7415
7479
  border: [
7416
7480
  "border-bottom-color",
7417
7481
  "border-bottom-style",
@@ -7443,6 +7507,39 @@ const COMPUTED_PROPERTY_EXPANSIONS = {
7443
7507
  "padding-inline": ["padding-left", "padding-right"],
7444
7508
  "padding-block": ["padding-bottom", "padding-top"]
7445
7509
  };
7510
+ const INHERITED_COMPUTED_PROPERTIES = new Set([
7511
+ "border-collapse",
7512
+ "border-spacing",
7513
+ "caption-side",
7514
+ "color",
7515
+ "cursor",
7516
+ "direction",
7517
+ "empty-cells",
7518
+ "font-family",
7519
+ "font-feature-settings",
7520
+ "font-kerning",
7521
+ "font-size",
7522
+ "font-stretch",
7523
+ "font-style",
7524
+ "font-variant",
7525
+ "font-variant-caps",
7526
+ "font-weight",
7527
+ "letter-spacing",
7528
+ "line-height",
7529
+ "list-style-image",
7530
+ "list-style-position",
7531
+ "list-style-type",
7532
+ "quotes",
7533
+ "tab-size",
7534
+ "text-align",
7535
+ "text-indent",
7536
+ "text-rendering",
7537
+ "text-transform",
7538
+ "visibility",
7539
+ "white-space",
7540
+ "word-break",
7541
+ "word-spacing"
7542
+ ]);
7446
7543
  function isStyleValue(value) {
7447
7544
  return value.kind === "literal" || value.kind === "unsupported";
7448
7545
  }
@@ -7662,11 +7759,11 @@ function InspectorPanel(props) {
7662
7759
  const contentScroller = A$1(null);
7663
7760
  const previousPreviewBarVisible = A$1(false);
7664
7761
  const pendingPreviewBarScrollDelta = A$1(0);
7665
- const inputMenuOpenCount = useSignal(0);
7666
- const previewBarVisible = useSignal(false);
7762
+ const inputMenuOpen = useSignal(false);
7667
7763
  const view = useComputed(() => selectedElementPanelView(selected.value));
7668
7764
  const inspectedComponentSource = useComputed(() => view.value.inspectedComponentSource);
7669
7765
  const previewChangeCount = useComputed(() => pendingPreviewChanges.value.size);
7766
+ const previewBarVisible = useComputed(() => previewChangeCount.value > 0 && !inputMenuOpen.value);
7670
7767
  const canUndoPreview = useComputed(() => previewUndoStack.value.length > 0 || previewHistoryBatchOpen.value);
7671
7768
  const canRedoPreview = useComputed(() => previewRedoStack.value.length > 0);
7672
7769
  const saving = useComputed(() => saveFlow.value.status === "saving");
@@ -7716,6 +7813,7 @@ function InspectorPanel(props) {
7716
7813
  };
7717
7814
  }, (error) => {
7718
7815
  if (inspectedComponentSource.value !== componentSource) return;
7816
+ logUnexpectedInspectorError("Failed to load component style module.", error);
7719
7817
  elementStyleModule.value = {
7720
7818
  status: "error",
7721
7819
  componentSource,
@@ -7724,13 +7822,11 @@ function InspectorPanel(props) {
7724
7822
  });
7725
7823
  }, [inspectedComponentSource.value]);
7726
7824
  _$2(() => {
7727
- const visible = previewChangeCount.value > 0;
7728
- if (inputMenuOpenCount.value > 0) return;
7825
+ const visible = previewBarVisible.value;
7729
7826
  if (visible === previousPreviewBarVisible.current) return;
7730
7827
  pendingPreviewBarScrollDelta.current += visible ? PREVIEW_CHANGES_BAR_HEIGHT : -45;
7731
7828
  previousPreviewBarVisible.current = visible;
7732
- previewBarVisible.value = visible;
7733
- }, [previewChangeCount.value > 0, inputMenuOpenCount.value]);
7829
+ }, [previewBarVisible.value]);
7734
7830
  _$2(() => {
7735
7831
  const scrollDelta = pendingPreviewBarScrollDelta.current;
7736
7832
  if (scrollDelta === 0) return;
@@ -7740,7 +7836,7 @@ function InspectorPanel(props) {
7740
7836
  scroller.scrollTop = Math.max(0, scroller.scrollTop + scrollDelta);
7741
7837
  }, [previewBarVisible.value]);
7742
7838
  const onInputMenuOpenChange = (open) => {
7743
- inputMenuOpenCount.value = Math.max(0, inputMenuOpenCount.value + (open ? 1 : -1));
7839
+ inputMenuOpen.value = open;
7744
7840
  };
7745
7841
  _$2(() => {
7746
7842
  const onAddPropertyShortcut = (event) => {
@@ -7802,7 +7898,8 @@ function InspectorPanel(props) {
7802
7898
  runtime.applyForcedStates?.(selectedElement.current, Array.from(forcedPreviewStates.value));
7803
7899
  const declarationsByEditId = /* @__PURE__ */ new Map();
7804
7900
  const includedChangeKeys = /* @__PURE__ */ new Set();
7805
- for (const target of view.value.editableTargets) for (const row of target.styleRows) {
7901
+ const previewTargets = editableTargetsWithPendingInlineSource(view.value, pendingPreviewChanges.value);
7902
+ for (const target of previewTargets) for (const row of target.styleRows) {
7806
7903
  if (row.previewValue === void 0) continue;
7807
7904
  const path = row.path.split(".");
7808
7905
  const condition = pandaPreviewCondition(path);
@@ -8246,6 +8343,7 @@ function InspectorPanel(props) {
8246
8343
  const changesByEditId = /* @__PURE__ */ new Map();
8247
8344
  for (const change of pendingPreviewChanges.value.values()) {
8248
8345
  if (isInlineSourcePreviewChange(change)) continue;
8346
+ if (change.editId.startsWith("inline-source:")) continue;
8249
8347
  if (isStyleModulePreviewChange(change)) continue;
8250
8348
  if (styleModuleCreateEditIds.has(change.editId)) continue;
8251
8349
  changesByEditId.set(change.editId, [...changesByEditId.get(change.editId) ?? [], change]);
@@ -8274,10 +8372,24 @@ function InspectorPanel(props) {
8274
8372
  flushPreviewHistoryBatch();
8275
8373
  return Array.from(pendingPreviewChanges.value.values()).flatMap((change) => {
8276
8374
  if (!isInlineSourcePreviewChange(change)) return [];
8375
+ const edits = Array.from(pendingPreviewChanges.value.values()).flatMap((propertyChange) => {
8376
+ if (propertyChange.editId !== change.editId) return [];
8377
+ if (isInlineSourcePreviewChange(propertyChange)) return [];
8378
+ if (propertyChange.op === "delete") return [{
8379
+ op: "delete",
8380
+ path: propertyChange.path
8381
+ }];
8382
+ return [{
8383
+ op: "set",
8384
+ path: propertyChange.path,
8385
+ value: propertyChange.value
8386
+ }];
8387
+ });
8277
8388
  return [{
8278
8389
  editId: change.editId,
8279
8390
  kind: "panda-css-inline-source",
8280
- jsxSource: change.value
8391
+ jsxSource: change.value,
8392
+ edits: edits.length > 0 ? edits : void 0
8281
8393
  }];
8282
8394
  });
8283
8395
  };
@@ -8330,15 +8442,29 @@ function InspectorPanel(props) {
8330
8442
  const styleModuleRequests = createStyleModuleRequests();
8331
8443
  if (requests.length === 0 && inlineSourceRequests.length === 0 && styleModuleRequests.length === 0) return;
8332
8444
  saveFlow.value = { status: "saving" };
8333
- const styleResponses = requests.length > 0 ? runtime.requestStyleEditBatch(requests, true) : Promise.resolve([]);
8334
- const inlineSourceResponses = Promise.all(inlineSourceRequests.map((request) => runtime.requestInlineCssSource(request, true)));
8335
- const styleModuleResponses = Promise.all(styleModuleRequests.map((request) => runtime.requestStyleModuleEdit(request, true)));
8336
- Promise.all([
8337
- styleResponses,
8338
- inlineSourceResponses,
8339
- styleModuleResponses
8340
- ]).then(async (responses) => {
8341
- const allResponses = responses.flat();
8445
+ const saveOperationCount = (requests.length > 0 ? 1 : 0) + inlineSourceRequests.length + styleModuleRequests.length;
8446
+ const requestResponses = (write) => {
8447
+ const styleResponses = requests.length > 0 ? runtime.requestStyleEditBatch(requests, write) : Promise.resolve([]);
8448
+ const inlineSourceResponses = Promise.all(inlineSourceRequests.map((request) => runtime.requestInlineCssSource(request, write)));
8449
+ const styleModuleResponses = Promise.all(styleModuleRequests.map((request) => runtime.requestStyleModuleEdit(request, write)));
8450
+ return Promise.all([
8451
+ styleResponses,
8452
+ inlineSourceResponses,
8453
+ styleModuleResponses
8454
+ ]).then((responses) => responses.flat());
8455
+ };
8456
+ (async () => {
8457
+ if (saveOperationCount > 1) {
8458
+ const dryRunFailure = (await requestResponses(false)).find((response) => !response.ok);
8459
+ if (dryRunFailure) {
8460
+ saveFlow.value = {
8461
+ status: "error",
8462
+ message: styleEditResponseMessage(dryRunFailure)
8463
+ };
8464
+ return;
8465
+ }
8466
+ }
8467
+ const allResponses = await requestResponses(true);
8342
8468
  const failure = allResponses.find((response) => !response.ok);
8343
8469
  if (failure) {
8344
8470
  saveFlow.value = {
@@ -8347,6 +8473,9 @@ function InspectorPanel(props) {
8347
8473
  };
8348
8474
  return;
8349
8475
  }
8476
+ return allResponses;
8477
+ })().then(async (allResponses) => {
8478
+ if (!allResponses) return;
8350
8479
  if (allResponses.find((response) => !response.manifestUpdate)) {
8351
8480
  saveFlow.value = {
8352
8481
  status: "error",
@@ -8357,6 +8486,7 @@ function InspectorPanel(props) {
8357
8486
  try {
8358
8487
  await refreshSelectedElementInfo();
8359
8488
  } catch (error) {
8489
+ logUnexpectedInspectorError("Failed to refresh selection after save.", error);
8360
8490
  saveFlow.value = {
8361
8491
  status: "error",
8362
8492
  message: errorMessage(error)
@@ -8367,6 +8497,7 @@ function InspectorPanel(props) {
8367
8497
  resetPreviewHistory();
8368
8498
  saveFlow.value = { status: "idle" };
8369
8499
  }, (error) => {
8500
+ logUnexpectedInspectorError("Failed to save preview changes.", error);
8370
8501
  saveFlow.value = {
8371
8502
  status: "error",
8372
8503
  message: errorMessage(error)
@@ -8403,6 +8534,7 @@ function InspectorPanel(props) {
8403
8534
  module: response
8404
8535
  };
8405
8536
  }, (error) => {
8537
+ logUnexpectedInspectorError("Failed to open style module.", error);
8406
8538
  styleModulePanel.value = {
8407
8539
  status: "error",
8408
8540
  component,
@@ -8698,6 +8830,67 @@ function InspectorPanel(props) {
8698
8830
  shorthandFocusRequest.value = null;
8699
8831
  }
8700
8832
  }),
8833
+ /* @__PURE__ */ u(EditableTargetsSection, {
8834
+ heading: "Inherited Styles",
8835
+ targets: view.value.inheritedTargets,
8836
+ view,
8837
+ preview,
8838
+ forcedPreviewStates,
8839
+ expandedShorthandInputs,
8840
+ shorthandFocusRequest,
8841
+ colorTokenOptions,
8842
+ fontTokenOptions,
8843
+ tokenSources,
8844
+ propertyOptions,
8845
+ saving,
8846
+ addedInputActivationRequest,
8847
+ onPreviewInput: updatePreviewInput,
8848
+ onCreateColorToken: createColorToken,
8849
+ onAddedInputActivationHandled: () => {
8850
+ addedInputActivationRequest.value = null;
8851
+ },
8852
+ onAddProperty: addPreviewProperty,
8853
+ onCreateInlineSource: createInlineSource,
8854
+ onRemoveProperty: removePreviewProperty,
8855
+ onFocusRestoreButton: focusRestoreButton,
8856
+ onFocusPreviewControl: focusPreviewControlByTarget,
8857
+ onRestoreProperty: restorePreviewProperty,
8858
+ onHighlightSourceTarget: (editId) => {
8859
+ runtime.highlightSourceTarget(editId);
8860
+ },
8861
+ onClearHighlight: () => {
8862
+ runtime.clearHighlight();
8863
+ },
8864
+ onOpenSource: (source) => {
8865
+ runtime.openSourceLocation({
8866
+ kind: "source",
8867
+ source
8868
+ });
8869
+ },
8870
+ onInputMenuOpenChange,
8871
+ onToggleShorthandInput: (key) => {
8872
+ const next = new Set(expandedShorthandInputs.value);
8873
+ if (next.has(key)) next.delete(key);
8874
+ else next.add(key);
8875
+ expandedShorthandInputs.value = next;
8876
+ },
8877
+ onExpandShorthandInput: (key) => {
8878
+ if (expandedShorthandInputs.value.has(key)) return;
8879
+ expandedShorthandInputs.value = new Set([...expandedShorthandInputs.value, key]);
8880
+ },
8881
+ onCollapseShorthandInput: (key) => {
8882
+ if (!expandedShorthandInputs.value.has(key)) return;
8883
+ const next = new Set(expandedShorthandInputs.value);
8884
+ next.delete(key);
8885
+ expandedShorthandInputs.value = next;
8886
+ },
8887
+ onRequestShorthandFocus: (request) => {
8888
+ shorthandFocusRequest.value = request;
8889
+ },
8890
+ onShorthandFocusRequestHandled: () => {
8891
+ shorthandFocusRequest.value = null;
8892
+ }
8893
+ }),
8701
8894
  /* @__PURE__ */ u(ComponentLayersSection, {
8702
8895
  view,
8703
8896
  onOpenStyleModule: openStyleModule,
@@ -9251,6 +9444,7 @@ function StyleModuleSection(props) {
9251
9444
  editable: editableStyleTargets.length > 0,
9252
9445
  styleRows: editableStyleTargets.flatMap((target) => target.styleRows),
9253
9446
  editableTargets: editableStyleTargets,
9447
+ inheritedTargets: [],
9254
9448
  inlineSourceCreate: void 0,
9255
9449
  inspectedJsxSource: void 0,
9256
9450
  inspectedComponentSource: void 0,
@@ -9364,7 +9558,9 @@ function StyleModuleSection(props) {
9364
9558
  });
9365
9559
  }
9366
9560
  function EditableTargetsSection(props) {
9367
- const { view, preview, elementStyleModule, heading = "Style Sources", forcedPreviewStates, expandedShorthandInputs, shorthandFocusRequest, colorTokenOptions, fontTokenOptions, tokenSources, propertyOptions, saving, addedInputActivationRequest, onPreviewInput, onCreateColorToken, onAddedInputActivationHandled, onAddProperty, onCreateInlineSource, onAttachStyleModuleSource, onDetachStyleModuleSource, onRemoveProperty, onFocusRestoreButton, onFocusPreviewControl, onRestoreProperty, onHighlightSourceTarget, onClearHighlight, onOpenSource, onInputMenuOpenChange, onToggleShorthandInput, onExpandShorthandInput, onCollapseShorthandInput, onRequestShorthandFocus, onShorthandFocusRequestHandled } = props;
9561
+ const { view, targets, preview, elementStyleModule, heading = "Style Sources", forcedPreviewStates, expandedShorthandInputs, shorthandFocusRequest, colorTokenOptions, fontTokenOptions, tokenSources, propertyOptions, saving, addedInputActivationRequest, onPreviewInput, onCreateColorToken, onAddedInputActivationHandled, onAddProperty, onCreateInlineSource, onAttachStyleModuleSource, onDetachStyleModuleSource, onRemoveProperty, onFocusRestoreButton, onFocusPreviewControl, onRestoreProperty, onHighlightSourceTarget, onClearHighlight, onOpenSource, onInputMenuOpenChange, onToggleShorthandInput, onExpandShorthandInput, onCollapseShorthandInput, onRequestShorthandFocus, onShorthandFocusRequestHandled } = props;
9562
+ const sourceManagementEnabled = targets === void 0;
9563
+ const baseEditableTargets = targets ?? view.value.editableTargets;
9368
9564
  const inspectedJsxSource = view.value.inspectedJsxSource;
9369
9565
  const inspectedComponentSource = view.value.inspectedComponentSource;
9370
9566
  const readyElementStyleModule = elementStyleModule?.value.status === "ready" && elementStyleModule.value.componentSource === inspectedComponentSource && elementStyleModule.value.module.exists ? elementStyleModule.value.module : void 0;
@@ -9373,7 +9569,7 @@ function EditableTargetsSection(props) {
9373
9569
  const action = styleModuleActionForPreviewChange(change);
9374
9570
  if (action && action.kind !== "create" && action.componentSource === inspectedComponentSource && action.jsxSource === inspectedJsxSource) styleModulePendingActions.push(action);
9375
9571
  }
9376
- const attachedStyleSourceNames = new Set(view.value.editableTargets.flatMap((target) => target.name && inspectedJsxSource && (target.jsxSource === inspectedJsxSource || (target.jsxSourceAliases ?? []).includes(inspectedJsxSource)) ? [target.name] : []));
9572
+ const attachedStyleSourceNames = new Set(baseEditableTargets.flatMap((target) => target.name && inspectedJsxSource && (target.jsxSource === inspectedJsxSource || (target.jsxSourceAliases ?? []).includes(inspectedJsxSource)) ? [target.name] : []));
9377
9573
  for (const action of styleModulePendingActions) {
9378
9574
  if (action.kind === "attach") attachedStyleSourceNames.add(action.name);
9379
9575
  if (action.kind === "detach") attachedStyleSourceNames.delete(action.name);
@@ -9385,7 +9581,26 @@ function EditableTargetsSection(props) {
9385
9581
  } : void 0;
9386
9582
  const canAttachStyleSource = attachStyleSourceContext !== void 0;
9387
9583
  const pendingAttachedStyleSources = styleModulePendingActions.filter((action) => action.kind === "attach");
9388
- if (view.value.editableTargets.length === 0 && !view.value.inlineSourceCreate && !canAttachStyleSource) return null;
9584
+ const pendingAttachedStyleSourceTargets = sourceManagementEnabled && inspectedJsxSource ? pendingAttachedStyleSources.flatMap((action) => {
9585
+ const source = readyElementStyleModule?.sources.find((candidate) => candidate.name === action.name);
9586
+ if (!source?.editId || !source.styleObject) return [];
9587
+ return [{
9588
+ id: source.editId,
9589
+ name: source.name,
9590
+ source: source.file,
9591
+ sourceLocation: source.editId,
9592
+ jsxSource: inspectedJsxSource,
9593
+ styleRows: styleObjectRows(source.styleObject)
9594
+ }];
9595
+ }) : [];
9596
+ const pendingInlineSourceTarget = sourceManagementEnabled ? pendingInlineSourceTargetForView(view.value, preview.changes.value) : void 0;
9597
+ const editableTargets = [
9598
+ ...baseEditableTargets,
9599
+ ...pendingAttachedStyleSourceTargets,
9600
+ ...pendingInlineSourceTarget ? [pendingInlineSourceTarget] : []
9601
+ ];
9602
+ const inlineSourceCreate = sourceManagementEnabled && view.value.inlineSourceCreate && !pendingInlineSourceTarget ? view.value.inlineSourceCreate : void 0;
9603
+ if (editableTargets.length === 0 && (!sourceManagementEnabled || !inlineSourceCreate) && (!sourceManagementEnabled || !canAttachStyleSource)) return null;
9389
9604
  return /* @__PURE__ */ u("section", {
9390
9605
  "data-editable-sources-section": "true",
9391
9606
  children: [
@@ -9396,19 +9611,19 @@ function EditableTargetsSection(props) {
9396
9611
  },
9397
9612
  children: heading
9398
9613
  }) : null,
9399
- view.value.inlineSourceCreate || canAttachStyleSource ? /* @__PURE__ */ u("div", {
9614
+ sourceManagementEnabled && (inlineSourceCreate || canAttachStyleSource) ? /* @__PURE__ */ u("div", {
9400
9615
  style: {
9401
9616
  display: "flex",
9402
9617
  flexWrap: "wrap",
9403
9618
  gap: "6px",
9404
9619
  marginTop: "4px"
9405
9620
  },
9406
- children: [view.value.inlineSourceCreate ? /* @__PURE__ */ u("button", {
9621
+ children: [inlineSourceCreate ? /* @__PURE__ */ u("button", {
9407
9622
  type: "button",
9408
9623
  "data-action": "create-inline-source",
9409
9624
  disabled: saving.value,
9410
9625
  onClick: () => {
9411
- if (view.value.inlineSourceCreate) onCreateInlineSource(view.value.inlineSourceCreate.jsxSource);
9626
+ onCreateInlineSource(inlineSourceCreate.jsxSource);
9412
9627
  },
9413
9628
  children: /* @__PURE__ */ u("span", {
9414
9629
  style: {
@@ -9431,40 +9646,7 @@ function EditableTargetsSection(props) {
9431
9646
  onMenuOpenChange: onInputMenuOpenChange
9432
9647
  }) : null]
9433
9648
  }) : null,
9434
- pendingAttachedStyleSources.length > 0 && onDetachStyleModuleSource ? /* @__PURE__ */ u("div", {
9435
- style: {
9436
- display: "grid",
9437
- gap: "4px",
9438
- marginTop: "8px"
9439
- },
9440
- children: pendingAttachedStyleSources.map((action) => /* @__PURE__ */ u("div", {
9441
- "data-pending-attached-style-source": "true",
9442
- style: {
9443
- display: "grid",
9444
- gridTemplateColumns: "minmax(0, 1fr) 24px",
9445
- alignItems: "center",
9446
- gap: "6px",
9447
- color: "#526070"
9448
- },
9449
- children: [/* @__PURE__ */ u("code", { children: [action.name, " (pending)"] }), /* @__PURE__ */ u("button", {
9450
- type: "button",
9451
- "data-action": "detach-style-source",
9452
- "data-style-source-name": action.name,
9453
- "data-icon-button": "true",
9454
- "aria-label": `Remove ${action.name} style source`,
9455
- title: `Remove ${action.name} style source`,
9456
- disabled: saving.value,
9457
- onClick: () => {
9458
- onDetachStyleModuleSource(action.componentSource, action.jsxSource, action.name);
9459
- },
9460
- children: /* @__PURE__ */ u(Trash2, {
9461
- size: 13,
9462
- "aria-hidden": "true"
9463
- })
9464
- })]
9465
- }, `${action.componentSource}:${action.jsxSource}:${action.name}`))
9466
- }) : null,
9467
- view.value.editableTargets.map((target) => /* @__PURE__ */ u("div", {
9649
+ editableTargets.map((target) => /* @__PURE__ */ u("div", {
9468
9650
  "data-editable-target-panel": "true",
9469
9651
  "data-editable-target-id": target.id,
9470
9652
  style: {
@@ -9497,6 +9679,13 @@ function EditableTargetsSection(props) {
9497
9679
  style: { color: "#172033" },
9498
9680
  children: target.name
9499
9681
  }) : null,
9682
+ "inheritedFrom" in target ? /* @__PURE__ */ u("span", {
9683
+ style: {
9684
+ color: "#667085",
9685
+ fontSize: "12px"
9686
+ },
9687
+ children: ["Inherited from ", target.inheritedFrom]
9688
+ }) : null,
9500
9689
  /* @__PURE__ */ u("button", {
9501
9690
  type: "button",
9502
9691
  "data-action": "open-editable-source-location",
@@ -9904,18 +10093,20 @@ function EditableTargetsSection(props) {
9904
10093
  options: propertyOptions,
9905
10094
  propertyContext: previewPropertyContext,
9906
10095
  saving,
10096
+ autoOpen: target.id === pendingInlineSourceTarget?.id,
9907
10097
  onAddProperty,
9908
10098
  onMenuOpenChange: onInputMenuOpenChange
9909
- }) : /* @__PURE__ */ u(AddPropertyMenu, {
10099
+ }) : sourceManagementEnabled ? /* @__PURE__ */ u(AddPropertyMenu, {
9910
10100
  targetId: target.id,
9911
10101
  pathPrefix: defaultAddPropertyPathPrefix,
9912
10102
  existingPaths,
9913
10103
  options: propertyOptions,
9914
10104
  propertyContext: previewPropertyContext,
9915
10105
  saving,
10106
+ autoOpen: target.id === pendingInlineSourceTarget?.id,
9916
10107
  onAddProperty,
9917
10108
  onMenuOpenChange: onInputMenuOpenChange
9918
- })
10109
+ }) : null
9919
10110
  ]
9920
10111
  }, group.key)) });
9921
10112
  })()]
@@ -10009,6 +10200,7 @@ function targetRowsWithPendingChanges(target, changes) {
10009
10200
  for (const change of changes.values()) {
10010
10201
  if (change.editId !== target.id || change.op !== "set") continue;
10011
10202
  if (isStyleModulePreviewChange(change)) continue;
10203
+ if (isInlineSourcePreviewChange(change)) continue;
10012
10204
  const path = change.path.join(".");
10013
10205
  if (existingPaths.has(path)) continue;
10014
10206
  rows.push({
@@ -10020,6 +10212,26 @@ function targetRowsWithPendingChanges(target, changes) {
10020
10212
  }
10021
10213
  return rows;
10022
10214
  }
10215
+ function editableTargetsWithPendingInlineSource(view, changes) {
10216
+ const pendingInlineSourceTarget = pendingInlineSourceTargetForView(view, changes);
10217
+ return pendingInlineSourceTarget ? [...view.editableTargets, pendingInlineSourceTarget] : view.editableTargets;
10218
+ }
10219
+ function pendingInlineSourceTargetForView(view, changes) {
10220
+ const inlineSourceCreate = view.inlineSourceCreate;
10221
+ if (!inlineSourceCreate) return void 0;
10222
+ const editId = inlineSourcePreviewEditId(inlineSourceCreate.jsxSource);
10223
+ const createChange = changes.get(previewChangeKey(editId, INLINE_SOURCE_PREVIEW_PATH));
10224
+ if (!createChange || !isInlineSourcePreviewChange(createChange)) return void 0;
10225
+ return {
10226
+ id: editId,
10227
+ name: "Inline source (new)",
10228
+ source: inlineSourceCreate.jsxSource.replace(/:\d+:\d+$/, ""),
10229
+ sourceLocation: inlineSourceCreate.jsxSource,
10230
+ attribute: "className",
10231
+ jsxSource: inlineSourceCreate.jsxSource,
10232
+ styleRows: []
10233
+ };
10234
+ }
10023
10235
  function propertySelectorOptions(metadata) {
10024
10236
  if (metadata?.properties.status !== "available") return [];
10025
10237
  return metadata.properties.items.flatMap((property) => {
@@ -10428,6 +10640,10 @@ function AttachStyleSourceMenu(props) {
10428
10640
  if (props.saving.value) return;
10429
10641
  menuOpen.value = false;
10430
10642
  query.value = "";
10643
+ if (previousMenuOpen.current) {
10644
+ props.onMenuOpenChange(false);
10645
+ previousMenuOpen.current = false;
10646
+ }
10431
10647
  props.onAttach(props.componentSource, props.jsxSource, option.name);
10432
10648
  };
10433
10649
  const moveActiveOption = (direction) => {
@@ -10555,6 +10771,7 @@ function AttachStyleSourceMenu(props) {
10555
10771
  children: "No matching style sources."
10556
10772
  }) : filteredOptions.map((option) => /* @__PURE__ */ u(ShadowMenuItem, {
10557
10773
  active: activeSelectableOptionId === option.id,
10774
+ class: "panda-property-selector-menu-item",
10558
10775
  disabled: props.saving.value,
10559
10776
  onPreview: () => {
10560
10777
  activeOptionId.value = option.id;
@@ -10571,7 +10788,8 @@ function AttachStyleSourceMenu(props) {
10571
10788
  style: {
10572
10789
  minWidth: 0,
10573
10790
  display: "grid",
10574
- gap: "2px"
10791
+ gap: "2px",
10792
+ textAlign: "left"
10575
10793
  },
10576
10794
  children: [/* @__PURE__ */ u("code", {
10577
10795
  style: { color: "#172033" },
@@ -10675,7 +10893,7 @@ function isVerticalAlignDisplay(display) {
10675
10893
  return display === "inline" || display === "inline-block" || display === "table-cell";
10676
10894
  }
10677
10895
  function AddPropertyMenu(props) {
10678
- const menuOpen = useSignal(false);
10896
+ const menuOpen = useSignal(props.autoOpen === true);
10679
10897
  const query = useSignal("");
10680
10898
  const activeOptionId = useSignal();
10681
10899
  const trigger = A$1(null);
@@ -11245,6 +11463,9 @@ function isInspectorOwnedElement(element) {
11245
11463
  function isShadowRoot(root) {
11246
11464
  return typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot;
11247
11465
  }
11466
+ function logUnexpectedInspectorError(message, error) {
11467
+ console.error(`[sculpted] ${message}`, error);
11468
+ }
11248
11469
  function isOnlyShiftAlt(event) {
11249
11470
  return event.shiftKey && event.altKey && !event.ctrlKey && !event.metaKey;
11250
11471
  }
package/dist/vite.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { l as SourceSyntaxOption } from "./sourceSyntax-U2iybN9L.mjs";
1
+ import { l as SourceSyntaxOption } from "./sourceSyntax-DKIh-VKA.mjs";
2
2
 
3
3
  //#region src/vite/types.d.ts
4
4
  type InspectorVitePluginOptions = {