camox 0.48.0 → 0.52.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 (127) hide show
  1. package/dist/core/createApp.d.ts +1 -0
  2. package/dist/core/createApp.js +1 -0
  3. package/dist/core/editing/contentEdits.js +78 -0
  4. package/dist/core/editing/createEditableBlock.js +277 -311
  5. package/dist/core/layoutContext.d.ts +1 -0
  6. package/dist/core/lib/contentType.js +2 -2
  7. package/dist/core/recordItem.js +3 -3
  8. package/dist/features/canvas/CamoxCanvas.js +15 -15
  9. package/dist/features/canvas/CanvasLoadingScreen.js +15 -11
  10. package/dist/features/canvas/CanvasPageFrame.js +81 -87
  11. package/dist/features/canvas/CanvasPreviewPageSlot.js +1 -1
  12. package/dist/features/canvas/DerivedPagePathInput.js +12 -12
  13. package/dist/features/canvas/canvasOverlayGeometry.js +1 -1
  14. package/dist/features/canvas/canvasStore.js +2 -2
  15. package/dist/features/canvas/sidebar/CanvasInspector.js +1 -1
  16. package/dist/features/canvas/sidebar/CuratedPageInspector.js +1 -1
  17. package/dist/features/canvas/sidebar/LayoutPageBlocks.js +23 -31
  18. package/dist/features/canvas/useCanvasCamera.js +1 -1
  19. package/dist/features/canvas/useDiscoveredPreviewPaths.js +16 -9
  20. package/dist/features/content/ContentAssets.js +84 -88
  21. package/dist/features/page/CuratedPageContent.js +1 -1
  22. package/dist/features/preview/CamoxPreview.d.ts +8 -4
  23. package/dist/features/preview/CamoxPreview.js +258 -443
  24. package/dist/features/preview/EditablePageContent.js +244 -2
  25. package/dist/features/preview/EditablePageExperience.js +19 -13
  26. package/dist/features/preview/components/AddBlockSheet.js +55 -15
  27. package/dist/features/preview/components/BlockActionsPopover.js +23 -51
  28. package/dist/features/preview/components/BlockPeek.js +66 -0
  29. package/dist/features/preview/components/BlockThumbnail.js +134 -119
  30. package/dist/features/preview/components/CanvasPreview.js +1 -1
  31. package/dist/features/preview/components/CreatePageModal.js +150 -156
  32. package/dist/features/preview/components/FieldToolbar.js +1 -1
  33. package/dist/features/preview/components/Frame.js +27 -4
  34. package/dist/features/preview/components/MobilePreviewDrawer.js +6 -9
  35. package/dist/features/preview/components/PageInfo.js +161 -126
  36. package/dist/features/preview/components/PagePicker.js +2 -2
  37. package/dist/features/preview/components/PageTree.js +174 -190
  38. package/dist/features/preview/components/PreviewPanel.js +13 -67
  39. package/dist/features/preview/components/PreviewToolbar.js +1 -1
  40. package/dist/features/preview/components/ReferenceFieldEditor.js +4 -4
  41. package/dist/features/preview/components/ReferenceListFieldEditor.js +4 -4
  42. package/dist/features/preview/components/RemovedBlockPlaceholder.js +37 -70
  43. package/dist/features/preview/components/RepeatableItemsList.js +1 -1
  44. package/dist/features/preview/components/SelectionEditor.js +248 -256
  45. package/dist/features/preview/components/StudioEditingFallback.js +22 -26
  46. package/dist/features/preview/components/useFieldWriter.js +19 -19
  47. package/dist/features/preview/components/useRecordView.js +105 -147
  48. package/dist/features/preview/components/useRepeatableItemActions.js +0 -2
  49. package/dist/features/preview/pageRecord.js +30 -24
  50. package/dist/features/preview/previewConstants.js +2 -8
  51. package/dist/features/preview/previewStore.js +2 -0
  52. package/dist/features/preview/studioNotice.js +20 -0
  53. package/dist/features/preview/usePreviewViewportActions.js +1 -1
  54. package/dist/features/provider/AuthenticatedCamoxProvider.js +47 -31
  55. package/dist/features/provider/components/CommandPalette.js +2 -5
  56. package/dist/features/provider/signInShortcut.js +1 -2
  57. package/dist/features/provider/useAdminShortcuts.js +47 -53
  58. package/dist/features/renderer/RendererApp.js +542 -0
  59. package/dist/features/renderer/RendererFrames.js +450 -0
  60. package/dist/features/renderer/definitionAnswers.js +26 -0
  61. package/dist/features/renderer/protocol.js +35 -0
  62. package/dist/features/renderer/rendererHost.js +249 -0
  63. package/dist/features/renderer/studioConnection.js +186 -0
  64. package/dist/features/routes/pageRuntime.d.ts +2 -1
  65. package/dist/features/routes/pageRuntime.js +34 -22
  66. package/dist/features/runtime/RuntimeChrome.js +2 -5
  67. package/dist/features/runtime/assetPrefix.js +14 -0
  68. package/dist/features/runtime/breadcrumbs.js +1 -1
  69. package/dist/features/runtime/editingFallback.js +4 -8
  70. package/dist/features/runtime/livePages.js +1 -1
  71. package/dist/features/runtime/pageApp.js +57 -83
  72. package/dist/features/runtime/pageClient.js +1 -1
  73. package/dist/features/runtime/pageNavigation.js +3 -2
  74. package/dist/features/runtime/publicCache.js +95 -0
  75. package/dist/features/runtime/publishingDraft.js +23 -0
  76. package/dist/features/runtime/rendererClient.d.ts +8 -0
  77. package/dist/features/runtime/rendererClient.js +77 -0
  78. package/dist/features/runtime/runtime.d.ts +22 -3
  79. package/dist/features/runtime/runtime.js +209 -96
  80. package/dist/features/runtime/runtimeRoutes.d.ts +2 -0
  81. package/dist/features/runtime/runtimeRoutes.js +2 -0
  82. package/dist/features/runtime/worker.d.ts +14 -1
  83. package/dist/features/runtime/worker.js +34 -4
  84. package/dist/features/settings/AnalyticsSettings.js +622 -0
  85. package/dist/features/settings/CamoxSettings.js +95 -0
  86. package/dist/features/settings/FaviconSettings.js +254 -0
  87. package/dist/features/settings/ProjectNameSettings.js +145 -0
  88. package/dist/features/settings/SettingsPart.js +73 -0
  89. package/dist/features/settings/SocialProfilesSettings.js +245 -0
  90. package/dist/features/settings/useProjectMutation.js +61 -0
  91. package/dist/features/studio/FollowAgentProvider.js +10 -10
  92. package/dist/features/studio/components/DraftsControl.js +136 -131
  93. package/dist/features/studio/components/LocalePicker.js +178 -174
  94. package/dist/features/studio/components/Navbar.js +107 -66
  95. package/dist/features/studio/components/ProjectMenu.js +119 -171
  96. package/dist/features/studio/components/ReviewDraftSheet.js +1151 -991
  97. package/dist/features/studio/components/ThreadMessages.js +100 -65
  98. package/dist/features/studio/components/UserButton.js +2 -2
  99. package/dist/features/studio/routes.js +3 -1
  100. package/dist/features/studio/showInCanvas.js +129 -0
  101. package/dist/features/vite/definitionsSync.js +5 -6
  102. package/dist/features/vite/hostedChecks.js +127 -0
  103. package/dist/features/vite/runtimeDev.js +58 -17
  104. package/dist/features/vite/staticAssetHeaders.js +52 -0
  105. package/dist/features/vite/vite.d.ts +1 -1
  106. package/dist/features/vite/vite.js +49 -9
  107. package/dist/hooks/use-page-destinations.js +10 -10
  108. package/dist/lib/api-client-server.d.ts +1 -1
  109. package/dist/lib/api-client.d.ts +2 -1
  110. package/dist/lib/draft-scope.d.ts +1 -0
  111. package/dist/lib/locale-path.d.ts +3 -11
  112. package/dist/lib/locale-path.js +3 -27
  113. package/dist/lib/queries.js +7 -1
  114. package/dist/lib/revisions.js +20 -0
  115. package/dist/lib/shortcuts.js +29 -0
  116. package/dist/lib/studio-definitions.js +160 -0
  117. package/dist/lib/studio-reads.d.ts +1 -0
  118. package/dist/lib/studio-reads.js +65 -21
  119. package/dist/lib/use-project-room.js +16 -10
  120. package/dist/lib/utils.js +1 -104
  121. package/dist/package.js +1 -1
  122. package/dist/studio.css +1 -1
  123. package/package.json +9 -4
  124. package/skills/camox/SKILL.md +4 -0
  125. package/skills/camox/references/artifacts.md +1 -1
  126. package/dist/features/studio/components/FaviconDialog.js +0 -318
  127. package/dist/features/studio/components/SocialProfilesDialog.js +0 -342
