@widgetic/creator 0.3.81 → 0.4.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.
Files changed (64) hide show
  1. package/README.md +157 -0
  2. package/dist/CreatorApp.svelte +1593 -812
  3. package/dist/CreatorApp.svelte.d.ts +22 -0
  4. package/dist/components/BrandKitPanel.svelte +48 -40
  5. package/dist/components/BrandKitPanel.svelte.d.ts +1 -1
  6. package/dist/components/DesignQuickEdit.svelte +13 -4
  7. package/dist/components/EditableName.svelte +13 -8
  8. package/dist/components/EditableName.svelte.d.ts +2 -2
  9. package/dist/components/FileUrlSourceControl.svelte +21 -8
  10. package/dist/components/HoverTooltip.svelte +1 -1
  11. package/dist/components/SelectorDropdown.svelte +19 -15
  12. package/dist/components/SelectorDropdown.svelte.d.ts +2 -2
  13. package/dist/components/VersionDropdownRow.svelte +14 -11
  14. package/dist/components/WidgetDetails.svelte +118 -92
  15. package/dist/components/WidgetShapeLivePreviews.svelte +105 -46
  16. package/dist/creator-types.d.ts +96 -0
  17. package/dist/host/creatorHost.d.ts +176 -0
  18. package/dist/host/creatorHost.js +242 -0
  19. package/dist/host/limitRefusal.d.ts +64 -0
  20. package/dist/host/limitRefusal.js +109 -0
  21. package/dist/i18n/index.d.ts +5 -0
  22. package/dist/i18n/index.js +5 -0
  23. package/dist/i18n/labels.d.ts +14 -0
  24. package/dist/i18n/labels.js +39 -0
  25. package/dist/i18n/language.d.ts +559 -0
  26. package/dist/i18n/language.js +47 -0
  27. package/dist/i18n/languageKit.d.ts +52 -0
  28. package/dist/i18n/languageKit.js +45 -0
  29. package/dist/i18n/messages.d.ts +526 -0
  30. package/dist/i18n/messages.js +548 -0
  31. package/dist/i18n/slots.d.ts +22 -0
  32. package/dist/i18n/slots.js +42 -0
  33. package/dist/i18n/statusText.d.ts +22 -0
  34. package/dist/i18n/statusText.js +223 -0
  35. package/dist/index.d.ts +1 -0
  36. package/dist/index.js +2 -0
  37. package/dist/stores/userSession.d.ts +8 -1
  38. package/dist/stores/userSession.js +18 -25
  39. package/dist/stores/websocketStore.d.ts +6 -0
  40. package/dist/stores/websocketStore.js +39 -4
  41. package/dist/utils/designIntentTelemetry.d.ts +8 -0
  42. package/dist/utils/designIntentTelemetry.js +52 -34
  43. package/dist/utils/directionPlacement.d.ts +51 -0
  44. package/dist/utils/directionPlacement.js +55 -0
  45. package/dist/utils/embedCode.d.ts +0 -1
  46. package/dist/utils/embedCode.js +0 -4
  47. package/dist/utils/generationSharing.d.ts +122 -0
  48. package/dist/utils/generationSharing.js +188 -0
  49. package/dist/utils/nativeScrollbarPadding.js +1 -1
  50. package/dist/utils/pickedFile.d.ts +15 -0
  51. package/dist/utils/pickedFile.js +21 -0
  52. package/dist/utils/widgeticChatUpload.d.ts +9 -0
  53. package/dist/utils/widgeticChatUpload.js +24 -2
  54. package/package.json +5 -3
  55. package/dist/retiredSurface.test.d.ts +0 -1
  56. package/dist/retiredSurface.test.js +0 -113
  57. package/dist/utils/designIntentResolver.test.d.ts +0 -1
  58. package/dist/utils/designIntentResolver.test.js +0 -246
  59. package/dist/utils/designIntentTelemetry.test.d.ts +0 -1
  60. package/dist/utils/designIntentTelemetry.test.js +0 -385
  61. package/dist/utils/designQuickEditValues.test.d.ts +0 -1
  62. package/dist/utils/designQuickEditValues.test.js +0 -100
  63. package/dist/utils/widgeticChatUpload.test.d.ts +0 -1
  64. package/dist/utils/widgeticChatUpload.test.js +0 -257
