@antglobal/copilot-cards-web 0.0.20260915071159-dev.1 → 0.0.20260915071159-dev.5
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/index.d.ts +1 -1
- package/dist/index.js +64 -50
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -107,7 +107,7 @@ declare function createResponsiveContext(isMobile: boolean, responsive?: Respons
|
|
|
107
107
|
*/
|
|
108
108
|
|
|
109
109
|
interface RenderCardOptions extends WebActionContextOptions {
|
|
110
|
-
/**
|
|
110
|
+
/** Block whole-card interaction and add a configurable overlay without restyling nodes. Default false. */
|
|
111
111
|
disabled?: boolean;
|
|
112
112
|
/** Enable mobile component layout explicitly (default false). */
|
|
113
113
|
isMobile?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -713,30 +713,9 @@ function buildHeatmapOption(config) {
|
|
|
713
713
|
};
|
|
714
714
|
}
|
|
715
715
|
|
|
716
|
-
const DISABLED_MARKER = 'data-copilot-card-disabled';
|
|
717
|
-
function applyDisabledState(element, disabled) {
|
|
718
|
-
if (!disabled)
|
|
719
|
-
return;
|
|
720
|
-
element.setAttribute('data-disabled', 'true');
|
|
721
|
-
element.setAttribute(DISABLED_MARKER, 'true');
|
|
722
|
-
// Inline declarations work inside host ShadowRoots too. Use the shorthand
|
|
723
|
-
// to mask background images/gradients, matching the historical disabled state.
|
|
724
|
-
element.style.background = 'var(--card-disabled-background, #F5F5F5)';
|
|
725
|
-
element.style.color = 'var(--card-disabled-foreground, #C0C0C0)';
|
|
726
|
-
element.style.pointerEvents = 'none';
|
|
727
|
-
element.style.cursor = 'default';
|
|
728
|
-
}
|
|
729
|
-
function applyDisabledDescendants(element, disabled) {
|
|
730
|
-
if (!disabled)
|
|
731
|
-
return;
|
|
732
|
-
element.querySelectorAll('*').forEach((child) => {
|
|
733
|
-
child.setAttribute('data-disabled', 'true');
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
|
|
737
716
|
const controllers = new WeakMap();
|
|
738
717
|
const interactionCleanups = new WeakMap();
|
|
739
|
-
/** Cancel slot-owned gestures before
|
|
718
|
+
/** Cancel slot-owned gestures before covering the card. */
|
|
740
719
|
function registerCardDisableCleanup(element, cleanup) {
|
|
741
720
|
let callbacks = interactionCleanups.get(element);
|
|
742
721
|
if (!callbacks) {
|
|
@@ -762,15 +741,13 @@ const BLOCKED_EVENTS = [
|
|
|
762
741
|
'compositionstart', 'compositionupdate', 'compositionend',
|
|
763
742
|
'choice-request-change', 'choice-navigate',
|
|
764
743
|
];
|
|
765
|
-
const TOUCH_EVENTS = ['pointerdown', 'pointerup', 'touchstart', 'touchend', 'mousedown', 'mouseup'];
|
|
744
|
+
const TOUCH_EVENTS = ['pointerdown', 'pointerup', 'touchstart', 'touchend', 'mousedown', 'mouseup', 'wheel'];
|
|
766
745
|
const TAB_TARGETS = [
|
|
767
746
|
'a[href]', 'area[href]', 'button', 'input', 'select', 'textarea', 'summary',
|
|
768
747
|
'iframe', 'object', 'embed', 'audio[controls]', 'video[controls]',
|
|
769
748
|
'[tabindex]', '[contenteditable]:not([contenteditable="false"])',
|
|
770
749
|
].join(',');
|
|
771
|
-
const
|
|
772
|
-
const ownsStyle = (name) => name === 'background' || name.startsWith('background-')
|
|
773
|
-
|| name === 'color' || name === 'pointer-events' || name === 'cursor';
|
|
750
|
+
const CARD_DISABLED_ATTRIBUTE = 'data-card-disabled';
|
|
774
751
|
function restoreAttribute(element, name, value) {
|
|
775
752
|
if (value === null)
|
|
776
753
|
element.removeAttribute(name);
|
|
@@ -784,7 +761,9 @@ function createCardDisabledController(container, initiallyDisabled = false) {
|
|
|
784
761
|
let updateDepth = 0;
|
|
785
762
|
let applyingPresentation = false;
|
|
786
763
|
let previousAriaDisabled = null;
|
|
787
|
-
let
|
|
764
|
+
let previousDisabledMarker = null;
|
|
765
|
+
let overlay;
|
|
766
|
+
let mountStyles = [];
|
|
788
767
|
let tabSnapshots = [];
|
|
789
768
|
let tabObserver;
|
|
790
769
|
const block = (event) => {
|
|
@@ -876,14 +855,39 @@ function createCardDisabledController(container, initiallyDisabled = false) {
|
|
|
876
855
|
}
|
|
877
856
|
function restorePresentation() {
|
|
878
857
|
restoreTabNavigation();
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
if (
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
858
|
+
overlay?.remove();
|
|
859
|
+
for (const [name, value, priority] of mountStyles) {
|
|
860
|
+
if (value)
|
|
861
|
+
container.style.setProperty(name, value, priority);
|
|
862
|
+
else
|
|
863
|
+
container.style.removeProperty(name);
|
|
885
864
|
}
|
|
886
|
-
|
|
865
|
+
mountStyles = [];
|
|
866
|
+
}
|
|
867
|
+
function coverCard() {
|
|
868
|
+
const root = container.firstElementChild;
|
|
869
|
+
if (!root)
|
|
870
|
+
return;
|
|
871
|
+
const style = container.ownerDocument.defaultView?.getComputedStyle(container);
|
|
872
|
+
const ownStyle = (name, value) => {
|
|
873
|
+
mountStyles.push([name, container.style.getPropertyValue(name), container.style.getPropertyPriority(name)]);
|
|
874
|
+
container.style.setProperty(name, value, 'important');
|
|
875
|
+
};
|
|
876
|
+
if (!style?.position || style.position === 'static')
|
|
877
|
+
ownStyle('position', 'relative');
|
|
878
|
+
// Keep the mask above card content without covering neighboring messages.
|
|
879
|
+
ownStyle('isolation', 'isolate');
|
|
880
|
+
overlay ?? (overlay = container.ownerDocument.createElement('div'));
|
|
881
|
+
overlay.setAttribute('data-card-disabled-overlay', '');
|
|
882
|
+
overlay.setAttribute('aria-hidden', 'true');
|
|
883
|
+
overlay.style.cssText = 'position:absolute;inset:0;z-index:2147483647;pointer-events:auto;cursor:default;'
|
|
884
|
+
+ 'background:var(--card-disabled-overlay-background, rgba(255, 255, 255, 0.6));';
|
|
885
|
+
// A dedicated mount normally shares the root card's bounds. Respect a mount
|
|
886
|
+
// radius when provided, otherwise match the rendered card's rounded corners.
|
|
887
|
+
const rootStyle = container.ownerDocument.defaultView?.getComputedStyle(root);
|
|
888
|
+
overlay.style.borderRadius = style?.borderRadius && style.borderRadius !== '0px'
|
|
889
|
+
? style.borderRadius : rootStyle?.borderRadius ?? '';
|
|
890
|
+
container.appendChild(overlay);
|
|
887
891
|
}
|
|
888
892
|
function applyPresentation() {
|
|
889
893
|
if (!disabled || disposed || updateDepth > 0 || applyingPresentation)
|
|
@@ -891,27 +895,13 @@ function createCardDisabledController(container, initiallyDisabled = false) {
|
|
|
891
895
|
applyingPresentation = true;
|
|
892
896
|
try {
|
|
893
897
|
// Blur/popup callbacks can synchronously update or toggle the card.
|
|
894
|
-
//
|
|
898
|
+
// Reattach only after renderer updates and popup/gesture cleanup finish.
|
|
895
899
|
restorePresentation();
|
|
896
900
|
closeTransientUI(container);
|
|
897
901
|
blurCardInput();
|
|
898
902
|
if (!disabled || disposed)
|
|
899
903
|
return;
|
|
900
|
-
|
|
901
|
-
const isRoot = element.parentElement === container;
|
|
902
|
-
snapshots.push({
|
|
903
|
-
element,
|
|
904
|
-
attributes: VISUAL_ATTRIBUTES.map(name => element.getAttribute(name)),
|
|
905
|
-
styles: isRoot ? Array.from(element.style).filter(ownsStyle)
|
|
906
|
-
.map(name => [name, element.style.getPropertyValue(name), element.style.getPropertyPriority(name)]) : undefined,
|
|
907
|
-
});
|
|
908
|
-
}
|
|
909
|
-
for (const root of Array.from(container.children)) {
|
|
910
|
-
if (!(root instanceof HTMLElement))
|
|
911
|
-
continue;
|
|
912
|
-
applyDisabledState(root, true);
|
|
913
|
-
applyDisabledDescendants(root, true);
|
|
914
|
-
}
|
|
904
|
+
coverCard();
|
|
915
905
|
excludeFromTabNavigation(container);
|
|
916
906
|
}
|
|
917
907
|
finally {
|
|
@@ -946,7 +936,9 @@ function createCardDisabledController(container, initiallyDisabled = false) {
|
|
|
946
936
|
epoch += 1;
|
|
947
937
|
if (disabled) {
|
|
948
938
|
previousAriaDisabled = container.getAttribute('aria-disabled');
|
|
939
|
+
previousDisabledMarker = container.getAttribute(CARD_DISABLED_ATTRIBUTE);
|
|
949
940
|
container.setAttribute('aria-disabled', 'true');
|
|
941
|
+
container.setAttribute(CARD_DISABLED_ATTRIBUTE, 'true');
|
|
950
942
|
listen(true);
|
|
951
943
|
blurCardInput();
|
|
952
944
|
applyPresentation();
|
|
@@ -954,6 +946,7 @@ function createCardDisabledController(container, initiallyDisabled = false) {
|
|
|
954
946
|
else {
|
|
955
947
|
restorePresentation();
|
|
956
948
|
restoreAttribute(container, 'aria-disabled', previousAriaDisabled);
|
|
949
|
+
restoreAttribute(container, CARD_DISABLED_ATTRIBUTE, previousDisabledMarker);
|
|
957
950
|
listen(false);
|
|
958
951
|
}
|
|
959
952
|
},
|
|
@@ -9661,6 +9654,27 @@ function createCardNodeAccess(container) {
|
|
|
9661
9654
|
};
|
|
9662
9655
|
}
|
|
9663
9656
|
|
|
9657
|
+
const DISABLED_MARKER = 'data-copilot-card-disabled';
|
|
9658
|
+
function applyDisabledState(element, disabled) {
|
|
9659
|
+
if (!disabled)
|
|
9660
|
+
return;
|
|
9661
|
+
element.setAttribute('data-disabled', 'true');
|
|
9662
|
+
element.setAttribute(DISABLED_MARKER, 'true');
|
|
9663
|
+
// Inline declarations work inside host ShadowRoots too. Use the shorthand
|
|
9664
|
+
// to mask background images/gradients, matching the historical disabled state.
|
|
9665
|
+
element.style.background = 'var(--card-disabled-background, #F5F5F5)';
|
|
9666
|
+
element.style.color = 'var(--card-disabled-foreground, #C0C0C0)';
|
|
9667
|
+
element.style.pointerEvents = 'none';
|
|
9668
|
+
element.style.cursor = 'default';
|
|
9669
|
+
}
|
|
9670
|
+
function applyDisabledDescendants(element, disabled) {
|
|
9671
|
+
if (!disabled)
|
|
9672
|
+
return;
|
|
9673
|
+
element.querySelectorAll('*').forEach((child) => {
|
|
9674
|
+
child.setAttribute('data-disabled', 'true');
|
|
9675
|
+
});
|
|
9676
|
+
}
|
|
9677
|
+
|
|
9664
9678
|
const FORCE_REPLACE = Symbol('bound-force-replace');
|
|
9665
9679
|
const REPEAT_APPEND = Symbol('bound-repeat-append');
|
|
9666
9680
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antglobal/copilot-cards-web",
|
|
3
|
-
"version": "0.0.20260915071159-dev.
|
|
3
|
+
"version": "0.0.20260915071159-dev.5",
|
|
4
4
|
"description": "Web Component renderer for copilot bot card SDK — PC + Mobile + WebView unified rendering via Custom Elements",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
],
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@antglobal/copilot-cards-core": "0.0.20260915071159-dev.
|
|
31
|
+
"@antglobal/copilot-cards-core": "0.0.20260915071159-dev.5",
|
|
32
32
|
"echarts": "^5.6.0",
|
|
33
33
|
"marked": "^18.0.5",
|
|
34
34
|
"tslib": "^2.8.1",
|