@tristan2828/ui-foundation 4.126.0 → 4.127.0
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/conventions/docs/add-an-entity.md +118 -34
- package/conventions/docs/cell-patterns.md +88 -41
- package/conventions/docs/design-language.md +45 -13
- package/dist/api/contracts.d.ts +8 -1
- package/dist/api/gateway/errors.js +4 -0
- package/dist/api/schema.d.ts +9 -0
- package/dist/components/app/data-table-tools.d.ts +12 -0
- package/dist/components/app/data-table-tools.js +2 -2
- package/dist/components/app/data-table.d.ts +2 -1
- package/dist/components/app/data-table.js +1 -1
- package/dist/components/app/edit-in-place-presets.d.ts +51 -1
- package/dist/components/app/edit-in-place-presets.js +30 -0
- package/dist/components/app/edit-in-place-store.d.ts +31 -4
- package/dist/components/app/edit-in-place-store.js +59 -11
- package/dist/components/app/edit-in-place.d.ts +11 -0
- package/dist/components/app/editable-value.js +43 -8
- package/dist/components/app/entity-view.js +5 -1
- package/dist/components/app/equal-items.d.ts +32 -6
- package/dist/components/app/equal-items.js +59 -8
- package/dist/components/app/error-state.js +1 -0
- package/dist/components/app/milkdown-editor.js +3 -2
- package/dist/components/app/pill-filter.d.ts +16 -0
- package/dist/components/app/pill-filter.js +22 -1
- package/dist/components/app/rating-input.d.ts +22 -0
- package/dist/components/app/rating-input.js +65 -0
- package/dist/components/app/rating-score.d.ts +2 -1
- package/dist/components/app/rating-score.js +2 -6
- package/dist/components/app/rich-text-editor.d.ts +4 -2
- package/dist/components/app/rich-text-editor.js +3 -2
- package/dist/components/app/rich-text-keyboard-bar.js +3 -2
- package/dist/components/app/rich-text-toolbar.js +1 -1
- package/dist/components/app/rich-text-tools-bar.d.ts +3 -1
- package/dist/components/app/rich-text-tools-bar.js +2 -2
- package/dist/hooks/use-record-update.d.ts +13 -1
- package/dist/hooks/use-record-update.js +17 -3
- package/dist/index.d.ts +4 -2
- package/dist/index.js +5 -0
- package/dist/lib/markdown-merge.d.ts +12 -0
- package/dist/lib/markdown-merge.js +90 -0
- package/dist/lib/rating-glyphs.d.ts +3 -0
- package/dist/lib/rating-glyphs.js +7 -0
- package/openapi/foundation.yaml +12 -0
- package/package.json +1 -1
|
@@ -393,6 +393,96 @@ export function mergeMarkdown(original, baseline, current) {
|
|
|
393
393
|
throw new MarkdownMergeError();
|
|
394
394
|
return out;
|
|
395
395
|
}
|
|
396
|
+
const keysOf = (list) => list.map((block) => block.key).join('\n');
|
|
397
|
+
/**
|
|
398
|
+
* Both edits at once, block by block: `mine` and `theirs` each started from
|
|
399
|
+
* `base` (the same saved text, edited in two places: this tab and another
|
|
400
|
+
* tab, a phone or an AI chat). Every top-level block only one side changed
|
|
401
|
+
* takes that side's change; a block neither changed keeps `theirs`'s own
|
|
402
|
+
* bytes. Returns null when both changed the same stretch of blocks (or
|
|
403
|
+
* both added text at the same place), when it can't be done without
|
|
404
|
+
* losing one of them: the caller asks the person instead. A three-way
|
|
405
|
+
* merge (diff3) over blocks matched by meaning, as `mergeMarkdown`
|
|
406
|
+
* matches them; it never merges inside a block.
|
|
407
|
+
*/
|
|
408
|
+
export function rebaseMarkdown(base, mine, theirs) {
|
|
409
|
+
if (mine === base || mine === theirs)
|
|
410
|
+
return theirs;
|
|
411
|
+
if (theirs === base)
|
|
412
|
+
return mine;
|
|
413
|
+
// What's written goes in theirs's own line ending (the text it lands in).
|
|
414
|
+
const eol = theirs[theirs.indexOf('\n') - 1] === '\r' ? '\r\n' : '\n';
|
|
415
|
+
const ownEnding = (text) => text.replace(/\r?\n/g, eol);
|
|
416
|
+
const based = blocks(base);
|
|
417
|
+
const lists = { mine: blocks(mine), theirs: blocks(theirs) };
|
|
418
|
+
const texts = { mine, theirs };
|
|
419
|
+
const theirsAt = new Map([...match(based, lists.theirs)].map(([to, from]) => [from, to]));
|
|
420
|
+
const hunks = (side) => {
|
|
421
|
+
const pairs = [...match(based, lists[side])].map(([to, from]) => [from, to]).sort((a, b) => a[0] - b[0]);
|
|
422
|
+
const out = [];
|
|
423
|
+
let [b, s] = [-1, -1];
|
|
424
|
+
for (const [nextB, nextS] of [...pairs, [based.length, lists[side].length]]) {
|
|
425
|
+
if (nextB > b + 1 || nextS > s + 1)
|
|
426
|
+
out.push({ side, start: b + 1, end: nextB, from: s + 1, to: nextS });
|
|
427
|
+
[b, s] = [nextB, nextS];
|
|
428
|
+
}
|
|
429
|
+
return out;
|
|
430
|
+
};
|
|
431
|
+
const keysIn = (hunk) => keysOf(lists[hunk.side].slice(hunk.from, hunk.to));
|
|
432
|
+
const mineHunks = hunks('mine');
|
|
433
|
+
const theirsHunks = hunks('theirs');
|
|
434
|
+
// Both changed the same stretch (or added at the same place) in
|
|
435
|
+
// different ways: no merge. The same change on both sides is one.
|
|
436
|
+
const kept = [...theirsHunks];
|
|
437
|
+
for (const ours of mineHunks) {
|
|
438
|
+
const clash = theirsHunks.find((other) => (ours.start < other.end && other.start < ours.end) || ours.start === other.start);
|
|
439
|
+
if (!clash)
|
|
440
|
+
kept.push(ours);
|
|
441
|
+
else if (clash.start !== ours.start || clash.end !== ours.end || keysIn(clash) !== keysIn(ours))
|
|
442
|
+
return null;
|
|
443
|
+
}
|
|
444
|
+
// In base order; at one place, an insertion before a replacement.
|
|
445
|
+
kept.sort((a, b) => a.start - b.start || a.end - b.end);
|
|
446
|
+
const pieces = [];
|
|
447
|
+
const add = (from, index) => pieces.push({ from, index, block: lists[from][index] });
|
|
448
|
+
let next = 0;
|
|
449
|
+
const keepBase = (until) => {
|
|
450
|
+
// Blocks no one changed: as theirs has them.
|
|
451
|
+
for (; next < until; next++)
|
|
452
|
+
add('theirs', theirsAt.get(next));
|
|
453
|
+
};
|
|
454
|
+
for (const hunk of kept) {
|
|
455
|
+
keepBase(hunk.start);
|
|
456
|
+
for (let index = hunk.from; index < hunk.to; index++)
|
|
457
|
+
add(hunk.side, index);
|
|
458
|
+
next = Math.max(next, hunk.end);
|
|
459
|
+
}
|
|
460
|
+
keepBase(based.length);
|
|
461
|
+
let out = '';
|
|
462
|
+
pieces.forEach((piece, k) => {
|
|
463
|
+
const previous = pieces[k - 1];
|
|
464
|
+
const list = lists[piece.from];
|
|
465
|
+
if (!previous) {
|
|
466
|
+
if (piece.index === 0)
|
|
467
|
+
out += ownEnding(texts[piece.from].slice(0, list[0].start));
|
|
468
|
+
}
|
|
469
|
+
else if (previous.from === piece.from && previous.index === piece.index - 1) {
|
|
470
|
+
out += ownEnding(texts[piece.from].slice(list[previous.index].end, piece.block.start));
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
out += eol + eol;
|
|
474
|
+
}
|
|
475
|
+
out += piece.from === 'theirs' ? piece.block.source : ownEnding(piece.block.source);
|
|
476
|
+
});
|
|
477
|
+
// The text ends the way theirs ends.
|
|
478
|
+
if (pieces.length > 0) {
|
|
479
|
+
const last = lists.theirs.at(-1);
|
|
480
|
+
out += last ? theirs.slice(last.end) : ownEnding(mine.slice(lists.mine.at(-1)?.end ?? mine.length));
|
|
481
|
+
}
|
|
482
|
+
// Guard, as in mergeMarkdown: the result must read as exactly the blocks
|
|
483
|
+
// picked (two blocks fusing across a seam would be something else).
|
|
484
|
+
return keysOf(blocks(out)) === keysOf(pieces.map((piece) => piece.block)) ? out : null;
|
|
485
|
+
}
|
|
396
486
|
/**
|
|
397
487
|
* The document's own marks, for writing a block the person edited the way
|
|
398
488
|
* the rest is written: its bullet (`-`, `*`, `+`) and its thematic break.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// The glyphs a score out of a few is drawn with (RatingScore, RatingInput).
|
|
2
|
+
// Lucide's star and heart (24×24), so they match the icons around them.
|
|
3
|
+
// RatingScore and RatingInput draw the same ones.
|
|
4
|
+
export const RATING_GLYPH_PATHS = {
|
|
5
|
+
star: 'M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z',
|
|
6
|
+
heart: 'M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5',
|
|
7
|
+
};
|
package/openapi/foundation.yaml
CHANGED
|
@@ -436,6 +436,18 @@ components:
|
|
|
436
436
|
content:
|
|
437
437
|
application/json:
|
|
438
438
|
schema: { $ref: "#/components/schemas/HTTPErrorBody" }
|
|
439
|
+
ConflictError:
|
|
440
|
+
# Optional: an app that checks no versions leaves it out, and
|
|
441
|
+
# check-contract doesn't ask for it.
|
|
442
|
+
x-optional: true
|
|
443
|
+
description: >
|
|
444
|
+
The record changed since the version the request was built on
|
|
445
|
+
(another tab, device or AI chat saved in between). Nothing was
|
|
446
|
+
written. The client fetches the record again and lets the person
|
|
447
|
+
choose; the gateway's toAppError makes it AppError kind "conflict".
|
|
448
|
+
content:
|
|
449
|
+
application/json:
|
|
450
|
+
schema: { $ref: "#/components/schemas/HTTPErrorBody" }
|
|
439
451
|
SignInExpiredError:
|
|
440
452
|
description: The pending sign-in is missing, expired or out of tries. Start again with POST /auth/login.
|
|
441
453
|
content:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.127.0",
|
|
4
4
|
"description": "Shared UI foundation for contract-first, database-backed React apps: shadcn primitives, DataTable/EntityForm composites, auth, the gateway error seam, design tokens, lint rules and the AI playbook.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|