@@ -33,6 +33,28 @@ declare const CreatorApp: $$__sveltets_2_IsomorphicComponent<{
33
33
  onPublishComplete?: CreatorAppProps["onPublishComplete"];
34
34
  onBack?: CreatorAppProps["onBack"];
35
35
  onWidgetRenamed?: CreatorAppProps["onWidgetRenamed"];
36
+ /**
37
+ * Partner mode (see `CreatorAppProps.getAccessToken`): the page hands over the token and keeps the storage, the
38
+ * address bar and the navigation for itself. Decided once, when the creator starts.
39
+ */ getAccessToken?: CreatorAppProps["getAccessToken"];
40
+ onSessionEnded?: CreatorAppProps["onSessionEnded"];
41
+ onReloadRequested?: CreatorAppProps["onReloadRequested"];
42
+ onLimitReached?: CreatorAppProps["onLimitReached"];
43
+ onCanvasUnavailable?: CreatorAppProps["onCanvasUnavailable"];
44
+ onCanvasChanged?: CreatorAppProps["onCanvasChanged"];
45
+ onReady?: CreatorAppProps["onReady"];
46
+ /** The page's own media library for the editor's file pickers (see `CreatorAppProps.mediaLibrary`). */ mediaLibrary?: CreatorAppProps["mediaLibrary"];
47
+ /**
48
+ * The language of everything the creator shows (see `CreatorAppProps.locale` and `CreatorAppProps.messages`). The one flat
49
+ * `messages` object is split between the creator's own words and the parts it draws: the editor (with its file
50
+ * browser), the chat and the canvas each have a catalog of their own.
51
+ */ locale?: CreatorAppProps["locale"];
52
+ messages?: CreatorAppProps["messages"];
53
+ /**
54
+ * The direction of the creator's screen (see `CreatorAppProps.dir`). Every part below (the chat, the canvas, the editor with
55
+ * its File Browser and rich text editor) reads it from Svelte's context and follows when the page changes `dir`;
56
+ * `textDirection` is the answer, for the creator's own decisions (where a pop-up opens from, which way a divider drags).
57
+ */ dir?: CreatorAppProps["dir"];
36
58
  class?: string;
37
59
  style?: string;
38
60
  }, {
@@ -4,6 +4,14 @@
4
4
  import { FontInputController } from '@widgetic/editor';
5
5
  import FileUrlSourceControl from './FileUrlSourceControl.svelte';
6
6
  import HoverTooltip from './HoverTooltip.svelte';
7
+ import { eventPathMatches } from '../host/creatorHost.js';
8
+ import { useCreatorLanguage } from '../i18n/index.js';
9
+ import { useTextDirection } from '@widgetic/design-system/components/textDirection';
10
+ import { popUpLeftFromAnchor } from '../utils/directionPlacement.js';
11
+
12
+ const { t } = useCreatorLanguage();
13
+ // The direction of the screen the panel is on (a panel with no screen around it reads left to right).
14
+ const textDirection = useTextDirection();
7
15
 
8
16
  interface FontModel {
9
17
  family: string;
@@ -186,7 +194,8 @@
186
194
  if (!anchor) return { top: 0, left: 8 };
187
195
  const rect = anchor.getBoundingClientRect();
188
196
  const height = panel?.offsetHeight || 320;
189
- const left = Math.max(8, Math.min(rect.left, window.innerWidth - width - 8));
197
+ // Its start edge is lined up with the start edge of the button: the left one on a left to right screen, the right one on a right to left screen.
198
+ const left = popUpLeftFromAnchor($textDirection, rect, width, window.innerWidth, 8);
190
199
  const below = rect.bottom + 6;
191
200
  const fitsBelow = below + height <= window.innerHeight - 8;
192
201
  const top = fitsBelow ? below : Math.max(8, rect.top - height - 6);
@@ -218,15 +227,16 @@
218
227
  return extensions.join(',');
219
228
  }
220
229
 
230
+ // Words a visitor reads, in the page's language: the function reads `$t`, so a language the page sets later is read on the next draw.
221
231
  function uploadTooltip(includeSvg: boolean) {
222
- return includeSvg ? 'Upload your icon library.' : 'Upload your custom library.';
232
+ return includeSvg ? $t('creator.brandKit.uploadIconLibraryTooltip') : $t('creator.brandKit.uploadCustomLibraryTooltip');
223
233
  }
224
234
 
225
235
  function urlPlaceholder(includeSvg: boolean) {
226
- const component = componentExtension();
236
+ const extension = componentExtension();
227
237
  return includeSvg
228
- ? `URL (git, archive, .svg, ${component})`
229
- : `URL (git, archive, .js, .ts, ${component})`;
238
+ ? $t('creator.brandKit.urlIcons', { extension })
239
+ : $t('creator.brandKit.urlLibraries', { extension });
230
240
  }
231
241
 
232
242
  $effect(() => {
@@ -241,12 +251,10 @@
241
251
  }
242
252
 
243
253
  function onPointerDown(event: PointerEvent) {
244
- const target = event.target as HTMLElement | null;
245
- if (!target) return;
246
- if (brandButtonEl?.contains(target)) return;
247
- if (target.closest('.generation-brand-kit-popover')) return;
248
- if (target.closest('.font-input-popover')) return;
249
- if (target.closest('#widgetic-font-picker-portal')) return;
254
+ // The whole path is looked at, not `event.target`: from `window` the target of a press inside a shadow root is
255
+ // the shadow's host element, so every press, the popover's own included, would count as outside it.
256
+ if (brandButtonEl && event.composedPath().includes(brandButtonEl)) return;
257
+ if (eventPathMatches(event, '.generation-brand-kit-popover, .font-input-popover, #widgetic-font-picker-portal')) return;
250
258
  closeFontPickers();
251
259
  brandPanelOpen = false;
252
260
  brandPanelMaxHeight = 0;
@@ -269,7 +277,7 @@
269
277
  {#if part === 'checks'}
270
278
  <div class="generation-options-checks contents {className}" {style}>
271
279
  <label
272
- class="generation-brand-kit-toggle ml-auto flex h-10 shrink-0 cursor-pointer items-center gap-1.5 rounded-lg border px-2 text-sm {brandKitEnabled ? 'border-[#314F2F] bg-[#314F2F] text-white' : 'border-gray-300 bg-white text-gray-800'}"
280
+ class="generation-brand-kit-toggle ms-auto flex h-10 shrink-0 cursor-pointer items-center gap-1.5 rounded-lg border px-2 text-sm {brandKitEnabled ? 'border-[#314F2F] bg-[#314F2F] text-white' : 'border-gray-300 bg-white text-gray-800'}"
273
281
  bind:this={brandButtonEl}
274
282
  >
275
283
  <input
@@ -278,13 +286,13 @@
278
286
  checked={brandKitEnabled}
279
287
  onchange={onBrandKitChange}
280
288
  />
281
- Brand kit
289
+ {$t('creator.brandKit.brandKit')}
282
290
  </label>
283
291
  <div class="generation-libraries-row flex w-full flex-col gap-2">
284
292
  <div class="generation-libraries-checks flex flex-nowrap items-center gap-1">
285
293
  {#if showLanguage}
286
294
  {#if languageLocked}
287
- <HoverTooltip class="inline-flex shrink-0" text="Language is fixed after the first generation">
295
+ <HoverTooltip class="inline-flex shrink-0" text={$t('creator.brandKit.languageIsFixedAfterThe')}>
288
296
  <span
289
297
  class="generation-language-select flex h-10 w-[4.75rem] shrink-0 cursor-default items-center justify-between gap-0.5 rounded-lg border border-gray-300 bg-white px-1.5 text-sm text-gray-900 opacity-60"
290
298
  aria-disabled="true"
@@ -293,7 +301,7 @@
293
301
  </span>
294
302
  </HoverTooltip>
295
303
  {:else}
296
- <HoverTooltip class="inline-flex shrink-0" text="Select language">
304
+ <HoverTooltip class="inline-flex shrink-0" text={$t('creator.brandKit.selectLanguage')}>
297
305
  <DropdownMenu.Root>
298
306
  <DropdownMenu.Trigger
299
307
  class="generation-language-select flex h-10 w-[4.75rem] shrink-0 cursor-pointer items-center justify-between gap-0.5 rounded-lg border border-gray-300 bg-white px-1.5 text-sm text-gray-900"
@@ -320,7 +328,7 @@
320
328
  {#if showPresetLibraries}
321
329
  <label class="generation-option-toggle flex h-10 shrink-0 cursor-pointer items-center gap-1.5 rounded-lg border px-2 text-sm {librariesEnabled ? 'border-[#314F2F] bg-[#314F2F] text-white' : 'border-gray-300 bg-white text-gray-800'}">
322
330
  <input class="generation-option-check cursor-pointer" type="checkbox" checked={librariesEnabled} onchange={onLibrariesChange} />
323
- Libraries
331
+ {$t('creator.brandKit.libraries')}
324
332
  </label>
325
333
  {/if}
326
334
  {#if librariesEnabled && showPresetLibraries}
@@ -337,11 +345,11 @@
337
345
  {/each}
338
346
  {/if}
339
347
  {#if librariesEnabled && showPresetLibraries}
340
- <HoverTooltip class="inline-flex shrink-0" text="Add Library">
348
+ <HoverTooltip class="inline-flex shrink-0" text={$t('creator.brandKit.addLibrary')}>
341
349
  <button
342
350
  type="button"
343
351
  class="generation-library-add flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-md border border-gray-300 bg-white text-sm text-gray-800"
344
- aria-label="Add Library"
352
+ aria-label={$t('creator.brandKit.addLibrary')}
345
353
  onclick={() => addSourceRow('library')}
346
354
  >+</button>
347
355
  </HoverTooltip>
@@ -356,7 +364,7 @@
356
364
  bind:fileContent={row.content}
357
365
  bind:fileEncoding={row.encoding}
358
366
  bind:url={row.url}
359
- fileLabel="Upload library"
367
+ fileLabel={$t('creator.brandKit.uploadLibrary')}
360
368
  fileTitle={uploadTooltip(false)}
361
369
  urlPlaceholder={urlPlaceholder(false)}
362
370
  accept={sourceAccept(false)}
@@ -365,7 +373,7 @@
365
373
  <button
366
374
  type="button"
367
375
  class="generation-source-remove flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-md border border-gray-300 text-gray-500"
368
- aria-label="Remove library"
376
+ aria-label={$t('creator.brandKit.removeLibrary')}
369
377
  onclick={() => removeSourceRow('library', row.id)}
370
378
  >
371
379
  <svg class="h-3.5 w-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
@@ -384,31 +392,31 @@
384
392
  <Portal
385
393
  target="generation-brand-kit-portal"
386
394
  class="generation-brand-kit-portal-root"
387
- style="position: fixed; top: {brandPanelTop}px; left: {brandPanelLeft}px; width: 320px; height: auto;"
395
+ style="position: fixed; top: {brandPanelTop}px; left: {brandPanelLeft}px; /* rtl-ok: worked out from where the button is on the screen and kept inside it, in pixels from the left edge */ width: 320px; height: auto;"
388
396
  >
389
397
  <div
390
398
  class="generation-brand-kit-popover flex flex-col gap-3 overflow-y-auto rounded-lg border border-gray-200 bg-white p-3 shadow-lg"
391
399
  style={brandPanelMaxHeight > 0 ? `max-height: ${brandPanelMaxHeight}px;` : ''}
392
400
  bind:this={brandPopoverEl}
393
401
  >
394
- <p class="generation-options-note text-xs text-gray-500">Replaces the Widgetic palette for this generation.</p>
402
+ <p class="generation-options-note text-xs text-gray-500">{$t('creator.brandKit.replacesTheWidgeticPaletteFor')}</p>
395
403
  <section class="generation-color-palette flex flex-col gap-2">
396
- <h3 class="generation-section-title text-xs font-semibold text-gray-800">Color palette</h3>
404
+ <h3 class="generation-section-title text-xs font-semibold text-gray-800">{$t('creator.brandKit.colorPalette')}</h3>
397
405
  <div class="generation-brand-colors flex flex-wrap items-end gap-3">
398
406
  <label class="generation-brand-color flex flex-col gap-1 text-xs text-gray-600">
399
- Primary
407
+ {$t('creator.brandKit.primary')}
400
408
  <input class="generation-brand-color-input h-8 w-14 cursor-pointer border border-gray-200 bg-white" type="color" bind:value={primary} />
401
409
  </label>
402
410
  <label class="generation-brand-color flex flex-col gap-1 text-xs text-gray-600">
403
- Secondary
411
+ {$t('creator.brandKit.secondary')}
404
412
  <input class="generation-brand-color-input h-8 w-14 cursor-pointer border border-gray-200 bg-white" type="color" bind:value={secondary} />
405
413
  </label>
406
414
  <label class="generation-brand-color flex flex-col gap-1 text-xs text-gray-600">
407
- Title
415
+ {$t('creator.brandKit.title')}
408
416
  <input class="generation-brand-color-input h-8 w-14 cursor-pointer border border-gray-200 bg-white" type="color" bind:value={title} />
409
417
  </label>
410
418
  <label class="generation-brand-color flex flex-col gap-1 text-xs text-gray-600">
411
- Sub
419
+ {$t('creator.brandKit.sub')}
412
420
  <input class="generation-brand-color-input h-8 w-14 cursor-pointer border border-gray-200 bg-white" type="color" bind:value={sub} />
413
421
  </label>
414
422
  </div>
@@ -416,14 +424,14 @@
416
424
  <div class="generation-section-separator border-t border-gray-200"></div>
417
425
  <section class="generation-brand-fonts flex flex-col gap-2">
418
426
  <div class="generation-fonts-header flex items-center justify-between gap-2">
419
- <h3 class="generation-section-title text-xs font-semibold text-gray-800">Fonts</h3>
427
+ <h3 class="generation-section-title text-xs font-semibold text-gray-800">{$t('creator.brandKit.fonts')}</h3>
420
428
  {#if fontModels.length < maxFonts && !suspendPickers}
421
429
  <button
422
430
  type="button"
423
431
  class="generation-brand-font-add h-7 cursor-pointer rounded-md border border-gray-300 px-2 text-xs text-gray-700"
424
432
  onclick={addFont}
425
433
  >
426
- + Font
434
+ {$t('creator.brandKit.addFont')}
427
435
  </button>
428
436
  {/if}
429
437
  </div>
@@ -434,7 +442,7 @@
434
442
  {:else}
435
443
  <div class="generation-brand-font-picker min-w-0 flex-1">
436
444
  <FontInputController
437
- label={index === 0 ? 'Font' : `Font ${index + 1}`}
445
+ label={index === 0 ? $t('creator.brandKit.fontLabel') : $t('creator.brandKit.font', { number: index + 1 })}
438
446
  controllerId="generation-brand-font-{index}"
439
447
  value={model}
440
448
  {openDropdowns}
@@ -449,7 +457,7 @@
449
457
  <button
450
458
  type="button"
451
459
  class="generation-brand-font-remove mt-1 flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-md border border-gray-300 text-gray-500"
452
- aria-label="Remove font"
460
+ aria-label={$t('creator.brandKit.removeFont')}
453
461
  onclick={() => removeFont(index)}
454
462
  >
455
463
  <svg class="h-3.5 w-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
@@ -468,16 +476,16 @@
468
476
  bind:fileContent={fontFileContent}
469
477
  bind:fileEncoding={fontFileEncoding}
470
478
  bind:url={fontFileUrl}
471
- fileLabel="Upload Fonts"
472
- fileTitle="Upload a font file or an archive."
473
- urlPlaceholder="URL (archive, .woff2, .ttf, .otf)"
479
+ fileLabel={$t('creator.brandKit.uploadFonts')}
480
+ fileTitle={$t('creator.brandKit.uploadAFontFileOr')}
481
+ urlPlaceholder={$t('creator.brandKit.urlArchiveWoff2TtfOtf')}
474
482
  accept=".woff,.woff2,.ttf,.otf,.eot,.zip,.tar,.tgz,.gz"
475
483
  />
476
484
  {#if fontFileName || fontFileUrl}
477
485
  <button
478
486
  type="button"
479
487
  class="generation-source-remove flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-md border border-gray-300 text-gray-500"
480
- aria-label="Remove uploaded font"
488
+ aria-label={$t('creator.brandKit.removeUploadedFont')}
481
489
  onclick={clearFontUpload}
482
490
  >
483
491
  <svg class="h-3.5 w-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
@@ -492,12 +500,12 @@
492
500
  <div class="generation-section-separator border-t border-gray-200"></div>
493
501
  <section class="generation-brand-icons flex flex-col gap-2">
494
502
  <div class="generation-icons-header flex items-center justify-between gap-2">
495
- <h3 class="generation-section-title text-xs font-semibold text-gray-800">Icons</h3>
496
- <HoverTooltip text="Add icon library">
503
+ <h3 class="generation-section-title text-xs font-semibold text-gray-800">{$t('creator.brandKit.icons')}</h3>
504
+ <HoverTooltip text={$t('creator.brandKit.addIconLibrary')}>
497
505
  <button
498
506
  type="button"
499
507
  class="generation-icon-add flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-gray-300 text-sm text-gray-700"
500
- aria-label="Add icon library"
508
+ aria-label={$t('creator.brandKit.addIconLibrary')}
501
509
  onclick={() => addSourceRow('icon')}
502
510
  >+</button>
503
511
  </HoverTooltip>
@@ -510,7 +518,7 @@
510
518
  bind:fileContent={row.content}
511
519
  bind:fileEncoding={row.encoding}
512
520
  bind:url={row.url}
513
- fileLabel="Upload library"
521
+ fileLabel={$t('creator.brandKit.uploadLibrary')}
514
522
  fileTitle={uploadTooltip(true)}
515
523
  urlPlaceholder={urlPlaceholder(true)}
516
524
  accept={sourceAccept(true)}
@@ -519,7 +527,7 @@
519
527
  <button
520
528
  type="button"
521
529
  class="generation-source-remove flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-md border border-gray-300 text-gray-500"
522
- aria-label="Remove icon library"
530
+ aria-label={$t('creator.brandKit.removeIconLibrary')}
523
531
  onclick={() => removeSourceRow('icon', row.id)}
524
532
  >
525
533
  <svg class="h-3.5 w-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
@@ -28,6 +28,6 @@ interface Props {
28
28
  language?: string;
29
29
  languageLocked?: boolean;
30
30
  }
31
- declare const BrandKitPanel: import("svelte").Component<Props, {}, "brandKitEnabled" | "librariesEnabled" | "primary" | "secondary" | "title" | "sub" | "fonts" | "libraries" | "libraryGitUrl" | "libraryFileName" | "libraryUploads" | "fontUploads" | "language">;
31
+ declare const BrandKitPanel: import("svelte").Component<Props, {}, "sub" | "title" | "brandKitEnabled" | "librariesEnabled" | "primary" | "secondary" | "fonts" | "libraries" | "libraryGitUrl" | "libraryFileName" | "libraryUploads" | "fontUploads" | "language">;
32
32
  type BrandKitPanel = ReturnType<typeof BrandKitPanel>;
33
33
  export default BrandKitPanel;
@@ -24,6 +24,13 @@
24
24
  isQuickEditPropertyAvailable,
25
25
  resolveQuickEditValues
26
26
  } from '../utils/designQuickEditValues';
27
+ import { useCreatorLanguage } from '../i18n/index.js';
28
+ import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
29
+
30
+ const { t } = useCreatorLanguage();
31
+ // The direction of the screen the card is on (with no screen around it, left to right): text a person typed is read by its
32
+ // own first letter on a right to left screen, once there is a first letter; a colour code is read left to right on every one.
33
+ const textDirection = useTextDirection();
27
34
 
28
35
  interface Props {
29
36
  spec: DesignControlRequest;
@@ -96,8 +103,7 @@
96
103
  <p class="text-xs leading-relaxed text-gray-600">{spec.summary}</p>
97
104
  {#if detached}
98
105
  <p class="text-[10px] leading-relaxed text-gray-400">
99
- Shown as applied. These controls were made for a different composition — reopen that one to
100
- keep adjusting them.
106
+ {$t('creator.designEdit.shownAsAppliedTheseControls')}
101
107
  </p>
102
108
  {/if}
103
109
  {#each spec.properties as property (property.id)}
@@ -115,7 +121,7 @@
115
121
  {#if detached}
116
122
  <span class="text-xs tabular-nums text-gray-500">{asString(property)}</span>
117
123
  {:else if !available}
118
- <span class="text-[10px] italic text-gray-400">Not available in this widget</span>
124
+ <span class="text-[10px] italic text-gray-400">{$t('creator.designEdit.notAvailableInThisWidget')}</span>
119
125
  {:else if type === 'colorpicker'}
120
126
  <div class="flex items-center gap-2">
121
127
  <input
@@ -127,6 +133,7 @@
127
133
  />
128
134
  <input
129
135
  type="text"
136
+ dir="ltr"
130
137
  class="w-24 rounded border border-gray-300 px-1.5 py-1 text-xs font-mono text-gray-700"
131
138
  value={asString(property)}
132
139
  onchange={(e) => commit(property, (e.currentTarget as HTMLInputElement).value.trim())}
@@ -144,7 +151,7 @@
144
151
  value={asNumber(property)}
145
152
  onchange={(e) => commit(property, Number((e.currentTarget as HTMLInputElement).value))}
146
153
  />
147
- <span class="w-8 text-right text-xs tabular-nums text-gray-700">{asNumber(property)}</span>
154
+ <span class="w-8 text-end text-xs tabular-nums text-gray-700">{asNumber(property)}</span>
148
155
  </div>
149
156
  {:else if type === 'number' || type === 'angle'}
150
157
  <input
@@ -179,6 +186,7 @@
179
186
  {:else if type === 'textarea'}
180
187
  <textarea
181
188
  id={`design-quick-${property.id}`}
189
+ dir={asString(property) ? dirForUserText($textDirection) : undefined}
182
190
  class="w-48 rounded border border-gray-300 px-1.5 py-1 text-xs text-gray-700"
183
191
  rows="2"
184
192
  value={asString(property)}
@@ -188,6 +196,7 @@
188
196
  <input
189
197
  id={`design-quick-${property.id}`}
190
198
  type="text"
199
+ dir={asString(property) ? dirForUserText($textDirection) : undefined}
191
200
  class="w-40 rounded border border-gray-300 px-1.5 py-1 text-xs text-gray-700"
192
201
  value={asString(property)}
193
202
  onchange={(e) => commit(property, (e.currentTarget as HTMLInputElement).value)}
@@ -1,10 +1,13 @@
1
1
  <script lang="ts">
2
2
  import { createEventDispatcher } from 'svelte';
3
3
  import HoverTooltip from './HoverTooltip.svelte';
4
+ import { useCreatorLanguage } from '../i18n/index.js';
5
+
6
+ const { t } = useCreatorLanguage();
4
7
 
5
8
  export let name: string = '';
6
- export let placeholder: string = 'Unnamed';
7
- export let tooltipText: string = 'Double-click to rename';
9
+ export let placeholder: string | undefined = undefined;
10
+ export let tooltipText: string | undefined = undefined;
8
11
  let className = '';
9
12
  export { className as class };
10
13
  export let style = '';
@@ -24,7 +27,7 @@
24
27
  let lastNameClickX = 0;
25
28
  let lastNameClickY = 0;
26
29
 
27
- $: nameDisplayText = isEditing ? inputValue : (name || placeholder);
30
+ $: nameDisplayText = isEditing ? inputValue : (name || placeholder || $t('creator.name.unnamed'));
28
31
 
29
32
  function openEditMode() {
30
33
  isEditing = true;
@@ -132,7 +135,7 @@
132
135
  </script>
133
136
 
134
137
  <!-- svelte-ignore a11y-no-static-element-interactions -->
135
- <HoverTooltip text={isEditing ? '' : tooltipText} class="min-w-0 w-max max-w-full" {style}>
138
+ <HoverTooltip text={isEditing ? '' : (tooltipText ?? $t('creator.common.doubleClickToRename'))} class="min-w-0 w-max max-w-full" {style}>
136
139
  <div
137
140
  class="editable-name-ct flex items-center w-max max-w-full min-w-0 {isEditing ? 'gap-0.5' : 'gap-0'} {className}"
138
141
  onpointerdown={onNamePointerDown}
@@ -163,7 +166,7 @@
163
166
  <button
164
167
  type="button"
165
168
  class="editable-name-pencil w-4 h-4 shrink-0 text-gray-400 text-[16px] leading-none cursor-pointer transition-opacity flex items-center justify-center p-0 bg-transparent border-0 {isEditing ? 'opacity-100' : 'opacity-0'}"
166
- aria-label={isEditing ? 'Save name' : 'Rename widget'}
169
+ aria-label={isEditing ? $t('creator.name.saveName') : $t('creator.name.renameWidget')}
167
170
  onmousedown={(e) => { e.preventDefault(); e.stopPropagation(); }}
168
171
  onpointerdown={(e) => e.stopPropagation()}
169
172
  onclick={toggleEditing}
@@ -177,15 +180,17 @@
177
180
  visibility: hidden;
178
181
  white-space: nowrap;
179
182
  font: inherit;
180
- padding: 2px 0 2px 2px;
183
+ padding-block: 2px;
184
+ padding-inline: 2px 0;
181
185
  }
182
186
  .editable-name-ct:focus-within .editable-name-sizer {
183
- padding-right: 2px;
187
+ padding-inline-end: 2px;
184
188
  }
185
189
  .editable-name-input {
186
190
  width: 100%;
187
191
  height: 100%;
188
- padding: 2px 0 2px 2px;
192
+ padding-block: 2px;
193
+ padding-inline: 2px 0;
189
194
  margin: 0;
190
195
  border-width: 1px;
191
196
  box-sizing: border-box;
@@ -13,8 +13,8 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
13
13
  }
14
14
  declare const EditableName: $$__sveltets_2_IsomorphicComponent<{
15
15
  name?: string;
16
- placeholder?: string;
17
- tooltipText?: string;
16
+ placeholder?: string | undefined;
17
+ tooltipText?: string | undefined;
18
18
  class?: string;
19
19
  style?: string;
20
20
  }, {
@@ -1,5 +1,12 @@
1
1
  <script lang="ts">
2
2
  import HoverTooltip from './HoverTooltip.svelte';
3
+ import { useCreatorLanguage } from '../i18n/index.js';
4
+ import { useTextDirection } from '@widgetic/design-system/components/textDirection';
5
+ import { contentOfPickedFile, isBinaryFileName } from '../utils/pickedFile.js';
6
+
7
+ const { t } = useCreatorLanguage();
8
+ // The direction of the screen the control is on (with no screen around it, left to right).
9
+ const textDirection = useTextDirection();
3
10
 
4
11
  interface Props {
5
12
  class?: string;
@@ -21,12 +28,16 @@
21
28
  fileContent = $bindable(''),
22
29
  fileEncoding = $bindable('utf8'),
23
30
  url = $bindable(''),
24
- fileLabel = 'Upload file',
31
+ fileLabel = '',
25
32
  fileTitle = '',
26
- urlPlaceholder = 'URL',
33
+ urlPlaceholder = '',
27
34
  accept = '.js,.mjs',
28
35
  }: Props = $props();
29
36
 
37
+ // What the control says when the page gave it no words of its own.
38
+ const uploadLabel = $derived(fileLabel || $t('creator.fileSource.uploadFile'));
39
+ const urlHint = $derived(urlPlaceholder || $t('creator.fileSource.url'));
40
+
30
41
  function onFile(event: Event) {
31
42
  const input = event.currentTarget as HTMLInputElement;
32
43
  const file = input.files?.[0];
@@ -34,11 +45,11 @@
34
45
  fileContent = '';
35
46
  if (!file) return;
36
47
  const reader = new FileReader();
37
- const binary = /\.(zip|tar|tgz|gz|woff2?|ttf|otf|eot)$/i.test(file.name);
48
+ // Archives and fonts are read as binary and sent as base64; anything else is text (see `utils/pickedFile.ts`).
49
+ const binary = isBinaryFileName(file.name);
38
50
  fileEncoding = binary ? 'base64' : 'utf8';
39
51
  reader.onload = () => {
40
- const result = String(reader.result || '');
41
- fileContent = archived ? result.slice(result.indexOf(',') + 1) : result;
52
+ fileContent = contentOfPickedFile(binary, String(reader.result || ''));
42
53
  };
43
54
  if (binary) reader.readAsDataURL(file);
44
55
  else reader.readAsText(file);
@@ -46,16 +57,18 @@
46
57
  </script>
47
58
 
48
59
  <div class="file-url-source flex min-w-0 flex-1 items-center gap-2 {className}" {style}>
49
- <HoverTooltip class="inline-flex shrink-0" text={fileTitle || fileLabel}>
60
+ <HoverTooltip class="inline-flex shrink-0" text={fileTitle || uploadLabel}>
50
61
  <label class="file-url-source-upload flex h-10 max-w-40 shrink-0 cursor-pointer items-center truncate rounded-lg border border-gray-300 bg-white px-2 text-xs text-gray-700">
51
- {fileName || fileLabel}
62
+ {fileName || uploadLabel}
52
63
  <input class="sr-only" type="file" {accept} onchange={onFile} />
53
64
  </label>
54
65
  </HoverTooltip>
66
+ <!-- A link is read left to right on every screen: on a right to left one, the dots and slashes at its ends would show on the wrong side. -->
55
67
  <input
56
68
  class="file-url-source-url h-10 min-w-0 flex-1 rounded-lg border border-gray-300 bg-white px-2 text-xs text-gray-900"
57
69
  type="text"
58
- placeholder={urlPlaceholder}
70
+ dir={$textDirection === 'rtl' ? 'ltr' : undefined}
71
+ placeholder={urlHint}
59
72
  bind:value={url}
60
73
  />
61
74
  </div>
@@ -53,7 +53,7 @@
53
53
  <Portal target={portalTarget}>
54
54
  <div
55
55
  class="wc-hover-tooltip-bubble pointer-events-none fixed z-[99999] -translate-x-1/2 -translate-y-full rounded-md bg-[#1f2937] px-2.5 py-1 text-xs leading-snug text-[#f9fafb] shadow-md {maxWidth ? 'whitespace-normal text-center' : 'whitespace-nowrap'}"
56
- style="top: {tipTop}px; left: {tipLeft}px;{maxWidth ? ` max-width: ${maxWidth}px;` : ''}"
56
+ style="top: {tipTop}px; left: {tipLeft}px; /* rtl-ok: centred above the middle of the trigger, so it is the same from either side */{maxWidth ? ` max-width: ${maxWidth}px;` : ''}"
57
57
  role="tooltip"
58
58
  >
59
59
  {text}
@@ -18,6 +18,9 @@
18
18
  * - Click-outside closes
19
19
  */
20
20
  import { onMount, onDestroy, tick } from 'svelte';
21
+ import { useCreatorLanguage } from '../i18n/index.js';
22
+
23
+ const { t } = useCreatorLanguage();
21
24
 
22
25
  let className = '';
23
26
  export { className as class };
@@ -27,8 +30,8 @@
27
30
  export let selectedId: string | null = null;
28
31
  export let label = '';
29
32
  export let labelPosition: 'above' | 'inline' = 'above';
30
- export let placeholder = 'Select...';
31
- export let newButtonLabel = 'New';
33
+ export let placeholder: string | undefined = undefined;
34
+ export let newButtonLabel: string | undefined = undefined;
32
35
  export let accentColor = '#314F2F';
33
36
  export let nameWidth = '160px';
34
37
  export let loading = false;
@@ -47,7 +50,7 @@
47
50
  let rootEl: HTMLElement;
48
51
 
49
52
  $: selectedItem = items.find(i => i.id === selectedId) || null;
50
- $: selectedName = selectedItem?.name || placeholder;
53
+ $: selectedName = selectedItem?.name || placeholder || $t('creator.selector.select');
51
54
 
52
55
  function toggle(e: MouseEvent) {
53
56
  e.stopPropagation();
@@ -100,8 +103,9 @@
100
103
  }
101
104
 
102
105
  function handleOutsideClick(e: MouseEvent) {
103
- const target = e.target as HTMLElement;
104
- if (rootEl && !rootEl.contains(target)) {
106
+ // The whole path is looked at, not `e.target`: from `window` the target of a click inside a shadow root is the
107
+ // shadow's host element, which is never inside this dropdown, so it would close on every click it is given.
108
+ if (rootEl && !e.composedPath().includes(rootEl)) {
105
109
  open = false;
106
110
  if (renaming) commitRename();
107
111
  }
@@ -122,7 +126,7 @@
122
126
  <div class="selector-dropdown-group flex items-center gap-1.5 relative {className}" style="{labelPosition === 'above' ? 'padding-top: 1rem;' : ''} {style}" bind:this={rootEl}>
123
127
  <!-- Label: above (legacy) or inline before selector -->
124
128
  {#if label && labelPosition === 'above'}
125
- <span class="selector-dropdown-label absolute top-0 left-0 pl-2 text-[10px] font-semibold uppercase tracking-wider whitespace-nowrap" style="color: {accentColor};">{label}</span>
129
+ <span class="selector-dropdown-label absolute top-0 start-0 ps-2 text-[10px] font-semibold uppercase tracking-wider whitespace-nowrap" style="color: {accentColor};">{label}</span>
126
130
  {:else if label && labelPosition === 'inline'}
127
131
  <span class="selector-dropdown-label shrink-0 text-[10px] font-semibold uppercase tracking-wider whitespace-nowrap" style="color: {accentColor};">{label}</span>
128
132
  {/if}
@@ -147,18 +151,18 @@
147
151
  <span
148
152
  class="selector-dropdown-selected-text text-[13px] font-medium text-gray-800 px-2.5 py-1 cursor-pointer whitespace-nowrap overflow-hidden text-ellipsis block leading-snug"
149
153
  style="width: {nameWidth};"
150
- title={allowRename && selectedItem ? `Double-click to rename · ${selectedId || ''}` : (selectedId || '')}
154
+ title={allowRename && selectedItem ? $t('creator.selector.doubleClickToRename', { id: selectedId || '' }) : (selectedId || '')}
151
155
  onclick={toggle}
152
156
  ondblclick={startRename}
153
157
  >
154
- {selectedName}{#if loading}<span class="text-gray-400 ml-1 animate-pulse text-[10px]">…</span>{/if}
158
+ {selectedName}{#if loading}<span class="text-gray-400 ms-1 animate-pulse text-[10px]">…</span>{/if}
155
159
  </span>
156
160
  {/if}
157
161
  </div>
158
162
  <button
159
- class="selector-dropdown-trigger flex items-center justify-center w-[26px] shrink-0 border-0 border-l border-gray-200 bg-transparent cursor-pointer text-gray-500 transition-colors hover:bg-gray-200 hover:text-gray-700 {open ? 'bg-gray-200 text-gray-900' : ''}"
163
+ class="selector-dropdown-trigger flex items-center justify-center w-[26px] shrink-0 border-0 border-s border-gray-200 bg-transparent cursor-pointer text-gray-500 transition-colors hover:bg-gray-200 hover:text-gray-700 {open ? 'bg-gray-200 text-gray-900' : ''}"
160
164
  onclick={toggle}
161
- title="Toggle list"
165
+ title={$t('creator.selector.toggleList')}
162
166
  >
163
167
  <svg width="12" height="12" viewBox="0 0 12 12" fill="none" class="transition-transform {open ? 'rotate-180' : ''}">
164
168
  <path d="M2 4l4 4 4-4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
@@ -173,18 +177,18 @@
173
177
  class="selector-dropdown-new-btn flex items-center gap-1 px-2.5 py-1 text-xs font-medium rounded border cursor-pointer whitespace-nowrap transition-colors"
174
178
  style="color: {accentColor}; background: {accentBg(accentColor)}; border-color: {accentBorder(accentColor)};"
175
179
  onclick={handleNew}
176
- title="{newButtonLabel}"
180
+ title={newButtonLabel ?? $t('creator.common.new')}
177
181
  >
178
182
  <svg width="14" height="14" viewBox="0 0 14 14" fill="none">
179
183
  <path d="M7 2v10M2 7h10" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
180
184
  </svg>
181
- {newButtonLabel}
185
+ {newButtonLabel ?? $t('creator.common.new')}
182
186
  </button>
183
187
  {/if}
184
188
 
185
189
  <!-- Dropdown list -->
186
190
  {#if open}
187
- <div class="selector-dropdown-list absolute top-[calc(100%+4px)] left-0 right-0 bg-white border border-gray-200 rounded-lg shadow-lg overflow-hidden p-1" style="z-index: 100;">
191
+ <div class="selector-dropdown-list absolute top-[calc(100%+4px)] start-0 end-0 bg-white border border-gray-200 rounded-lg shadow-lg overflow-hidden p-1" style="z-index: 100;">
188
192
  <div class="selector-dropdown-items max-h-80 overflow-y-auto overflow-x-hidden scrollbar-thin">
189
193
  {#each items as entry (entry.id)}
190
194
  <!-- svelte-ignore a11y_click_events_have_key_events -->
@@ -218,7 +222,7 @@
218
222
  {#if ondelete}
219
223
  <button
220
224
  class="selector-dropdown-item-delete shrink-0 w-5 h-5 flex items-center justify-center rounded text-gray-300 hover:text-red-500 hover:bg-red-50 transition-colors"
221
- title="Delete"
225
+ title={$t('creator.common.delete')}
222
226
  onclick={(e) => handleDelete(entry, e)}
223
227
  >
224
228
  <svg width="10" height="10" viewBox="0 0 10 10" fill="none">
@@ -229,7 +233,7 @@
229
233
  </div>
230
234
  {:else}
231
235
  <div class="selector-dropdown-empty text-xs text-gray-400 px-2 py-3 text-center">
232
- {loading ? 'Loading...' : 'No items found'}
236
+ {loading ? $t('creator.common.loading') : $t('creator.selector.noItemsFound')}
233
237
  </div>
234
238
  {/each}
235
239
  </div>
@@ -23,8 +23,8 @@ declare const SelectorDropdown: $$__sveltets_2_IsomorphicComponent<{
23
23
  selectedId?: string | null;
24
24
  label?: string;
25
25
  labelPosition?: "above" | "inline";
26
- placeholder?: string;
27
- newButtonLabel?: string;
26
+ placeholder?: string | undefined;
27
+ newButtonLabel?: string | undefined;
28
28
  accentColor?: string;
29
29
  nameWidth?: string;
30
30
  loading?: boolean;