@@ -0,0 +1,160 @@
1
+ import { useProjectUuid } from "./auth.js";
2
+ import { reads, useReadQuery } from "./studio-reads.js";
3
+ import { c } from "react/compiler-runtime";
4
+
5
+ //#region src/lib/studio-definitions.ts
6
+ const toBlockDefinitions = (rows) => rows.map((row) => ({
7
+ id: row.blockId,
8
+ title: row.title,
9
+ description: row.description,
10
+ contentSchema: row.contentSchema,
11
+ settingsSchema: row.settingsSchema ?? void 0,
12
+ defaultContent: row.defaultContent ?? {},
13
+ defaultSettings: row.defaultSettings ?? {},
14
+ layoutOnly: !!row.layoutOnly,
15
+ synced: row.synced
16
+ }));
17
+ const toLayoutDefinitions = (rows) => rows.map((row) => ({
18
+ id: row.layoutId,
19
+ title: row.title ?? row.layoutId,
20
+ kind: row.kind
21
+ }));
22
+ function useProjectId() {
23
+ const { data: project } = useReadQuery(reads.project({ projectUuid: useProjectUuid() }));
24
+ return project?.id;
25
+ }
26
+ const NO_BLOCKS = [];
27
+ const NO_LAYOUTS = [];
28
+ /** Every block definition, empty until they load. */
29
+ function useBlockDefinitions() {
30
+ const $ = c(4);
31
+ const projectId = useProjectId();
32
+ let t0;
33
+ if ($[0] !== projectId) {
34
+ t0 = reads.blockDefinitionList({ projectId: projectId ?? 0 });
35
+ $[0] = projectId;
36
+ $[1] = t0;
37
+ } else t0 = $[1];
38
+ const t1 = projectId != null;
39
+ let t2;
40
+ if ($[2] !== t1) {
41
+ t2 = {
42
+ enabled: t1,
43
+ select: toBlockDefinitions
44
+ };
45
+ $[2] = t1;
46
+ $[3] = t2;
47
+ } else t2 = $[3];
48
+ const { data } = useReadQuery(t0, t2);
49
+ return data ?? NO_BLOCKS;
50
+ }
51
+ /** The definition of a block type, undefined while loading or when the draft has none. */
52
+ function useBlockDefinition(type) {
53
+ const $ = c(3);
54
+ const definitions = useBlockDefinitions();
55
+ let t0;
56
+ if ($[0] !== definitions || $[1] !== type) {
57
+ t0 = type === void 0 ? void 0 : definitions.find((definition) => definition.id === type);
58
+ $[0] = definitions;
59
+ $[1] = type;
60
+ $[2] = t0;
61
+ } else t0 = $[2];
62
+ return t0;
63
+ }
64
+ /** Every layout definition, empty until they load. */
65
+ function useLayoutDefinitions() {
66
+ const $ = c(4);
67
+ const projectId = useProjectId();
68
+ let t0;
69
+ if ($[0] !== projectId) {
70
+ t0 = reads.layoutList({ projectId: projectId ?? 0 });
71
+ $[0] = projectId;
72
+ $[1] = t0;
73
+ } else t0 = $[1];
74
+ const t1 = projectId != null;
75
+ let t2;
76
+ if ($[2] !== t1) {
77
+ t2 = {
78
+ enabled: t1,
79
+ select: toLayoutDefinitions
80
+ };
81
+ $[2] = t1;
82
+ $[3] = t2;
83
+ } else t2 = $[3];
84
+ const { data } = useReadQuery(t0, t2);
85
+ return data ?? NO_LAYOUTS;
86
+ }
87
+ const NO_ROUTABLE_LAYOUTS = [];
88
+ const toRoutableLayouts = (rows) => toLayoutDefinitions(rows).map((definition) => ({ _internal: definition }));
89
+ /** Every layout definition, as the route helpers read layouts: empty until they load. */
90
+ function useRoutableLayouts() {
91
+ const $ = c(4);
92
+ const projectId = useProjectId();
93
+ let t0;
94
+ if ($[0] !== projectId) {
95
+ t0 = reads.layoutList({ projectId: projectId ?? 0 });
96
+ $[0] = projectId;
97
+ $[1] = t0;
98
+ } else t0 = $[1];
99
+ const t1 = projectId != null;
100
+ let t2;
101
+ if ($[2] !== t1) {
102
+ t2 = {
103
+ enabled: t1,
104
+ select: toRoutableLayouts
105
+ };
106
+ $[2] = t1;
107
+ $[3] = t2;
108
+ } else t2 = $[3];
109
+ const { data } = useReadQuery(t0, t2);
110
+ return data ?? NO_ROUTABLE_LAYOUTS;
111
+ }
112
+ /** The definition of a layout, undefined while loading or when the draft has none. */
113
+ function useLayoutDefinition(id) {
114
+ const $ = c(3);
115
+ const definitions = useLayoutDefinitions();
116
+ let t0;
117
+ if ($[0] !== definitions || $[1] !== id) {
118
+ t0 = id === void 0 ? void 0 : definitions.find((definition) => definition.id === id);
119
+ $[0] = definitions;
120
+ $[1] = id;
121
+ $[2] = t0;
122
+ } else t0 = $[2];
123
+ return t0;
124
+ }
125
+ const toCollectionDefinition = (row) => ({
126
+ id: row.collectionId,
127
+ title: row.title,
128
+ toTitle: row.toTitle,
129
+ toDescription: row.toDescription,
130
+ contentSchema: row.contentSchema
131
+ });
132
+ /** The definition of a collection, undefined while loading or when the draft has none. */
133
+ function useCollectionDefinition(collectionId) {
134
+ const $ = c(5);
135
+ const projectUuid = useProjectUuid();
136
+ let t0;
137
+ if ($[0] !== collectionId || $[1] !== projectUuid) {
138
+ t0 = reads.collection({
139
+ projectUuid,
140
+ collectionId: collectionId ?? ""
141
+ });
142
+ $[0] = collectionId;
143
+ $[1] = projectUuid;
144
+ $[2] = t0;
145
+ } else t0 = $[2];
146
+ const t1 = collectionId != null;
147
+ let t2;
148
+ if ($[3] !== t1) {
149
+ t2 = {
150
+ enabled: t1,
151
+ select: toCollectionDefinition
152
+ };
153
+ $[3] = t1;
154
+ $[4] = t2;
155
+ } else t2 = $[4];
156
+ return useReadQuery(t0, t2).data;
157
+ }
158
+
159
+ //#endregion
160
+ export { useBlockDefinition, useBlockDefinitions, useCollectionDefinition, useLayoutDefinition, useLayoutDefinitions, useRoutableLayouts };
@@ -1,3 +1,4 @@
1
+ import "./locale-path.js";
1
2
  import "../core/createLayout.js";
