actual-css 0.20.2 → 0.21.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/CHANGELOG.md +74 -0
- package/README.md +6 -6
- package/components.json +19 -4
- package/dist/actual.full.css +451 -118
- package/dist/actual.full.js +2 -2
- package/dist/actual.full.min.css +1 -1
- package/dist/types/data-flag.d.ts +1 -0
- package/dist/types/enhancement-loader-state.d.ts +6 -0
- package/dist/types/enhancement-loader.d.ts +0 -2
- package/dist/types/parse-config.d.ts +0 -1
- package/dist/types/popover-transport.d.ts +2 -0
- package/dist/types/status.d.ts +0 -1
- package/dist/types/validation.d.ts +6 -2
- package/docs/pages/components/app-navigation.md +67 -0
- package/docs/pages/components/button.md +3 -0
- package/docs/pages/components/dialog.md +3 -0
- package/docs/pages/components/list.md +13 -0
- package/docs/pages/components/segmented.md +7 -4
- package/docs/pages/components/table.md +4 -1
- package/docs/pages/enhancements/flyout.md +12 -3
- package/docs/pages/enhancements/tooltip.md +1 -0
- package/docs/pages/examples/overview.md +29 -1
- package/docs/pages/forms/combobox.md +10 -8
- package/docs/pages/forms/labels.md +7 -0
- package/docs/pages/forms/overview.md +13 -10
- package/docs/pages/forms/validation.md +3 -3
- package/docs/pages/foundations/philosophy.md +26 -0
- package/docs/pages/foundations/theming.md +80 -7
- package/docs/pages/foundations/tokens.md +39 -2
- package/docs/pages/guides/coding-agents.md +11 -0
- package/docs/pages/guides/introduction.md +1 -1
- package/docs/pages/guides/progressive-enhancement.md +88 -20
- package/docs/pages/guides/tailwind.md +12 -6
- package/docs/pages/guides/upgrading.md +52 -0
- package/docs/pages/layout/app-layout.md +50 -1
- package/docs/pages/patterns/empty-state.md +48 -10
- package/forms.json +325 -0
- package/llms.txt +2 -1
- package/package.json +3 -1
- package/reserved-classes.json +1 -0
- package/skills/actual-css/SKILL.md +1 -1
- package/skills/actual-css/references/api-and-vocabulary.md +2 -1
- package/src/cli/actual-css.js +8 -2
- package/src/css/components/app-nav.css +75 -18
- package/src/css/components/badge.css +7 -1
- package/src/css/components/button.css +20 -3
- package/src/css/components/flyout.css +5 -2
- package/src/css/components/list.css +28 -13
- package/src/css/components/menu.css +18 -0
- package/src/css/components/meter.css +4 -0
- package/src/css/components/progress.css +9 -2
- package/src/css/components/segmented.css +22 -12
- package/src/css/components/table.css +21 -2
- package/src/css/core/theme.css +11 -1
- package/src/css/core/tokens.css +16 -2
- package/src/css/forms/choice-card.css +4 -3
- package/src/css/forms/choice.css +28 -16
- package/src/css/forms/control.css +23 -16
- package/src/css/forms/custom-select.css +3 -1
- package/src/css/forms/form.css +8 -5
- package/src/css/forms/otp.css +2 -1
- package/src/css/forms/range.css +20 -6
- package/src/css/forms/select.css +12 -4
- package/src/css/forms/switch.css +11 -5
- package/src/css/layout/app-layout.css +104 -5
- package/src/js/data-flag.js +4 -0
- package/src/js/dialog.js +5 -8
- package/src/js/enhancement-loader-state.js +7 -0
- package/src/js/enhancement-loader.js +4 -21
- package/src/js/keys.js +5 -7
- package/src/js/parse-config.js +0 -2
- package/src/js/popover-transport.js +18 -0
- package/src/js/status.js +0 -2
- package/src/js/surface.js +35 -41
- package/src/js/tooltip.js +8 -36
- package/src/js/validation.js +24 -10
- package/src/tooling/css-bundle.js +5 -0
- package/src/tooling/design-tokens.js +8 -1
- package/src/tooling/theme-contrast.js +45 -17
- package/tokens.json +4 -0
package/src/css/forms/range.css
CHANGED
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
--range-fill-from: to left;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
/* A rail, recessed with the fields when a theme sets --shadow-inset. */
|
|
70
71
|
.range::-webkit-slider-runnable-track {
|
|
71
72
|
block-size: var(--range-track-height);
|
|
72
73
|
border-radius: var(--radius-full);
|
|
@@ -75,6 +76,7 @@
|
|
|
75
76
|
var(--range-fill-bg) var(--range-progress),
|
|
76
77
|
var(--range-track-bg) var(--range-progress)
|
|
77
78
|
);
|
|
79
|
+
box-shadow: var(--shadow-inset, none);
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
.range::-moz-range-track {
|
|
@@ -85,6 +87,7 @@
|
|
|
85
87
|
var(--range-fill-bg) var(--range-progress),
|
|
86
88
|
var(--range-track-bg) var(--range-progress)
|
|
87
89
|
);
|
|
90
|
+
box-shadow: var(--shadow-inset, none);
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
.range::-webkit-slider-thumb {
|
|
@@ -99,8 +102,11 @@
|
|
|
99
102
|
cursor: inherit;
|
|
100
103
|
/* Permanent surface separator: the fill defaults to the thumb color, so
|
|
101
104
|
without this the thumb would melt into the filled part of the track.
|
|
102
|
-
Focus-visible keeps this ring and adds the --focus ring outside it.
|
|
103
|
-
|
|
105
|
+
Focus-visible keeps this ring and adds the --focus ring outside it. A
|
|
106
|
+
theme's --shadow-control comes last, under both rings. */
|
|
107
|
+
box-shadow:
|
|
108
|
+
0 0 0 2px var(--surface-opaque),
|
|
109
|
+
var(--shadow-control, 0 0 #0000);
|
|
104
110
|
transition: box-shadow var(--duration);
|
|
105
111
|
}
|
|
106
112
|
|
|
@@ -111,7 +117,9 @@
|
|
|
111
117
|
border: 0;
|
|
112
118
|
background: var(--range-thumb-bg);
|
|
113
119
|
cursor: inherit;
|
|
114
|
-
box-shadow:
|
|
120
|
+
box-shadow:
|
|
121
|
+
0 0 0 2px var(--surface-opaque),
|
|
122
|
+
var(--shadow-control, 0 0 #0000);
|
|
115
123
|
transition: box-shadow var(--duration);
|
|
116
124
|
}
|
|
117
125
|
|
|
@@ -130,13 +138,15 @@
|
|
|
130
138
|
.range:focus-visible::-webkit-slider-thumb {
|
|
131
139
|
box-shadow:
|
|
132
140
|
0 0 0 2px var(--surface-opaque),
|
|
133
|
-
0 0 0 calc(2px + var(--focus-ring-width)) var(--focus)
|
|
141
|
+
0 0 0 calc(2px + var(--focus-ring-width)) var(--focus),
|
|
142
|
+
var(--shadow-control, 0 0 #0000);
|
|
134
143
|
}
|
|
135
144
|
|
|
136
145
|
.range:focus-visible::-moz-range-thumb {
|
|
137
146
|
box-shadow:
|
|
138
147
|
0 0 0 2px var(--surface-opaque),
|
|
139
|
-
0 0 0 calc(2px + var(--focus-ring-width)) var(--focus)
|
|
148
|
+
0 0 0 calc(2px + var(--focus-ring-width)) var(--focus),
|
|
149
|
+
var(--shadow-control, 0 0 #0000);
|
|
140
150
|
}
|
|
141
151
|
|
|
142
152
|
.range:disabled {
|
|
@@ -154,7 +164,9 @@
|
|
|
154
164
|
and would win the variable, leaving a Canvas-remapped fill.
|
|
155
165
|
The split lives in a background-image, which forced-color-adjust: auto
|
|
156
166
|
drops — so the tracks opt out locally. The colors stay system keywords,
|
|
157
|
-
keeping native contrast adaptation; only the host keeps adjusting.
|
|
167
|
+
keeping native contrast adaptation; only the host keeps adjusting. Opting
|
|
168
|
+
out also keeps a theme's --shadow-inset, which the forced palette would
|
|
169
|
+
drop everywhere else, hence the reset. */
|
|
158
170
|
@media (forced-colors: active) {
|
|
159
171
|
.range {
|
|
160
172
|
--range-track-bg: CanvasText;
|
|
@@ -169,6 +181,7 @@
|
|
|
169
181
|
Highlight var(--range-progress),
|
|
170
182
|
CanvasText var(--range-progress)
|
|
171
183
|
);
|
|
184
|
+
box-shadow: none;
|
|
172
185
|
}
|
|
173
186
|
|
|
174
187
|
.range::-moz-range-track {
|
|
@@ -178,6 +191,7 @@
|
|
|
178
191
|
Highlight var(--range-progress),
|
|
179
192
|
CanvasText var(--range-progress)
|
|
180
193
|
);
|
|
194
|
+
box-shadow: none;
|
|
181
195
|
}
|
|
182
196
|
.range::-webkit-slider-thumb {
|
|
183
197
|
background: ButtonFace;
|
package/src/css/forms/select.css
CHANGED
|
@@ -12,17 +12,25 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Public hooks:
|
|
14
14
|
* --select-icon-size
|
|
15
|
+
* --select-icon-inset
|
|
15
16
|
*/
|
|
16
17
|
/* --select-icon-size is typographic (em), so the reserved slot and the
|
|
17
18
|
pictogram scale with the control's font size, not a fixed rem sliver. */
|
|
18
19
|
.select:not(:is([multiple], [size]:not([size="1"]))) {
|
|
19
20
|
--select-icon-size: 1em;
|
|
21
|
+
/* why: optical, not geometric. The chevron is drawn on the middle half of
|
|
22
|
+
its box (6..18 of 24), so a box at the pad left its ink a quarter icon
|
|
23
|
+
further in than the text on the other side and than the native date,
|
|
24
|
+
time and search icons, which fill their box. Shifting the box by that
|
|
25
|
+
margin puts the ink at the pad. A replacement --icon-chevron that fills
|
|
26
|
+
its box sets this to the pad. */
|
|
27
|
+
--select-icon-inset: calc(var(--control-pad-x) - var(--select-icon-size) * 0.25);
|
|
20
28
|
|
|
21
29
|
appearance: none;
|
|
22
30
|
-webkit-appearance: none;
|
|
23
31
|
padding-inline-end: calc(var(--control-pad-x) * 2 + var(--select-icon-size));
|
|
24
32
|
background-image: var(--icon-chevron);
|
|
25
|
-
background-position: center right var(--
|
|
33
|
+
background-position: center right var(--select-icon-inset);
|
|
26
34
|
background-size: var(--select-icon-size) auto;
|
|
27
35
|
background-repeat: no-repeat;
|
|
28
36
|
}
|
|
@@ -34,15 +42,15 @@
|
|
|
34
42
|
directionality, so the explicit ltr rule neutralizes an outer RTL fallback
|
|
35
43
|
for a nested direction change. */
|
|
36
44
|
[dir="rtl"] .select:not(:is([multiple], [size]:not([size="1"]))) {
|
|
37
|
-
background-position: center left var(--
|
|
45
|
+
background-position: center left var(--select-icon-inset);
|
|
38
46
|
}
|
|
39
47
|
|
|
40
48
|
.select:not(:is([multiple], [size]:not([size="1"]))):dir(ltr) {
|
|
41
|
-
background-position: center right var(--
|
|
49
|
+
background-position: center right var(--select-icon-inset);
|
|
42
50
|
}
|
|
43
51
|
|
|
44
52
|
.select:not(:is([multiple], [size]:not([size="1"]))):dir(rtl) {
|
|
45
|
-
background-position: center left var(--
|
|
53
|
+
background-position: center left var(--select-icon-inset);
|
|
46
54
|
}
|
|
47
55
|
|
|
48
56
|
/* Both forced-colors and prefers-contrast hand the arrow back to the
|
package/src/css/forms/switch.css
CHANGED
|
@@ -76,6 +76,8 @@
|
|
|
76
76
|
border: var(--border-width) solid var(--form-invalid-border, var(--switch-border));
|
|
77
77
|
border-radius: var(--radius-full);
|
|
78
78
|
background: var(--switch-bg);
|
|
79
|
+
/* A rail, recessed with the fields when a theme sets --shadow-inset. */
|
|
80
|
+
box-shadow: var(--shadow-inset, none);
|
|
79
81
|
appearance: none;
|
|
80
82
|
-webkit-appearance: none;
|
|
81
83
|
cursor: pointer;
|
|
@@ -96,11 +98,11 @@
|
|
|
96
98
|
}
|
|
97
99
|
}
|
|
98
100
|
|
|
99
|
-
/*
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
against the track is what makes
|
|
101
|
+
/* Never --shadow on the knob: it is a surface elevation (card, modal, drawer,
|
|
102
|
+
fab), and at this size its 12px blur reads as a smudge that spills past the
|
|
103
|
+
rail while carrying no state. A theme lifts it with the control-scale
|
|
104
|
+
--shadow-control; unset, the knob stays flat and the concentric inset
|
|
105
|
+
against the track is what makes it legible. */
|
|
104
106
|
.switch::before {
|
|
105
107
|
content: "";
|
|
106
108
|
/* Out of flow like the checkbox mark, so the track carries no in-flow item
|
|
@@ -116,6 +118,7 @@
|
|
|
116
118
|
block-size: var(--switch-knob-size);
|
|
117
119
|
border-radius: var(--radius-full);
|
|
118
120
|
background: var(--switch-knob);
|
|
121
|
+
box-shadow: var(--shadow-control, none);
|
|
119
122
|
transition:
|
|
120
123
|
transform var(--duration),
|
|
121
124
|
background-color var(--duration);
|
|
@@ -129,10 +132,13 @@
|
|
|
129
132
|
}
|
|
130
133
|
}
|
|
131
134
|
|
|
135
|
+
/* The checked track is a solid fill: it takes the theme finish. */
|
|
132
136
|
.switch:checked {
|
|
133
137
|
--switch-bg: var(--intent, var(--state-selected));
|
|
134
138
|
--switch-border: var(--switch-bg);
|
|
135
139
|
--switch-knob: var(--intent-fg, var(--state-selected-fg));
|
|
140
|
+
|
|
141
|
+
background-image: var(--finish, none);
|
|
136
142
|
}
|
|
137
143
|
|
|
138
144
|
.switch:checked::before {
|
|
@@ -7,11 +7,19 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Docs: docs/pages/layout/app-layout.md
|
|
9
9
|
*
|
|
10
|
+
* data-nav="rail" is the application's desktop preference for a captioned rail.
|
|
11
|
+
* It only changes the side presentation; the bottom bar ignores it. Setting,
|
|
12
|
+
* toggling and persisting it belong to the application.
|
|
13
|
+
*
|
|
10
14
|
* Public hooks:
|
|
11
15
|
* --app-nav-side-size
|
|
16
|
+
* --app-nav-rail-size
|
|
17
|
+
* --app-layout-bar-size
|
|
12
18
|
*/
|
|
13
19
|
.app-layout {
|
|
14
20
|
--app-nav-side-size: 12rem;
|
|
21
|
+
--app-nav-rail-size: 5.5rem;
|
|
22
|
+
--app-layout-bar-size: calc(var(--control-size) + var(--space-30) * 2);
|
|
15
23
|
|
|
16
24
|
display: grid;
|
|
17
25
|
grid-template:
|
|
@@ -58,23 +66,68 @@
|
|
|
58
66
|
/ var(--app-nav-side-size) minmax(0, 1fr);
|
|
59
67
|
}
|
|
60
68
|
|
|
69
|
+
/* A column, not grid rows: the footer takes the free space above it with an
|
|
70
|
+
auto margin. Scrolls on its own when the destinations outgrow a short
|
|
71
|
+
viewport, so the footer follows the last link instead of covering it. */
|
|
72
|
+
/* Where the brand lives decides who owns the top-left corner. A nav header
|
|
73
|
+
claims it, and the nav runs the full height; without one the brand is in
|
|
74
|
+
the topbar, which then spans the navigation as a global bar. Areas only:
|
|
75
|
+
columns stay with the rules above and the rail's, which this selector
|
|
76
|
+
would outweigh. Without :has() the nav keeps the full height. */
|
|
77
|
+
.app-layout:not(:has(> .app-nav > header)) {
|
|
78
|
+
grid-template-areas:
|
|
79
|
+
"topbar topbar"
|
|
80
|
+
"nav main";
|
|
81
|
+
}
|
|
82
|
+
|
|
61
83
|
.app-layout > .app-nav {
|
|
62
84
|
position: sticky;
|
|
63
85
|
inset-block: 0;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
grid-auto-columns: auto;
|
|
67
|
-
align-content: start;
|
|
86
|
+
display: flex;
|
|
87
|
+
flex-direction: column;
|
|
68
88
|
gap: var(--space-20);
|
|
69
89
|
min-block-size: 0;
|
|
70
90
|
padding-block: max(var(--space-20), env(safe-area-inset-top))
|
|
71
91
|
max(var(--space-20), env(safe-area-inset-bottom));
|
|
72
92
|
padding-inline: var(--space-20);
|
|
93
|
+
overflow-y: auto;
|
|
73
94
|
border-block-start: 0;
|
|
74
95
|
border-inline-end: var(--border-width) solid var(--ui-border, var(--border));
|
|
75
96
|
}
|
|
76
97
|
|
|
77
|
-
|
|
98
|
+
/* An explicit tile min-size would otherwise let an overflowing column
|
|
99
|
+
shrink a two-line label below its content. */
|
|
100
|
+
.app-layout > .app-nav > * {
|
|
101
|
+
flex: none;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.app-layout > .app-nav > :is(header, footer) {
|
|
105
|
+
display: grid;
|
|
106
|
+
gap: var(--space-20);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* The nav spans both rows, so its header cannot read the topbar's height.
|
|
110
|
+
Both share one band instead: the header's first row (the brand) centres
|
|
111
|
+
on the topbar's line, a primary action stacks below it, and the first
|
|
112
|
+
destination starts below the band, level with the main region. */
|
|
113
|
+
.app-layout > .topbar {
|
|
114
|
+
min-block-size: calc(var(--app-layout-bar-size) + env(safe-area-inset-top));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.app-layout > .app-nav > header {
|
|
118
|
+
grid-template-rows: var(--app-layout-bar-size);
|
|
119
|
+
align-items: center;
|
|
120
|
+
/* Starts at the nav's border edge, as the topbar does at the viewport's:
|
|
121
|
+
cancels the nav's top padding and re-adds the inset above the band. */
|
|
122
|
+
margin-block-start: calc(max(var(--space-20), env(safe-area-inset-top)) * -1);
|
|
123
|
+
padding-block-start: env(safe-area-inset-top);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.app-layout > .app-nav > footer {
|
|
127
|
+
margin-block-start: auto;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.app-layout > .app-nav > :is(a, button) {
|
|
78
131
|
grid-template-rows: auto;
|
|
79
132
|
grid-template-columns: 1.5rem minmax(0, 1fr);
|
|
80
133
|
place-content: center start;
|
|
@@ -82,9 +135,55 @@
|
|
|
82
135
|
justify-items: start;
|
|
83
136
|
gap: var(--space-30);
|
|
84
137
|
padding-inline: var(--space-30);
|
|
138
|
+
/* The xs caption suits a label under an icon in a cramped bar; beside the
|
|
139
|
+
icon it reads as a navigation link, at body size like .nav-link. */
|
|
140
|
+
font-size: inherit;
|
|
85
141
|
text-align: start;
|
|
86
142
|
}
|
|
87
143
|
|
|
144
|
+
/* A labelled row is the target itself: the state fills the whole row and
|
|
145
|
+
the icon drops its pill (app-nav.css), back to a plain glyph. */
|
|
146
|
+
.app-layout:not([data-nav="rail"]) > .app-nav > :is(a, button) {
|
|
147
|
+
background: var(--app-nav-fill, transparent);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.app-layout:not([data-nav="rail"]) > .app-nav > a[aria-current="page"] {
|
|
151
|
+
color: var(--app-nav-ink);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.app-layout:not([data-nav="rail"])
|
|
155
|
+
> .app-nav
|
|
156
|
+
> :is(a, button)
|
|
157
|
+
> :where(svg, img, [aria-hidden="true"]) {
|
|
158
|
+
padding: 0;
|
|
159
|
+
background: none;
|
|
160
|
+
color: inherit;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.app-layout[data-nav="rail"] {
|
|
164
|
+
grid-template-columns: var(--app-nav-rail-size) minmax(0, 1fr);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/* The rail keeps a caption under each icon, the bottom bar's tile turned
|
|
168
|
+
upright: a visible label needs no tooltip and names the tile for everyone.
|
|
169
|
+
The track fits single-word xs captions ("Notifications" measured 76px),
|
|
170
|
+
with the nav's inline padding narrowed so the tile keeps that width; two
|
|
171
|
+
words wrap onto a second line. */
|
|
172
|
+
.app-layout[data-nav="rail"] > .app-nav {
|
|
173
|
+
padding-inline: var(--space-10);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.app-layout[data-nav="rail"] > .app-nav > :is(a, button) {
|
|
177
|
+
grid-template-rows: auto auto;
|
|
178
|
+
grid-template-columns: auto;
|
|
179
|
+
place-content: center;
|
|
180
|
+
justify-items: center;
|
|
181
|
+
gap: var(--space-10);
|
|
182
|
+
padding: var(--space-10) 0;
|
|
183
|
+
font-size: var(--font-size-xs);
|
|
184
|
+
text-align: center;
|
|
185
|
+
}
|
|
186
|
+
|
|
88
187
|
/* In the side layout the FAB owns the viewport's bottom safe-area inset. */
|
|
89
188
|
.app-layout > .fab {
|
|
90
189
|
margin-block-end: max(var(--fab-offset), env(safe-area-inset-bottom));
|
package/src/js/dialog.js
CHANGED
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
import { registerCommands, targetFor } from "./command.js";
|
|
33
|
+
import { readDataFlag } from "./data-flag.js";
|
|
33
34
|
import enhance, { registerEnhancement } from "./enhance.js";
|
|
34
35
|
import { EVENTS } from "./events.js";
|
|
35
36
|
import { submissionSetting } from "./form-submission.js";
|
|
@@ -65,10 +66,6 @@ function allowsDialogEnhancement(dialog) {
|
|
|
65
66
|
return true;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
function boolData(el, name) {
|
|
69
|
-
return el.hasAttribute(name) && el.getAttribute(name) !== "false";
|
|
70
|
-
}
|
|
71
|
-
|
|
72
69
|
function setOwnedAttribute(state, el, name, value) {
|
|
73
70
|
const current = el.getAttribute(name);
|
|
74
71
|
if (current === value) return;
|
|
@@ -136,7 +133,7 @@ function syncDialogSemantics(dialog, state, modal = isModal(dialog)) {
|
|
|
136
133
|
}
|
|
137
134
|
|
|
138
135
|
function isModal(dialog) {
|
|
139
|
-
return dialog
|
|
136
|
+
return readDataFlag(dialog, "data-dialog-modal", true);
|
|
140
137
|
}
|
|
141
138
|
|
|
142
139
|
function resolveModalMode(dialog, forcedModal = null) {
|
|
@@ -190,11 +187,11 @@ function syncModalOpenClass(doc = document) {
|
|
|
190
187
|
}
|
|
191
188
|
|
|
192
189
|
function isDismissible(dialog) {
|
|
193
|
-
return
|
|
190
|
+
return readDataFlag(dialog, "data-dialog-dismissible");
|
|
194
191
|
}
|
|
195
192
|
|
|
196
193
|
function wantsViewTransition(dialog) {
|
|
197
|
-
return
|
|
194
|
+
return readDataFlag(dialog, "data-dialog-view-transition");
|
|
198
195
|
}
|
|
199
196
|
|
|
200
197
|
const VT_NAME = "actual-dialog";
|
|
@@ -577,7 +574,7 @@ function swallowNextClose(dialog) {
|
|
|
577
574
|
without JavaScript, non-modally; the runtime upgrades it to its modal mode.
|
|
578
575
|
A reinserted node does not reopen; a new node does. */
|
|
579
576
|
function autoOpen(dialog) {
|
|
580
|
-
if (!
|
|
577
|
+
if (!readDataFlag(dialog, "data-dialog-open") || autoOpened.has(dialog)) return;
|
|
581
578
|
if (dialog.open) {
|
|
582
579
|
// Already modal (a command came first), or meant to stay non-modal.
|
|
583
580
|
if (isModalOpen(dialog) || !isModal(dialog)) {
|
|
@@ -16,22 +16,15 @@
|
|
|
16
16
|
* One map keyed by name reserves the slot immediately, so concurrent calls
|
|
17
17
|
* for the same name share one promise. The browser's native module cache
|
|
18
18
|
* handles URL dedup. Script/style helpers fill the gap for non-ESM assets.
|
|
19
|
-
*
|
|
20
|
-
* Exports prefixed with `__` are test hooks and are not part of the
|
|
21
|
-
* supported public API or SemVer contract.
|
|
22
19
|
*/
|
|
23
20
|
|
|
24
21
|
import enhance, { registerEnhancement } from "./enhance.js";
|
|
22
|
+
import { loaderState } from "./enhancement-loader-state.js";
|
|
25
23
|
import { parseConfig } from "./parse-config.js";
|
|
26
24
|
|
|
27
25
|
const MANIFEST_SELECTOR = 'script[type="application/json"][data-enhance-modules]';
|
|
28
26
|
|
|
29
|
-
const enhancements =
|
|
30
|
-
|
|
31
|
-
const scriptLoads = new Map();
|
|
32
|
-
const styleLoads = new Map();
|
|
33
|
-
|
|
34
|
-
let moduleImporter = (url) => import(url);
|
|
27
|
+
const { enhancements, scriptLoads, styleLoads } = loaderState;
|
|
35
28
|
|
|
36
29
|
function loadAsset(url, loads, kind) {
|
|
37
30
|
const absoluteUrl = new URL(url, document.baseURI).href;
|
|
@@ -141,7 +134,8 @@ export function loadEnhancement(name, url) {
|
|
|
141
134
|
return existing.promise.then(() => ({ name, status: "skipped" }));
|
|
142
135
|
}
|
|
143
136
|
|
|
144
|
-
const promise =
|
|
137
|
+
const promise = loaderState
|
|
138
|
+
.importModule(absoluteUrl)
|
|
145
139
|
.then(async (mod) => {
|
|
146
140
|
if (typeof mod.default !== "function") {
|
|
147
141
|
throw new TypeError(`Enhancement "${name}" must export a default function.`);
|
|
@@ -285,14 +279,3 @@ export async function loadResponse(response) {
|
|
|
285
279
|
|
|
286
280
|
return loadManifest(Object.entries(manifest));
|
|
287
281
|
}
|
|
288
|
-
|
|
289
|
-
export function __setModuleImporter(fn) {
|
|
290
|
-
moduleImporter = fn;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
export function __reset() {
|
|
294
|
-
enhancements.clear();
|
|
295
|
-
scriptLoads.clear();
|
|
296
|
-
styleLoads.clear();
|
|
297
|
-
moduleImporter = (url) => import(url);
|
|
298
|
-
}
|
package/src/js/keys.js
CHANGED
|
@@ -30,14 +30,13 @@ export function lastItem(items) {
|
|
|
30
30
|
export function nextItem(items, current, delta, opts = {}) {
|
|
31
31
|
if (!items.length) return null;
|
|
32
32
|
|
|
33
|
-
const wrap = opts.wrap !== false;
|
|
34
33
|
const idx = items.indexOf(current);
|
|
35
34
|
if (idx === -1) {
|
|
36
35
|
return delta > 0 ? firstItem(items) : lastItem(items);
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
const next = idx + delta;
|
|
40
|
-
if (
|
|
39
|
+
if (opts.wrap !== true) return items[next] || null;
|
|
41
40
|
|
|
42
41
|
const wrapped = ((next % items.length) + items.length) % items.length;
|
|
43
42
|
return items[wrapped];
|
|
@@ -45,7 +44,6 @@ export function nextItem(items, current, delta, opts = {}) {
|
|
|
45
44
|
|
|
46
45
|
export function itemForKey(items, current, key, opts = {}) {
|
|
47
46
|
const orientation = opts.orientation || "horizontal";
|
|
48
|
-
const wrap = opts.wrap === true;
|
|
49
47
|
const direction = opts.direction || "ltr";
|
|
50
48
|
|
|
51
49
|
switch (key) {
|
|
@@ -55,16 +53,16 @@ export function itemForKey(items, current, key, opts = {}) {
|
|
|
55
53
|
return lastItem(items);
|
|
56
54
|
case "ArrowRight":
|
|
57
55
|
if (orientation !== "horizontal") return null;
|
|
58
|
-
return nextItem(items, current, direction === "rtl" ? -1 : 1,
|
|
56
|
+
return nextItem(items, current, direction === "rtl" ? -1 : 1, opts);
|
|
59
57
|
case "ArrowLeft":
|
|
60
58
|
if (orientation !== "horizontal") return null;
|
|
61
|
-
return nextItem(items, current, direction === "rtl" ? 1 : -1,
|
|
59
|
+
return nextItem(items, current, direction === "rtl" ? 1 : -1, opts);
|
|
62
60
|
case "ArrowDown":
|
|
63
61
|
if (orientation !== "vertical") return null;
|
|
64
|
-
return nextItem(items, current, 1,
|
|
62
|
+
return nextItem(items, current, 1, opts);
|
|
65
63
|
case "ArrowUp":
|
|
66
64
|
if (orientation !== "vertical") return null;
|
|
67
|
-
return nextItem(items, current, -1,
|
|
65
|
+
return nextItem(items, current, -1, opts);
|
|
68
66
|
default:
|
|
69
67
|
return null;
|
|
70
68
|
}
|
package/src/js/parse-config.js
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// A popover can become detached before the native call. Let the caller handle
|
|
2
|
+
// a failed show and allow its own teardown to finish after a failed hide.
|
|
3
|
+
export function showPopover(element) {
|
|
4
|
+
try {
|
|
5
|
+
element.showPopover();
|
|
6
|
+
return true;
|
|
7
|
+
} catch {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function hidePopover(element) {
|
|
13
|
+
try {
|
|
14
|
+
element.hidePopover();
|
|
15
|
+
} catch {
|
|
16
|
+
/* Already closed or detached; nothing left to hide. */
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/js/status.js
CHANGED
package/src/js/surface.js
CHANGED
|
@@ -3,7 +3,7 @@ import enhance from "./enhance.js";
|
|
|
3
3
|
import { registerEscapeDismissal } from "./escape.js";
|
|
4
4
|
import { EVENTS } from "./events.js";
|
|
5
5
|
import { positionModeFor } from "./floating-space.js";
|
|
6
|
-
|
|
6
|
+
import { hidePopover, showPopover } from "./popover-transport.js";
|
|
7
7
|
import { CLASSES } from "./selectors.js";
|
|
8
8
|
import { surfaceFocusReturns } from "./surface-focus.js";
|
|
9
9
|
|
|
@@ -44,36 +44,6 @@ function reaperFor(menu) {
|
|
|
44
44
|
return reaper;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
/*
|
|
48
|
-
* Transport: the top layer, via popover="manual".
|
|
49
|
-
*
|
|
50
|
-
* The runtime owns the whole lifecycle, so "manual" is the only usable mode —
|
|
51
|
-
* it supplies promotion to the top layer and nothing else, leaving the
|
|
52
|
-
* dismissal policy, Escape ordering and focus restoration below untouched.
|
|
53
|
-
*
|
|
54
|
-
* The attribute is set by the runtime, not asked of the author: a surface is
|
|
55
|
-
* still marked up exactly as before. showPopover/hidePopover throw on an
|
|
56
|
-
* out-of-order call (already open, not connected), which is a state Actual's
|
|
57
|
-
* own guards should already have excluded — the try/catch is there so a
|
|
58
|
-
* surprising DOM does not take the lifecycle down with it.
|
|
59
|
-
*/
|
|
60
|
-
function showTransport(menu) {
|
|
61
|
-
try {
|
|
62
|
-
menu.showPopover();
|
|
63
|
-
return true;
|
|
64
|
-
} catch {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function hideTransport(menu) {
|
|
70
|
-
try {
|
|
71
|
-
menu.hidePopover();
|
|
72
|
-
} catch {
|
|
73
|
-
/* Already closed or detached; nothing left to hide. */
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
47
|
/*
|
|
78
48
|
* Trigger state sync stays Actual's job, deliberately.
|
|
79
49
|
*
|
|
@@ -136,6 +106,7 @@ function ensureSurfaceWired(menu) {
|
|
|
136
106
|
ensureDocumentClick(menu);
|
|
137
107
|
const state = {
|
|
138
108
|
stopTracking: null,
|
|
109
|
+
stopWatchingMove: null,
|
|
139
110
|
stopScrollIntent: null,
|
|
140
111
|
unregisterEscape: null,
|
|
141
112
|
trigger: null,
|
|
@@ -220,6 +191,21 @@ function startSurfaceResources(menu, state) {
|
|
|
220
191
|
if (type === "scroll" && state.dismissOnScroll) return;
|
|
221
192
|
if (!positionSurface(menu)) closeSurface(menu);
|
|
222
193
|
});
|
|
194
|
+
|
|
195
|
+
if (menu.matches(":popover-open")) {
|
|
196
|
+
// Moving a popover can close it without a toggle event. The reaper
|
|
197
|
+
// handles detachment, while this check follows the active opening.
|
|
198
|
+
const observer = new MutationObserver((records) => {
|
|
199
|
+
const moved = records.some(({ removedNodes }) =>
|
|
200
|
+
Array.from(removedNodes).some((node) => node.contains(menu)),
|
|
201
|
+
);
|
|
202
|
+
if (moved && menu.isConnected && !menu.matches(":popover-open")) {
|
|
203
|
+
closeSurface(menu, { restoreFocus: false });
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
observer.observe(menu.ownerDocument, { childList: true, subtree: true });
|
|
207
|
+
state.stopWatchingMove = () => observer.disconnect();
|
|
208
|
+
}
|
|
223
209
|
}
|
|
224
210
|
|
|
225
211
|
export function isSurfaceOpen(menu) {
|
|
@@ -230,7 +216,7 @@ export function isSurfaceOpen(menu) {
|
|
|
230
216
|
}
|
|
231
217
|
|
|
232
218
|
export function prepareSurface(menu) {
|
|
233
|
-
if (!menu) return;
|
|
219
|
+
if (!menu || isSurfaceOpen(menu)) return;
|
|
234
220
|
menu.style.position = "fixed";
|
|
235
221
|
// A closed popover is hidden by the platform, so [hidden] is no longer the
|
|
236
222
|
// closed state. Any left over from author markup would outrank it.
|
|
@@ -312,7 +298,7 @@ export function openSurface(menu, opts = {}) {
|
|
|
312
298
|
// again, and that close must observe the open state to tear down.
|
|
313
299
|
openSurfaces.add(menu);
|
|
314
300
|
// Promote before measuring: a closed popover has no box to position.
|
|
315
|
-
if (!
|
|
301
|
+
if (!showPopover(menu)) {
|
|
316
302
|
openSurfaces.delete(menu);
|
|
317
303
|
surfaceFocusReturns.delete(menu);
|
|
318
304
|
return false;
|
|
@@ -365,12 +351,14 @@ export function closeSurface(menu, opts = {}) {
|
|
|
365
351
|
const shouldRestoreFocus = opts.restoreFocus ?? menu.contains(activeElement);
|
|
366
352
|
const restoreFocusTo = surfaceFocusReturns.get(menu);
|
|
367
353
|
menu.classList.remove(CLASSES.open);
|
|
368
|
-
|
|
354
|
+
hidePopover(menu);
|
|
369
355
|
openSurfaces.delete(menu);
|
|
370
356
|
syncExpanded(menu, false);
|
|
371
357
|
state?.unregisterEscape?.();
|
|
372
358
|
state?.stopScrollIntent?.();
|
|
373
359
|
state?.stopTracking?.();
|
|
360
|
+
state?.stopWatchingMove?.();
|
|
361
|
+
if (state) state.stopWatchingMove = null;
|
|
374
362
|
|
|
375
363
|
if (shouldRestoreFocus && restoreFocusTo?.isConnected) {
|
|
376
364
|
restoreFocusTo.focus({ preventScroll: true });
|
|
@@ -399,6 +387,16 @@ function isKeyboardRadioMove(e) {
|
|
|
399
387
|
return e.detail === 0 && e.target?.matches?.('input[type="radio"]') === true;
|
|
400
388
|
}
|
|
401
389
|
|
|
390
|
+
/* A click on a field, or on its label, starts an edit, not a pick: closing on
|
|
391
|
+
it shut an account menu on the click that opened its theme select. A
|
|
392
|
+
checkbox or radio is still a pick (a palette closes on its color). */
|
|
393
|
+
const FIELD =
|
|
394
|
+
'select,textarea,input:not([type="button"],[type="submit"],[type="reset"],[type="image"],[type="checkbox"],[type="radio"])';
|
|
395
|
+
|
|
396
|
+
function isFieldEdit(node) {
|
|
397
|
+
return node instanceof Element && (node.matches(FIELD) || !!node.control?.matches(FIELD));
|
|
398
|
+
}
|
|
399
|
+
|
|
402
400
|
function onDocumentClick(e) {
|
|
403
401
|
const path = e.composedPath();
|
|
404
402
|
const radioMove = isKeyboardRadioMove(e);
|
|
@@ -411,16 +409,12 @@ function onDocumentClick(e) {
|
|
|
411
409
|
const menuIndex = path.indexOf(menu);
|
|
412
410
|
const isInside = menuIndex >= 0;
|
|
413
411
|
if (isInside && radioMove) continue;
|
|
414
|
-
const
|
|
415
|
-
|
|
416
|
-
path
|
|
417
|
-
.slice(0, menuIndex)
|
|
418
|
-
.some((node) => node instanceof Element && node.hasAttribute("data-flyout-close"));
|
|
419
|
-
|
|
420
|
-
if (hasCloseTrigger) {
|
|
412
|
+
const inner = isInside ? path.slice(0, menuIndex) : [];
|
|
413
|
+
if (inner.some((node) => node instanceof Element && node.hasAttribute("data-flyout-close"))) {
|
|
421
414
|
closeSurface(menu);
|
|
422
415
|
continue;
|
|
423
416
|
}
|
|
417
|
+
if (inner.some(isFieldEdit)) continue;
|
|
424
418
|
|
|
425
419
|
const closesInside = state.autoClose === "true" || state.autoClose === "inside";
|
|
426
420
|
const closesOutside = state.autoClose === "true" || state.autoClose === "outside";
|