pict-section-form 1.3.5 → 1.3.6
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/CONTRIBUTING.md +1 -1
- package/README.md +2 -2
- package/package.json +1 -1
- package/source/providers/layouts/Pict-Layout-Tabular.js +278 -25
package/CONTRIBUTING.md
CHANGED
|
@@ -47,4 +47,4 @@ When in doubt, match what the surrounding code does.
|
|
|
47
47
|
|
|
48
48
|
## Repository Structure
|
|
49
49
|
|
|
50
|
-
Each module is its own git repository. The [retold](https://github.com/
|
|
50
|
+
Each module is its own git repository. The [retold](https://github.com/fable-retold/retold) repository tracks module organization but does not contain module source code. Direct your pull request to the specific module repository where your change belongs.
|
package/README.md
CHANGED
|
@@ -271,7 +271,7 @@ of data in your application.
|
|
|
271
271
|
|
|
272
272
|
## Documentation
|
|
273
273
|
|
|
274
|
-
The complete documentation - an interactive guide with live examples - is hosted at **[
|
|
274
|
+
The complete documentation - an interactive guide with live examples - is hosted at **[fable-retold.github.io/pict-section-form](https://fable-retold.github.io/pict-section-form/)**:
|
|
275
275
|
|
|
276
276
|
| Document | Description |
|
|
277
277
|
|----------|-------------|
|
|
@@ -365,4 +365,4 @@ MIT
|
|
|
365
365
|
|
|
366
366
|
## Contributing
|
|
367
367
|
|
|
368
|
-
Pull requests are welcome. For details on our code of conduct, contribution process, and testing requirements, see the [Retold Contributing Guide](https://github.com/
|
|
368
|
+
Pull requests are welcome. For details on our code of conduct, contribution process, and testing requirements, see the [Retold Contributing Guide](https://github.com/fable-retold/retold/blob/main/docs/contributing.md).
|
package/package.json
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
const libPictSectionGroupLayout = require('../Pict-Provider-DynamicLayout.js');
|
|
2
2
|
|
|
3
|
+
// The resolved --theme-color-* tokens carried onto a column-chooser popover when it is portaled to
|
|
4
|
+
// <body>: off its scoped container it would otherwise fall back to the stylesheet's hex defaults.
|
|
5
|
+
// Mirrors pict-section-picker's PictView-Picker `_THEME_TOKENS`.
|
|
6
|
+
const _COLCHOOSER_THEME_TOKENS =
|
|
7
|
+
[
|
|
8
|
+
'--theme-color-text-primary', '--theme-color-text-secondary', '--theme-color-text-muted',
|
|
9
|
+
'--theme-color-border-default', '--theme-color-border-light', '--theme-color-background-panel',
|
|
10
|
+
'--theme-color-background-tertiary',
|
|
11
|
+
];
|
|
12
|
+
|
|
3
13
|
class TabularLayout extends libPictSectionGroupLayout
|
|
4
14
|
{
|
|
5
15
|
constructor(pFable, pOptions, pServiceHash)
|
|
@@ -39,19 +49,24 @@ class TabularLayout extends libPictSectionGroupLayout
|
|
|
39
49
|
+ ' .pict-tabular-sort-control.pict-tabular-sort-asc, .pict-tabular-sort-control.pict-tabular-sort-desc { opacity: 1; }',
|
|
40
50
|
500);
|
|
41
51
|
|
|
42
|
-
// CSS for the optional ColumnChooser feature: a right-aligned trigger button
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
// CSS for the optional ColumnChooser feature: a right-aligned trigger button above the
|
|
53
|
+
// table plus a checkbox popover. Anchored the same listener-free way as pict-section-picker:
|
|
54
|
+
// the popover is position:absolute under the (position:relative) bar so it rides page scroll
|
|
55
|
+
// for free, and is portaled to <body> in DOCUMENT coords only when a clipping ancestor would
|
|
56
|
+
// otherwise cut it -- no scroll/resize handlers. The transparent backdrop catches outside
|
|
57
|
+
// clicks. Dark-mode blocks (below, with DARK var() fallbacks) let the widget theme correctly
|
|
58
|
+
// even where the host has not defined the --theme-color-* tokens; a host that HAS defined
|
|
59
|
+
// them still wins, and the token values are carried across when the popover is portaled.
|
|
60
|
+
let tmpColumnChooserBaseCSS = /*css*/`
|
|
61
|
+
.pict-tabular-colchooser-bar { position: relative; display: flex; justify-content: flex-end; margin: 0 0 0.35rem; }
|
|
48
62
|
.pict-tabular-colchooser-trigger { display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer; font: inherit; font-size: 0.88rem;
|
|
49
63
|
padding: 0.3rem 0.65rem; border: 1px solid var(--theme-color-border-default, #d7dce3); border-radius: 7px;
|
|
50
64
|
background: var(--theme-color-background-panel, #fff); color: var(--theme-color-text-secondary, #45505f); }
|
|
51
65
|
.pict-tabular-colchooser-trigger:hover { background: var(--theme-color-background-tertiary, #eceef2); color: var(--theme-color-text-primary, #1f2733); }
|
|
52
66
|
.pict-tabular-colchooser-count { font-size: 0.8em; color: var(--theme-color-text-muted, #6b7686); }
|
|
53
|
-
.pict-tabular-colchooser-pop { position:
|
|
67
|
+
.pict-tabular-colchooser-pop { position: absolute; top: calc(100% + 6px); right: 0; z-index: 30; min-width: 220px; max-width: 320px; display: none; }
|
|
54
68
|
.pict-tabular-colchooser-pop.open { display: block; }
|
|
69
|
+
.pict-tabular-colchooser-pop.pict-tabular-colchooser-pop-portal { right: auto; }
|
|
55
70
|
.pict-tabular-colchooser-backdrop { position: fixed; inset: 0; z-index: 0; }
|
|
56
71
|
.pict-tabular-colchooser-panel { position: relative; z-index: 1; display: flex; flex-direction: column; max-height: min(70vh, 420px);
|
|
57
72
|
background: var(--theme-color-background-panel, #fff); border: 1px solid var(--theme-color-border-default, #d7dce3);
|
|
@@ -64,7 +79,29 @@ class TabularLayout extends libPictSectionGroupLayout
|
|
|
64
79
|
.pict-tabular-colchooser-footer { flex: 0 0 auto; display: flex; justify-content: flex-end; padding: 0.45rem 0.7rem; border-top: 1px solid var(--theme-color-border-light, #e8ebf0); }
|
|
65
80
|
.pict-tabular-colchooser-reset { font: inherit; font-size: 0.84rem; cursor: pointer; border: none; background: transparent; color: var(--theme-color-text-muted, #6b7686); padding: 0.15rem 0.3rem; border-radius: 5px; }
|
|
66
81
|
.pict-tabular-colchooser-reset:hover { color: var(--theme-color-text-primary, #1f2733); background: var(--theme-color-background-tertiary, #eceef2); }
|
|
67
|
-
|
|
82
|
+
`;
|
|
83
|
+
// Dark-mode overrides: re-declare only the color-bearing rules with DARK var() fallbacks under
|
|
84
|
+
// each of the app's dark signals. Duplicated per selector (explicit [data-theme=dark] and
|
|
85
|
+
// .theme-dark, plus the system preference guarded by html:not([data-theme=light]) so an
|
|
86
|
+
// explicit light choice still wins) exactly as headlight-styles' bulma-*.scss does. Higher
|
|
87
|
+
// specificity than the base rules, so dark wins whenever its selector matches; the [data-theme]
|
|
88
|
+
// signal lives on <html>, so these still apply after a popover is portaled to <body>.
|
|
89
|
+
let fColumnChooserDarkRules = (pScope) => /*css*/`
|
|
90
|
+
${pScope} .pict-tabular-colchooser-trigger { border-color: var(--theme-color-border-default, #3a4250); background: var(--theme-color-background-panel, #242b36); color: var(--theme-color-text-secondary, #c3cad4); }
|
|
91
|
+
${pScope} .pict-tabular-colchooser-trigger:hover { background: var(--theme-color-background-tertiary, #2c3542); color: var(--theme-color-text-primary, #e6e9ee); }
|
|
92
|
+
${pScope} .pict-tabular-colchooser-count { color: var(--theme-color-text-muted, #8b95a4); }
|
|
93
|
+
${pScope} .pict-tabular-colchooser-panel { background: var(--theme-color-background-panel, #242b36); border-color: var(--theme-color-border-default, #3a4250); }
|
|
94
|
+
${pScope} .pict-tabular-colchooser-row { color: var(--theme-color-text-primary, #e6e9ee); }
|
|
95
|
+
${pScope} .pict-tabular-colchooser-row:hover { background: var(--theme-color-background-tertiary, #2c3542); }
|
|
96
|
+
${pScope} .pict-tabular-colchooser-footer { border-top-color: var(--theme-color-border-light, #333b47); }
|
|
97
|
+
${pScope} .pict-tabular-colchooser-reset { color: var(--theme-color-text-muted, #8b95a4); }
|
|
98
|
+
${pScope} .pict-tabular-colchooser-reset:hover { color: var(--theme-color-text-primary, #e6e9ee); background: var(--theme-color-background-tertiary, #2c3542); }
|
|
99
|
+
`;
|
|
100
|
+
this.pict.CSSMap.addCSS('Pict-Layout-Tabular-ColumnChooser-CSS',
|
|
101
|
+
tmpColumnChooserBaseCSS
|
|
102
|
+
+ fColumnChooserDarkRules('[data-theme="dark"]')
|
|
103
|
+
+ fColumnChooserDarkRules('.theme-dark')
|
|
104
|
+
+ `@media (prefers-color-scheme: dark) {` + fColumnChooserDarkRules('html:not([data-theme="light"])') + `}`,
|
|
68
105
|
500);
|
|
69
106
|
}
|
|
70
107
|
}
|
|
@@ -1098,52 +1135,268 @@ class TabularLayout extends libPictSectionGroupLayout
|
|
|
1098
1135
|
tmpPopoverElements[0].classList.toggle('open', !!pOpen);
|
|
1099
1136
|
if (pOpen)
|
|
1100
1137
|
{
|
|
1101
|
-
this.
|
|
1138
|
+
this._applyTabularColumnChooserAnchor(pView, pGroup, tmpPopoverElements[0]);
|
|
1139
|
+
}
|
|
1140
|
+
else
|
|
1141
|
+
{
|
|
1142
|
+
// Bring a portaled popover home on close so a closed chooser never strands a node on <body>.
|
|
1143
|
+
this._restoreTabularColumnChooserPopover(pView, pGroup, tmpPopoverElements[0]);
|
|
1102
1144
|
}
|
|
1103
1145
|
}
|
|
1104
1146
|
|
|
1105
1147
|
/**
|
|
1106
|
-
*
|
|
1107
|
-
*
|
|
1108
|
-
*
|
|
1148
|
+
* Anchor the (open) chooser popover to its trigger with the same listener-free strategy as
|
|
1149
|
+
* pict-section-picker: keep it in the DOM and CSS-absolute under the (position:relative) bar --
|
|
1150
|
+
* which rides page scroll for free -- UNLESS a clipping ancestor would cut it, in which case
|
|
1151
|
+
* portal it to <body> and place it in document coords. No scroll/resize handlers: an absolute
|
|
1152
|
+
* (not fixed) panel tracks the document as it scrolls, so one placement holds.
|
|
1109
1153
|
*
|
|
1110
1154
|
* @param {Object} pView
|
|
1111
1155
|
* @param {Object} pGroup
|
|
1112
1156
|
* @param {HTMLElement} pPopover
|
|
1113
1157
|
*/
|
|
1114
|
-
|
|
1158
|
+
_applyTabularColumnChooserAnchor(pView, pGroup, pPopover)
|
|
1159
|
+
{
|
|
1160
|
+
if (!pPopover || (typeof document === 'undefined') || (typeof window === 'undefined'))
|
|
1161
|
+
{
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
let tmpTrigger = document.getElementById(this._getTabularColumnChooserElementId(pView, pGroup, 'TRIGGER'));
|
|
1165
|
+
if (!tmpTrigger)
|
|
1166
|
+
{
|
|
1167
|
+
return;
|
|
1168
|
+
}
|
|
1169
|
+
// Judge from the trigger (it never moves); a portaled panel has no clipping ancestors, so
|
|
1170
|
+
// testing the panel itself would flip-flop.
|
|
1171
|
+
if (this._tabularColumnChooserShouldPortal(tmpTrigger, pPopover))
|
|
1172
|
+
{
|
|
1173
|
+
this._portalTabularColumnChooserPopover(pPopover, tmpTrigger);
|
|
1174
|
+
}
|
|
1175
|
+
else
|
|
1176
|
+
{
|
|
1177
|
+
this._restoreTabularColumnChooserPopover(pView, pGroup, pPopover);
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
/**
|
|
1182
|
+
* Move the popover to <body> and place it against the trigger in document coords (viewport rect +
|
|
1183
|
+
* scroll), flipping above when the room below is genuinely cramped. Carries the resolved
|
|
1184
|
+
* --theme-color-* tokens across so the panel stays themed off its scoped container.
|
|
1185
|
+
*
|
|
1186
|
+
* @param {HTMLElement} pPopover
|
|
1187
|
+
* @param {HTMLElement} pTrigger
|
|
1188
|
+
*/
|
|
1189
|
+
_portalTabularColumnChooserPopover(pPopover, pTrigger)
|
|
1115
1190
|
{
|
|
1116
|
-
|
|
1117
|
-
if (!tmpTriggerElements.length || (typeof window === 'undefined'))
|
|
1191
|
+
if (!pPopover || !pTrigger || (typeof document === 'undefined') || (typeof window === 'undefined'))
|
|
1118
1192
|
{
|
|
1119
1193
|
return;
|
|
1120
1194
|
}
|
|
1195
|
+
// Adopt this popover onto <body>, sweeping any stale same-id copy a prior re-render left behind.
|
|
1196
|
+
this._sweepPortaledColchooserOrphans(pPopover.getAttribute('id'), pPopover);
|
|
1197
|
+
if (pPopover.parentElement !== document.body)
|
|
1198
|
+
{
|
|
1199
|
+
document.body.appendChild(pPopover);
|
|
1200
|
+
}
|
|
1201
|
+
pPopover.classList.add('pict-tabular-colchooser-pop-portal');
|
|
1202
|
+
// Carry the resolved --theme-color-* tokens across: off its scoped container the panel would
|
|
1203
|
+
// otherwise fall back to the stylesheet hex defaults. Skip empty reads so a token the host never
|
|
1204
|
+
// defined keeps its own var(--token, #hex) fallback (matches pict-section-picker's _portalPop).
|
|
1205
|
+
if (typeof window.getComputedStyle === 'function')
|
|
1206
|
+
{
|
|
1207
|
+
let tmpComputed = window.getComputedStyle(pTrigger);
|
|
1208
|
+
_COLCHOOSER_THEME_TOKENS.forEach((pToken) =>
|
|
1209
|
+
{
|
|
1210
|
+
let tmpValue = tmpComputed.getPropertyValue(pToken);
|
|
1211
|
+
if (tmpValue && tmpValue.trim() !== '')
|
|
1212
|
+
{
|
|
1213
|
+
pPopover.style.setProperty(pToken, tmpValue.trim());
|
|
1214
|
+
}
|
|
1215
|
+
});
|
|
1216
|
+
}
|
|
1121
1217
|
let tmpPanel = pPopover.querySelector('.pict-tabular-colchooser-panel');
|
|
1122
|
-
let tmpRect =
|
|
1218
|
+
let tmpRect = pTrigger.getBoundingClientRect();
|
|
1123
1219
|
let tmpGap = 6;
|
|
1124
1220
|
let tmpMargin = 8;
|
|
1221
|
+
let tmpWidth = pPopover.offsetWidth || 240;
|
|
1125
1222
|
let tmpViewportHeight = window.innerHeight;
|
|
1126
1223
|
let tmpViewportWidth = window.innerWidth;
|
|
1127
|
-
let tmpWidth = pPopover.offsetWidth || 240;
|
|
1128
|
-
// Right-align the popover to the (right-aligned) trigger, clamped into the viewport.
|
|
1129
|
-
pPopover.style.left = `${Math.round(Math.max(tmpMargin, Math.min(tmpRect.right - tmpWidth, tmpViewportWidth - tmpWidth - tmpMargin)))}px`;
|
|
1130
|
-
pPopover.style.right = 'auto';
|
|
1131
1224
|
let tmpSpaceBelow = tmpViewportHeight - tmpRect.bottom - tmpGap - tmpMargin;
|
|
1132
1225
|
let tmpSpaceAbove = tmpRect.top - tmpGap - tmpMargin;
|
|
1133
|
-
|
|
1226
|
+
let tmpBelow = (tmpSpaceBelow >= 220) || (tmpSpaceBelow >= tmpSpaceAbove);
|
|
1227
|
+
// Document coords (viewport rect + scroll): absolute against <body>, so the panel rides page
|
|
1228
|
+
// scroll with no listener. Right-aligned to the trigger, clamped into the viewport.
|
|
1229
|
+
pPopover.style.right = 'auto';
|
|
1230
|
+
pPopover.style.bottom = 'auto';
|
|
1231
|
+
pPopover.style.left = `${Math.round(Math.max(tmpMargin, Math.min(tmpRect.right - tmpWidth, tmpViewportWidth - tmpWidth - tmpMargin)) + window.scrollX)}px`;
|
|
1232
|
+
if (tmpBelow)
|
|
1134
1233
|
{
|
|
1135
|
-
pPopover.style.top = `${Math.round(tmpRect.bottom + tmpGap)}px`;
|
|
1136
|
-
pPopover.style.
|
|
1234
|
+
pPopover.style.top = `${Math.round(tmpRect.bottom + tmpGap + window.scrollY)}px`;
|
|
1235
|
+
pPopover.style.transform = '';
|
|
1137
1236
|
if (tmpPanel) { tmpPanel.style.maxHeight = `${Math.max(160, Math.min(tmpSpaceBelow, 420))}px`; }
|
|
1138
1237
|
}
|
|
1139
1238
|
else
|
|
1140
1239
|
{
|
|
1141
|
-
pPopover.style.top =
|
|
1142
|
-
pPopover.style.
|
|
1240
|
+
pPopover.style.top = `${Math.round(tmpRect.top - tmpGap + window.scrollY)}px`;
|
|
1241
|
+
pPopover.style.transform = 'translateY(-100%)';
|
|
1143
1242
|
if (tmpPanel) { tmpPanel.style.maxHeight = `${Math.max(160, Math.min(tmpSpaceAbove, 420))}px`; }
|
|
1144
1243
|
}
|
|
1145
1244
|
}
|
|
1146
1245
|
|
|
1246
|
+
/**
|
|
1247
|
+
* Re-home a portaled popover into its bar and drop everything the portal wrote. Doubles as the
|
|
1248
|
+
* orphan sweeper: if a re-render already baked a fresh in-bar popover, the portaled one is stale
|
|
1249
|
+
* and gets discarded rather than duplicated.
|
|
1250
|
+
*
|
|
1251
|
+
* @param {Object} pView
|
|
1252
|
+
* @param {Object} pGroup
|
|
1253
|
+
* @param {HTMLElement} pPopover
|
|
1254
|
+
*/
|
|
1255
|
+
_restoreTabularColumnChooserPopover(pView, pGroup, pPopover)
|
|
1256
|
+
{
|
|
1257
|
+
if (!pPopover || (typeof document === 'undefined'))
|
|
1258
|
+
{
|
|
1259
|
+
return;
|
|
1260
|
+
}
|
|
1261
|
+
// Discard any OTHER portaled copy of this popover a prior re-render may have left on <body>.
|
|
1262
|
+
this._sweepPortaledColchooserOrphans(pPopover.getAttribute('id'), pPopover);
|
|
1263
|
+
if (pPopover.parentElement === document.body)
|
|
1264
|
+
{
|
|
1265
|
+
let tmpTrigger = document.getElementById(this._getTabularColumnChooserElementId(pView, pGroup, 'TRIGGER'));
|
|
1266
|
+
let tmpBar = tmpTrigger ? tmpTrigger.parentElement : null;
|
|
1267
|
+
let tmpFreshInBar = tmpBar ? tmpBar.querySelector('.pict-tabular-colchooser-pop') : null;
|
|
1268
|
+
if (tmpBar && (!tmpFreshInBar || tmpFreshInBar === pPopover))
|
|
1269
|
+
{
|
|
1270
|
+
// Re-home the popover next to its trigger, inside the bar.
|
|
1271
|
+
tmpBar.appendChild(pPopover);
|
|
1272
|
+
}
|
|
1273
|
+
else
|
|
1274
|
+
{
|
|
1275
|
+
// A re-render already baked a fresh in-bar popover; this portaled one is a leftover.
|
|
1276
|
+
pPopover.remove();
|
|
1277
|
+
return;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
pPopover.classList.remove('pict-tabular-colchooser-pop-portal');
|
|
1281
|
+
// Clear the inline offsets/transform, or they'd override the stylesheet and strand the panel.
|
|
1282
|
+
pPopover.style.top = '';
|
|
1283
|
+
pPopover.style.left = '';
|
|
1284
|
+
pPopover.style.right = '';
|
|
1285
|
+
pPopover.style.bottom = '';
|
|
1286
|
+
pPopover.style.transform = '';
|
|
1287
|
+
// Drop the copied tokens so back in the bar it inherits them live again.
|
|
1288
|
+
_COLCHOOSER_THEME_TOKENS.forEach((pToken) => pPopover.style.removeProperty(pToken));
|
|
1289
|
+
let tmpPanel = pPopover.querySelector('.pict-tabular-colchooser-panel');
|
|
1290
|
+
if (tmpPanel) { tmpPanel.style.maxHeight = ''; }
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
/**
|
|
1294
|
+
* Remove any portaled copies of a chooser popover (matched by element id) that are direct children
|
|
1295
|
+
* of <body>, except the one to keep. Iterates body children so no attribute-selector escaping of
|
|
1296
|
+
* the id is needed, and is scoped by id so it never touches another table's portaled popover.
|
|
1297
|
+
*
|
|
1298
|
+
* @param {string} pElementId
|
|
1299
|
+
* @param {HTMLElement} pKeep
|
|
1300
|
+
*/
|
|
1301
|
+
_sweepPortaledColchooserOrphans(pElementId, pKeep)
|
|
1302
|
+
{
|
|
1303
|
+
if (!pElementId || (typeof document === 'undefined') || !document.body)
|
|
1304
|
+
{
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
Array.prototype.slice.call(document.body.children).forEach((pNode) =>
|
|
1308
|
+
{
|
|
1309
|
+
if (pNode !== pKeep && pNode.id === pElementId
|
|
1310
|
+
&& pNode.classList && pNode.classList.contains('pict-tabular-colchooser-pop'))
|
|
1311
|
+
{
|
|
1312
|
+
pNode.remove();
|
|
1313
|
+
}
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* Portal when ANY clipping ancestor of the trigger would actually cut the popover -- an overflow
|
|
1319
|
+
* ancestor alone isn't enough, but a roomy inner clipper doesn't excuse a tighter one further out.
|
|
1320
|
+
*
|
|
1321
|
+
* @param {HTMLElement} pTrigger
|
|
1322
|
+
* @param {HTMLElement} pPopover
|
|
1323
|
+
* @returns {boolean}
|
|
1324
|
+
*/
|
|
1325
|
+
_tabularColumnChooserShouldPortal(pTrigger, pPopover)
|
|
1326
|
+
{
|
|
1327
|
+
let tmpWidth = (pPopover && pPopover.offsetWidth) ? pPopover.offsetWidth : 240;
|
|
1328
|
+
let tmpClipper = this._tabularColumnChooserClippingAncestor(pTrigger);
|
|
1329
|
+
while (tmpClipper)
|
|
1330
|
+
{
|
|
1331
|
+
if (this._tabularColumnChooserClipBites(pTrigger, tmpClipper, tmpWidth))
|
|
1332
|
+
{
|
|
1333
|
+
return true;
|
|
1334
|
+
}
|
|
1335
|
+
tmpClipper = this._tabularColumnChooserClippingAncestor(tmpClipper);
|
|
1336
|
+
}
|
|
1337
|
+
return false;
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
/**
|
|
1341
|
+
* Nearest ancestor (up to, not including, <body>) with an overflow clip on any axis, or null.
|
|
1342
|
+
* Stops at <body> because the document's own scroll is what the absolute anchoring rides on.
|
|
1343
|
+
*
|
|
1344
|
+
* @param {HTMLElement} pElement
|
|
1345
|
+
* @returns {HTMLElement|null}
|
|
1346
|
+
*/
|
|
1347
|
+
_tabularColumnChooserClippingAncestor(pElement)
|
|
1348
|
+
{
|
|
1349
|
+
if ((typeof window === 'undefined') || (typeof window.getComputedStyle !== 'function'))
|
|
1350
|
+
{
|
|
1351
|
+
return null;
|
|
1352
|
+
}
|
|
1353
|
+
let tmpNode = pElement ? pElement.parentElement : null;
|
|
1354
|
+
while (tmpNode && tmpNode.nodeType === 1 && tmpNode !== document.body)
|
|
1355
|
+
{
|
|
1356
|
+
let tmpStyle = window.getComputedStyle(tmpNode);
|
|
1357
|
+
if (tmpStyle && [ tmpStyle.overflow, tmpStyle.overflowX, tmpStyle.overflowY ].some((pValue) => pValue && pValue !== 'visible'))
|
|
1358
|
+
{
|
|
1359
|
+
return tmpNode;
|
|
1360
|
+
}
|
|
1361
|
+
tmpNode = tmpNode.parentElement;
|
|
1362
|
+
}
|
|
1363
|
+
return null;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
/**
|
|
1367
|
+
* Would the clipper cut the popover if it opened in place? The CSS path opens downward, right-
|
|
1368
|
+
* aligned to the trigger; project that worst-case box (trigger bottom + gap, up to the max height)
|
|
1369
|
+
* and test whether any edge falls outside the clipper. 1px slack avoids a needless portal on a
|
|
1370
|
+
* flush edge.
|
|
1371
|
+
*
|
|
1372
|
+
* @param {HTMLElement} pTrigger
|
|
1373
|
+
* @param {HTMLElement} pClipper
|
|
1374
|
+
* @param {number} pWidth
|
|
1375
|
+
* @returns {boolean}
|
|
1376
|
+
*/
|
|
1377
|
+
_tabularColumnChooserClipBites(pTrigger, pClipper, pWidth)
|
|
1378
|
+
{
|
|
1379
|
+
if (!pTrigger || !pClipper || (typeof pTrigger.getBoundingClientRect !== 'function')
|
|
1380
|
+
|| (typeof pClipper.getBoundingClientRect !== 'function'))
|
|
1381
|
+
{
|
|
1382
|
+
return true;
|
|
1383
|
+
}
|
|
1384
|
+
let tmpTriggerRect = pTrigger.getBoundingClientRect();
|
|
1385
|
+
let tmpClipRect = pClipper.getBoundingClientRect();
|
|
1386
|
+
let tmpGap = 6;
|
|
1387
|
+
let tmpIdeal = 420;
|
|
1388
|
+
let tmpSlack = 1;
|
|
1389
|
+
let tmpWidthResolved = Math.max(220, pWidth || 220);
|
|
1390
|
+
let tmpPanelTop = tmpTriggerRect.bottom + tmpGap;
|
|
1391
|
+
let tmpPanelBottom = tmpPanelTop + tmpIdeal;
|
|
1392
|
+
let tmpPanelRight = tmpTriggerRect.right;
|
|
1393
|
+
let tmpPanelLeft = tmpTriggerRect.right - tmpWidthResolved;
|
|
1394
|
+
return (tmpPanelBottom > tmpClipRect.bottom + tmpSlack)
|
|
1395
|
+
|| (tmpPanelTop < tmpClipRect.top - tmpSlack)
|
|
1396
|
+
|| (tmpPanelLeft < tmpClipRect.left - tmpSlack)
|
|
1397
|
+
|| (tmpPanelRight > tmpClipRect.right + tmpSlack);
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1147
1400
|
/**
|
|
1148
1401
|
* Rebuild + re-render a tabular view and re-marshal the form data into it.
|
|
1149
1402
|
* Same tail as sortTabularColumn: the rebuild re-bakes the table template
|