@threadlabs/looma 0.53.15 → 0.53.17

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/docs/catalog.json CHANGED
@@ -780,7 +780,7 @@
780
780
  ],
781
781
  "schemaVersion": 1,
782
782
  "package": "@threadlabs/looma",
783
- "version": "0.53.15",
783
+ "version": "0.53.17",
784
784
  "groups": [
785
785
  {
786
786
  "id": "layout",
@@ -21160,9 +21160,39 @@
21160
21160
  }
21161
21161
  ],
21162
21162
  "shared": [
21163
+ {
21164
+ "name": "--ui-accent"
21165
+ },
21166
+ {
21167
+ "name": "--ui-accent-outline-border",
21168
+ "fallbacks": [
21169
+ "var(--ui-accent-subtle-text)"
21170
+ ]
21171
+ },
21163
21172
  {
21164
21173
  "name": "--ui-accent-solid"
21165
21174
  },
21175
+ {
21176
+ "name": "--ui-accent-subtle-text"
21177
+ },
21178
+ {
21179
+ "name": "--ui-accent-wash"
21180
+ },
21181
+ {
21182
+ "name": "--ui-accent-wash-hover"
21183
+ },
21184
+ {
21185
+ "name": "--ui-action-inset-sm",
21186
+ "fallbacks": [
21187
+ "var(--ui-space-2)"
21188
+ ]
21189
+ },
21190
+ {
21191
+ "name": "--ui-action-radius",
21192
+ "fallbacks": [
21193
+ "var(--ui-radius-md)"
21194
+ ]
21195
+ },
21166
21196
  {
21167
21197
  "name": "--ui-border-strong"
21168
21198
  },
@@ -21259,6 +21289,9 @@
21259
21289
  {
21260
21290
  "name": "--ui-focus-width"
21261
21291
  },
21292
+ {
21293
+ "name": "--ui-font-medium"
21294
+ },
21262
21295
  {
21263
21296
  "name": "--ui-font-size-md"
21264
21297
  },
@@ -21274,6 +21307,12 @@
21274
21307
  {
21275
21308
  "name": "--ui-motion-fast"
21276
21309
  },
21310
+ {
21311
+ "name": "--ui-neutral-shadow"
21312
+ },
21313
+ {
21314
+ "name": "--ui-pressed"
21315
+ },
21277
21316
  {
21278
21317
  "name": "--ui-radius-md"
21279
21318
  },
@@ -21306,6 +21345,12 @@
21306
21345
  },
21307
21346
  {
21308
21347
  "name": "--ui-text-secondary"
21348
+ },
21349
+ {
21350
+ "name": "--ui-tonal-opacity",
21351
+ "fallbacks": [
21352
+ "1"
21353
+ ]
21309
21354
  }
21310
21355
  ]
21311
21356
  },
@@ -211,11 +211,12 @@
211
211
  box-shadow: none;
212
212
  background-image: none;
213
213
  }
214
- :scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component])))[data-appearance="card"][size="lg"] {
214
+ :scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component])))[data-ui-button-state~="size=lg"][data-appearance="card"] {
215
215
  min-block-size: max(var(--ui-control-min-block-size), var(--ui-control-size-lg));
216
216
  }
217
- :scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component])))[data-appearance="card"][size="sm"] {
217
+ :scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component])))[data-ui-button-state~="size=sm"][data-appearance="card"] {
218
218
  min-block-size: var(--ui-control-size-sm);
219
+ align-items: center !important;
219
220
  gap: var(--ui-space-2) !important;
220
221
  }
221
222
  :scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component])))[data-ui-button-state~="fit"][data-appearance="card"] {
@@ -3465,6 +3466,41 @@
3465
3466
  }
3466
3467
  }
3467
3468
 
