@wipco/sdui 1.4.2 → 1.6.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/dist/{DatePicker-C_TT_SOw.d.ts → DatePicker-DX9juElE.d.ts} +10 -1
- package/dist/{chunk-GZBY7I4Y.js → chunk-2KQL6DYG.js} +3 -3
- package/dist/{chunk-RYBBPFI7.js → chunk-2QXA52DG.js} +4 -4
- package/dist/{chunk-DMLDKW7K.js → chunk-37BNG4DT.js} +1 -1
- package/dist/{chunk-5WW4MBRO.js → chunk-3JTBOABA.js} +6 -2
- package/dist/{chunk-UV6HHFEW.js → chunk-4OABUPIU.js} +129 -68
- package/dist/{chunk-ZORQPB6B.js → chunk-53KS4E5N.js} +318 -359
- package/dist/{chunk-I5SD7XRA.js → chunk-6TI4WF5Y.js} +3 -3
- package/dist/{chunk-44TDRCKR.js → chunk-6XI2VF2O.js} +5 -5
- package/dist/{chunk-HBIIEYKW.js → chunk-7C54CKFZ.js} +4 -4
- package/dist/{chunk-IZ3JA2BR.js → chunk-7JP52QQO.js} +3 -3
- package/dist/{chunk-I45EUZC6.js → chunk-AY4GM6KQ.js} +4 -2
- package/dist/{chunk-SAPBDJJQ.js → chunk-AZSLSAJB.js} +2 -2
- package/dist/chunk-BITS7UJY.js +333 -0
- package/dist/{chunk-RNOUXUBO.js → chunk-BLFJMMBW.js} +306 -57
- package/dist/{chunk-YOZN35HD.js → chunk-CEVZAFPO.js} +3 -3
- package/dist/chunk-CI5OZ2QT.js +106 -0
- package/dist/{chunk-FNMS7OB7.js → chunk-CSE3PZOZ.js} +5 -5
- package/dist/chunk-CSZCWBOE.js +256 -0
- package/dist/{chunk-JIV4YHCZ.js → chunk-EJIWOD7W.js} +1 -1
- package/dist/{chunk-JZXU22PE.js → chunk-FEKKOBPX.js} +208 -117
- package/dist/chunk-GSM664TX.js +38 -0
- package/dist/{chunk-JYAR7D5U.js → chunk-HRHKQOOF.js} +2 -2
- package/dist/{chunk-CXW6KT6X.js → chunk-HXLQSO66.js} +3 -3
- package/dist/{chunk-O4IISNE7.js → chunk-IB2ZPUTF.js} +51 -12
- package/dist/{chunk-MPT7WJG2.js → chunk-IQXLNICY.js} +5 -5
- package/dist/{chunk-OQ52XMGG.js → chunk-K6RE23XX.js} +4 -4
- package/dist/{chunk-VY7MVBSE.js → chunk-KZ6U6FKB.js} +2 -2
- package/dist/{chunk-WPSK2CB5.js → chunk-LIZTK3HO.js} +16 -5
- package/dist/{chunk-Q4SWUINA.js → chunk-LKQJJSVJ.js} +1 -1
- package/dist/{chunk-E6ISNQK3.js → chunk-M6H3SHIS.js} +31 -8
- package/dist/chunk-MN4RZ2WP.js +380 -0
- package/dist/{chunk-GTGS2QRL.js → chunk-NA232CBX.js} +3 -3
- package/dist/{chunk-ZFNFPXPR.js → chunk-NAIWQQPW.js} +2 -2
- package/dist/{chunk-YVTV4ZV6.js → chunk-NWYYNE3Q.js} +1 -1
- package/dist/{chunk-DKVSM5HX.js → chunk-OUEJWC2Z.js} +6 -6
- package/dist/{chunk-DOL57OOP.js → chunk-OYDJHQNZ.js} +3 -3
- package/dist/{chunk-YWUDBLO6.js → chunk-QVS6K4FP.js} +2 -2
- package/dist/{chunk-N5RKM6IC.js → chunk-RU5U2YMT.js} +4 -4
- package/dist/{chunk-A6LAIGUS.js → chunk-V7BWMOHO.js} +7 -4
- package/dist/{chunk-2HLXCKK7.js → chunk-VPOOIEKT.js} +2 -2
- package/dist/{chunk-2YP5N4VV.js → chunk-VZOQRQAR.js} +1 -1
- package/dist/{chunk-GNA6SX2H.js → chunk-W4VA76QO.js} +2 -2
- package/dist/{chunk-BEM2YS7U.js → chunk-WEG3V7ZB.js} +3 -3
- package/dist/{chunk-XGFDY43I.js → chunk-WTIYILY3.js} +88 -18
- package/dist/{chunk-RWSH2MBU.js → chunk-X2NIRVLN.js} +73 -19
- package/dist/{chunk-AXGF4M57.js → chunk-XAXROQKB.js} +1 -1
- package/dist/{chunk-NIJUVTEW.js → chunk-XG22XKKD.js} +3 -3
- package/dist/{chunk-A5XQOEVH.js → chunk-YN7X7BEO.js} +4 -4
- package/dist/{chunk-KO6OEY3G.js → chunk-YNEEJCSZ.js} +3 -13
- package/dist/{chunk-7P7N43JV.js → chunk-YZTTFEL4.js} +2 -2
- package/dist/index.d.ts +494 -89
- package/dist/index.js +1098 -124
- package/dist/{layout-C3nRXMwb.d.ts → layout-DmRikwZb.d.ts} +5 -4
- package/dist/meta.d.ts +1 -1
- package/dist/meta.js +286 -22
- package/dist/rich/ExcelUploadCard.d.ts +1 -1
- package/dist/rich/ExcelUploadCard.js +5 -4
- package/dist/rich.d.ts +21 -3
- package/dist/rich.js +277 -35
- package/dist/styles.css +102 -4
- package/dist/{types-COjGKgmd.d.ts → types-CYfIthux.d.ts} +57 -1
- package/dist/widgets/ApprovalLineEditor.d.ts +1 -1
- package/dist/widgets/ApprovalLineEditor.js +9 -8
- package/dist/widgets/ApprovalOverridesEditor.d.ts +1 -1
- package/dist/widgets/ApprovalOverridesEditor.js +11 -10
- package/dist/widgets/ApprovalStepper.d.ts +29 -4
- package/dist/widgets/ApprovalStepper.js +3 -3
- package/dist/widgets/AutocompleteField.d.ts +1 -1
- package/dist/widgets/AutocompleteField.js +9 -8
- package/dist/widgets/ColumnBoard.d.ts +1 -1
- package/dist/widgets/ColumnBoard.js +3 -3
- package/dist/widgets/DiffView.d.ts +1 -1
- package/dist/widgets/DiffView.js +3 -3
- package/dist/widgets/Disclosure.d.ts +1 -1
- package/dist/widgets/Disclosure.js +3 -3
- package/dist/widgets/EventCalendar.d.ts +5 -1
- package/dist/widgets/EventCalendar.js +5 -3
- package/dist/widgets/FileDropzone.d.ts +1 -1
- package/dist/widgets/FileDropzone.js +9 -7
- package/dist/widgets/ImageLightbox.d.ts +1 -1
- package/dist/widgets/ImageLightbox.js +7 -5
- package/dist/widgets/InlineEdit.d.ts +1 -1
- package/dist/widgets/InlineEdit.js +3 -3
- package/dist/widgets/JsonField.d.ts +1 -1
- package/dist/widgets/JsonField.js +3 -3
- package/dist/widgets/LiveClock.d.ts +1 -1
- package/dist/widgets/LiveClock.js +2 -2
- package/dist/widgets/OptionSchemaEditor.d.ts +1 -1
- package/dist/widgets/OptionSchemaEditor.js +4 -4
- package/dist/widgets/OptionValueFields.d.ts +1 -1
- package/dist/widgets/OptionValueFields.js +4 -4
- package/dist/widgets/OrgChart.d.ts +1 -1
- package/dist/widgets/OrgChart.js +4 -4
- package/dist/widgets/OrgChartBoard.d.ts +15 -33
- package/dist/widgets/OrgChartBoard.js +10 -8
- package/dist/widgets/PeriodFilter.d.ts +1 -1
- package/dist/widgets/PeriodFilter.js +6 -5
- package/dist/widgets/PermissionMatrixEditor.d.ts +34 -2
- package/dist/widgets/PermissionMatrixEditor.js +6 -4
- package/dist/widgets/PositionSelect.d.ts +1 -1
- package/dist/widgets/PositionSelect.js +5 -4
- package/dist/widgets/PrintSheet.d.ts +15 -2
- package/dist/widgets/PrintSheet.js +3 -3
- package/dist/widgets/ProfileEditDiffCard.d.ts +1 -1
- package/dist/widgets/ProfileEditDiffCard.js +5 -4
- package/dist/widgets/QRDisplay.d.ts +1 -1
- package/dist/widgets/QRDisplay.js +5 -4
- package/dist/widgets/RankBoard.d.ts +1 -1
- package/dist/widgets/RankBoard.js +8 -6
- package/dist/widgets/RecordSheet.d.ts +1 -1
- package/dist/widgets/RecordSheet.js +2 -2
- package/dist/widgets/RoleMemberPicker.d.ts +1 -1
- package/dist/widgets/RoleMemberPicker.js +6 -5
- package/dist/widgets/SearchableMultiPicker.d.ts +1 -1
- package/dist/widgets/SearchableMultiPicker.js +7 -6
- package/dist/widgets/SecureScreen.d.ts +1 -1
- package/dist/widgets/SecureScreen.js +3 -3
- package/dist/widgets/StackedMeter.d.ts +1 -1
- package/dist/widgets/StackedMeter.js +2 -2
- package/dist/widgets/StagePeriodEditor.d.ts +1 -1
- package/dist/widgets/StagePeriodEditor.js +6 -5
- package/dist/widgets/Strip.d.ts +1 -1
- package/dist/widgets/Strip.js +2 -2
- package/dist/widgets/SummaryTable.d.ts +1 -1
- package/dist/widgets/SummaryTable.js +2 -2
- package/dist/widgets/TagInput.d.ts +1 -1
- package/dist/widgets/TagInput.js +3 -3
- package/dist/widgets/TagMultiSelect.d.ts +1 -1
- package/dist/widgets/TagMultiSelect.js +5 -4
- package/dist/widgets/Timeline.d.ts +1 -1
- package/dist/widgets/Timeline.js +4 -4
- package/dist/widgets/TreePicker.d.ts +1 -1
- package/dist/widgets/TreePicker.js +8 -7
- package/dist/widgets/TreeView.d.ts +1 -1
- package/dist/widgets/TreeView.js +7 -6
- package/dist/widgets/index.d.ts +3 -3
- package/dist/widgets/index.js +84 -83
- package/package.json +1 -1
- package/dist/chunk-LFEJLOFN.js +0 -352
- package/dist/chunk-MMIGOPO5.js +0 -111
- package/dist/chunk-TFGNKFL2.js +0 -39
- package/dist/chunk-XQPTSEJC.js +0 -135
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useSduiAdapter, hostFetchOf } from './chunk-
|
|
2
|
-
import { Badge, Tag } from './chunk-
|
|
3
|
-
import { boxed } from './chunk-
|
|
1
|
+
import { useSduiAdapter, hostFetchOf } from './chunk-YNEEJCSZ.js';
|
|
2
|
+
import { Badge, Tag } from './chunk-BLFJMMBW.js';
|
|
3
|
+
import { boxed } from './chunk-3JTBOABA.js';
|
|
4
4
|
import { useRef, useEffect, useMemo, useState } from 'react';
|
|
5
5
|
import { jsx } from 'react/jsx-runtime';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DateRangePicker } from './chunk-
|
|
2
|
-
import { SegmentedControl, Select } from './chunk-
|
|
3
|
-
import { boxed } from './chunk-
|
|
1
|
+
import { DateRangePicker } from './chunk-X2NIRVLN.js';
|
|
2
|
+
import { SegmentedControl, Select } from './chunk-BLFJMMBW.js';
|
|
3
|
+
import { boxed } from './chunk-3JTBOABA.js';
|
|
4
4
|
import { useState, useMemo } from 'react';
|
|
5
5
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
6
|
|
|
@@ -161,14 +161,14 @@ function PeriodFilterImpl({ value, onChange, years, modes }) {
|
|
|
161
161
|
gap: "var(--wp-space-2)"
|
|
162
162
|
},
|
|
163
163
|
children: [
|
|
164
|
-
/* @__PURE__ */ jsx(
|
|
164
|
+
modeItems.length > 1 ? /* @__PURE__ */ jsx(
|
|
165
165
|
SegmentedControl,
|
|
166
166
|
{
|
|
167
167
|
items: [...modeItems],
|
|
168
168
|
value: period.mode,
|
|
169
169
|
onChange: (m) => emit(convertMode(period, m))
|
|
170
170
|
}
|
|
171
|
-
),
|
|
171
|
+
) : null,
|
|
172
172
|
period.mode !== "custom" ? /* @__PURE__ */ jsx("span", { style: { width: 96, flex: "none" }, children: /* @__PURE__ */ jsx(
|
|
173
173
|
Select,
|
|
174
174
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { includesLooseSearch } from './chunk-
|
|
2
|
-
import { OverlayLayer } from './chunk-
|
|
3
|
-
import { Button, Dialog, Input, Tag, Checkbox } from './chunk-
|
|
4
|
-
import { boxed } from './chunk-
|
|
1
|
+
import { includesLooseSearch } from './chunk-4OABUPIU.js';
|
|
2
|
+
import { OverlayLayer } from './chunk-BITS7UJY.js';
|
|
3
|
+
import { Button, Dialog, Input, Tag, Checkbox } from './chunk-BLFJMMBW.js';
|
|
4
|
+
import { boxed } from './chunk-3JTBOABA.js';
|
|
5
5
|
import React, { useMemo, useState } from 'react';
|
|
6
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
7
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useSduiAssetResolver } from './chunk-
|
|
2
|
-
import { Spinner, Icon } from './chunk-
|
|
3
|
-
import { boxed } from './chunk-
|
|
1
|
+
import { useSduiAssetResolver } from './chunk-YNEEJCSZ.js';
|
|
2
|
+
import { Spinner, Icon } from './chunk-BLFJMMBW.js';
|
|
3
|
+
import { boxed } from './chunk-3JTBOABA.js';
|
|
4
4
|
import { useState, useEffect } from 'react';
|
|
5
5
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Icon } from './chunk-
|
|
2
|
-
import { boxed } from './chunk-
|
|
1
|
+
import { Icon } from './chunk-BLFJMMBW.js';
|
|
2
|
+
import { boxed } from './chunk-3JTBOABA.js';
|
|
3
3
|
import { useRef, useState, useEffect } from 'react';
|
|
4
4
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
5
|
|
|
@@ -17,6 +17,8 @@ var SECURE_CSS = `
|
|
|
17
17
|
@media print{
|
|
18
18
|
.erp-secure--enabled .erp-secure__content{display:none !important}
|
|
19
19
|
.erp-secure--enabled .erp-secure__print-warning{display:flex !important;position:static;background:none;backdrop-filter:none;-webkit-backdrop-filter:none;color:inherit;cursor:default}
|
|
20
|
+
/* \uBB38\uAD6C\uB294 \uD654\uBA74\uC6A9 \uBC18\uC804\uC0C9(\uD770 \uAE00\uC790)\uC744 \uB530\uB85C \uB4E4\uACE0 \uC788\uB2E4 \u2014 \uC885\uC774\uC5D0\uC11C\uB294 \uCEE8\uD14C\uC774\uB108 \uAE00\uC790\uC0C9\uC744 \uB530\uB77C\uC57C \uC77D\uD78C\uB2E4 */
|
|
21
|
+
.erp-secure--enabled .erp-secure__print-warning .erp-secure__cover-notice{color:inherit}
|
|
20
22
|
}
|
|
21
23
|
`;
|
|
22
24
|
function SecureStyles() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useOverlayLayer, OverlayContainerContext, getOverlayRoot } from './chunk-
|
|
2
|
-
import { IconButton } from './chunk-
|
|
1
|
+
import { useOverlayLayer, OverlayContainerContext, getOverlayRoot } from './chunk-BITS7UJY.js';
|
|
2
|
+
import { IconButton } from './chunk-BLFJMMBW.js';
|
|
3
3
|
import { useState, useRef, useCallback, useEffect, useContext } from 'react';
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
5
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { HoistedStyle } from './chunk-RIZRM7OO.js';
|
|
2
|
+
import { MOBILE_MEDIA_QUERY } from './chunk-GSM664TX.js';
|
|
3
|
+
import React, { useSyncExternalStore, useRef, useEffect } from 'react';
|
|
4
|
+
import { createPortal } from 'react-dom';
|
|
5
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var OVERLAY_ROOT_ID = "wp-overlay-root";
|
|
8
|
+
function isMobileViewport() {
|
|
9
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia(MOBILE_MEDIA_QUERY).matches : false;
|
|
10
|
+
}
|
|
11
|
+
var DOCUMENT_POSITION_FOLLOWING = 4;
|
|
12
|
+
function getOverlayRoot() {
|
|
13
|
+
if (typeof document === "undefined") return null;
|
|
14
|
+
const existing = document.getElementById(OVERLAY_ROOT_ID);
|
|
15
|
+
if (existing) return existing;
|
|
16
|
+
const created = document.createElement("div");
|
|
17
|
+
created.id = OVERLAY_ROOT_ID;
|
|
18
|
+
document.body.appendChild(created);
|
|
19
|
+
return created;
|
|
20
|
+
}
|
|
21
|
+
var layers = [];
|
|
22
|
+
var nextId = 0;
|
|
23
|
+
var subscribers = /* @__PURE__ */ new Set();
|
|
24
|
+
var keyListenerBound = false;
|
|
25
|
+
function emit() {
|
|
26
|
+
layers = layers.slice();
|
|
27
|
+
subscribers.forEach((fn) => fn());
|
|
28
|
+
}
|
|
29
|
+
function topLayer(list) {
|
|
30
|
+
let best;
|
|
31
|
+
let bestNode = null;
|
|
32
|
+
for (const layer of list) {
|
|
33
|
+
const node = layer.node();
|
|
34
|
+
if (!best) {
|
|
35
|
+
best = layer;
|
|
36
|
+
bestNode = node;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (!node) continue;
|
|
40
|
+
if (!bestNode) {
|
|
41
|
+
best = layer;
|
|
42
|
+
bestNode = node;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (bestNode.compareDocumentPosition(node) & DOCUMENT_POSITION_FOLLOWING) {
|
|
46
|
+
best = layer;
|
|
47
|
+
bestNode = node;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return best;
|
|
51
|
+
}
|
|
52
|
+
function layerHoldsTop(list, id) {
|
|
53
|
+
const top = topLayer(list);
|
|
54
|
+
if (!top) return false;
|
|
55
|
+
if (top.id === id) return true;
|
|
56
|
+
const mine = list.find((l) => l.id === id)?.node();
|
|
57
|
+
const topNode = top.node();
|
|
58
|
+
return !!mine && !!topNode && mine.contains(topNode);
|
|
59
|
+
}
|
|
60
|
+
function escapeTopmost() {
|
|
61
|
+
topLayer(layers)?.onEscape();
|
|
62
|
+
}
|
|
63
|
+
function handleKeyDown(event) {
|
|
64
|
+
if (event.key === "Tab") {
|
|
65
|
+
trapTab(event);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (event.key !== "Escape") return;
|
|
69
|
+
escapeTopmost();
|
|
70
|
+
}
|
|
71
|
+
var TABBABLE = 'a[href], area[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), iframe, [contenteditable="true"], [tabindex]:not([tabindex="-1"])';
|
|
72
|
+
function tabbablesIn(root) {
|
|
73
|
+
return Array.from(root.querySelectorAll(TABBABLE)).filter((el) => {
|
|
74
|
+
if (el.tabIndex < 0) return false;
|
|
75
|
+
if (el.closest("[inert]")) return false;
|
|
76
|
+
return typeof el.getClientRects !== "function" || el.getClientRects().length > 0 || !hasLayout();
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function hasLayout() {
|
|
80
|
+
return typeof document !== "undefined" && document.documentElement.getClientRects().length > 0;
|
|
81
|
+
}
|
|
82
|
+
function topModal() {
|
|
83
|
+
return topLayer(layers.filter((layer) => layer.modal));
|
|
84
|
+
}
|
|
85
|
+
function trapTab(event) {
|
|
86
|
+
const modal = topModal();
|
|
87
|
+
const root = modal?.node();
|
|
88
|
+
if (!modal || !root) return;
|
|
89
|
+
const active = typeof document !== "undefined" ? document.activeElement : null;
|
|
90
|
+
if (active instanceof HTMLElement && !root.contains(active) && active.closest(".wp-anchored-pop")) return;
|
|
91
|
+
const stops = tabbablesIn(root);
|
|
92
|
+
const container = root.querySelector('[role="dialog"]');
|
|
93
|
+
if (stops.length === 0) {
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
(container ?? root).focus?.();
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const first = stops[0];
|
|
99
|
+
const last = stops[stops.length - 1];
|
|
100
|
+
const inside = active instanceof HTMLElement && root.contains(active);
|
|
101
|
+
if (!inside) {
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
(event.shiftKey ? last : first).focus();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (event.shiftKey && (active === first || active === container)) {
|
|
107
|
+
event.preventDefault();
|
|
108
|
+
last.focus();
|
|
109
|
+
} else if (!event.shiftKey && active === last) {
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
first.focus();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
var FIELD = "input, select, textarea";
|
|
115
|
+
var TEXT_INPUT_TYPES = /* @__PURE__ */ new Set(["", "text", "search", "email", "tel", "url", "number", "password"]);
|
|
116
|
+
function isPlainTextField(el) {
|
|
117
|
+
if (el.matches(":disabled") || el.hasAttribute("readonly")) return false;
|
|
118
|
+
if (el.getAttribute("aria-haspopup") || el.getAttribute("role") === "combobox") return false;
|
|
119
|
+
if (el.tagName === "INPUT") return TEXT_INPUT_TYPES.has((el.getAttribute("type") ?? "").toLowerCase());
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
function initialFocusTarget(root, preferField) {
|
|
123
|
+
const explicit = root.querySelector("[autofocus], [data-autofocus]");
|
|
124
|
+
if (explicit) return explicit;
|
|
125
|
+
const container = root.querySelector('[role="dialog"]');
|
|
126
|
+
if (preferField) {
|
|
127
|
+
const body = root.querySelector(".wp-dialog__body") ?? container ?? root;
|
|
128
|
+
const firstField = Array.from(body.querySelectorAll(FIELD)).find(
|
|
129
|
+
(el) => !(el.tagName === "INPUT" && el.getAttribute("type") === "hidden") && !el.closest("[inert]")
|
|
130
|
+
);
|
|
131
|
+
if (firstField && isPlainTextField(firstField)) return firstField;
|
|
132
|
+
}
|
|
133
|
+
if (container) {
|
|
134
|
+
if (!container.hasAttribute("tabindex")) container.setAttribute("tabindex", "-1");
|
|
135
|
+
return container;
|
|
136
|
+
}
|
|
137
|
+
return tabbablesIn(root)[0] ?? null;
|
|
138
|
+
}
|
|
139
|
+
var pendingRestores = [];
|
|
140
|
+
var restoreTimer = null;
|
|
141
|
+
function scheduleRestore(target) {
|
|
142
|
+
if (target) pendingRestores.push(target);
|
|
143
|
+
if (restoreTimer) return;
|
|
144
|
+
restoreTimer = setTimeout(() => {
|
|
145
|
+
restoreTimer = null;
|
|
146
|
+
const candidates = pendingRestores;
|
|
147
|
+
pendingRestores = [];
|
|
148
|
+
const active = document.activeElement;
|
|
149
|
+
if (active && active !== document.body && active.isConnected) return;
|
|
150
|
+
const target2 = [...candidates].reverse().find((el) => el.isConnected);
|
|
151
|
+
if (target2) {
|
|
152
|
+
target2.focus({ preventScroll: true });
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const root = topModal()?.node();
|
|
156
|
+
if (root) initialFocusTarget(root, !isMobileViewport())?.focus({ preventScroll: true });
|
|
157
|
+
}, 0);
|
|
158
|
+
}
|
|
159
|
+
function takeRestoreTarget() {
|
|
160
|
+
const inherited = [...pendingRestores].reverse().find((el) => el.isConnected);
|
|
161
|
+
if (inherited) {
|
|
162
|
+
pendingRestores = pendingRestores.filter((el) => el !== inherited);
|
|
163
|
+
return inherited;
|
|
164
|
+
}
|
|
165
|
+
if (typeof document === "undefined") return null;
|
|
166
|
+
const active = document.activeElement;
|
|
167
|
+
return active instanceof HTMLElement && active !== document.body ? active : null;
|
|
168
|
+
}
|
|
169
|
+
var HISTORY_MARK = "__wpModal";
|
|
170
|
+
var TOKEN_PREFIX = Date.now().toString(36);
|
|
171
|
+
var tokenSeq = 0;
|
|
172
|
+
var pushedToken = "";
|
|
173
|
+
var historyPushed = false;
|
|
174
|
+
var pushedPath = "";
|
|
175
|
+
var pushedLength = 0;
|
|
176
|
+
var ignorePops = 0;
|
|
177
|
+
var popBound = false;
|
|
178
|
+
var reconcileTimer = null;
|
|
179
|
+
function historyModals() {
|
|
180
|
+
return layers.filter((layer) => layer.modal && layer.history);
|
|
181
|
+
}
|
|
182
|
+
function canUseHistory() {
|
|
183
|
+
return typeof window !== "undefined" && typeof window.history?.pushState === "function";
|
|
184
|
+
}
|
|
185
|
+
function pushHistoryEntry() {
|
|
186
|
+
if (historyPushed || !canUseHistory() || !isMobileViewport()) return;
|
|
187
|
+
const current = window.history.state;
|
|
188
|
+
tokenSeq += 1;
|
|
189
|
+
pushedToken = `${TOKEN_PREFIX}-${tokenSeq}`;
|
|
190
|
+
window.history.pushState({ ...current ?? {}, [HISTORY_MARK]: pushedToken }, "", window.location.href);
|
|
191
|
+
historyPushed = true;
|
|
192
|
+
pushedPath = window.location.pathname;
|
|
193
|
+
pushedLength = window.history.length;
|
|
194
|
+
if (!popBound) {
|
|
195
|
+
window.addEventListener("popstate", handlePopState);
|
|
196
|
+
popBound = true;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function reconcileHistory() {
|
|
200
|
+
reconcileTimer = null;
|
|
201
|
+
if (!canUseHistory()) return;
|
|
202
|
+
const open = historyModals().length > 0;
|
|
203
|
+
if (open && !historyPushed) {
|
|
204
|
+
pushHistoryEntry();
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (!open && historyPushed) {
|
|
208
|
+
historyPushed = false;
|
|
209
|
+
if (window.location.pathname === pushedPath && window.history.length === pushedLength) {
|
|
210
|
+
ignorePops += 1;
|
|
211
|
+
window.history.back();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function scheduleReconcile(delay = 0) {
|
|
216
|
+
if (!canUseHistory()) return;
|
|
217
|
+
if (reconcileTimer) clearTimeout(reconcileTimer);
|
|
218
|
+
reconcileTimer = setTimeout(reconcileHistory, delay);
|
|
219
|
+
}
|
|
220
|
+
function handlePopState() {
|
|
221
|
+
if (ignorePops > 0) {
|
|
222
|
+
ignorePops -= 1;
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (!historyPushed) return;
|
|
226
|
+
const landed = window.history.state;
|
|
227
|
+
if (landed?.[HISTORY_MARK] === pushedToken) return;
|
|
228
|
+
historyPushed = false;
|
|
229
|
+
if (historyModals().length === 0) return;
|
|
230
|
+
escapeTopmost();
|
|
231
|
+
scheduleReconcile(300);
|
|
232
|
+
}
|
|
233
|
+
function push(layer) {
|
|
234
|
+
layers.push(layer);
|
|
235
|
+
if (!keyListenerBound && typeof document !== "undefined") {
|
|
236
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
237
|
+
keyListenerBound = true;
|
|
238
|
+
}
|
|
239
|
+
if (layer.modal && layer.history) pushHistoryEntry();
|
|
240
|
+
emit();
|
|
241
|
+
}
|
|
242
|
+
function remove(id) {
|
|
243
|
+
const removed = layers.find((l) => l.id === id);
|
|
244
|
+
layers = layers.filter((l) => l.id !== id);
|
|
245
|
+
if (removed?.modal && removed.history) scheduleReconcile();
|
|
246
|
+
emit();
|
|
247
|
+
}
|
|
248
|
+
function subscribe(fn) {
|
|
249
|
+
subscribers.add(fn);
|
|
250
|
+
return () => {
|
|
251
|
+
subscribers.delete(fn);
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
var snapshot = () => layers;
|
|
255
|
+
var serverSnapshot = () => [];
|
|
256
|
+
function useOverlayLayer(active, onEscape, nodeRef) {
|
|
257
|
+
return useLayer(active, onEscape, nodeRef, false, false);
|
|
258
|
+
}
|
|
259
|
+
var anyModalSnapshot = () => layers.some((layer) => layer.modal === true);
|
|
260
|
+
var anyModalServerSnapshot = () => false;
|
|
261
|
+
function useAnyModalOpen() {
|
|
262
|
+
return useSyncExternalStore(subscribe, anyModalSnapshot, anyModalServerSnapshot);
|
|
263
|
+
}
|
|
264
|
+
function useLayer(active, onEscape, nodeRef, modal, history) {
|
|
265
|
+
const idRef = useRef(0);
|
|
266
|
+
if (idRef.current === 0) idRef.current = ++nextId;
|
|
267
|
+
const escapeRef = useRef(onEscape);
|
|
268
|
+
escapeRef.current = onEscape;
|
|
269
|
+
const nodeRefRef = useRef(nodeRef);
|
|
270
|
+
nodeRefRef.current = nodeRef;
|
|
271
|
+
useEffect(() => {
|
|
272
|
+
if (!active) return;
|
|
273
|
+
const id2 = idRef.current;
|
|
274
|
+
push({
|
|
275
|
+
id: id2,
|
|
276
|
+
onEscape: () => escapeRef.current?.(),
|
|
277
|
+
node: () => nodeRefRef.current?.current ?? null,
|
|
278
|
+
modal,
|
|
279
|
+
history
|
|
280
|
+
});
|
|
281
|
+
return () => remove(id2);
|
|
282
|
+
}, [active, modal, history]);
|
|
283
|
+
const current = useSyncExternalStore(subscribe, snapshot, serverSnapshot);
|
|
284
|
+
const id = idRef.current;
|
|
285
|
+
return {
|
|
286
|
+
isTop: active && topLayer(current)?.id === id,
|
|
287
|
+
holdsTop: active && layerHoldsTop(current, id)
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
var OverlayContainerContext = React.createContext(null);
|
|
291
|
+
function OverlayLayer({
|
|
292
|
+
onClose,
|
|
293
|
+
children
|
|
294
|
+
}) {
|
|
295
|
+
const ref = useRef(null);
|
|
296
|
+
const container = React.useContext(OverlayContainerContext);
|
|
297
|
+
const { holdsTop } = useLayer(true, onClose, ref, true, container === null);
|
|
298
|
+
const restoreRef = useRef(null);
|
|
299
|
+
useEffect(() => {
|
|
300
|
+
restoreRef.current = takeRestoreTarget();
|
|
301
|
+
return () => scheduleRestore(restoreRef.current);
|
|
302
|
+
}, []);
|
|
303
|
+
const focusedRef = useRef(false);
|
|
304
|
+
useEffect(() => {
|
|
305
|
+
const root2 = ref.current;
|
|
306
|
+
root2?.toggleAttribute("inert", !holdsTop);
|
|
307
|
+
if (!root2 || !holdsTop || focusedRef.current) return;
|
|
308
|
+
focusedRef.current = true;
|
|
309
|
+
if (document.activeElement && root2.contains(document.activeElement)) return;
|
|
310
|
+
initialFocusTarget(root2, !isMobileViewport())?.focus({ preventScroll: true });
|
|
311
|
+
}, [holdsTop]);
|
|
312
|
+
const layer = /* @__PURE__ */ jsxs(
|
|
313
|
+
"div",
|
|
314
|
+
{
|
|
315
|
+
ref,
|
|
316
|
+
className: "wp-overlay-layer",
|
|
317
|
+
onClick: (event) => {
|
|
318
|
+
if (onClose && event.target instanceof HTMLElement && event.target.classList.contains("wp-overlay")) {
|
|
319
|
+
onClose();
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
children: [
|
|
323
|
+
/* @__PURE__ */ jsx(HoistedStyle, { id: "wp-overlay-focus", css: OVERLAY_FOCUS_CSS }),
|
|
324
|
+
children
|
|
325
|
+
]
|
|
326
|
+
}
|
|
327
|
+
);
|
|
328
|
+
const root = container ?? getOverlayRoot();
|
|
329
|
+
return root ? createPortal(layer, root) : layer;
|
|
330
|
+
}
|
|
331
|
+
var OVERLAY_FOCUS_CSS = `.wp-overlay-layer [role="dialog"][tabindex="-1"]:focus{outline:none}`;
|
|
332
|
+
|
|
333
|
+
export { OverlayContainerContext, OverlayLayer, getOverlayRoot, useAnyModalOpen, useOverlayLayer };
|