2
3
  import "../features/runtime/runtime.js";
3
4
  import "./draft-scope.js";
@@ -21,6 +21,11 @@ function entry(definition) {
21
21
  }
22
22
  const usageCountsPrefix = queryKeys.blocks.getUsageCounts;
23
23
  const collectionsPrefix = ["camox", "collections"];
24
+ const blockDefinitionsPrefix = [
25
+ "camox",
26
+ "blockDefinitions",
27
+ "list"
28
+ ];
24
29
  const loadLayout = ({ api, signal }, { projectUuid, layoutId }) => api.layouts.get({
25
30
  projectUuid,
26
31
  layoutId
@@ -115,6 +120,11 @@ const reads = {
115
120
  fetch: ({ api, signal }, { projectId }) => api.layouts.list({ projectId }, { signal }),
116
121
  staleTime: Infinity
117
122
  }),
123
+ blockDefinitionList: entry({
124
+ key: () => blockDefinitionsPrefix,
125
+ fetch: ({ api, signal }, { projectId }) => api.blockDefinitions.list({ projectId }, { signal }),
126
+ staleTime: Infinity
127
+ }),
118
128
  blockBundle: entry({
119
129
  key: (id) => queryKeys.blocks.get(id),
120
130
  fetch: ({ api, signal }, id) => api.blocks.get({ id }, { signal }),
@@ -321,6 +331,28 @@ function createStudioCache({ queryClient, scope, api, runtimeJson = (endpoint, b
321
331
  fill: (read, value) => queryClient.setQueryData(keyOf(read, target), value)
322
332
  });
323
333
  const neverAborted = () => new AbortController().signal;
334
+ const listeners = /* @__PURE__ */ new Set();
335
+ const changed = (change) => {
336
+ for (const listener of listeners) listener(change);
337
+ };
338
+ const write = (key, value) => {
339
+ const data = queryClient.setQueryData(key, value);
340
+ changed({
341
+ type: "wrote",
342
+ queryKey: key,
343
+ value: data
344
+ });
345
+ };
346
+ const forget = (key) => {
347
+ queryClient.removeQueries({
348
+ queryKey: key,
349
+ exact: true
350
+ });
351
+ changed({
352
+ type: "wrote",
353
+ queryKey: key
354
+ });
355
+ };
324
356
  const options = (read, inDraft) => {
325
357
  const target = targetOf(inDraft);
326
358
  const definition = read.entry.definition;
@@ -361,21 +393,29 @@ function createStudioCache({ queryClient, scope, api, runtimeJson = (endpoint, b
361
393
  return {
362
394
  options,
363
395
  get: (read, inDraft) => queryClient.getQueryData(keyOf(read, targetOf(inDraft))),
364
- set: (read, value, inDraft) => queryClient.setQueryData(keyOf(read, targetOf(inDraft)), value),
396
+ set: (read, value, inDraft) => write(keyOf(read, targetOf(inDraft)), value),
365
397
  land,
366
398
  ensure: async (read, inDraft) => {
367
399
  const cached = queryClient.getQueryData(keyOf(read, targetOf(inDraft)));
368
400
  return cached !== void 0 ? cached : loadFully(read, inDraft);
369
401
  },
370
402
  reload: loadFully,
371
- invalidate: (read, inDraft) => queryClient.invalidateQueries({
372
- queryKey: keyOf(read, targetOf(inDraft)),
373
- exact: true
374
- }),
375
- remove: (read, inDraft) => queryClient.removeQueries({
376
- queryKey: keyOf(read, targetOf(inDraft)),
377
- exact: true
378
- }),
403
+ invalidate: (read, inDraft) => {
404
+ const queryKey = keyOf(read, targetOf(inDraft));
405
+ changed({
406
+ type: "outdated",
407
+ queryKeys: [queryKey]
408
+ });
409
+ return queryClient.invalidateQueries({
410
+ queryKey,
411
+ exact: true
412
+ });
413
+ },
414
+ remove: (read, inDraft) => forget(keyOf(read, targetOf(inDraft))),
415
+ subscribe(listener) {
416
+ listeners.add(listener);
417
+ return () => listeners.delete(listener);
418
+ },
379
419
  edit: () => {
380
420
  const target = targetOf();
381
421
  const snapshots = /* @__PURE__ */ new Map();
@@ -396,27 +436,31 @@ function createStudioCache({ queryClient, scope, api, runtimeJson = (endpoint, b
396
436
  };
397
437
  return {
398
438
  get: (read) => queryClient.getQueryData(keyOf(read, target)),
399
- set: (read, value) => queryClient.setQueryData(touch(read), value),
400
- remove: (read) => queryClient.removeQueries({
401
- queryKey: touch(read),
402
- exact: true
403
- }),
439
+ set: (read, value) => write(touch(read), value),
440
+ remove: (read) => forget(touch(read)),
404
441
  rollback: () => {
405
- for (const { key, data } of snapshots.values()) if (data === void 0) queryClient.removeQueries({
406
- queryKey: key,
407
- exact: true
408
- });
409
- else queryClient.setQueryData(key, data);
442
+ for (const { key, data } of snapshots.values()) if (data === void 0) forget(key);
443
+ else write(key, data);
410
444
  },
411
445
  settle: () => {
412
- for (const { key } of snapshots.values()) queryClient.invalidateQueries({
413
- queryKey: key,
446
+ const queryKeys = [...snapshots.values()].map(({ key }) => key);
447
+ if (queryKeys.length) changed({
448
+ type: "outdated",
449
+ queryKeys
450
+ });
451
+ for (const queryKey of queryKeys) queryClient.invalidateQueries({
452
+ queryKey,
414
453
  exact: true
415
454
  });
416
455
  }
417
456
  };
418
457
  },
419
458
  receive: async (message, projectId) => {
459
+ changed({
460
+ type: "received",
461
+ message,
462
+ projectId
463
+ });
420
464
  const keyScope = message.draftId === null ? null : await scope.keyScopeOfDraft(message.draftId, projectId);
421
465
  await Promise.all(message.targets.map((queryKey) => queryClient.invalidateQueries({
422
466
  queryKey,
@@ -11,14 +11,14 @@ const DEBOUNCE_MS = 300;
11
11
  * wherever they change nothing. The studio cache applies each one to the reads it reaches.
12
12
  */
13
13
  function useProjectRoom(apiUrl, projectId, studioCache, t0) {
14
- const $ = c(12);
14
+ const $ = c(13);
15
15
  let t1;
16
16
  if ($[0] !== t0) {
17
17
  t1 = t0 === void 0 ? {} : t0;
18
18
  $[0] = t0;
19
19
  $[1] = t1;
20
20
  } else t1 = $[1];
21
- const { onDraftEnded } = t1;
21
+ const { onDraftEnded, onRevision } = t1;
22
22
  const timerRef = useRef(void 0);
23
23
  let t2;
24
24
  if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
@@ -35,7 +35,7 @@ function useProjectRoom(apiUrl, projectId, studioCache, t0) {
35
35
  const t4 = String(projectId ?? "");
36
36
  const t5 = !!projectId;
37
37
  let t6;
38
- if ($[5] !== onDraftEnded || $[6] !== projectId || $[7] !== studioCache || $[8] !== t3 || $[9] !== t4 || $[10] !== t5) {
38
+ if ($[5] !== onDraftEnded || $[6] !== onRevision || $[7] !== projectId || $[8] !== studioCache || $[9] !== t3 || $[10] !== t4 || $[11] !== t5) {
39
39
  t6 = {
40
40
  ...t3,
41
41
  party: "project-room",
@@ -63,6 +63,11 @@ function useProjectRoom(apiUrl, projectId, studioCache, t0) {
63
63
  onDraftEnded?.(ended);
64
64
  return;
65
65
  }
66
+ if (data.type === "revision") {
67
+ const { type: _type_0, ...revision } = data;
68
+ onRevision?.(revision);
69
+ return;
70
+ }
66
71
  if (data.type !== "invalidate") return;
67
72
  pendingRef.current.push(data);
68
73
  clearTimeout(timerRef.current);
@@ -74,13 +79,14 @@ function useProjectRoom(apiUrl, projectId, studioCache, t0) {
74
79
  }
75
80
  };
76
81
  $[5] = onDraftEnded;
77
- $[6] = projectId;
78
- $[7] = studioCache;
79
- $[8] = t3;
80
- $[9] = t4;
81
- $[10] = t5;
82
- $[11] = t6;
83
- } else t6 = $[11];
82
+ $[6] = onRevision;
83
+ $[7] = projectId;
84
+ $[8] = studioCache;
85
+ $[9] = t3;
86
+ $[10] = t4;
87
+ $[11] = t5;
88
+ $[12] = t6;
89
+ } else t6 = $[12];
84
90
  usePartySocket(t6);
85
91
  }
86
92
 
package/dist/lib/utils.js CHANGED
@@ -1,112 +1,9 @@
1
- import { PlatformLabel } from "../components/PlatformLabel.js";
2
- import { c } from "react/compiler-runtime";
3
- import { jsx } from "react/jsx-runtime";
4
- import { Kbd } from "@camox/ui/kbd";
5
1
  import { INPUT_BASE_STYLES, INPUT_FOCUS_STYLES, cn } from "@camox/ui/utils";
6
2
 
7
3
  //#region src/lib/utils.tsx
8
4
  function checkIfInputFocused(document = window.document) {
9
5
  return document.activeElement?.tagName === "INPUT" || document.activeElement?.tagName === "TEXTAREA" || (document.activeElement?.getAttribute("contenteditable") ?? "false") === "true";
10
6
  }
11
- /**
12
- * Formats an action shortcut into a keyboard shortcut display component.
13
- * Automatically detects the platform and uses the appropriate modifier keys.
14
- *
15
- * @param shortcut - The shortcut configuration from an Action
16
- * @returns React element displaying the keyboard shortcut
17
- *
18
- * @example
19
- * ```tsx
20
- * formatShortcut({ key: "e", withMeta: true }) // Returns <KbdGroup><Kbd>⌘</Kbd><Kbd>E</Kbd></KbdGroup>
21
- * formatShortcut({ key: "l" }) // Returns <Kbd>L</Kbd>
22
- * ```
23
- */
24
- function formatShortcut(shortcut) {
25
- if (!shortcut) return null;
26
- return /* @__PURE__ */ jsx(Shortcut, { shortcut });
27
- }
28
- function Shortcut(t0) {
29
- const $ = c(14);
30
- const { shortcut } = t0;
31
- let t1;
32
- bb0: {
33
- if (shortcut.key === "Enter") {
34
- t1 = "↵";
35
- break bb0;
36
- }
37
- if (shortcut.key === "Escape") {
38
- t1 = "Esc";
39
- break bb0;
40
- }
41
- if (shortcut.key === "Backspace") {
42
- t1 = "⌫";
43
- break bb0;
44
- }
45
- if (shortcut.key === "ArrowUp") {
46
- t1 = "↑";
47
- break bb0;
48
- }
49
- if (shortcut.key === "ArrowDown") {
50
- t1 = "↓";
51
- break bb0;
52
- }
53
- if (shortcut.key === "ArrowLeft") {
54
- t1 = "←";
55
- break bb0;
56
- }
57
- if (shortcut.key === "ArrowRight") {
58
- t1 = "→";
59
- break bb0;
60
- }
61
- let t2;
62
- if ($[0] !== shortcut.key) {
63
- t2 = shortcut.key.toUpperCase();
64
- $[0] = shortcut.key;
65
- $[1] = t2;
66
- } else t2 = $[1];
67
- t1 = t2;
68
- }
69
- const formattedKey = t1;
70
- let t2;
71
- if ($[2] !== formattedKey || $[3] !== shortcut.withAlt || $[4] !== shortcut.withMeta || $[5] !== shortcut.withShift) {
72
- t2 = (mac) => {
73
- const modifiers = [];
74
- if (shortcut.withMeta) modifiers.push(mac ? "⌘" : "Ctrl");
75
- if (shortcut.withAlt) modifiers.push(mac ? "⌥" : "Alt");
76
- if (shortcut.withShift) modifiers.push(mac ? "⇧" : "Shift");
77
- return `${modifiers.join()} ${formattedKey}`.trim();
78
- };
79
- $[2] = formattedKey;
80
- $[3] = shortcut.withAlt;
81
- $[4] = shortcut.withMeta;
82
- $[5] = shortcut.withShift;
83
- $[6] = t2;
84
- } else t2 = $[6];
85
- const label = t2;
86
- let t3;
87
- if ($[7] !== label) {
88
- t3 = label(true);
89
- $[7] = label;
90
- $[8] = t3;
91
- } else t3 = $[8];
92
- let t4;
93
- if ($[9] !== label) {
94
- t4 = label(false);
95
- $[9] = label;
96
- $[10] = t4;
97
- } else t4 = $[10];
98
- let t5;
99
- if ($[11] !== t3 || $[12] !== t4) {
100
- t5 = /* @__PURE__ */ jsx(Kbd, { children: /* @__PURE__ */ jsx(PlatformLabel, {
101
- mac: t3,
102
- other: t4
103
- }) });
104
- $[11] = t3;
105
- $[12] = t4;
106
- $[13] = t5;
107
- } else t5 = $[13];
108
- return t5;
109
- }
110
7
 
111
8
  //#endregion
112
- export { INPUT_BASE_STYLES, INPUT_FOCUS_STYLES, checkIfInputFocused, cn, formatShortcut };
9
+ export { INPUT_BASE_STYLES, INPUT_FOCUS_STYLES, checkIfInputFocused, cn };
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.48.0";
2
+ var version = "0.52.1";
3
3
 
4
4
  //#endregion
5
5
  export { version };