3469
+ /* The native file action uses the outline button palette. The input still owns pointer and keyboard activation. */
3470
+ :scope:where(:is([component~="ui-input"]:not(template), [data-component~="ui-input"]:not([component])))[type="file"]::file-selector-button {
3471
+ appearance: none;
3472
+ min-block-size: var(--ui-control-size-sm);
3473
+ margin-inline-end: var(--ui-space-2) !important;
3474
+ padding: var(--ui-control-inset-block-sm, var(--ui-space-1)) var(--ui-action-inset-sm, var(--ui-space-2)) !important;
3475
+ border: var(--ui-border-width) solid var(--ui-accent-outline-border, var(--ui-accent-subtle-text));
3476
+ border-radius: var(--ui-action-radius, var(--ui-radius-md));
3477
+ background-color: transparent;
3478
+ background-image: linear-gradient(var(--ui-accent-wash), var(--ui-accent-wash));
3479
+ color: var(--ui-accent-subtle-text);
3480
+ box-shadow: var(--ui-neutral-shadow);
3481
+ font: inherit;
3482
+ font-weight: var(--ui-font-medium);
3483
+ cursor: pointer;
3484
+ }
3485
+
3486
+ :scope:where(:is([component~="ui-input"]:not(template), [data-component~="ui-input"]:not([component])))[type="file"]:enabled:hover::file-selector-button {
3487
+ background-image: linear-gradient(var(--ui-accent-wash-hover), var(--ui-accent-wash-hover));
3488
+ }
3489
+
3490
+ :scope:where(:is([component~="ui-input"]:not(template), [data-component~="ui-input"]:not([component])))[type="file"]:enabled:active::file-selector-button {
3491
+ background-image: none;
3492
+ background-color: oklch(from var(--ui-accent) l c h / calc(18% * var(--ui-tonal-opacity, 1)));
3493
+ box-shadow: var(--ui-pressed);
3494
+ }
3495
+
3496
+ :scope:where(:is([component~="ui-input"]:not(template), [data-component~="ui-input"]:not([component])))[type="file"]:disabled::file-selector-button {
3497
+ border-color: var(--ui-control-border);
3498
+ background: transparent;
3499
+ color: var(--ui-disabled-text);
3500
+ box-shadow: none;
3501
+ cursor: not-allowed;
3502
+ }
3503
+
3468
3504
  /* Tabbing into a field selects its text; tint that selection softly instead of the page highlight. */
