@widgetic/creator 0.4.31 → 0.4.32

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.
@@ -4928,6 +4928,34 @@
4928
4928
  return true;
4929
4929
  }
4930
4930
 
4931
+ /**
4932
+ * A generation that had to create the property (it was not in the schema yet)
4933
+ * still ends with the card, so the next tweak is the control and not another build.
4934
+ */
4935
+ async function attachDesignCardAfterGeneration(widgetId: string, promptText: string): Promise<void> {
4936
+ try {
4937
+ // The generation just wrote design.json. A load that started earlier
4938
+ // still holds the previous schema, so a fresh read is required or the
4939
+ // new property (a font the message just added) never becomes a card.
4940
+ await loadWidgetSchemas(widgetId, { force: true });
4941
+ const ps = getPanelDisplayState(widgetId);
4942
+ const schema = ps.compositionDesignSchema;
4943
+ if (!schema) return;
4944
+ const resolution = resolveDesignIntent(promptText, schema, ps.liveDesignValues ?? {});
4945
+ if (!resolution) return;
4946
+ const card = toDesignControlRequest(
4947
+ resolution,
4948
+ schema,
4949
+ ps.liveDesignValues ?? {},
4950
+ ps.selectedComposition?.id ?? null
4951
+ );
4952
+ getChatMethodsForWidget(widgetId)?.addDesignControlsMessage?.(resolution.summary, card);
4953
+ console.log('[DesignIntent] card after generation', resolution.changes.map((change) => change.propertyId).join(','));
4954
+ } catch (err) {
4955
+ console.warn('[DesignIntent] card after generation skipped', err);
4956
+ }
4957
+ }
4958
+
4931
4959
  /**
4932
4960
  * Jev-backed fallback for the deterministic resolver: when the message names
4933
4961
  * a design property semantically and no literal value can be parsed, ask the
@@ -5275,9 +5303,20 @@
5275
5303
  const panelRef = getWidgetDetailsRef(widgetId);
5276
5304
  const step = widgetId === focusedPanelWidgetId ? widgetDetailsStep : 'create';
5277
5305
  if (step === 'create') {
5278
- // Create shows the generated defaults, not a saved composition.
5279
- // The slides still have to reach both preview iframes.
5306
+ // Create shows the generated defaults, plus a design value the chat
5307
+ // already applied, so a color set here is still there after the
5308
+ // preview reloads.
5280
5309
  postContentItemsToPreviewFrames(widgetId);
5310
+ const ps = getPanelDisplayState(widgetId);
5311
+ const design = ps.liveDesignValues as Record<string, unknown> | undefined;
5312
+ if (design && Object.keys(design).length > 0) {
5313
+ const designMessage = {
5314
+ type: 'widgetic:update',
5315
+ design: flattenDesignValuesForPreview(design),
5316
+ };
5317
+ getWidgetDetailsRef(widgetId)?.sendMessageToPreview(designMessage);
5318
+ resolveLiveWidgetShapeIframe(widgetId)?.contentWindow?.postMessage(designMessage, '*');
5319
+ }
5281
5320
  return;
5282
5321
  }
5283
5322
  if (!panelRef) return;
@@ -5405,16 +5444,15 @@
5405
5444
  ensurePanelPublishHistory(widgetId);
5406
5445
 
5407
5446
  const needsSchemas = !ps.compositionDesignSchema && !ps.compositionContentSchema && !ps.compositionSchemasError;
5408
- const onEditOrEmbed = ps.widgetDetailsStep === 'edit' || ps.widgetDetailsStep === 'embed';
5409
5447
 
5410
- // Load schemas only on Edit/Embed — Create step panels stay hidden and must not compete for API slots
5411
- if (needsSchemas && onEditOrEmbed) {
5448
+ // Create needs the schema too: a chat card (color, number, font) is chosen from it.
5449
+ if (needsSchemas) {
5412
5450
  void scheduleWidgetSchemaLoad(widgetId);
5413
5451
  return;
5414
5452
  }
5415
5453
 
5416
- if (!onEditOrEmbed) return;
5417
-
5454
+ // Create step still needs the composition, so a property edit has a row
5455
+ // to save into and a reload can put that color back on the preview.
5418
5456
  if (!ps.compositions.length || !ps.selectedComposition) {
5419
5457
  void loadCompositionsForPanel(widgetId);
5420
5458
  } else {
@@ -11049,19 +11087,22 @@ Requirements:
11049
11087
  const schemaProp = collectDesignProperties(psNow.compositionDesignSchema).find(
11050
11088
  (property) => property.id === propertyKey || property.id.endsWith(`.${propertyKey}`)
11051
11089
  );
11052
- const label = schemaProp?.label || propertyKey;
11090
+ const label = schemaProp?.label || (typeof gatedData.label === 'string' ? gatedData.label : '') || propertyKey;
11091
+ const controllerType =
11092
+ schemaProp?.controllerType
11093
+ || (typeof gatedData.controllerType === 'string' ? gatedData.controllerType : '');
11053
11094
  const card: DesignControlRequest = {
11054
11095
  summary: gatedData.reply || $t('creator.general.setTo', { label, value: String(propertyValue) }),
11055
11096
  properties: propertyKey
11056
11097
  ? [{
11057
11098
  id: schemaProp?.id || propertyKey,
11058
11099
  label,
11059
- controllerType: schemaProp?.controllerType ?? '',
11100
+ controllerType,
11060
11101
  value: propertyValue,
11061
11102
  options: schemaProp?.options,
11062
- min: schemaProp?.min,
11063
- max: schemaProp?.max,
11064
- step: schemaProp?.step,
11103
+ min: schemaProp?.min ?? (typeof gatedData.min === 'number' ? gatedData.min : undefined),
11104
+ max: schemaProp?.max ?? (typeof gatedData.max === 'number' ? gatedData.max : undefined),
11105
+ step: schemaProp?.step ?? (typeof gatedData.step === 'number' ? gatedData.step : undefined),
11065
11106
  helpText: schemaProp?.helpText,
11066
11107
  }]
11067
11108
  : [],
@@ -11599,6 +11640,10 @@ Requirements:
11599
11640
  panelChat?.addAssistantMessage(designContractWarning, true);
11600
11641
  }
11601
11642
 
11643
+ if (!options.compileFixOnly && prompt.trim()) {
11644
+ void attachDesignCardAfterGeneration(generationWidgetId, prompt);
11645
+ }
11646
+
11602
11647
  setTimeout(async () => {
11603
11648
  if (!getWidgetDetailsRef(generationWidgetId)) return;
11604
11649
  const activePanelRef = getWidgetDetailsRef(generationWidgetId);
@@ -19544,12 +19589,8 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
19544
19589
  {#if generatingWidgetIds[panelWidgetId] && previewUnblockedByWidgetId[panelWidgetId] && !ps.lastGenerationFailed}
19545
19590
  <span class="codegen-save-spinner inline-block h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-gray-300 border-t-forest-green" aria-hidden="true"></span>
19546
19591
  {/if}
19547
- <div class="generate-code-status-el text-xs flex-1 min-w-0 truncate {ps.lastGenerationFailed && !hourlyLimit ? 'text-red-600' : 'text-gray-500'}">
19548
- {#if ps.lastGenerationFailed && !hourlyLimit}
19549
- <span class="text-red-500 font-medium">{$t('creator.codegen.generationFailed')}</span>
19550
- {:else}
19551
- <span class="text-gray-400">{$t('creator.status.label')}</span> {hourlyLimit ? $t('creator.status.ready') : statusLabel(statusText, $t)}
19552
- {/if}
19592
+ <div class="generate-code-status-el text-xs flex-1 min-w-0 truncate text-gray-500">
19593
+ <span class="text-gray-400">{$t('creator.status.label')}</span> {hourlyLimit || ps.lastGenerationFailed ? $t('creator.status.ready') : statusLabel(statusText, $t)}
19553
19594
  </div>
19554
19595
  </div>
19555
19596
  {#if publishPlanMessageByWidgetId[panelWidgetId]}
@@ -19579,61 +19620,6 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
19579
19620
  </div>
19580
19621
  </div>
19581
19622
  {/if}
19582
- {#if ps.lastGenerationFailed && !hourlyLimit}
19583
- <div class="p-3 bg-red-50 border border-red-200" style="border-radius: 0;">
19584
- <p class="text-xs text-red-700 whitespace-pre-wrap">{errorLabel(ps.lastGenerationError, $t)}</p>
19585
- <div class="flex gap-2 mt-3 justify-center">
19586
- {#if isPlanLimitMessage(ps.lastGenerationError)}
19587
- <Button
19588
- onclick={openUpgradePlans}
19589
- variant="default"
19590
- size="sm"
19591
- class="bg-red-600 hover:bg-red-700 text-white rounded-lg"
19592
- >
19593
- {$t('creator.general.upgrade')}
19594
- </Button>
19595
- {:else}
19596
- <Button
19597
- onclick={() => {
19598
- if (!isPanelFocused) focusWidgetPanel(panelWidgetId);
19599
- generateCode({
19600
- prompt: lastGenerationPrompt || ps.codeGenerationPrompt,
19601
- widgetId: panelWidgetId,
19602
- });
19603
- }}
19604
- variant="default"
19605
- size="sm"
19606
- class="bg-red-600 hover:bg-red-700 text-white rounded-lg"
19607
- >
19608
- {$t('creator.common.retry')}
19609
- </Button>
19610
- {/if}
19611
- <Button
19612
- onclick={() => {
19613
- if (!isPanelFocused) focusWidgetPanel(panelWidgetId);
19614
- patchPanelSnapshot(panelWidgetId, {
19615
- lastGenerationFailed: false,
19616
- lastGenerationError: null,
19617
- generateCodeStatus: 'Ready',
19618
- });
19619
- if (isPanelFocused || focusedPanelWidgetId === panelWidgetId) {
19620
- lastGenerationFailed = false;
19621
- lastGenerationError = null;
19622
- generateCodeStatus = 'Ready';
19623
- }
19624
- // A status-only patch does not bump the panel revision, so the
19625
- // banner, which reads that revision, stayed on screen.
19626
- panelDisplayRevision += 1;
19627
- }}
19628
- variant="outline"
19629
- size="sm"
19630
- class="border-gray-300 text-gray-600 hover:bg-gray-50 rounded-lg"
19631
- >
19632
- {$t('creator.general.dismiss')}
19633
- </Button>
19634
- </div>
19635
- </div>
19636
- {/if}
19637
19623
  </div>
19638
19624
  {/if}
19639
19625
  </svelte:fragment>
@@ -19642,12 +19628,65 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
19642
19628
  {@const chatUserHeight = rev(panelDisplayRevision, getChatContainerHeightForPanel(panelWidgetId))}
19643
19629
  <!-- svelte-ignore a11y_no_static_element_interactions -->
19644
19630
  <div
19645
- class="generation-scroll-ct flex flex-col h-full min-h-0 overflow-y-auto border-t border-gray-200"
19631
+ class="generation-scroll-ct relative flex flex-col h-full min-h-0 overflow-y-auto border-t border-gray-200"
19646
19632
  style="padding: 0;"
19647
19633
  use:nativeScrollbarPadding={0}
19648
19634
  use:pinScrollToBottom
19649
19635
  onmousedown={() => { if (!isPanelFocused) focusWidgetPanel(panelWidgetId); }}
19650
19636
  >
19637
+ {#if ps.lastGenerationFailed && !isHourlyLimitText(ps.lastGenerationError)}
19638
+ <div class="generation-failed-overlay sticky top-0 z-20 mx-3 mt-3 border border-red-200 bg-red-50 p-3">
19639
+ <p class="text-xs text-red-700 whitespace-pre-wrap">{errorLabel(ps.lastGenerationError, $t)}</p>
19640
+ <div class="generation-failed-actions mt-3 flex justify-center gap-2">
19641
+ {#if isPlanLimitMessage(ps.lastGenerationError)}
19642
+ <Button
19643
+ onclick={openUpgradePlans}
19644
+ variant="default"
19645
+ size="sm"
19646
+ class="rounded-lg bg-red-600 text-white hover:bg-red-700"
19647
+ >
19648
+ {$t('creator.general.upgrade')}
19649
+ </Button>
19650
+ {:else}
19651
+ <Button
19652
+ onclick={() => {
19653
+ if (!isPanelFocused) focusWidgetPanel(panelWidgetId);
19654
+ generateCode({
19655
+ prompt: lastGenerationPrompt || ps.codeGenerationPrompt,
19656
+ widgetId: panelWidgetId,
19657
+ });
19658
+ }}
19659
+ variant="default"
19660
+ size="sm"
19661
+ class="rounded-lg bg-red-600 text-white hover:bg-red-700"
19662
+ >
19663
+ {$t('creator.common.retry')}
19664
+ </Button>
19665
+ {/if}
19666
+ <Button
19667
+ onclick={() => {
19668
+ if (!isPanelFocused) focusWidgetPanel(panelWidgetId);
19669
+ patchPanelSnapshot(panelWidgetId, {
19670
+ lastGenerationFailed: false,
19671
+ lastGenerationError: null,
19672
+ generateCodeStatus: 'Ready',
19673
+ });
19674
+ if (isPanelFocused || focusedPanelWidgetId === panelWidgetId) {
19675
+ lastGenerationFailed = false;
19676
+ lastGenerationError = null;
19677
+ generateCodeStatus = 'Ready';
19678
+ }
19679
+ panelDisplayRevision += 1;
19680
+ }}
19681
+ variant="outline"
19682
+ size="sm"
19683
+ class="rounded-lg border-gray-300 text-gray-600 hover:bg-gray-50 focus:outline-none focus:shadow-none"
19684
+ >
19685
+ {$t('creator.general.dismiss')}
19686
+ </Button>
19687
+ </div>
19688
+ </div>
19689
+ {/if}
19651
19690
  {#key panelInstanceKey}
19652
19691
  <div
19653
19692
  class="code-generation-chat-host w-full min-h-0 {chatUserHeight == null ? 'flex-1' : 'shrink-0'}"
@@ -20433,6 +20472,11 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
20433
20472
  :global(.wc-logo-type path) {
20434
20473
  fill: #0F2010;
20435
20474
  }
20475
+ .generation-failed-overlay :global(button:focus),
20476
+ .generation-failed-overlay :global(button:focus-visible) {
20477
+ outline: none;
20478
+ box-shadow: none;
20479
+ }
20436
20480
  /* Thin scrollbar for canvas dropdown list */
