@italia/popover 1.0.0-alpha.8 → 1.0.0-beta.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/custom-elements.json +20 -1
- package/dist/src/it-popover.d.ts +2 -0
- package/dist/src/it-popover.d.ts.map +1 -1
- package/dist/src/it-popover.js +195 -185
- package/dist/src/it-popover.js.map +1 -1
- package/package.json +8 -8
- package/styles/globals.scss +2 -1
package/dist/src/it-popover.js
CHANGED
|
@@ -35,14 +35,80 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
35
35
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
+
const ARIA_IDREF_ATTRIBUTES = new Map([
|
|
39
|
+
['aria-activedescendant', 'ariaActivedescendantElement'],
|
|
40
|
+
['aria-controls', 'ariaControlsElements'],
|
|
41
|
+
['aria-describedby', 'ariaDescribedByElements'],
|
|
42
|
+
['aria-details', 'ariaDetailsElements'],
|
|
43
|
+
['aria-errormessage', 'ariaErrormessageElements'],
|
|
44
|
+
['aria-flowto', 'ariaFlowtoElements'],
|
|
45
|
+
['aria-labelledby', 'ariaLabelledByElements'],
|
|
46
|
+
['aria-owns', 'ariaOwnsElements'],
|
|
47
|
+
]);
|
|
48
|
+
function resolveAriaIdRefs(element, value) {
|
|
49
|
+
const ids = value
|
|
50
|
+
.trim()
|
|
51
|
+
.split(/\s+/)
|
|
52
|
+
.filter((id) => id.length > 0);
|
|
53
|
+
if (ids.length === 0)
|
|
54
|
+
return null;
|
|
55
|
+
const root = element.getRootNode();
|
|
56
|
+
let resolvedElements = [];
|
|
57
|
+
if (root instanceof ShadowRoot) {
|
|
58
|
+
resolvedElements = ids.map((id) => root.getElementById(id));
|
|
59
|
+
}
|
|
60
|
+
else if (root instanceof Document) {
|
|
61
|
+
resolvedElements = ids.map((id) => root.getElementById(id));
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
resolvedElements = ids.map((id) => document.getElementById(id));
|
|
65
|
+
}
|
|
66
|
+
if (resolvedElements.filter((el) => el !== null).length === 0) {
|
|
67
|
+
resolvedElements = ids.map((id) => document.getElementById(id));
|
|
68
|
+
}
|
|
69
|
+
const validElements = resolvedElements.filter((el) => el !== null);
|
|
70
|
+
return validElements.length === ids.length ? validElements : null;
|
|
71
|
+
}
|
|
72
|
+
function setInternalsProperty(el, name, resolvedElements) {
|
|
73
|
+
if (name === 'aria-activedescendant') {
|
|
74
|
+
const [firstElement] = resolvedElements;
|
|
75
|
+
// eslint-disable-next-line no-param-reassign
|
|
76
|
+
el[name] = firstElement;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// eslint-disable-next-line no-param-reassign
|
|
80
|
+
el[name] = resolvedElements;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
38
83
|
class SetAttributesDirective extends Directive {
|
|
39
84
|
update(part, [attributes]) {
|
|
40
85
|
const el = part.element;
|
|
86
|
+
const internals = el.internals ?? null;
|
|
41
87
|
for (const [name, value] of Object.entries(attributes)) {
|
|
42
|
-
if (value
|
|
43
|
-
el.setAttribute(name, value);
|
|
44
|
-
else
|
|
88
|
+
if (value == null) {
|
|
45
89
|
el.removeAttribute(name);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const internalsPropertyName = ARIA_IDREF_ATTRIBUTES.get(name);
|
|
93
|
+
if (internalsPropertyName) {
|
|
94
|
+
const resolvedElements = resolveAriaIdRefs(el, String(value));
|
|
95
|
+
if (resolvedElements) {
|
|
96
|
+
if (internals) {
|
|
97
|
+
// Set on ElementInternals
|
|
98
|
+
setInternalsProperty(internals, internalsPropertyName, resolvedElements);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
// Set internals property on shadowdom item
|
|
102
|
+
el.setAttribute(name, String(value));
|
|
103
|
+
setInternalsProperty(el, internalsPropertyName, resolvedElements);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
// Non-ARIA IDREF attributes: set normally
|
|
109
|
+
el.setAttribute(name, String(value));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
46
112
|
}
|
|
47
113
|
return null;
|
|
48
114
|
}
|
|
@@ -113,7 +179,9 @@ function registerTranslation(...translation) {
|
|
|
113
179
|
});
|
|
114
180
|
update();
|
|
115
181
|
}
|
|
116
|
-
window
|
|
182
|
+
if (typeof window !== 'undefined') {
|
|
183
|
+
window.registerTranslation = registerTranslation;
|
|
184
|
+
}
|
|
117
185
|
/**
|
|
118
186
|
* Localize Reactive Controller for components built with Lit
|
|
119
187
|
*
|
|
@@ -408,6 +476,26 @@ class BaseComponent extends LitElement {
|
|
|
408
476
|
// generate internal _id
|
|
409
477
|
const prefix = this.id?.length > 0 ? this.id : this.tagName.toLowerCase();
|
|
410
478
|
this._id = this.generateId(prefix);
|
|
479
|
+
this.ariaAttributesObserver = new MutationObserver((mutations) => {
|
|
480
|
+
const shouldUpdate = mutations.some((mutation) => {
|
|
481
|
+
if (mutation.type !== 'attributes' || !mutation.attributeName) {
|
|
482
|
+
return false;
|
|
483
|
+
}
|
|
484
|
+
return mutation.attributeName === 'it-role' || mutation.attributeName.startsWith('it-aria-');
|
|
485
|
+
});
|
|
486
|
+
if (shouldUpdate) {
|
|
487
|
+
this.requestUpdate();
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
this.ariaAttributesObserver.observe(this, {
|
|
491
|
+
attributes: true,
|
|
492
|
+
attributeOldValue: true,
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
disconnectedCallback() {
|
|
496
|
+
this.ariaAttributesObserver?.disconnect();
|
|
497
|
+
this.ariaAttributesObserver = undefined;
|
|
498
|
+
super.disconnectedCallback();
|
|
411
499
|
}
|
|
412
500
|
}
|
|
413
501
|
const BaseLocalizedComponent = LocalizeMixin(BaseComponent);
|
|
@@ -471,6 +559,14 @@ class FormControlController {
|
|
|
471
559
|
case 'it-toggle-group':
|
|
472
560
|
// non settare valori in formData, perchè ogni singola checkbox setta il suo valore
|
|
473
561
|
break;
|
|
562
|
+
case 'it-upload':
|
|
563
|
+
// value is File[] — append each File object directly (not as string)
|
|
564
|
+
if (Array.isArray(value)) {
|
|
565
|
+
value.forEach((file) => {
|
|
566
|
+
event.formData.append(name, file);
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
break;
|
|
474
570
|
default:
|
|
475
571
|
if (Array.isArray(value)) {
|
|
476
572
|
value.forEach((val) => {
|
|
@@ -832,7 +928,7 @@ class FormControl extends BaseLocalizedComponent {
|
|
|
832
928
|
});
|
|
833
929
|
// TODO: verificare se serve davvero con il fatto che usiamo form-controller
|
|
834
930
|
// static formAssociated = true;
|
|
835
|
-
//
|
|
931
|
+
// @property()
|
|
836
932
|
// internals = this.attachInternals();
|
|
837
933
|
this._touched = false;
|
|
838
934
|
/** The name of the input, submitted as a name/value pair with form data. */
|
|
@@ -1080,7 +1176,7 @@ if (typeof window !== 'undefined') {
|
|
|
1080
1176
|
window._itAnalytics = window._itAnalytics || {};
|
|
1081
1177
|
window._itAnalytics = {
|
|
1082
1178
|
...window._itAnalytics,
|
|
1083
|
-
version: '1.0.0-
|
|
1179
|
+
version: '1.0.0-beta.0',
|
|
1084
1180
|
};
|
|
1085
1181
|
}
|
|
1086
1182
|
|
|
@@ -1103,10 +1199,6 @@ const oppositeSideMap = {
|
|
|
1103
1199
|
bottom: 'top',
|
|
1104
1200
|
top: 'bottom'
|
|
1105
1201
|
};
|
|
1106
|
-
const oppositeAlignmentMap = {
|
|
1107
|
-
start: 'end',
|
|
1108
|
-
end: 'start'
|
|
1109
|
-
};
|
|
1110
1202
|
function clamp(start, value, end) {
|
|
1111
1203
|
return max(start, min(value, end));
|
|
1112
1204
|
}
|
|
@@ -1125,9 +1217,9 @@ function getOppositeAxis(axis) {
|
|
|
1125
1217
|
function getAxisLength(axis) {
|
|
1126
1218
|
return axis === 'y' ? 'height' : 'width';
|
|
1127
1219
|
}
|
|
1128
|
-
const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
|
|
1129
1220
|
function getSideAxis(placement) {
|
|
1130
|
-
|
|
1221
|
+
const firstChar = placement[0];
|
|
1222
|
+
return firstChar === 't' || firstChar === 'b' ? 'y' : 'x';
|
|
1131
1223
|
}
|
|
1132
1224
|
function getAlignmentAxis(placement) {
|
|
1133
1225
|
return getOppositeAxis(getSideAxis(placement));
|
|
@@ -1150,7 +1242,7 @@ function getExpandedPlacements(placement) {
|
|
|
1150
1242
|
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
1151
1243
|
}
|
|
1152
1244
|
function getOppositeAlignmentPlacement(placement) {
|
|
1153
|
-
return placement.replace(
|
|
1245
|
+
return placement.includes('start') ? placement.replace('start', 'end') : placement.replace('end', 'start');
|
|
1154
1246
|
}
|
|
1155
1247
|
const lrPlacement = ['left', 'right'];
|
|
1156
1248
|
const rlPlacement = ['right', 'left'];
|
|
@@ -1181,7 +1273,8 @@ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
|
1181
1273
|
return list;
|
|
1182
1274
|
}
|
|
1183
1275
|
function getOppositePlacement(placement) {
|
|
1184
|
-
|
|
1276
|
+
const side = getSide(placement);
|
|
1277
|
+
return oppositeSideMap[side] + placement.slice(side.length);
|
|
1185
1278
|
}
|
|
1186
1279
|
function expandPaddingObject(padding) {
|
|
1187
1280
|
return {
|
|
@@ -1340,6 +1433,9 @@ async function detectOverflow(state, options) {
|
|
|
1340
1433
|
};
|
|
1341
1434
|
}
|
|
1342
1435
|
|
|
1436
|
+
// Maximum number of resets that can occur before bailing to avoid infinite reset loops.
|
|
1437
|
+
const MAX_RESET_COUNT = 50;
|
|
1438
|
+
|
|
1343
1439
|
/**
|
|
1344
1440
|
* Computes the `x` and `y` coordinates that will place the floating element
|
|
1345
1441
|
* next to a given reference element.
|
|
@@ -1354,7 +1450,10 @@ const computePosition$1 = async (reference, floating, config) => {
|
|
|
1354
1450
|
middleware = [],
|
|
1355
1451
|
platform
|
|
1356
1452
|
} = config;
|
|
1357
|
-
const
|
|
1453
|
+
const platformWithDetectOverflow = platform.detectOverflow ? platform : {
|
|
1454
|
+
...platform,
|
|
1455
|
+
detectOverflow
|
|
1456
|
+
};
|
|
1358
1457
|
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
1359
1458
|
let rects = await platform.getElementRects({
|
|
1360
1459
|
reference,
|
|
@@ -1366,14 +1465,17 @@ const computePosition$1 = async (reference, floating, config) => {
|
|
|
1366
1465
|
y
|
|
1367
1466
|
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
1368
1467
|
let statefulPlacement = placement;
|
|
1369
|
-
let middlewareData = {};
|
|
1370
1468
|
let resetCount = 0;
|
|
1371
|
-
|
|
1372
|
-
|
|
1469
|
+
const middlewareData = {};
|
|
1470
|
+
for (let i = 0; i < middleware.length; i++) {
|
|
1471
|
+
const currentMiddleware = middleware[i];
|
|
1472
|
+
if (!currentMiddleware) {
|
|
1473
|
+
continue;
|
|
1474
|
+
}
|
|
1373
1475
|
const {
|
|
1374
1476
|
name,
|
|
1375
1477
|
fn
|
|
1376
|
-
} =
|
|
1478
|
+
} = currentMiddleware;
|
|
1377
1479
|
const {
|
|
1378
1480
|
x: nextX,
|
|
1379
1481
|
y: nextY,
|
|
@@ -1387,10 +1489,7 @@ const computePosition$1 = async (reference, floating, config) => {
|
|
|
1387
1489
|
strategy,
|
|
1388
1490
|
middlewareData,
|
|
1389
1491
|
rects,
|
|
1390
|
-
platform:
|
|
1391
|
-
...platform,
|
|
1392
|
-
detectOverflow: (_platform$detectOverf = platform.detectOverflow) != null ? _platform$detectOverf : detectOverflow
|
|
1393
|
-
},
|
|
1492
|
+
platform: platformWithDetectOverflow,
|
|
1394
1493
|
elements: {
|
|
1395
1494
|
reference,
|
|
1396
1495
|
floating
|
|
@@ -1398,14 +1497,11 @@ const computePosition$1 = async (reference, floating, config) => {
|
|
|
1398
1497
|
});
|
|
1399
1498
|
x = nextX != null ? nextX : x;
|
|
1400
1499
|
y = nextY != null ? nextY : y;
|
|
1401
|
-
middlewareData = {
|
|
1402
|
-
...middlewareData,
|
|
1403
|
-
|
|
1404
|
-
...middlewareData[name],
|
|
1405
|
-
...data
|
|
1406
|
-
}
|
|
1500
|
+
middlewareData[name] = {
|
|
1501
|
+
...middlewareData[name],
|
|
1502
|
+
...data
|
|
1407
1503
|
};
|
|
1408
|
-
if (reset && resetCount
|
|
1504
|
+
if (reset && resetCount < MAX_RESET_COUNT) {
|
|
1409
1505
|
resetCount++;
|
|
1410
1506
|
if (typeof reset === 'object') {
|
|
1411
1507
|
if (reset.placement) {
|
|
@@ -1814,90 +1910,6 @@ const shift$1 = function (options) {
|
|
|
1814
1910
|
};
|
|
1815
1911
|
};
|
|
1816
1912
|
|
|
1817
|
-
/**
|
|
1818
|
-
* Provides data that allows you to change the size of the floating element —
|
|
1819
|
-
* for instance, prevent it from overflowing the clipping boundary or match the
|
|
1820
|
-
* width of the reference element.
|
|
1821
|
-
* @see https://floating-ui.com/docs/size
|
|
1822
|
-
*/
|
|
1823
|
-
const size$1 = function (options) {
|
|
1824
|
-
if (options === void 0) {
|
|
1825
|
-
options = {};
|
|
1826
|
-
}
|
|
1827
|
-
return {
|
|
1828
|
-
name: 'size',
|
|
1829
|
-
options,
|
|
1830
|
-
async fn(state) {
|
|
1831
|
-
var _state$middlewareData, _state$middlewareData2;
|
|
1832
|
-
const {
|
|
1833
|
-
placement,
|
|
1834
|
-
rects,
|
|
1835
|
-
platform,
|
|
1836
|
-
elements
|
|
1837
|
-
} = state;
|
|
1838
|
-
const {
|
|
1839
|
-
apply = () => {},
|
|
1840
|
-
...detectOverflowOptions
|
|
1841
|
-
} = evaluate(options, state);
|
|
1842
|
-
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
1843
|
-
const side = getSide(placement);
|
|
1844
|
-
const alignment = getAlignment(placement);
|
|
1845
|
-
const isYAxis = getSideAxis(placement) === 'y';
|
|
1846
|
-
const {
|
|
1847
|
-
width,
|
|
1848
|
-
height
|
|
1849
|
-
} = rects.floating;
|
|
1850
|
-
let heightSide;
|
|
1851
|
-
let widthSide;
|
|
1852
|
-
if (side === 'top' || side === 'bottom') {
|
|
1853
|
-
heightSide = side;
|
|
1854
|
-
widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
|
|
1855
|
-
} else {
|
|
1856
|
-
widthSide = side;
|
|
1857
|
-
heightSide = alignment === 'end' ? 'top' : 'bottom';
|
|
1858
|
-
}
|
|
1859
|
-
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
|
1860
|
-
const maximumClippingWidth = width - overflow.left - overflow.right;
|
|
1861
|
-
const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
|
|
1862
|
-
const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
|
|
1863
|
-
const noShift = !state.middlewareData.shift;
|
|
1864
|
-
let availableHeight = overflowAvailableHeight;
|
|
1865
|
-
let availableWidth = overflowAvailableWidth;
|
|
1866
|
-
if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
|
|
1867
|
-
availableWidth = maximumClippingWidth;
|
|
1868
|
-
}
|
|
1869
|
-
if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
|
|
1870
|
-
availableHeight = maximumClippingHeight;
|
|
1871
|
-
}
|
|
1872
|
-
if (noShift && !alignment) {
|
|
1873
|
-
const xMin = max(overflow.left, 0);
|
|
1874
|
-
const xMax = max(overflow.right, 0);
|
|
1875
|
-
const yMin = max(overflow.top, 0);
|
|
1876
|
-
const yMax = max(overflow.bottom, 0);
|
|
1877
|
-
if (isYAxis) {
|
|
1878
|
-
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
|
|
1879
|
-
} else {
|
|
1880
|
-
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
|
|
1881
|
-
}
|
|
1882
|
-
}
|
|
1883
|
-
await apply({
|
|
1884
|
-
...state,
|
|
1885
|
-
availableWidth,
|
|
1886
|
-
availableHeight
|
|
1887
|
-
});
|
|
1888
|
-
const nextDimensions = await platform.getDimensions(elements.floating);
|
|
1889
|
-
if (width !== nextDimensions.width || height !== nextDimensions.height) {
|
|
1890
|
-
return {
|
|
1891
|
-
reset: {
|
|
1892
|
-
rects: true
|
|
1893
|
-
}
|
|
1894
|
-
};
|
|
1895
|
-
}
|
|
1896
|
-
return {};
|
|
1897
|
-
}
|
|
1898
|
-
};
|
|
1899
|
-
};
|
|
1900
|
-
|
|
1901
1913
|
function hasWindow() {
|
|
1902
1914
|
return typeof window !== 'undefined';
|
|
1903
1915
|
}
|
|
@@ -1942,7 +1954,6 @@ function isShadowRoot(value) {
|
|
|
1942
1954
|
}
|
|
1943
1955
|
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
1944
1956
|
}
|
|
1945
|
-
const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
|
|
1946
1957
|
function isOverflowElement(element) {
|
|
1947
1958
|
const {
|
|
1948
1959
|
overflow,
|
|
@@ -1950,32 +1961,35 @@ function isOverflowElement(element) {
|
|
|
1950
1961
|
overflowY,
|
|
1951
1962
|
display
|
|
1952
1963
|
} = getComputedStyle$1(element);
|
|
1953
|
-
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) &&
|
|
1964
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== 'inline' && display !== 'contents';
|
|
1954
1965
|
}
|
|
1955
|
-
const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
|
|
1956
1966
|
function isTableElement(element) {
|
|
1957
|
-
return
|
|
1967
|
+
return /^(table|td|th)$/.test(getNodeName(element));
|
|
1958
1968
|
}
|
|
1959
|
-
const topLayerSelectors = [':popover-open', ':modal'];
|
|
1960
1969
|
function isTopLayer(element) {
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
return
|
|
1964
|
-
} catch (_e) {
|
|
1965
|
-
return false;
|
|
1970
|
+
try {
|
|
1971
|
+
if (element.matches(':popover-open')) {
|
|
1972
|
+
return true;
|
|
1966
1973
|
}
|
|
1967
|
-
})
|
|
1974
|
+
} catch (_e) {
|
|
1975
|
+
// no-op
|
|
1976
|
+
}
|
|
1977
|
+
try {
|
|
1978
|
+
return element.matches(':modal');
|
|
1979
|
+
} catch (_e) {
|
|
1980
|
+
return false;
|
|
1981
|
+
}
|
|
1968
1982
|
}
|
|
1969
|
-
const
|
|
1970
|
-
const
|
|
1971
|
-
const
|
|
1983
|
+
const willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
|
|
1984
|
+
const containRe = /paint|layout|strict|content/;
|
|
1985
|
+
const isNotNone = value => !!value && value !== 'none';
|
|
1986
|
+
let isWebKitValue;
|
|
1972
1987
|
function isContainingBlock(elementOrCss) {
|
|
1973
|
-
const webkit = isWebKit();
|
|
1974
1988
|
const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
|
|
1975
1989
|
|
|
1976
1990
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
1977
1991
|
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
|
1978
|
-
return
|
|
1992
|
+
return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || '') || containRe.test(css.contain || '');
|
|
1979
1993
|
}
|
|
1980
1994
|
function getContainingBlock(element) {
|
|
1981
1995
|
let currentNode = getParentNode(element);
|
|
@@ -1990,12 +2004,13 @@ function getContainingBlock(element) {
|
|
|
1990
2004
|
return null;
|
|
1991
2005
|
}
|
|
1992
2006
|
function isWebKit() {
|
|
1993
|
-
if (
|
|
1994
|
-
|
|
2007
|
+
if (isWebKitValue == null) {
|
|
2008
|
+
isWebKitValue = typeof CSS !== 'undefined' && CSS.supports && CSS.supports('-webkit-backdrop-filter', 'none');
|
|
2009
|
+
}
|
|
2010
|
+
return isWebKitValue;
|
|
1995
2011
|
}
|
|
1996
|
-
const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
|
|
1997
2012
|
function isLastTraversableNode(node) {
|
|
1998
|
-
return
|
|
2013
|
+
return /^(html|body|#document)$/.test(getNodeName(node));
|
|
1999
2014
|
}
|
|
2000
2015
|
function getComputedStyle$1(element) {
|
|
2001
2016
|
return getWindow(element).getComputedStyle(element);
|
|
@@ -2051,8 +2066,9 @@ function getOverflowAncestors(node, list, traverseIframes) {
|
|
|
2051
2066
|
if (isBody) {
|
|
2052
2067
|
const frameElement = getFrameElement(win);
|
|
2053
2068
|
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
2069
|
+
} else {
|
|
2070
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
2054
2071
|
}
|
|
2055
|
-
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
2056
2072
|
}
|
|
2057
2073
|
function getFrameElement(win) {
|
|
2058
2074
|
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
@@ -2229,7 +2245,7 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
|
2229
2245
|
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
2230
2246
|
scroll = getNodeScroll(offsetParent);
|
|
2231
2247
|
}
|
|
2232
|
-
if (
|
|
2248
|
+
if (isOffsetParentAnElement) {
|
|
2233
2249
|
const offsetRect = getBoundingClientRect(offsetParent);
|
|
2234
2250
|
scale = getScale(offsetParent);
|
|
2235
2251
|
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
@@ -2317,7 +2333,6 @@ function getViewportRect(element, strategy) {
|
|
|
2317
2333
|
};
|
|
2318
2334
|
}
|
|
2319
2335
|
|
|
2320
|
-
const absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);
|
|
2321
2336
|
// Returns the inner client rect, subtracting scrollbars if present.
|
|
2322
2337
|
function getInnerBoundingClientRect(element, strategy) {
|
|
2323
2338
|
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
|
@@ -2382,7 +2397,7 @@ function getClippingElementAncestors(element, cache) {
|
|
|
2382
2397
|
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
|
2383
2398
|
currentContainingBlockComputedStyle = null;
|
|
2384
2399
|
}
|
|
2385
|
-
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle &&
|
|
2400
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === 'absolute' || currentContainingBlockComputedStyle.position === 'fixed') || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
2386
2401
|
if (shouldDropCurrentNode) {
|
|
2387
2402
|
// Drop non-containing blocks.
|
|
2388
2403
|
result = result.filter(ancestor => ancestor !== currentNode);
|
|
@@ -2407,20 +2422,23 @@ function getClippingRect(_ref) {
|
|
|
2407
2422
|
} = _ref;
|
|
2408
2423
|
const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
2409
2424
|
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
2410
|
-
const
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2425
|
+
const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
|
|
2426
|
+
let top = firstRect.top;
|
|
2427
|
+
let right = firstRect.right;
|
|
2428
|
+
let bottom = firstRect.bottom;
|
|
2429
|
+
let left = firstRect.left;
|
|
2430
|
+
for (let i = 1; i < clippingAncestors.length; i++) {
|
|
2431
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);
|
|
2432
|
+
top = max(rect.top, top);
|
|
2433
|
+
right = min(rect.right, right);
|
|
2434
|
+
bottom = min(rect.bottom, bottom);
|
|
2435
|
+
left = max(rect.left, left);
|
|
2436
|
+
}
|
|
2419
2437
|
return {
|
|
2420
|
-
width:
|
|
2421
|
-
height:
|
|
2422
|
-
x:
|
|
2423
|
-
y:
|
|
2438
|
+
width: right - left,
|
|
2439
|
+
height: bottom - top,
|
|
2440
|
+
x: left,
|
|
2441
|
+
y: top
|
|
2424
2442
|
};
|
|
2425
2443
|
}
|
|
2426
2444
|
|
|
@@ -2671,7 +2689,7 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
2671
2689
|
animationFrame = false
|
|
2672
2690
|
} = options;
|
|
2673
2691
|
const referenceEl = unwrapElement(reference);
|
|
2674
|
-
const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
|
|
2692
|
+
const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...(floating ? getOverflowAncestors(floating) : [])] : [];
|
|
2675
2693
|
ancestors.forEach(ancestor => {
|
|
2676
2694
|
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
|
2677
2695
|
passive: true
|
|
@@ -2684,7 +2702,7 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
2684
2702
|
if (elementResize) {
|
|
2685
2703
|
resizeObserver = new ResizeObserver(_ref => {
|
|
2686
2704
|
let [firstEntry] = _ref;
|
|
2687
|
-
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
|
2705
|
+
if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
|
|
2688
2706
|
// Prevent update loops when using the `size` middleware.
|
|
2689
2707
|
// https://github.com/floating-ui/floating-ui/issues/1740
|
|
2690
2708
|
resizeObserver.unobserve(floating);
|
|
@@ -2699,7 +2717,9 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
2699
2717
|
if (referenceEl && !animationFrame) {
|
|
2700
2718
|
resizeObserver.observe(referenceEl);
|
|
2701
2719
|
}
|
|
2702
|
-
|
|
2720
|
+
if (floating) {
|
|
2721
|
+
resizeObserver.observe(floating);
|
|
2722
|
+
}
|
|
2703
2723
|
}
|
|
2704
2724
|
let frameId;
|
|
2705
2725
|
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
@@ -2754,14 +2774,6 @@ const shift = shift$1;
|
|
|
2754
2774
|
*/
|
|
2755
2775
|
const flip = flip$1;
|
|
2756
2776
|
|
|
2757
|
-
/**
|
|
2758
|
-
* Provides data that allows you to change the size of the floating element —
|
|
2759
|
-
* for instance, prevent it from overflowing the clipping boundary or match the
|
|
2760
|
-
* width of the reference element.
|
|
2761
|
-
* @see https://floating-ui.com/docs/size
|
|
2762
|
-
*/
|
|
2763
|
-
const size = size$1;
|
|
2764
|
-
|
|
2765
2777
|
/**
|
|
2766
2778
|
* Provides data to position an inner element of the floating element so that it
|
|
2767
2779
|
* appears centered to the reference element.
|
|
@@ -2792,20 +2804,7 @@ const computePosition = (reference, floating, options) => {
|
|
|
2792
2804
|
});
|
|
2793
2805
|
};
|
|
2794
2806
|
|
|
2795
|
-
var styles = css
|
|
2796
|
-
/***************************** 2 ****************************************/
|
|
2797
|
-
/***************************** 1 ****************************************/
|
|
2798
|
-
/***************************** 2 ****************************************/
|
|
2799
|
-
/***************************** 1 ****************************************/
|
|
2800
|
-
/***************************** 2 ****************************************/
|
|
2801
|
-
/***************************** 3 ****************************************/
|
|
2802
|
-
/***************************** 1 ****************************************/
|
|
2803
|
-
/***************************** 2 ****************************************/
|
|
2804
|
-
/***************************** 3 ****************************************/
|
|
2805
|
-
/***************************** NEUTRAL 1 ****************************************/
|
|
2806
|
-
/***************************** NEUTRAL 2 ****************************************/
|
|
2807
|
-
/***************************** NEUTRAL 2 / 3 ****************************************/
|
|
2808
|
-
:host {
|
|
2807
|
+
var styles = css`:host {
|
|
2809
2808
|
--bsi-dropdown-background: var(--bsi-color-background-inverse);
|
|
2810
2809
|
}`;
|
|
2811
2810
|
|
|
@@ -2817,6 +2816,8 @@ let ItPopover = class ItPopover extends BaseComponent {
|
|
|
2817
2816
|
this.placement = 'bottom-start';
|
|
2818
2817
|
this.offset = 12;
|
|
2819
2818
|
this.noFlip = false;
|
|
2819
|
+
/** Centre the arrow on the trigger instead of the fixed notch position. Used by avatar dropdowns. */
|
|
2820
|
+
this.centerArrow = false;
|
|
2820
2821
|
this._onDocumentClick = (event) => {
|
|
2821
2822
|
if (!this.open)
|
|
2822
2823
|
return;
|
|
@@ -2920,13 +2921,14 @@ let ItPopover = class ItPopover extends BaseComponent {
|
|
|
2920
2921
|
offset(this.offset),
|
|
2921
2922
|
flip({ mainAxis: !this.noFlip, crossAxis: !this.noFlip }),
|
|
2922
2923
|
shift({ padding: 8 }),
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
}
|
|
2924
|
+
// Commentato perchè nella toolbar con dropdown che ha position absolute, vogliamo il min-width impostato da css con var(--bsi-dropdown-min-width)
|
|
2925
|
+
// size({
|
|
2926
|
+
// apply({ rects, elements }) {
|
|
2927
|
+
// Object.assign(elements.floating.style, {
|
|
2928
|
+
// minWidth: `${rects.reference.width}px`,
|
|
2929
|
+
// });
|
|
2930
|
+
// },
|
|
2931
|
+
// }),
|
|
2930
2932
|
arrow({ element: this._arrowElement }),
|
|
2931
2933
|
],
|
|
2932
2934
|
}).then(({ x, y, placement, middlewareData }) => {
|
|
@@ -2946,8 +2948,12 @@ let ItPopover = class ItPopover extends BaseComponent {
|
|
|
2946
2948
|
const contentRect = this._contentElement.getBoundingClientRect();
|
|
2947
2949
|
const triggerCenter = triggerRect.left + triggerRect.width / 2;
|
|
2948
2950
|
const arrowLeft = triggerCenter - contentRect.left - this._triggerElement.offsetWidth / 2 + 20;
|
|
2951
|
+
// When `centerArrow` is set (e.g. avatar dropdowns), centre the arrow
|
|
2952
|
+
// on the trigger using Floating UI's computed offset. Otherwise keep
|
|
2953
|
+
// the fixed notch position relied on by standard dropdowns.
|
|
2954
|
+
const left = this.centerArrow ? arrowX : arrowLeft;
|
|
2949
2955
|
Object.assign(this._arrowElement.style, {
|
|
2950
|
-
left: arrowX != null ? `${
|
|
2956
|
+
left: arrowX != null ? `${left}px` : '',
|
|
2951
2957
|
top: arrowY != null ? `${arrowY}px` : '',
|
|
2952
2958
|
right: '',
|
|
2953
2959
|
bottom: '',
|
|
@@ -2979,7 +2985,7 @@ let ItPopover = class ItPopover extends BaseComponent {
|
|
|
2979
2985
|
render() {
|
|
2980
2986
|
return html `
|
|
2981
2987
|
<slot name="trigger" part="trigger" @slotchange=${this._setChildrenProperties}></slot>
|
|
2982
|
-
<slot name="content"></slot>
|
|
2988
|
+
<slot name="content" part="popover-content"></slot>
|
|
2983
2989
|
`;
|
|
2984
2990
|
}
|
|
2985
2991
|
};
|
|
@@ -3004,6 +3010,10 @@ __decorate([
|
|
|
3004
3010
|
property({ type: Boolean, attribute: 'no-flip' }),
|
|
3005
3011
|
__metadata("design:type", Boolean)
|
|
3006
3012
|
], ItPopover.prototype, "noFlip", void 0);
|
|
3013
|
+
__decorate([
|
|
3014
|
+
property({ type: Boolean, attribute: 'center-arrow' }),
|
|
3015
|
+
__metadata("design:type", Boolean)
|
|
3016
|
+
], ItPopover.prototype, "centerArrow", void 0);
|
|
3007
3017
|
__decorate([
|
|
3008
3018
|
query('slot[name="trigger"]'),
|
|
3009
3019
|
__metadata("design:type", HTMLSlotElement)
|