phoenix_duskmoon 9.16.15 → 9.16.16

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Unreleased
2
2
 
3
+ ### Breaking changes
4
+
5
+ - Remove the six `dm_git_*` repository components, their automatic imports,
6
+ Storybook demos and delegated Git clipboard runtime. Git presentation is now
7
+ application-owned. There is no replacement published package; see
8
+ [the migration guide](guides/migrating-git-components.md) before upgrading.
9
+
3
10
  ### Added
4
11
 
5
12
  - Public React Chat hook factory, custom composer and renderer integration, and
@@ -36,6 +43,10 @@
36
43
 
37
44
  ### Fixed
38
45
 
46
+ - Hide the simple appbar's mobile toggle and navigation when no menu entries exist,
47
+ preserving its logo and user-profile slots.
48
+ - Generate React Chat submission IDs on HTTP LAN origins with a cryptographic
49
+ UUIDv4 fallback when the native `crypto.randomUUID()` API is unavailable.
39
50
  - Forward React form field attributes to their interactive controls and preserve
40
51
  application-disabled fields when the LiveView connection recovers.
41
52
  - Preserve selected-value arrays for native checkbox groups named with `[]`,
package/README.md CHANGED
@@ -14,6 +14,11 @@ Requires Elixir `>= 1.18` and `tailwindcss >= 4.0`.
14
14
 
