@robert-stackflow/oneui 0.6.8 → 0.6.17
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 +62 -0
- package/README.md +255 -188
- package/components/AccountItem.module.css +103 -103
- package/components/Alert.d.ts +2 -9
- package/components/Alert.js +2 -40
- package/components/AppShell.d.ts +7 -7
- package/components/AppShell.js +37 -33
- package/components/AppShell.module.css +223 -271
- package/components/AppearanceSettings.js +25 -32
- package/components/Badge.module.css +30 -30
- package/components/Banner.d.ts +17 -0
- package/components/Banner.js +99 -0
- package/components/Banner.module.css +143 -0
- package/components/BarChart.module.css +35 -34
- package/components/Breadcrumb.module.css +97 -97
- package/components/Button.module.css +120 -120
- package/components/Cascader.js +1 -0
- package/components/CharacterPicker.js +2 -0
- package/components/Checkbox.module.css +95 -95
- package/components/Combobox.js +1 -0
- package/components/Combobox.module.css +6 -1
- package/components/CommandPalette.js +2 -2
- package/components/ContributionCalendar.module.css +121 -121
- package/components/Control.module.css +86 -86
- package/components/DataTable.d.ts +3 -2
- package/components/DataTable.js +92 -66
- package/components/DataTable.module.css +3 -31
- package/components/DatePicker.js +1 -0
- package/components/DateRangePicker.js +1 -0
- package/components/Dialog.d.ts +3 -1
- package/components/Dialog.js +11 -4
- package/components/Dialog.module.css +139 -97
- package/components/DialogVariants.d.ts +2 -1
- package/components/DialogVariants.js +35 -7
- package/components/HierarchyPicker.module.css +185 -181
- package/components/IconPicker.js +2 -0
- package/components/Indicator.module.css +83 -83
- package/components/Layout.module.css +82 -82
- package/components/Markdown.d.ts +13 -0
- package/components/Markdown.js +164 -0
- package/components/Markdown.module.css +227 -0
- package/components/MenuItem.module.css +172 -172
- package/components/MultiSelect.js +1 -0
- package/components/MultiSelect.module.css +2 -0
- package/components/NavBar.d.ts +20 -0
- package/components/NavBar.js +197 -0
- package/components/NavBar.module.css +130 -0
- package/components/NavigationSurface.module.css +27 -0
- package/components/Picker.module.css +7 -0
- package/components/Popover.d.ts +6 -1
- package/components/Popover.js +39 -13
- package/components/Popover.module.css +8 -0
- package/components/Progress.module.css +33 -33
- package/components/RadioGroup.module.css +87 -87
- package/components/RangeSlider.module.css +141 -141
- package/components/ResizablePanel.module.css +101 -101
- package/components/ResourceCard.module.css +98 -98
- package/components/SelectSettingRow.d.ts +7 -0
- package/components/SelectSettingRow.js +58 -0
- package/components/SettingRow.d.ts +9 -3
- package/components/SettingRow.js +32 -8
- package/components/SettingRow.module.css +17 -0
- package/components/SettingsLayout.d.ts +15 -3
- package/components/SettingsLayout.js +46 -29
- package/components/SideBar.d.ts +9 -0
- package/components/SideBar.js +30 -0
- package/components/SidebarNavigation.d.ts +24 -3
- package/components/SidebarNavigation.js +274 -47
- package/components/SidebarNavigation.module.css +266 -42
- package/components/Slider.module.css +19 -19
- package/components/Steps.module.css +176 -176
- package/components/Switch.d.ts +3 -1
- package/components/Switch.js +5 -1
- package/components/Switch.module.css +59 -59
- package/components/SwitchSettingRow.d.ts +7 -0
- package/components/SwitchSettingRow.js +45 -0
- package/components/Table.d.ts +8 -1
- package/components/Table.js +34 -17
- package/components/Table.module.css +87 -48
- package/components/TableMarkup.d.ts +2 -1
- package/components/TableMarkup.js +18 -1
- package/components/TableOfContents.d.ts +22 -0
- package/components/TableOfContents.js +462 -0
- package/components/TableOfContents.module.css +252 -0
- package/components/TextAreaSettingRow.d.ts +9 -0
- package/components/TextAreaSettingRow.js +47 -0
- package/components/TextSettingRow.d.ts +9 -0
- package/components/TextSettingRow.js +45 -0
- package/components/ThemePicker.module.css +178 -178
- package/components/ThemeProvider.js +2 -0
- package/components/TimeColumns.module.css +47 -47
- package/components/Timeline.module.css +202 -202
- package/components/Toast.d.ts +8 -1
- package/components/Toast.js +49 -17
- package/components/Toast.module.css +25 -0
- package/components/ToastProvider.d.ts +4 -1
- package/components/ToastProvider.js +67 -12
- package/components/TreeSelect.js +1 -0
- package/components/TreeTable.d.ts +3 -3
- package/components/TreeTable.js +12 -2
- package/components/TreeTable.module.css +57 -53
- package/components/createToaster.d.ts +2 -1
- package/components/createToaster.js +28 -14
- package/components/index.d.ts +18 -1
- package/components/index.js +24 -0
- package/components/motion.d.ts +1 -0
- package/components/motion.js +18 -6
- package/components/settingRowControl.d.ts +7 -0
- package/components/settingRowControl.js +15 -0
- package/package.json +57 -3
- package/styles/base.css +206 -206
- package/styles/blue.css +270 -268
- package/styles/minimal.css +1 -0
|
@@ -1,202 +1,202 @@
|
|
|
1
|
-
.timeline {
|
|
2
|
-
container-type: inline-size;
|
|
3
|
-
margin: 0;
|
|
4
|
-
padding: 0;
|
|
5
|
-
list-style: none;
|
|
6
|
-
}
|
|
7
|
-
.item {
|
|
8
|
-
display: grid;
|
|
9
|
-
grid-template-columns: 24px minmax(0, 1fr);
|
|
10
|
-
gap: 14px;
|
|
11
|
-
min-width: 0;
|
|
12
|
-
animation: timelineIn 140ms var(--ease);
|
|
13
|
-
}
|
|
14
|
-
.marker {
|
|
15
|
-
position: relative;
|
|
16
|
-
grid-column: 1;
|
|
17
|
-
grid-row: 1;
|
|
18
|
-
min-height: 22px;
|
|
19
|
-
color: var(--timeline-color, var(--accent));
|
|
20
|
-
}
|
|
21
|
-
.item:not(:last-child) .marker::after {
|
|
22
|
-
content: "";
|
|
23
|
-
position: absolute;
|
|
24
|
-
width: var(--separator-width);
|
|
25
|
-
background: var(--separator-color);
|
|
26
|
-
top: 23px;
|
|
27
|
-
bottom: 0;
|
|
28
|
-
left: 50%;
|
|
29
|
-
transform: translateX(-50%);
|
|
30
|
-
}
|
|
31
|
-
.dot {
|
|
32
|
-
position: absolute;
|
|
33
|
-
top: 1px;
|
|
34
|
-
left: 50%;
|
|
35
|
-
transform: translateX(-50%);
|
|
36
|
-
display: grid;
|
|
37
|
-
place-items: center;
|
|
38
|
-
width: 20px;
|
|
39
|
-
height: 20px;
|
|
40
|
-
}
|
|
41
|
-
.dot > i {
|
|
42
|
-
display: block;
|
|
43
|
-
width: 7px;
|
|
44
|
-
height: 7px;
|
|
45
|
-
border-radius: 50%;
|
|
46
|
-
background: currentColor;
|
|
47
|
-
}
|
|
48
|
-
.dot > svg {
|
|
49
|
-
width: 16px;
|
|
50
|
-
height: 16px;
|
|
51
|
-
}
|
|
52
|
-
.item[data-status="success"] .marker {
|
|
53
|
-
color: var(--timeline-color, var(--success));
|
|
54
|
-
}
|
|
55
|
-
.item[data-status="error"] .marker {
|
|
56
|
-
color: var(--timeline-color, var(--danger));
|
|
57
|
-
}
|
|
58
|
-
.item[data-status="warning"] .marker {
|
|
59
|
-
color: var(--timeline-color, var(--warning));
|
|
60
|
-
}
|
|
61
|
-
.body {
|
|
62
|
-
grid-column: 2;
|
|
63
|
-
grid-row: 1;
|
|
64
|
-
padding-bottom: 28px;
|
|
65
|
-
min-width: 0;
|
|
66
|
-
font-size: 12px;
|
|
67
|
-
line-height: 22px;
|
|
68
|
-
}
|
|
69
|
-
.item:last-child .body {
|
|
70
|
-
padding-bottom: 0;
|
|
71
|
-
}
|
|
72
|
-
.heading {
|
|
73
|
-
display: flex;
|
|
74
|
-
align-items: center;
|
|
75
|
-
gap: 8px;
|
|
76
|
-
min-height: 22px;
|
|
77
|
-
}
|
|
78
|
-
.title {
|
|
79
|
-
font-weight: 500;
|
|
80
|
-
overflow-wrap: anywhere;
|
|
81
|
-
}
|
|
82
|
-
.time {
|
|
83
|
-
display: block;
|
|
84
|
-
color: var(--muted);
|
|
85
|
-
font-size: 11px;
|
|
86
|
-
line-height: 20px;
|
|
87
|
-
margin-top: 2px;
|
|
88
|
-
}
|
|
89
|
-
.description {
|
|
90
|
-
margin-top: 5px;
|
|
91
|
-
color: var(--muted);
|
|
92
|
-
overflow-wrap: anywhere;
|
|
93
|
-
}
|
|
94
|
-
.toggle {
|
|
95
|
-
display: inline-flex;
|
|
96
|
-
align-items: center;
|
|
97
|
-
justify-content: center;
|
|
98
|
-
width: 24px;
|
|
99
|
-
height: 24px;
|
|
100
|
-
padding: 0;
|
|
101
|
-
border: 0;
|
|
102
|
-
border-radius: 5px;
|
|
103
|
-
background: transparent;
|
|
104
|
-
color: var(--muted);
|
|
105
|
-
cursor: pointer;
|
|
106
|
-
flex-shrink: 0;
|
|
107
|
-
}
|
|
108
|
-
.toggle:hover {
|
|
109
|
-
background: var(--hover);
|
|
110
|
-
}
|
|
111
|
-
.toggle svg {
|
|
112
|
-
width: 14px;
|
|
113
|
-
height: 14px;
|
|
114
|
-
}
|
|
115
|
-
.details {
|
|
116
|
-
display: grid;
|
|
117
|
-
grid-template-rows: 0fr;
|
|
118
|
-
opacity: 0;
|
|
119
|
-
transition:
|
|
120
|
-
grid-template-rows var(--motion-segment) var(--ease),
|
|
121
|
-
opacity var(--motion-hover);
|
|
122
|
-
}
|
|
123
|
-
.details[data-open="true"] {
|
|
124
|
-
grid-template-rows: 1fr;
|
|
125
|
-
opacity: 1;
|
|
126
|
-
}
|
|
127
|
-
.clip {
|
|
128
|
-
min-height: 0;
|
|
129
|
-
overflow: hidden;
|
|
130
|
-
}
|
|
131
|
-
.content {
|
|
132
|
-
padding-top: 10px;
|
|
133
|
-
overflow-wrap: anywhere;
|
|
134
|
-
text-align: start;
|
|
135
|
-
}
|
|
136
|
-
.timeline[data-mode="alternate"] .item {
|
|
137
|
-
grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr);
|
|
138
|
-
}
|
|
139
|
-
.timeline[data-mode="alternate"] .marker {
|
|
140
|
-
grid-column: 2;
|
|
141
|
-
}
|
|
142
|
-
.timeline[data-mode="alternate"] .item[data-side="left"] .body {
|
|
143
|
-
grid-column: 1;
|
|
144
|
-
text-align: right;
|
|
145
|
-
}
|
|
146
|
-
.timeline[data-mode="alternate"] .item[data-side="left"] .heading {
|
|
147
|
-
justify-content: flex-end;
|
|
148
|
-
}
|
|
149
|
-
.timeline[data-mode="alternate"] .item[data-side="right"] .body {
|
|
150
|
-
grid-column: 3;
|
|
151
|
-
}
|
|
152
|
-
.skeleton {
|
|
153
|
-
margin-top: 10px;
|
|
154
|
-
}
|
|
155
|
-
.empty {
|
|
156
|
-
font-size: 12px;
|
|
157
|
-
color: var(--muted);
|
|
158
|
-
padding: 24px;
|
|
159
|
-
text-align: center;
|
|
160
|
-
}
|
|
161
|
-
@container (max-width:600px) {
|
|
162
|
-
.timeline[data-mode="alternate"] .item {
|
|
163
|
-
grid-template-columns: 24px minmax(0, 1fr);
|
|
164
|
-
}
|
|
165
|
-
.timeline[data-mode="alternate"] .marker {
|
|
166
|
-
grid-column: 1;
|
|
167
|
-
}
|
|
168
|
-
.timeline[data-mode="alternate"]
|
|
169
|
-
.item:is([data-side="left"], [data-side="right"])
|
|
170
|
-
.body {
|
|
171
|
-
grid-column: 2;
|
|
172
|
-
text-align: start;
|
|
173
|
-
}
|
|
174
|
-
.timeline[data-mode="alternate"] .item[data-side="left"] .heading {
|
|
175
|
-
justify-content: flex-start;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
@media (prefers-reduced-motion: reduce) {
|
|
179
|
-
.details {
|
|
180
|
-
transition: none;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
.sr {
|
|
185
|
-
composes: visuallyHidden from "./Accessibility.module.css";
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
@keyframes timelineIn {
|
|
189
|
-
from {
|
|
190
|
-
opacity: 0;
|
|
191
|
-
transform: translateY(4px);
|
|
192
|
-
}
|
|
193
|
-
to {
|
|
194
|
-
opacity: 1;
|
|
195
|
-
transform: none;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
@media (prefers-reduced-motion: reduce) {
|
|
199
|
-
.item {
|
|
200
|
-
animation: none;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
1
|
+
.timeline {
|
|
2
|
+
container-type: inline-size;
|
|
3
|
+
margin: 0;
|
|
4
|
+
padding: 0;
|
|
5
|
+
list-style: none;
|
|
6
|
+
}
|
|
7
|
+
.item {
|
|
8
|
+
display: grid;
|
|
9
|
+
grid-template-columns: 24px minmax(0, 1fr);
|
|
10
|
+
gap: 14px;
|
|
11
|
+
min-width: 0;
|
|
12
|
+
animation: timelineIn 140ms var(--ease);
|
|
13
|
+
}
|
|
14
|
+
.marker {
|
|
15
|
+
position: relative;
|
|
16
|
+
grid-column: 1;
|
|
17
|
+
grid-row: 1;
|
|
18
|
+
min-height: 22px;
|
|
19
|
+
color: var(--timeline-color, var(--accent-ink, var(--accent)));
|
|
20
|
+
}
|
|
21
|
+
.item:not(:last-child) .marker::after {
|
|
22
|
+
content: "";
|
|
23
|
+
position: absolute;
|
|
24
|
+
width: var(--separator-width);
|
|
25
|
+
background: var(--separator-color);
|
|
26
|
+
top: 23px;
|
|
27
|
+
bottom: 0;
|
|
28
|
+
left: 50%;
|
|
29
|
+
transform: translateX(-50%);
|
|
30
|
+
}
|
|
31
|
+
.dot {
|
|
32
|
+
position: absolute;
|
|
33
|
+
top: 1px;
|
|
34
|
+
left: 50%;
|
|
35
|
+
transform: translateX(-50%);
|
|
36
|
+
display: grid;
|
|
37
|
+
place-items: center;
|
|
38
|
+
width: 20px;
|
|
39
|
+
height: 20px;
|
|
40
|
+
}
|
|
41
|
+
.dot > i {
|
|
42
|
+
display: block;
|
|
43
|
+
width: 7px;
|
|
44
|
+
height: 7px;
|
|
45
|
+
border-radius: 50%;
|
|
46
|
+
background: currentColor;
|
|
47
|
+
}
|
|
48
|
+
.dot > svg {
|
|
49
|
+
width: 16px;
|
|
50
|
+
height: 16px;
|
|
51
|
+
}
|
|
52
|
+
.item[data-status="success"] .marker {
|
|
53
|
+
color: var(--timeline-color, var(--success));
|
|
54
|
+
}
|
|
55
|
+
.item[data-status="error"] .marker {
|
|
56
|
+
color: var(--timeline-color, var(--danger));
|
|
57
|
+
}
|
|
58
|
+
.item[data-status="warning"] .marker {
|
|
59
|
+
color: var(--timeline-color, var(--warning));
|
|
60
|
+
}
|
|
61
|
+
.body {
|
|
62
|
+
grid-column: 2;
|
|
63
|
+
grid-row: 1;
|
|
64
|
+
padding-bottom: 28px;
|
|
65
|
+
min-width: 0;
|
|
66
|
+
font-size: 12px;
|
|
67
|
+
line-height: 22px;
|
|
68
|
+
}
|
|
69
|
+
.item:last-child .body {
|
|
70
|
+
padding-bottom: 0;
|
|
71
|
+
}
|
|
72
|
+
.heading {
|
|
73
|
+
display: flex;
|
|
74
|
+
align-items: center;
|
|
75
|
+
gap: 8px;
|
|
76
|
+
min-height: 22px;
|
|
77
|
+
}
|
|
78
|
+
.title {
|
|
79
|
+
font-weight: 500;
|
|
80
|
+
overflow-wrap: anywhere;
|
|
81
|
+
}
|
|
82
|
+
.time {
|
|
83
|
+
display: block;
|
|
84
|
+
color: var(--muted);
|
|
85
|
+
font-size: 11px;
|
|
86
|
+
line-height: 20px;
|
|
87
|
+
margin-top: 2px;
|
|
88
|
+
}
|
|
89
|
+
.description {
|
|
90
|
+
margin-top: 5px;
|
|
91
|
+
color: var(--muted);
|
|
92
|
+
overflow-wrap: anywhere;
|
|
93
|
+
}
|
|
94
|
+
.toggle {
|
|
95
|
+
display: inline-flex;
|
|
96
|
+
align-items: center;
|
|
97
|
+
justify-content: center;
|
|
98
|
+
width: 24px;
|
|
99
|
+
height: 24px;
|
|
100
|
+
padding: 0;
|
|
101
|
+
border: 0;
|
|
102
|
+
border-radius: 5px;
|
|
103
|
+
background: transparent;
|
|
104
|
+
color: var(--muted);
|
|
105
|
+
cursor: pointer;
|
|
106
|
+
flex-shrink: 0;
|
|
107
|
+
}
|
|
108
|
+
.toggle:hover {
|
|
109
|
+
background: var(--hover);
|
|
110
|
+
}
|
|
111
|
+
.toggle svg {
|
|
112
|
+
width: 14px;
|
|
113
|
+
height: 14px;
|
|
114
|
+
}
|
|
115
|
+
.details {
|
|
116
|
+
display: grid;
|
|
117
|
+
grid-template-rows: 0fr;
|
|
118
|
+
opacity: 0;
|
|
119
|
+
transition:
|
|
120
|
+
grid-template-rows var(--motion-segment) var(--ease),
|
|
121
|
+
opacity var(--motion-hover);
|
|
122
|
+
}
|
|
123
|
+
.details[data-open="true"] {
|
|
124
|
+
grid-template-rows: 1fr;
|
|
125
|
+
opacity: 1;
|
|
126
|
+
}
|
|
127
|
+
.clip {
|
|
128
|
+
min-height: 0;
|
|
129
|
+
overflow: hidden;
|
|
130
|
+
}
|
|
131
|
+
.content {
|
|
132
|
+
padding-top: 10px;
|
|
133
|
+
overflow-wrap: anywhere;
|
|
134
|
+
text-align: start;
|
|
135
|
+
}
|
|
136
|
+
.timeline[data-mode="alternate"] .item {
|
|
137
|
+
grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr);
|
|
138
|
+
}
|
|
139
|
+
.timeline[data-mode="alternate"] .marker {
|
|
140
|
+
grid-column: 2;
|
|
141
|
+
}
|
|
142
|
+
.timeline[data-mode="alternate"] .item[data-side="left"] .body {
|
|
143
|
+
grid-column: 1;
|
|
144
|
+
text-align: right;
|
|
145
|
+
}
|
|
146
|
+
.timeline[data-mode="alternate"] .item[data-side="left"] .heading {
|
|
147
|
+
justify-content: flex-end;
|
|
148
|
+
}
|
|
149
|
+
.timeline[data-mode="alternate"] .item[data-side="right"] .body {
|
|
150
|
+
grid-column: 3;
|
|
151
|
+
}
|
|
152
|
+
.skeleton {
|
|
153
|
+
margin-top: 10px;
|
|
154
|
+
}
|
|
155
|
+
.empty {
|
|
156
|
+
font-size: 12px;
|
|
157
|
+
color: var(--muted);
|
|
158
|
+
padding: 24px;
|
|
159
|
+
text-align: center;
|
|
160
|
+
}
|
|
161
|
+
@container (max-width:600px) {
|
|
162
|
+
.timeline[data-mode="alternate"] .item {
|
|
163
|
+
grid-template-columns: 24px minmax(0, 1fr);
|
|
164
|
+
}
|
|
165
|
+
.timeline[data-mode="alternate"] .marker {
|
|
166
|
+
grid-column: 1;
|
|
167
|
+
}
|
|
168
|
+
.timeline[data-mode="alternate"]
|
|
169
|
+
.item:is([data-side="left"], [data-side="right"])
|
|
170
|
+
.body {
|
|
171
|
+
grid-column: 2;
|
|
172
|
+
text-align: start;
|
|
173
|
+
}
|
|
174
|
+
.timeline[data-mode="alternate"] .item[data-side="left"] .heading {
|
|
175
|
+
justify-content: flex-start;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
@media (prefers-reduced-motion: reduce) {
|
|
179
|
+
.details {
|
|
180
|
+
transition: none;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.sr {
|
|
185
|
+
composes: visuallyHidden from "./Accessibility.module.css";
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
@keyframes timelineIn {
|
|
189
|
+
from {
|
|
190
|
+
opacity: 0;
|
|
191
|
+
transform: translateY(4px);
|
|
192
|
+
}
|
|
193
|
+
to {
|
|
194
|
+
opacity: 1;
|
|
195
|
+
transform: none;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
@media (prefers-reduced-motion: reduce) {
|
|
199
|
+
.item {
|
|
200
|
+
animation: none;
|
|
201
|
+
}
|
|
202
|
+
}
|
package/components/Toast.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { ToastMessage } from "./ToastProvider";
|
|
2
|
-
export declare function Toast({ toast, position, onDismiss, }: {
|
|
2
|
+
export declare function Toast({ toast, position, onDismiss, stackIndex, stackOffset, stackExpanded, stackHidden, paused, onHoverChange, onHeightChange, }: {
|
|
3
3
|
toast: ToastMessage | null;
|
|
4
4
|
position: string;
|
|
5
5
|
onDismiss(id: number): void;
|
|
6
|
+
stackIndex?: number;
|
|
7
|
+
stackOffset?: number;
|
|
8
|
+
stackExpanded?: boolean;
|
|
9
|
+
stackHidden?: boolean;
|
|
10
|
+
paused?: boolean;
|
|
11
|
+
onHoverChange?(inside: boolean): void;
|
|
12
|
+
onHeightChange?(height: number): void;
|
|
6
13
|
}): import("react").ReactPortal;
|
package/components/Toast.js
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
CircleX,
|
|
15
15
|
LoaderCircle
|
|
16
16
|
} from "lucide-react";
|
|
17
|
-
import {
|
|
17
|
+
import { toastMotion, cancelMotion } from "./motion.js";
|
|
18
18
|
import s from "./Toast.module.css";
|
|
19
19
|
const icons = {
|
|
20
20
|
neutral: Info,
|
|
@@ -26,7 +26,14 @@ const icons = {
|
|
|
26
26
|
function Toast({
|
|
27
27
|
toast,
|
|
28
28
|
position,
|
|
29
|
-
onDismiss
|
|
29
|
+
onDismiss,
|
|
30
|
+
stackIndex = 0,
|
|
31
|
+
stackOffset = 0,
|
|
32
|
+
stackExpanded = false,
|
|
33
|
+
stackHidden = false,
|
|
34
|
+
paused = false,
|
|
35
|
+
onHoverChange,
|
|
36
|
+
onHeightChange
|
|
30
37
|
}) {
|
|
31
38
|
const ref = useRef(null), current = useRef(toast), timer = useRef(void 0), pendingId = useRef(null);
|
|
32
39
|
const [pending, setPending] = useState(false), [error, setError] = useState("");
|
|
@@ -35,11 +42,7 @@ function Toast({
|
|
|
35
42
|
clearTimeout(timer.current);
|
|
36
43
|
const message = current.current, node = ref.current;
|
|
37
44
|
if (!message) return;
|
|
38
|
-
void
|
|
39
|
-
node,
|
|
40
|
-
"exit",
|
|
41
|
-
position.startsWith("top") ? "0 -4px" : "0 4px"
|
|
42
|
-
).then((done) => {
|
|
45
|
+
void toastMotion(node, "exit", position).then((done) => {
|
|
43
46
|
if (done && current.current?.id === message.id) {
|
|
44
47
|
if (node.matches(":popover-open")) node.hidePopover();
|
|
45
48
|
onDismiss(message.id);
|
|
@@ -49,7 +52,7 @@ function Toast({
|
|
|
49
52
|
const arm = () => {
|
|
50
53
|
clearTimeout(timer.current);
|
|
51
54
|
const message = current.current, node = ref.current;
|
|
52
|
-
if (message && !message.closing && !message.options?.persistent && pendingId.current !== message.id && !node?.matches(":hover") && !node?.contains(document.activeElement))
|
|
55
|
+
if (message && !paused && !message.closing && !message.options?.persistent && pendingId.current !== message.id && !node?.matches(":hover") && !node?.contains(document.activeElement))
|
|
53
56
|
timer.current = setTimeout(
|
|
54
57
|
dismiss,
|
|
55
58
|
Math.max(0, message.options?.duration ?? 5e3)
|
|
@@ -70,11 +73,7 @@ function Toast({
|
|
|
70
73
|
}
|
|
71
74
|
const already = node.matches(":popover-open");
|
|
72
75
|
if (!already) node.showPopover();
|
|
73
|
-
void
|
|
74
|
-
node,
|
|
75
|
-
already ? "update" : "enter",
|
|
76
|
-
position.startsWith("top") ? "0 -4px" : "0 4px"
|
|
77
|
-
);
|
|
76
|
+
void toastMotion(node, already ? "update" : "enter", position);
|
|
78
77
|
arm();
|
|
79
78
|
return () => clearTimeout(timer.current);
|
|
80
79
|
}, [toast, position]);
|
|
@@ -85,6 +84,20 @@ function Toast({
|
|
|
85
84
|
cancelMotion(node);
|
|
86
85
|
};
|
|
87
86
|
}, []);
|
|
87
|
+
const heightChange = useRef(onHeightChange);
|
|
88
|
+
heightChange.current = onHeightChange;
|
|
89
|
+
useLayoutEffect(() => {
|
|
90
|
+
const node = ref.current;
|
|
91
|
+
const observer = new ResizeObserver(
|
|
92
|
+
() => heightChange.current?.(node.offsetHeight)
|
|
93
|
+
);
|
|
94
|
+
observer.observe(node);
|
|
95
|
+
return () => observer.disconnect();
|
|
96
|
+
}, []);
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (paused) clearTimeout(timer.current);
|
|
99
|
+
else arm();
|
|
100
|
+
}, [paused]);
|
|
88
101
|
const execute = async () => {
|
|
89
102
|
const message = current.current, action2 = message?.options?.action;
|
|
90
103
|
if (!message || !action2 || pendingId.current === message.id) return;
|
|
@@ -109,6 +122,8 @@ function Toast({
|
|
|
109
122
|
const options = toast?.options || {}, tone = options.tone || "neutral", Icon = icons[tone], action = options.action;
|
|
110
123
|
const icon = options.icon === false ? null : options.icon === true || options.icon === void 0 ? tone !== "neutral" || options.icon === true ? /* @__PURE__ */ jsx(Icon, {}) : null : options.icon;
|
|
111
124
|
const style = {
|
|
125
|
+
"--toast-stack-offset": `${stackOffset}px`,
|
|
126
|
+
"--toast-stack-scale": stackExpanded ? 1 : Math.max(0.85, 1 - stackIndex * 0.045),
|
|
112
127
|
"--toast-icon-color": options.iconColor,
|
|
113
128
|
"--toast-text-color": options.textColor
|
|
114
129
|
};
|
|
@@ -120,17 +135,34 @@ function Toast({
|
|
|
120
135
|
popover: "manual",
|
|
121
136
|
className: s.toast,
|
|
122
137
|
"data-position": position,
|
|
138
|
+
"data-stack-index": stackIndex,
|
|
139
|
+
"data-stack-expanded": stackExpanded,
|
|
140
|
+
"data-stack-hidden": stackHidden,
|
|
141
|
+
inert: stackHidden,
|
|
142
|
+
"aria-hidden": stackHidden || void 0,
|
|
123
143
|
"data-tone": tone,
|
|
124
144
|
"data-variant": options.variant || "solid",
|
|
125
145
|
role: "status",
|
|
126
146
|
"aria-live": "polite",
|
|
127
147
|
"aria-atomic": "true",
|
|
128
148
|
style,
|
|
129
|
-
onPointerEnter: () =>
|
|
130
|
-
|
|
131
|
-
|
|
149
|
+
onPointerEnter: () => {
|
|
150
|
+
clearTimeout(timer.current);
|
|
151
|
+
onHoverChange?.(true);
|
|
152
|
+
},
|
|
153
|
+
onPointerLeave: () => {
|
|
154
|
+
onHoverChange?.(false);
|
|
155
|
+
arm();
|
|
156
|
+
},
|
|
157
|
+
onFocus: () => {
|
|
158
|
+
clearTimeout(timer.current);
|
|
159
|
+
onHoverChange?.(true);
|
|
160
|
+
},
|
|
132
161
|
onBlur: (e) => {
|
|
133
|
-
if (!e.currentTarget.contains(e.relatedTarget))
|
|
162
|
+
if (!e.currentTarget.contains(e.relatedTarget)) {
|
|
163
|
+
onHoverChange?.(false);
|
|
164
|
+
queueMicrotask(arm);
|
|
165
|
+
}
|
|
134
166
|
},
|
|
135
167
|
onKeyDown: (e) => {
|
|
136
168
|
if (e.key === "Escape") {
|
|
@@ -173,3 +173,28 @@
|
|
|
173
173
|
transform: rotate(360deg);
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
+
|
|
177
|
+
.toast {
|
|
178
|
+
--toast-stack-sign: 1;
|
|
179
|
+
transform: translateY(
|
|
180
|
+
calc(var(--toast-stack-offset, 0px) * var(--toast-stack-sign))
|
|
181
|
+
);
|
|
182
|
+
transition: transform 320ms cubic-bezier(0.16, 1, 0.3, 1);
|
|
183
|
+
will-change: transform, opacity;
|
|
184
|
+
}
|
|
185
|
+
.toast[data-position^="bottom"] {
|
|
186
|
+
--toast-stack-sign: -1;
|
|
187
|
+
}
|
|
188
|
+
.toast[data-position$="center"] {
|
|
189
|
+
transform: translateX(-50%)
|
|
190
|
+
translateY(calc(var(--toast-stack-offset, 0px) * var(--toast-stack-sign)));
|
|
191
|
+
}
|
|
192
|
+
.toast[data-stack-hidden="true"] {
|
|
193
|
+
visibility: hidden;
|
|
194
|
+
pointer-events: none;
|
|
195
|
+
}
|
|
196
|
+
@media (prefers-reduced-motion: reduce) {
|
|
197
|
+
.toast {
|
|
198
|
+
transition: none;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
@@ -10,6 +10,8 @@ export type ToastAction = {
|
|
|
10
10
|
closeOnClick?: boolean;
|
|
11
11
|
};
|
|
12
12
|
export type ToastOptions = {
|
|
13
|
+
/** Reusing a key updates the existing notification in place. */
|
|
14
|
+
id?: string | number;
|
|
13
15
|
duration?: number;
|
|
14
16
|
persistent?: boolean;
|
|
15
17
|
closable?: boolean;
|
|
@@ -28,8 +30,9 @@ export type ToastMessage = {
|
|
|
28
30
|
options?: ToastOptions;
|
|
29
31
|
closing?: boolean;
|
|
30
32
|
};
|
|
31
|
-
export declare function ToastProvider({ children, controller, }: {
|
|
33
|
+
export declare function ToastProvider({ children, controller, maxVisible, }: {
|
|
32
34
|
children: ReactNode;
|
|
33
35
|
controller?: ToastController;
|
|
36
|
+
maxVisible?: number;
|
|
34
37
|
}): import("react").JSX.Element;
|
|
35
38
|
export declare const useToast: () => ToastNotify;
|
|
@@ -3,6 +3,8 @@ import {
|
|
|
3
3
|
createContext,
|
|
4
4
|
useContext,
|
|
5
5
|
useState,
|
|
6
|
+
useRef,
|
|
7
|
+
useEffect,
|
|
6
8
|
useSyncExternalStore
|
|
7
9
|
} from "react";
|
|
8
10
|
import { useUIConfig } from "./UIProvider.js";
|
|
@@ -15,26 +17,79 @@ const Context = createContext(() => () => {
|
|
|
15
17
|
const serverSnapshot = () => null;
|
|
16
18
|
function ToastProvider({
|
|
17
19
|
children,
|
|
18
|
-
controller
|
|
20
|
+
controller,
|
|
21
|
+
maxVisible = 3
|
|
19
22
|
}) {
|
|
20
23
|
const config = useUIConfig();
|
|
21
24
|
const [local] = useState(createToaster), source = controller || local;
|
|
22
|
-
const
|
|
25
|
+
const snapshot = useSyncExternalStore(
|
|
23
26
|
source.subscribe,
|
|
24
|
-
source.getSnapshot,
|
|
27
|
+
source.getQueueSnapshot ?? source.getSnapshot,
|
|
25
28
|
serverSnapshot
|
|
26
29
|
);
|
|
30
|
+
const messages = Array.isArray(snapshot) ? snapshot : snapshot ? [snapshot] : [];
|
|
31
|
+
const [expanded, setExpanded] = useState([]);
|
|
32
|
+
const [heights, setHeights] = useState({});
|
|
33
|
+
const timers = useRef(/* @__PURE__ */ new Map());
|
|
34
|
+
const hover = (position, inside) => {
|
|
35
|
+
clearTimeout(timers.current.get(position));
|
|
36
|
+
if (inside)
|
|
37
|
+
setExpanded((old) => old.includes(position) ? old : [...old, position]);
|
|
38
|
+
else
|
|
39
|
+
timers.current.set(
|
|
40
|
+
position,
|
|
41
|
+
setTimeout(
|
|
42
|
+
() => setExpanded((old) => old.filter((entry) => entry !== position)),
|
|
43
|
+
140
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
useEffect(() => () => timers.current.forEach(clearTimeout), []);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
setHeights((previous) => {
|
|
50
|
+
const ids = new Set(messages.map((message) => String(message.id)));
|
|
51
|
+
return Object.keys(previous).every((id) => ids.has(id)) ? previous : Object.fromEntries(
|
|
52
|
+
Object.entries(previous).filter(([id]) => ids.has(id))
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
}, [snapshot]);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
setExpanded([]);
|
|
58
|
+
setHeights({});
|
|
59
|
+
}, [source.id]);
|
|
60
|
+
const limit = Number.isFinite(maxVisible) ? Math.max(1, Math.floor(maxVisible)) : 3;
|
|
27
61
|
return /* @__PURE__ */ jsxs(Context, { value: source.notify, children: [
|
|
28
62
|
children,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
63
|
+
messages.map((toast) => {
|
|
64
|
+
const position = toast.options?.position || config.toastPosition;
|
|
65
|
+
const group = messages.filter(
|
|
66
|
+
(message) => (message.options?.position || config.toastPosition) === position
|
|
67
|
+
).toReversed();
|
|
68
|
+
const index = group.findIndex((message) => message.id === toast.id);
|
|
69
|
+
const isExpanded = expanded.includes(position);
|
|
70
|
+
const offset = group.slice(0, index).reduce(
|
|
71
|
+
(total, message) => total + (heights[message.id] ?? 56) + 10,
|
|
72
|
+
0
|
|
73
|
+
);
|
|
74
|
+
return /* @__PURE__ */ jsx(
|
|
75
|
+
Toast,
|
|
76
|
+
{
|
|
77
|
+
toast,
|
|
78
|
+
position,
|
|
79
|
+
onDismiss: source.clear,
|
|
80
|
+
stackIndex: index,
|
|
81
|
+
stackOffset: offset,
|
|
82
|
+
stackExpanded: isExpanded,
|
|
83
|
+
stackHidden: index >= limit,
|
|
84
|
+
paused: isExpanded,
|
|
85
|
+
onHoverChange: (inside) => hover(position, inside),
|
|
86
|
+
onHeightChange: (height) => setHeights(
|
|
87
|
+
(old) => old[toast.id] === height ? old : { ...old, [toast.id]: height }
|
|
88
|
+
)
|
|
89
|
+
},
|
|
90
|
+
`${source.id}-${toast.id}`
|
|
91
|
+
);
|
|
92
|
+
})
|
|
38
93
|
] });
|
|
39
94
|
}
|
|
40
95
|
const useToast = () => useContext(Context);
|