3469
3505
  :scope:where(:is([component~="ui-input"]:not(template), [data-component~="ui-input"]:not([component])))::selection {
3470
3506
  background: color-mix(in srgb, var(--ui-accent-solid) 20%, transparent);
@@ -3542,6 +3578,8 @@
3542
3578
  @media (pointer: coarse) {
3543
3579
  }
3544
3580
 
3581
+ /* The native file action uses the outline button palette. The input still owns pointer and keyboard activation. */
3582
+
3545
3583
  /* Tabbing into a field selects its text; tint that selection softly instead of the page highlight. */
3546
3584
 
3547
3585
  /* The app's invalid flag, or the browser's own verdict once the user has left an invalid field. */
@@ -7,5 +7,7 @@ export interface FileDeletionServices {
7
7
  remove: (file: LoomaFileDescriptor, signal: AbortSignal) => Promise<boolean>;
8
8
  onError: (error: unknown, file: LoomaFileDescriptor) => void;
9
9
  }
10
+ /** Remove an authored reference without changing the original file's availability. */
11
+ export declare function removeFileBlock(editor: Editor, position: () => number | undefined): void;
10
12
  /** Remove one block optimistically; retain a mapped rollback anchor while transport runs. */
11
13
  export declare function deleteFileBlock(editor: Editor, position: () => number | undefined, file: LoomaFileDescriptor, services: FileDeletionServices): Promise<void>;
package/editor/index.js CHANGED
@@ -14144,6 +14144,16 @@ var dividerNodeView = ({ editor, getPos }) => {
14144
14144
  };
14145
14145
  //#endregion
14146
14146
  //#region src/editor/file-deletions.ts
14147
+ /** Remove an authored reference without changing the original file's availability. */
14148
+ function removeFileBlock(editor, position) {
14149
+ if (editor.isDestroyed || !editor.isEditable) return;
14150
+ const at = position();
14151
+ if (at === void 0) return;
14152
+ const original = editor.state.doc.nodeAt(at);
14153
+ if (original?.type.name !== "loomaFileAttachment") return;
14154
+ editor.view.dispatch(closeHistory(editor.state.tr).delete(at, at + original.nodeSize));
14155
+ editor.view.focus();
14156
+ }
14147
14157
  /** Remove one block optimistically; retain a mapped rollback anchor while transport runs. */
14148
14158
  async function deleteFileBlock(editor, position, file, services) {
14149
14159
  if (!services.enabled() || editor.isDestroyed || !editor.isEditable) return;
@@ -14196,7 +14206,7 @@ async function deleteFileBlock(editor, position, file, services) {
14196
14206
  //#endregion
14197
14207
  //#region src/editor/node-views/file-attachment.ts
14198
14208
  var sequence = 0;
14199
- /** A compact native file link with a separate, permission-scoped deletion action. */
14209
+ /** A compact file link with an editable reference action and optional original deletion. */
14200
14210
  var createFileAttachmentNodeView = (services) => ({ node, editor, getPos }) => {
14201
14211
  let current = node, pending = false;
14202
14212
  const metadata = () => {
@@ -14206,6 +14216,10 @@ var createFileAttachmentNodeView = (services) => ({ node, editor, getPos }) => {
14206
14216
  return null;
14207
14217
  }
14208
14218
  };
14219
+ const deletesOriginal = () => {
14220
+ const a = metadata(), display = a ? getReferenceDisplay(editor)[`attachment:${a.href}`] : void 0;
14221
+ return Boolean(a && services.enabled() && display?.status !== "deleted" && display?.status !== "pending" && display?.deletable !== false);
14222
+ };
14209
14223
  const name = document.createTextNode(""), size = document.createTextNode("");
14210
14224
  const download = createUiIcon({
14211
14225
  name: "download",
@@ -14251,17 +14265,22 @@ var createFileAttachmentNodeView = (services) => ({ node, editor, getPos }) => {
14251
14265
  label: "Delete file",
14252
14266
  variant: "ghost",
14253
14267
  tone: "neutral",
14254
- size: "sm",
14268
+ size: "xs",
14255
14269
  attributes: {
14256
14270
  id,
14257
14271
  "data-looma-file-delete": ""
14258
14272
  },
14259
14273
  children: [createUiIcon({
14260
14274
  name: "trash",
14275
+ tone: "muted",
14261
14276
  attributes: { "aria-hidden": "true" }
14262
14277
  })]
14263
14278
  });
14264
14279
  trash.addEventListener("click", async () => {
14280
+ if (!deletesOriginal()) {
14281
+ removeFileBlock(editor, getPos);
14282
+ return;
14283
+ }
14265
14284
  const a = metadata();
14266
14285
  if (!a || pending) return;
14267
14286
  pending = true;
@@ -14273,6 +14292,7 @@ var createFileAttachmentNodeView = (services) => ({ node, editor, getPos }) => {
14273
14292
  render();
14274
14293
  }
14275
14294
  });
14295
+ const tooltip = document.createTextNode("");
14276
14296
  const dom = createUiCluster({
14277
14297
  padding: "s",
14278
14298
  gap: "xs",
@@ -14286,7 +14306,7 @@ var createFileAttachmentNodeView = (services) => ({ node, editor, getPos }) => {
14286
14306
  trash,
14287
14307
  createUiTooltip({
14288
14308
  for: id,
14289
- children: [document.createTextNode("Delete file")]
14309
+ children: [tooltip]
14290
14310
  })
14291
14311
  ]
14292
14312
  });
@@ -14300,10 +14320,12 @@ var createFileAttachmentNodeView = (services) => ({ node, editor, getPos }) => {
14300
14320
  disabled: !a || deleted || display?.status === "pending"
14301
14321
  });
14302
14322
  download.hidden = deleted;
14303
- trash.hidden = !a || deleted || display?.status === "pending" || display?.deletable === false || !editor.isEditable || !services.enabled();
14323
+ trash.hidden = !editor.isEditable;
14324
+ const deleteOriginal = deletesOriginal(), verb = deleteOriginal ? "Delete" : "Remove";
14325
+ tooltip.data = deleteOriginal ? "Delete file and remove reference" : "Remove attachment reference";
14304
14326
  componentRegistry.update(trash, {
14305
14327
  loading: pending,
14306
- label: `Delete ${a?.name ?? "file"}`
14328
+ label: `${verb} ${a?.name ?? "unavailable attachment"}`
14307
14329
  });
14308
14330
  };
14309
14331
  const stop = observeReferenceDisplay(editor, render);
@@ -1,4 +1,4 @@
1
1
  import type { NodeViewRenderer } from '@tiptap/core';
2
2
  import { type FileDeletionServices } from '../file-deletions';
3
- /** A compact native file link with a separate, permission-scoped deletion action. */
3
+ /** A compact file link with an editable reference action and optional original deletion. */
4
4
  export declare const createFileAttachmentNodeView: (services: FileDeletionServices) => NodeViewRenderer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threadlabs/looma",
3
- "version": "0.53.15",
3
+ "version": "0.53.17",
4
4
  "type": "module",
5
5
  "description": "HTML Next UI components, native DOM support and design tokens.",
6
6
  "license": "MIT",
@@ -211,11 +211,12 @@
211
211
  box-shadow: none;
212
212
  background-image: none;
213
213
  }
214
- :scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component])))[data-appearance="card"][size="lg"] {
214
+ :scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component])))[data-ui-button-state~="size=lg"][data-appearance="card"] {
215
215
  min-block-size: max(var(--ui-control-min-block-size), var(--ui-control-size-lg));
216
216
  }