20437
20481
  .wc-canvas-dropdown-items::-webkit-scrollbar {
20438
20482
  width: 4px;
@@ -9,9 +9,8 @@
9
9
  *
10
10
  * The chat package stays design-agnostic: it renders this via a host-provided
11
11
  * snippet and only passes the resolution payload (see `renderDesignControls`).
12
- * Controls are intentionally lightweight and mirror `inputController.type`
13
- * rather than importing the editor's controller components, so the production
14
- * build does not depend on editor internals.
12
+ * A font property uses the editor's font picker. The other controls stay
13
+ * lightweight and follow `inputController.type`.
15
14
  *
16
15
  * Values are not frozen at insert: the card reads the host's live design state
17
16
  * so a property dragged in the PropsEditor panel moves the control here too,
@@ -19,6 +18,8 @@
19
18
  * See `designQuickEditValues.ts` for the resolution rules.
20
19
  -->
21
20
  <script lang="ts">
21
+ import { writable } from 'svelte/store';
22
+ import { FontInputController } from '@widgetic/editor';
22
23
  import type { DesignControlRequest, DesignControlProperty } from '../utils/designIntentResolver';
23
24
  import {
24
25
  isQuickEditPropertyAvailable,
@@ -123,6 +124,47 @@
123
124
  function asBool(property: DesignControlProperty): boolean {
124
125
  return currentValue(property) === true;
125
126
  }
127
+
128
+ const openFontDropdowns = writable(new Set<string>());
129
+
130
+ function toggleFontDropdown(id: string) {
131
+ openFontDropdowns.update((current) => {
132
+ const next = new Set(current);
133
+ if (next.has(id)) next.delete(id);
134
+ else {
135
+ next.clear();
136
+ next.add(id);
137
+ }
138
+ return next;
139
+ });
140
+ }
141
+
142
+ function fontModel(property: DesignControlProperty): { family: string; weight: string; category: string } {
143
+ const raw = currentValue(property);
144
+ if (raw && typeof raw === 'object' && 'family' in raw) {
145
+ const font = raw as { family?: string; weight?: string; category?: string };
146
+ return {
147
+ family: font.family?.trim() || 'Inter',
148
+ weight: font.weight || '400',
149
+ category: font.category || 'sans-serif'
150
+ };
151
+ }
152
+ const family = asString(property).split(',')[0]?.replace(/["']/g, '').trim() || 'Inter';
153
+ return { family, weight: '400', category: 'sans-serif' };
154
+ }
155
+
156
+ /** A card saved before the schema loaded still has an empty controller. The id and the value say what to show. */
157
+ function controlKind(property: DesignControlProperty): string {
158
+ const declared = String(property.controllerType ?? '').toLowerCase();
159
+ if (declared && declared !== 'textinput' && declared !== 'text') return declared;
160
+ const raw = property.value;
161
+ const looksHex = typeof raw === 'string' && /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(raw.trim());
162
+ const looksNumber = raw !== '' && raw != null && Number.isFinite(Number(raw)) && !/[a-z]/i.test(String(raw));
163
+ if (/color|colour/i.test(property.id) || looksHex) return 'colorpicker';
164
+ if (looksNumber && /size|padding|gap|column|width|radius|opacity/i.test(property.id)) return 'number';
165
+ if (/font/i.test(property.id) && !/size/i.test(property.id)) return 'font';
166
+ return declared || 'textinput';
167
+ }
126
168
  </script>
127
169
 
128
170
  <div class="design-quick-edit flex flex-col gap-2 overflow-visible rounded-lg border border-gray-200 bg-white p-3 shadow-sm">
@@ -132,7 +174,7 @@
132
174
  </p>
133
175
  {/if}
134
176
  {#each spec.properties as property (property.id)}
135
- {@const type = String(property.controllerType ?? '').toLowerCase()}
177
+ {@const type = controlKind(property)}
136
178
  {@const isColor = type.includes('color') || type.includes('colour')}
137
179
  {@const available = isQuickEditPropertyAvailable(property.id, knownPropertyIds)}
138
180
  {@const editable = !detached && available}
@@ -172,7 +214,8 @@
172
214
  <input
173
215
  id={`design-quick-${property.id}`}
174
216
  type="range"
175
- class="w-36"
217
+ tabindex="-1"
218
+ class="w-36 outline-none"
176
219
  min={property.min}
177
220
  max={property.max}
178
221
  step={property.step ?? 1}
@@ -185,7 +228,8 @@
185
228
  <input
186
229
  id={`design-quick-${property.id}`}
187
230
  type="number"
188
- class="w-24 rounded border border-gray-300 px-1.5 py-1 text-xs tabular-nums text-gray-700"
231
+ tabindex="-1"
232
+ class="w-24 rounded border border-gray-300 px-1.5 py-1 text-xs tabular-nums text-gray-700 outline-none"
189
233
  value={asNumber(property)}
190
234
  min={property.min}
191
235
  max={property.max}
@@ -196,14 +240,16 @@
196
240
  <input
197
241
  id={`design-quick-${property.id}`}
198
242
  type="checkbox"
199
- class="h-4 w-4 cursor-pointer"
243
+ tabindex="-1"
244
+ class="h-4 w-4 cursor-pointer outline-none"
200
245
  checked={asBool(property)}
201
246
  onchange={(e) => commit(property, (e.currentTarget as HTMLInputElement).checked)}
202
247
  />
203
248
  {:else if (type === 'dropdown' || type === 'radiogroup') && property.options?.length}
204
249
  <select
205
250
  id={`design-quick-${property.id}`}
206
- class="w-36 rounded border border-gray-300 bg-white px-1.5 py-1 text-xs text-gray-700"
251
+ tabindex="-1"
252
+ class="w-36 rounded border border-gray-300 bg-white px-1.5 py-1 text-xs text-gray-700 outline-none"
207
253
  value={asString(property)}
208
254
  onchange={(e) => commit(property, (e.currentTarget as HTMLSelectElement).value)}
209
255
  >
@@ -211,11 +257,34 @@
211
257
  <option value={option.value}>{option.label}</option>
212
258
  {/each}
213
259
  </select>
260
+ {:else if type === 'font'}
261
+ <div class="design-quick-font min-w-0 w-44">
262
+ <FontInputController
263
+ label=""
264
+ controllerId={`design-quick-font-${property.id}`}
265
+ value={fontModel(property)}
266
+ openDropdowns={openFontDropdowns}
267
+ toggleDropdown={toggleFontDropdown}
268
+ hideTrashIcon={true}
269
+ hideRecentFromList={true}
270
+ onChange={(next) => {
271
+ if (!editable) return;
272
+ const family = next?.family?.trim();
273
+ if (!family) return;
274
+ commit(property, {
275
+ family,
276
+ weight: next.weight || '400',
277
+ category: next.category || 'sans-serif'
278
+ });
279
+ }}
280
+ />
281
+ </div>
214
282
  {:else if type === 'textarea'}
215
283
  <textarea
216
284
  id={`design-quick-${property.id}`}
217
285
  dir={asString(property) ? dirForUserText($textDirection) : undefined}
218
- class="w-48 rounded border border-gray-300 px-1.5 py-1 text-xs text-gray-700"
286
+ tabindex="-1"
287
+ class="w-48 rounded border border-gray-300 px-1.5 py-1 text-xs text-gray-700 outline-none"
219
288
  rows="2"
220
289
  value={asString(property)}
221
290
  onchange={(e) => commit(property, (e.currentTarget as HTMLTextAreaElement).value)}
@@ -224,8 +293,9 @@
224
293
  <input
225
294
  id={`design-quick-${property.id}`}
226
295
  type="text"
296
+ tabindex="-1"
227
297
  dir={asString(property) ? dirForUserText($textDirection) : undefined}
228
- class="w-40 rounded border border-gray-300 px-1.5 py-1 text-xs text-gray-700"
298
+ class="w-40 rounded border border-gray-300 px-1.5 py-1 text-xs text-gray-700 outline-none"
229
299
  value={asString(property)}
230
300
  oninput={(e) => commitText(property, (e.currentTarget as HTMLInputElement).value)}
231
301
  />
@@ -28,6 +28,7 @@ const NUMBER_CONTROLLERS = new Set(['slider', 'number', 'angle']);
28
28
  const BOOLEAN_CONTROLLERS = new Set(['switch', 'checkbox']);
29
29
  const OPTION_CONTROLLERS = new Set(['dropdown', 'radiogroup']);
30
30
  const TEXT_CONTROLLERS = new Set(['textinput', 'textarea']);
31
+ const FONT_CONTROLLERS = new Set(['font']);
31
32
  /** Common CSS named colors → hex. Deliberately a small, unambiguous subset. */
32
33
  const NAMED_COLORS = {
33
34
  black: '#000000',
@@ -393,6 +394,12 @@ function buildCandidate(property, message) {
393
394
  }
394
395
  return null;
395
396
  }
397
+ if (FONT_CONTROLLERS.has(type)) {
398
+ const named = message.match(/\bto\s+([A-Za-z][A-Za-z0-9 ]{1,40})/);
399
+ if (!named)
400
+ return null;
401
+ return { property, value: named[1].trim(), reason: 'explicit-text' };
402
+ }
396
403
  if (TEXT_CONTROLLERS.has(type)) {
397
404
  const text = extractQuotedText(message);
398
405
  if (text)
@@ -40,12 +40,9 @@ export declare function isQuickEditPropertyAvailable(propertyId: string, knownPr
40
40
  * the whole guard: an older card under a newly selected composition must not
41
41
  * show — or write — that composition's value under a shared property id.
42
42
  *
43
- * A card with no recorded composition (created before the field existed, or by
44
- * a host that edits design values with no saved composition) counts as
45
- * attached. That is the behaviour that preceded re-attachment, and detaching it
46
- * would freeze cards that were working. A card that *did* record one, read back
47
- * while no composition is selected, is detached instead: the live values cannot
48
- * be shown to belong to it, and reopening the composition is cheap while a
49
- * wrong write is not.
43
+ * A card with no recorded composition counts as attached. A card that recorded
44
+ * one, while no composition is selected yet, also stays attached: the control
45
+ * has to be visible on the first edit, and the save waits until a composition
46
+ * is selected. A card under a different selected composition stays detached.
50
47
  */
51
48
  export declare function isDesignCardAttached(card: Pick<DesignControlRequest, 'compositionId'>, currentCompositionId?: string | null): boolean;
@@ -61,17 +61,16 @@ export function isQuickEditPropertyAvailable(propertyId, knownPropertyIds) {
61
61
  * the whole guard: an older card under a newly selected composition must not
62
62
  * show — or write — that composition's value under a shared property id.
63
63
  *
64
- * A card with no recorded composition (created before the field existed, or by
65
- * a host that edits design values with no saved composition) counts as
66
- * attached. That is the behaviour that preceded re-attachment, and detaching it
67
- * would freeze cards that were working. A card that *did* record one, read back
68
- * while no composition is selected, is detached instead: the live values cannot
69
- * be shown to belong to it, and reopening the composition is cheap while a
70
- * wrong write is not.
64
+ * A card with no recorded composition counts as attached. A card that recorded
65
+ * one, while no composition is selected yet, also stays attached: the control
66
+ * has to be visible on the first edit, and the save waits until a composition
67
+ * is selected. A card under a different selected composition stays detached.
71
68
  */
72
69
  export function isDesignCardAttached(card, currentCompositionId) {
73
70
  const cardCompositionId = card.compositionId ?? null;
74
71
  if (cardCompositionId === null)
75
72
  return true;
76
- return cardCompositionId === (currentCompositionId ?? null);
73
+ if (currentCompositionId == null)
74
+ return true;
75
+ return cardCompositionId === currentCompositionId;
77
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widgetic/creator",
3
- "version": "0.4.31",
3
+ "version": "0.4.32",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "type": "module",
6
6
  "peerDependencies": {