@activecollab/components 2.0.414 → 2.0.415
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/dist/cjs/components/Media/Media.js.map +1 -1
- package/dist/cjs/components/PortableText/renderers.js +10 -0
- package/dist/cjs/components/PortableText/renderers.js.map +1 -1
- package/dist/cjs/components/PortableText/types.js +18 -1
- package/dist/cjs/components/PortableText/types.js.map +1 -1
- package/dist/cjs/components/PortableText/types.test.js +17 -0
- package/dist/cjs/components/PortableText/types.test.js.map +1 -1
- package/dist/cjs/presentation/shared/MessageDialog.js.map +1 -1
- package/dist/esm/components/Media/Media.d.ts +3 -2
- package/dist/esm/components/Media/Media.d.ts.map +1 -1
- package/dist/esm/components/Media/Media.js.map +1 -1
- package/dist/esm/components/PortableText/renderers.d.ts.map +1 -1
- package/dist/esm/components/PortableText/renderers.js +10 -0
- package/dist/esm/components/PortableText/renderers.js.map +1 -1
- package/dist/esm/components/PortableText/types.d.ts +10 -1
- package/dist/esm/components/PortableText/types.d.ts.map +1 -1
- package/dist/esm/components/PortableText/types.js +15 -0
- package/dist/esm/components/PortableText/types.js.map +1 -1
- package/dist/esm/components/PortableText/types.test.js +18 -1
- package/dist/esm/components/PortableText/types.test.js.map +1 -1
- package/dist/esm/presentation/shared/MessageDialog.d.ts.map +1 -1
- package/dist/esm/presentation/shared/MessageDialog.js.map +1 -1
- package/dist/index.js +161 -134
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25331,6 +25331,157 @@
|
|
|
25331
25331
|
}, SPACE.xs);
|
|
25332
25332
|
StyledList$1.displayName = "StyledList";
|
|
25333
25333
|
|
|
25334
|
+
/**
|
|
25335
|
+
* Portable Text envelope — the general content contract for structured,
|
|
25336
|
+
* renderer-independent content (in-app messages, help, changelogs).
|
|
25337
|
+
*
|
|
25338
|
+
* The design system owns this envelope and the universal default set below.
|
|
25339
|
+
* It never hardcodes a product element: concrete elements (callout,
|
|
25340
|
+
* button-reference, doc-link, …) are defined in the application catalog and
|
|
25341
|
+
* injected into the Portable Text engine through {@link PortableTextComponents}.
|
|
25342
|
+
* See README.md next to this file for the full contract.
|
|
25343
|
+
*/
|
|
25344
|
+
|
|
25345
|
+
/* ---- Spans and marks ------------------------------------------------- */
|
|
25346
|
+
|
|
25347
|
+
/**
|
|
25348
|
+
* A mark with data. Parameterless marks travel as plain strings ("strong");
|
|
25349
|
+
* marks that need data travel as objects discriminated by `type`.
|
|
25350
|
+
*/
|
|
25351
|
+
|
|
25352
|
+
/** The one default mark that carries data. */
|
|
25353
|
+
|
|
25354
|
+
/** The leaf of every text run: a piece of text plus the marks wrapping it. */
|
|
25355
|
+
|
|
25356
|
+
/** Marks every client understands without injection. */
|
|
25357
|
+
var PORTABLE_TEXT_DEFAULT_MARKS = ["strong", "em", "code", "link"];
|
|
25358
|
+
|
|
25359
|
+
/* ---- Blocks ----------------------------------------------------------- */
|
|
25360
|
+
|
|
25361
|
+
/** 1 maps to Title1, 2 to Title2, 3 to Header2 typography. */
|
|
25362
|
+
|
|
25363
|
+
/** Screenshots render framed (border, no shadow); illustrations render flat. */
|
|
25364
|
+
|
|
25365
|
+
/**
|
|
25366
|
+
* Video variants name the hosting service; `src` is the canonical video URL.
|
|
25367
|
+
* Their rendering carries service semantics (URL parsing, embed derivation),
|
|
25368
|
+
* so it belongs to the application catalog — injected as a `media` block
|
|
25369
|
+
* override — never to the default set. The default renderer degrades them.
|
|
25370
|
+
*/
|
|
25371
|
+
|
|
25372
|
+
// A Record so the compiler checks the list against the union in both
|
|
25373
|
+
// directions: a missing and a stray key each fail to build.
|
|
25374
|
+
var MEDIA_IMAGE_VARIANTS = {
|
|
25375
|
+
screenshot: true,
|
|
25376
|
+
illustration: true
|
|
25377
|
+
};
|
|
25378
|
+
var isPortableTextMediaImageVariant = function isPortableTextMediaImageVariant(value) {
|
|
25379
|
+
return typeof value === "string" && value in MEDIA_IMAGE_VARIANTS;
|
|
25380
|
+
};
|
|
25381
|
+
|
|
25382
|
+
/** A table cell is a span array, so inline marks work inside cells. */
|
|
25383
|
+
|
|
25384
|
+
/** A themed horizontal rule between sections. Carries no data. */
|
|
25385
|
+
|
|
25386
|
+
/**
|
|
25387
|
+
* Derived from the union's discriminators, so adding a block to the union
|
|
25388
|
+
* without a renderer entry is a compile error, never silent drift.
|
|
25389
|
+
*/
|
|
25390
|
+
|
|
25391
|
+
// A Record so the compiler checks the list against the union in both
|
|
25392
|
+
// directions: a missing and a stray key each fail to build.
|
|
25393
|
+
var DEFAULT_BLOCK_TYPES = {
|
|
25394
|
+
paragraph: true,
|
|
25395
|
+
heading: true,
|
|
25396
|
+
list: true,
|
|
25397
|
+
"list-item": true,
|
|
25398
|
+
media: true,
|
|
25399
|
+
"titled-text": true,
|
|
25400
|
+
"code-block": true,
|
|
25401
|
+
table: true,
|
|
25402
|
+
divider: true
|
|
25403
|
+
};
|
|
25404
|
+
|
|
25405
|
+
/** Blocks every client understands without injection. */
|
|
25406
|
+
var PORTABLE_TEXT_DEFAULT_BLOCKS = Object.keys(DEFAULT_BLOCK_TYPES);
|
|
25407
|
+
|
|
25408
|
+
/* ---- Objects ----------------------------------------------------------- */
|
|
25409
|
+
|
|
25410
|
+
/**
|
|
25411
|
+
* An embedded component the envelope does not interpret: `_type` names an
|
|
25412
|
+
* application-catalog element, everything else is that element's data. An
|
|
25413
|
+
* object whose `_type` has no injected renderer renders nothing and is logged.
|
|
25414
|
+
*/
|
|
25415
|
+
|
|
25416
|
+
/** The root of a message body: what an API returns under `content`. */
|
|
25417
|
+
|
|
25418
|
+
/* ---- Injection contract ------------------------------------------------ */
|
|
25419
|
+
|
|
25420
|
+
/**
|
|
25421
|
+
* Called once per unknown type instead of rendering it, so content written
|
|
25422
|
+
* for newer clients degrades silently on older ones.
|
|
25423
|
+
*/
|
|
25424
|
+
|
|
25425
|
+
/**
|
|
25426
|
+
* What an application injects into the Portable Text engine: renderers for
|
|
25427
|
+
* its catalog marks and objects, optional overrides for the default blocks,
|
|
25428
|
+
* and the unknown-type hook.
|
|
25429
|
+
*/
|
|
25430
|
+
|
|
25431
|
+
/* ---- Runtime guards ----------------------------------------------------- */
|
|
25432
|
+
|
|
25433
|
+
var isRecord = function isRecord(value) {
|
|
25434
|
+
return typeof value === "object" && value !== null;
|
|
25435
|
+
};
|
|
25436
|
+
var isPortableTextSpan = function isPortableTextSpan(value) {
|
|
25437
|
+
return isRecord(value) && typeof value.text === "string";
|
|
25438
|
+
};
|
|
25439
|
+
var isPortableTextTableRow = function isPortableTextTableRow(value) {
|
|
25440
|
+
return Array.isArray(value) && value.every(function (cell) {
|
|
25441
|
+
return Array.isArray(cell) && cell.every(isPortableTextSpan);
|
|
25442
|
+
});
|
|
25443
|
+
};
|
|
25444
|
+
var isPortableTextObjectNode = function isPortableTextObjectNode(value) {
|
|
25445
|
+
return isRecord(value) && value.type === "object" && typeof value._type === "string";
|
|
25446
|
+
};
|
|
25447
|
+
|
|
25448
|
+
/**
|
|
25449
|
+
* A block is any non-object node with a string `type`. Unknown block types
|
|
25450
|
+
* stay valid on purpose — they render nothing on clients that predate them.
|
|
25451
|
+
* Known types are held to their shape, so a serializer bug (a paragraph
|
|
25452
|
+
* without `children`, a list of non-nodes) fails here instead of at render.
|
|
25453
|
+
*/
|
|
25454
|
+
var _isPortableTextBlock = function isPortableTextBlock(value) {
|
|
25455
|
+
if (!isRecord(value) || typeof value.type !== "string" || value.type === "object") {
|
|
25456
|
+
return false;
|
|
25457
|
+
}
|
|
25458
|
+
switch (value.type) {
|
|
25459
|
+
case "paragraph":
|
|
25460
|
+
case "heading":
|
|
25461
|
+
case "list-item":
|
|
25462
|
+
return Array.isArray(value.children) && value.children.every(isPortableTextSpan);
|
|
25463
|
+
case "list":
|
|
25464
|
+
return Array.isArray(value.children) && value.children.every(_isPortableTextBlock);
|
|
25465
|
+
case "media":
|
|
25466
|
+
return typeof value.src === "string";
|
|
25467
|
+
case "titled-text":
|
|
25468
|
+
return typeof value.title === "string" && (value.content === undefined || isPortableTextContent(value.content));
|
|
25469
|
+
case "code-block":
|
|
25470
|
+
return typeof value.code === "string" && (value.language === undefined || typeof value.language === "string");
|
|
25471
|
+
case "table":
|
|
25472
|
+
return isPortableTextTableRow(value.header) && Array.isArray(value.rows) && value.rows.every(isPortableTextTableRow);
|
|
25473
|
+
case "divider":
|
|
25474
|
+
return true;
|
|
25475
|
+
default:
|
|
25476
|
+
return true;
|
|
25477
|
+
}
|
|
25478
|
+
};
|
|
25479
|
+
var isPortableTextContent = function isPortableTextContent(value) {
|
|
25480
|
+
return Array.isArray(value) && value.every(function (node) {
|
|
25481
|
+
return _isPortableTextBlock(node) || isPortableTextObjectNode(node);
|
|
25482
|
+
});
|
|
25483
|
+
};
|
|
25484
|
+
|
|
25334
25485
|
var StyledMedia = styled__default["default"].div.withConfig({
|
|
25335
25486
|
displayName: "Styles__StyledMedia",
|
|
25336
25487
|
componentId: "sc-zjz7mh-0"
|
|
@@ -25539,6 +25690,15 @@
|
|
|
25539
25690
|
alt = _ref1.alt,
|
|
25540
25691
|
variant = _ref1.variant,
|
|
25541
25692
|
caption = _ref1.caption;
|
|
25693
|
+
|
|
25694
|
+
// Video (and future) variants carry service semantics, so their renderer
|
|
25695
|
+
// is application-catalog territory — an injected `media` override. The
|
|
25696
|
+
// universal set covers images only; anything else degrades and warns, per
|
|
25697
|
+
// the contract's degradation rule.
|
|
25698
|
+
if (variant !== undefined && !isPortableTextMediaImageVariant(variant)) {
|
|
25699
|
+
console.warn("PortableText: no default renderer for media variant \"".concat(variant, "\"."));
|
|
25700
|
+
return null;
|
|
25701
|
+
}
|
|
25542
25702
|
return /*#__PURE__*/React__default["default"].createElement(Media, {
|
|
25543
25703
|
src: src,
|
|
25544
25704
|
alt: alt,
|
|
@@ -25602,140 +25762,6 @@
|
|
|
25602
25762
|
}
|
|
25603
25763
|
};
|
|
25604
25764
|
|
|
25605
|
-
/**
|
|
25606
|
-
* Portable Text envelope — the general content contract for structured,
|
|
25607
|
-
* renderer-independent content (in-app messages, help, changelogs).
|
|
25608
|
-
*
|
|
25609
|
-
* The design system owns this envelope and the universal default set below.
|
|
25610
|
-
* It never hardcodes a product element: concrete elements (callout,
|
|
25611
|
-
* button-reference, doc-link, …) are defined in the application catalog and
|
|
25612
|
-
* injected into the Portable Text engine through {@link PortableTextComponents}.
|
|
25613
|
-
* See README.md next to this file for the full contract.
|
|
25614
|
-
*/
|
|
25615
|
-
|
|
25616
|
-
/* ---- Spans and marks ------------------------------------------------- */
|
|
25617
|
-
|
|
25618
|
-
/**
|
|
25619
|
-
* A mark with data. Parameterless marks travel as plain strings ("strong");
|
|
25620
|
-
* marks that need data travel as objects discriminated by `type`.
|
|
25621
|
-
*/
|
|
25622
|
-
|
|
25623
|
-
/** The one default mark that carries data. */
|
|
25624
|
-
|
|
25625
|
-
/** The leaf of every text run: a piece of text plus the marks wrapping it. */
|
|
25626
|
-
|
|
25627
|
-
/** Marks every client understands without injection. */
|
|
25628
|
-
var PORTABLE_TEXT_DEFAULT_MARKS = ["strong", "em", "code", "link"];
|
|
25629
|
-
|
|
25630
|
-
/* ---- Blocks ----------------------------------------------------------- */
|
|
25631
|
-
|
|
25632
|
-
/** 1 maps to Title1, 2 to Title2, 3 to Header2 typography. */
|
|
25633
|
-
|
|
25634
|
-
/** Screenshots render framed (border, no shadow); illustrations render flat. */
|
|
25635
|
-
|
|
25636
|
-
/** A table cell is a span array, so inline marks work inside cells. */
|
|
25637
|
-
|
|
25638
|
-
/** A themed horizontal rule between sections. Carries no data. */
|
|
25639
|
-
|
|
25640
|
-
/**
|
|
25641
|
-
* Derived from the union's discriminators, so adding a block to the union
|
|
25642
|
-
* without a renderer entry is a compile error, never silent drift.
|
|
25643
|
-
*/
|
|
25644
|
-
|
|
25645
|
-
// A Record so the compiler checks the list against the union in both
|
|
25646
|
-
// directions: a missing and a stray key each fail to build.
|
|
25647
|
-
var DEFAULT_BLOCK_TYPES = {
|
|
25648
|
-
paragraph: true,
|
|
25649
|
-
heading: true,
|
|
25650
|
-
list: true,
|
|
25651
|
-
"list-item": true,
|
|
25652
|
-
media: true,
|
|
25653
|
-
"titled-text": true,
|
|
25654
|
-
"code-block": true,
|
|
25655
|
-
table: true,
|
|
25656
|
-
divider: true
|
|
25657
|
-
};
|
|
25658
|
-
|
|
25659
|
-
/** Blocks every client understands without injection. */
|
|
25660
|
-
var PORTABLE_TEXT_DEFAULT_BLOCKS = Object.keys(DEFAULT_BLOCK_TYPES);
|
|
25661
|
-
|
|
25662
|
-
/* ---- Objects ----------------------------------------------------------- */
|
|
25663
|
-
|
|
25664
|
-
/**
|
|
25665
|
-
* An embedded component the envelope does not interpret: `_type` names an
|
|
25666
|
-
* application-catalog element, everything else is that element's data. An
|
|
25667
|
-
* object whose `_type` has no injected renderer renders nothing and is logged.
|
|
25668
|
-
*/
|
|
25669
|
-
|
|
25670
|
-
/** The root of a message body: what an API returns under `content`. */
|
|
25671
|
-
|
|
25672
|
-
/* ---- Injection contract ------------------------------------------------ */
|
|
25673
|
-
|
|
25674
|
-
/**
|
|
25675
|
-
* Called once per unknown type instead of rendering it, so content written
|
|
25676
|
-
* for newer clients degrades silently on older ones.
|
|
25677
|
-
*/
|
|
25678
|
-
|
|
25679
|
-
/**
|
|
25680
|
-
* What an application injects into the Portable Text engine: renderers for
|
|
25681
|
-
* its catalog marks and objects, optional overrides for the default blocks,
|
|
25682
|
-
* and the unknown-type hook.
|
|
25683
|
-
*/
|
|
25684
|
-
|
|
25685
|
-
/* ---- Runtime guards ----------------------------------------------------- */
|
|
25686
|
-
|
|
25687
|
-
var isRecord = function isRecord(value) {
|
|
25688
|
-
return typeof value === "object" && value !== null;
|
|
25689
|
-
};
|
|
25690
|
-
var isPortableTextSpan = function isPortableTextSpan(value) {
|
|
25691
|
-
return isRecord(value) && typeof value.text === "string";
|
|
25692
|
-
};
|
|
25693
|
-
var isPortableTextTableRow = function isPortableTextTableRow(value) {
|
|
25694
|
-
return Array.isArray(value) && value.every(function (cell) {
|
|
25695
|
-
return Array.isArray(cell) && cell.every(isPortableTextSpan);
|
|
25696
|
-
});
|
|
25697
|
-
};
|
|
25698
|
-
var isPortableTextObjectNode = function isPortableTextObjectNode(value) {
|
|
25699
|
-
return isRecord(value) && value.type === "object" && typeof value._type === "string";
|
|
25700
|
-
};
|
|
25701
|
-
|
|
25702
|
-
/**
|
|
25703
|
-
* A block is any non-object node with a string `type`. Unknown block types
|
|
25704
|
-
* stay valid on purpose — they render nothing on clients that predate them.
|
|
25705
|
-
* Known types are held to their shape, so a serializer bug (a paragraph
|
|
25706
|
-
* without `children`, a list of non-nodes) fails here instead of at render.
|
|
25707
|
-
*/
|
|
25708
|
-
var _isPortableTextBlock = function isPortableTextBlock(value) {
|
|
25709
|
-
if (!isRecord(value) || typeof value.type !== "string" || value.type === "object") {
|
|
25710
|
-
return false;
|
|
25711
|
-
}
|
|
25712
|
-
switch (value.type) {
|
|
25713
|
-
case "paragraph":
|
|
25714
|
-
case "heading":
|
|
25715
|
-
case "list-item":
|
|
25716
|
-
return Array.isArray(value.children) && value.children.every(isPortableTextSpan);
|
|
25717
|
-
case "list":
|
|
25718
|
-
return Array.isArray(value.children) && value.children.every(_isPortableTextBlock);
|
|
25719
|
-
case "media":
|
|
25720
|
-
return typeof value.src === "string";
|
|
25721
|
-
case "titled-text":
|
|
25722
|
-
return typeof value.title === "string" && (value.content === undefined || isPortableTextContent(value.content));
|
|
25723
|
-
case "code-block":
|
|
25724
|
-
return typeof value.code === "string" && (value.language === undefined || typeof value.language === "string");
|
|
25725
|
-
case "table":
|
|
25726
|
-
return isPortableTextTableRow(value.header) && Array.isArray(value.rows) && value.rows.every(isPortableTextTableRow);
|
|
25727
|
-
case "divider":
|
|
25728
|
-
return true;
|
|
25729
|
-
default:
|
|
25730
|
-
return true;
|
|
25731
|
-
}
|
|
25732
|
-
};
|
|
25733
|
-
var isPortableTextContent = function isPortableTextContent(value) {
|
|
25734
|
-
return Array.isArray(value) && value.every(function (node) {
|
|
25735
|
-
return _isPortableTextBlock(node) || isPortableTextObjectNode(node);
|
|
25736
|
-
});
|
|
25737
|
-
};
|
|
25738
|
-
|
|
25739
25765
|
var _excluded$o = ["content", "components", "space"];
|
|
25740
25766
|
var defaultUnknownTypeHandler = function defaultUnknownTypeHandler(kind, type) {
|
|
25741
25767
|
console.warn("PortableText: no renderer for ".concat(kind, " type \"").concat(type, "\"."));
|
|
@@ -30521,6 +30547,7 @@
|
|
|
30521
30547
|
exports.isOptionGroup = isOptionGroup;
|
|
30522
30548
|
exports.isPortableTextBlock = _isPortableTextBlock;
|
|
30523
30549
|
exports.isPortableTextContent = isPortableTextContent;
|
|
30550
|
+
exports.isPortableTextMediaImageVariant = isPortableTextMediaImageVariant;
|
|
30524
30551
|
exports.isPortableTextObjectNode = isPortableTextObjectNode;
|
|
30525
30552
|
exports.isPortableTextSpan = isPortableTextSpan;
|
|
30526
30553
|
exports.isPortableTextTableRow = isPortableTextTableRow;
|