217
- :scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component])))[data-appearance="card"][size="sm"] {
217
+ :scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component])))[data-ui-button-state~="size=sm"][data-appearance="card"] {
218
218
  min-block-size: var(--ui-control-size-sm);
219
+ align-items: center !important;
219
220
  gap: var(--ui-space-2) !important;
220
221
  }
221
222
  :scope:where(:is([component~="ui-button"]:not(template), [data-component~="ui-button"]:not([component])))[data-ui-button-state~="fit"][data-appearance="card"] {
@@ -78,6 +78,41 @@
78
78
  }
79
79
  }
80
80
 
81
+ /* The native file action uses the outline button palette. The input still owns pointer and keyboard activation. */
82
+ :scope:where(:is([component~="ui-input"]:not(template), [data-component~="ui-input"]:not([component])))[type="file"]::file-selector-button {
83
+ appearance: none;
84
+ min-block-size: var(--ui-control-size-sm);
85
+ margin-inline-end: var(--ui-space-2) !important;
86
+ padding: var(--ui-control-inset-block-sm, var(--ui-space-1)) var(--ui-action-inset-sm, var(--ui-space-2)) !important;
87
+ border: var(--ui-border-width) solid var(--ui-accent-outline-border, var(--ui-accent-subtle-text));
88
+ border-radius: var(--ui-action-radius, var(--ui-radius-md));
89
+ background-color: transparent;
90
+ background-image: linear-gradient(var(--ui-accent-wash), var(--ui-accent-wash));
91
+ color: var(--ui-accent-subtle-text);
92
+ box-shadow: var(--ui-neutral-shadow);
93
+ font: inherit;
94
+ font-weight: var(--ui-font-medium);
95
+ cursor: pointer;
96
+ }
97
+
98
+ :scope:where(:is([component~="ui-input"]:not(template), [data-component~="ui-input"]:not([component])))[type="file"]:enabled:hover::file-selector-button {
99
+ background-image: linear-gradient(var(--ui-accent-wash-hover), var(--ui-accent-wash-hover));
100
+ }
101
+
102
+ :scope:where(:is([component~="ui-input"]:not(template), [data-component~="ui-input"]:not([component])))[type="file"]:enabled:active::file-selector-button {
103
+ background-image: none;
104
+ background-color: oklch(from var(--ui-accent) l c h / calc(18% * var(--ui-tonal-opacity, 1)));
105
+ box-shadow: var(--ui-pressed);
106
+ }
107
+
108
+ :scope:where(:is([component~="ui-input"]:not(template), [data-component~="ui-input"]:not([component])))[type="file"]:disabled::file-selector-button {
109
+ border-color: var(--ui-control-border);
110
+ background: transparent;
111
+ color: var(--ui-disabled-text);
112
+ box-shadow: none;
113
+ cursor: not-allowed;
114
+ }
115
+
81
116
  /* Tabbing into a field selects its text; tint that selection softly instead of the page highlight. */
82
117
  :scope:where(:is([component~="ui-input"]:not(template), [data-component~="ui-input"]:not([component])))::selection {
83
118
  background: color-mix(in srgb, var(--ui-accent-solid) 20%, transparent);
@@ -155,6 +190,8 @@
155
190
  @media (pointer: coarse) {
156
191
  }
157
192
 
193
+ /* The native file action uses the outline button palette. The input still owns pointer and keyboard activation. */
194
+
158
195
  /* Tabbing into a field selects its text; tint that selection softly instead of the page highlight. */
159
196
 
160
197
  /* The app's invalid flag, or the browser's own verdict once the user has left an invalid field. */