15
15
  See the [docs](https://hexdocs.pm/phoenix_duskmoon/) for more information.
16
16
 
17
+ The unreleased removal of Git repository components is a breaking API change.
18
+ Applications using `dm_git_*` helpers or the Git clipboard runtime must migrate
19
+ to application-owned components before upgrading; see the
20
+ [Git component migration guide](https://github.com/duskmoon-dev/phoenix-duskmoon-ui/blob/main/apps/phoenix_duskmoon/guides/migrating-git-components.md).
21
+
17
22
 
18
23
  ## Install
19
24
 
@@ -11,13 +11,9 @@ const DM_EVENTS = [
11
11
  "dm-submit", "dm-select", "dm-close", "dm-open", "dm-toggle",
12
12
  ];
13
13
 
14
- const COPY_SELECTOR = "[data-copy-value]";
15
- const COPY_FEEDBACK_DURATION = 2000;
16
- const COPY_LISTENER = Symbol.for("phoenix-duskmoon.copy-listener");
17
14
  const DIALOG_SELECTOR = 'dialog[data-dm-confirm-dialog="true"]';
18
15
  const DIALOG_CONFIRM_SELECTOR = '[data-dm-confirm-action="true"]';
19
16
  const DIALOG_BEHAVIOR_LISTENERS = Symbol.for("phoenix-duskmoon.dialog-behavior-listeners");
20
- const copyFeedback = new WeakMap();
21
17
 
22
18
  /**
23
19
  * WebComponentHook - Universal LiveView ↔ Custom Element bridge
@@ -262,106 +258,6 @@ export const FormElementHook = {
262
258
  },
263
259
  };
264
260
 
265
- /** Copy text with the Clipboard API, falling back only when it is unavailable. */
266
- export async function copyTextToClipboard(value, environment = globalThis) {
267
- const clipboard = environment.navigator?.clipboard;
268
-
269
- if (typeof clipboard?.writeText === "function") {
270
- await clipboard.writeText(value);
271
- return;
272
- }
273
-
274
- const document = environment.document;
275
-
276
- if (!document?.body || typeof document.execCommand !== "function") {
277
- throw new Error("Clipboard API is unavailable");
278
- }
279
-
280
- const textArea = document.createElement("textarea");
281
- const activeElement = document.activeElement;
282
- textArea.value = value;
283
- textArea.setAttribute("readonly", "");
284
- textArea.style.position = "fixed";
285
- textArea.style.opacity = "0";
286
- document.body.appendChild(textArea);
287
-
288
- try {
289
- textArea.focus();
290
- textArea.select();
291
-
292
- if (!document.execCommand("copy")) {
293
- throw new Error("Clipboard copy command failed");
294
- }
295
- } finally {
296
- document.body.removeChild(textArea);
297
- activeElement?.focus?.();
298
- }
299
- }
300
-
301
- function copyStatus(button) {
302
- const sibling = button.nextElementSibling;
303
-
304
- if (sibling?.matches?.("[data-copy-status]")) {
305
- return sibling;
306
- }
307
-
308
- return button.parentElement?.querySelector?.("[data-copy-status]") ?? null;
309
- }
310
-
311
- function showCopyFeedback(button, message, state, options) {
312
- const label = button.querySelector?.("[data-copy-label]");
313
- const status = copyStatus(button);
314
- const previous = copyFeedback.get(button);
315
- const cancelReset = options.cancelReset ?? globalThis.clearTimeout;
316
- const scheduleReset = options.scheduleReset ?? globalThis.setTimeout;
317
-
318
- if (previous?.timer !== undefined) {
319
- cancelReset(previous.timer);
320
- }
321
-
322
- const originalLabel = previous?.originalLabel ?? label?.textContent ?? "Copy";
323
-
324
- if (label) label.textContent = message;
325
- if (status) status.textContent = message;
326
- button.dataset.copyState = state;
327
-
328
- const timer = scheduleReset(() => {
329
- if (label) label.textContent = originalLabel;
330
- if (status) status.textContent = "";
331
- delete button.dataset.copyState;
332
- copyFeedback.delete(button);
333
- }, COPY_FEEDBACK_DURATION);
334
-
335
- copyFeedback.set(button, { originalLabel, timer });
336
- }
337
-
338
- /** Handle clicks from any descendant of a generated copy control. */
339
- export async function handleClipboardClick(event, options = {}) {
340
- const button = event.target?.closest?.(COPY_SELECTOR);
341
-
342
- if (!button || button.disabled || button.getAttribute?.("aria-disabled") === "true") {
343
- return;
344
- }
345
-
346
- const copy = options.copy ?? copyTextToClipboard;
347
-
348
- try {
349
- await copy(button.dataset.copyValue);
350
- showCopyFeedback(button, button.dataset.copySuccess ?? "Copied", "success", options);
351
- } catch (_error) {
352
- showCopyFeedback(button, button.dataset.copyFailure ?? "Copy failed", "error", options);
353
- }
354
- }
355
-
356
- /** Install one delegated listener so LiveView-patched copy controls also work. */
357
- export function installClipboardBehavior(root = globalThis.document, options = {}) {
358
- if (!root?.addEventListener || root[COPY_LISTENER]) return;
359
-
360
- const listener = (event) => handleClipboardClick(event, options);
361
- root.addEventListener("click", listener);
362
- root[COPY_LISTENER] = listener;
363
- }
364
-
365
261
  /** Close the current confirm dialog before submit/reset/custom command default actions. */
366
262
  export function handleDialogConfirmClick(event) {
367
263
  const path = event.composedPath?.() ?? [];
@@ -379,7 +275,6 @@ export function installDialogBehavior(root = globalThis.document) {
379
275
  root[DIALOG_BEHAVIOR_LISTENERS] = handleDialogConfirmClick;
380
276
  }
381
277
 
382
- installClipboardBehavior();
383
278
  installDialogBehavior();
384
279
 
385
280
  // Export to window for non-module usage
@@ -131,6 +131,21 @@ const Message = memo(function Message(props) {
131
131
  );
132
132
  });
133
133
 
134
+ function requestId() {
135
+ if (typeof crypto.randomUUID === "function") return crypto.randomUUID();
136
+ const bytes = crypto.getRandomValues(new Uint8Array(16));
137
+ bytes[6] = (bytes[6] & 0x0f) | 0x40;
138
+ bytes[8] = (bytes[8] & 0x3f) | 0x80;
139
+ const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0"));
140
+ return [
141
+ hex.slice(0, 4).join(""),
142
+ hex.slice(4, 6).join(""),
143
+ hex.slice(6, 8).join(""),
144
+ hex.slice(8, 10).join(""),
145
+ hex.slice(10).join(""),
146
+ ].join("-");
147
+ }
148
+
134
149
  // A composer owns its draft/attachments. This helper only owns admission and UI requests.
135
150
  export function useChatSubmission({ bridge, canSubmit }) {
136
151
  const [busy, setBusy] = useState(false);
@@ -151,7 +166,7 @@ export function useChatSubmission({ bridge, canSubmit }) {
151
166
  setNotice("");
152
167
  try {
153
168
  return await bridge.send("send", {
154
- request_id: crypto.randomUUID(),
169
+ request_id: requestId(),
155
170
  ...payload,
156
171
  });
157
172
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phoenix_duskmoon",
3
- "version": "9.16.15",
3
+ "version": "9.16.16",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./priv/static/assets/js/phoenix_duskmoon.js",