tiun 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/docs/components/images.md +34 -4
- data/docs/components/images.ru.md +33 -4
- data/docs/components/login.md +2 -0
- data/docs/components/login.ru.md +2 -0
- data/docs/components/profile.md +3 -1
- data/docs/components/profile.ru.md +3 -1
- data/docs/components/schema-records.md +2 -0
- data/docs/components/schema-records.ru.md +2 -0
- data/docs/components/signup.md +3 -1
- data/docs/components/signup.ru.md +3 -1
- data/docs/components/theme.md +3 -1
- data/docs/components/theme.ru.md +3 -1
- data/docs/reference.ru.md +6 -6
- data/lib/config/locale/ru.yml +0 -3
- data/lib/tiun/auth/token_identity.rb +9 -0
- data/lib/tiun/controller/auth/identity.rb +78 -19
- data/lib/tiun/controller/auth/registration.rb +23 -0
- data/lib/tiun/controller/auth.rb +4 -4
- data/lib/tiun/controller/base/representation.rb +12 -1
- data/lib/tiun/mailer/confirmation.rb +10 -2
- data/lib/tiun/model/account.rb +79 -3
- data/lib/tiun/model/auth.rb +2 -0
- data/lib/tiun/model/me.rb +83 -2
- data/lib/tiun/model/settings.rb +7 -0
- data/lib/tiun/model/token.rb +2 -2
- data/lib/tiun/proceed/schemas/constants.rb +1 -0
- data/lib/tiun/proceed/schemas/spans.rb +1 -0
- data/lib/tiun/routes/mounts.rb +7 -4
- data/lib/tiun/service/email_confirmation.rb +84 -12
- data/lib/tiun/version.rb +1 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- data/src/components/Component.tsx +4 -1
- data/src/components/Image.tsx +36 -25
- data/src/components/Index.tsx +193 -24
- data/src/components/Loader.tsx +11 -9
- data/src/components/Lorem.tsx +7 -1
- data/src/components/Modal.tsx +8 -1
- data/src/components/Paginator.tsx +9 -3
- data/src/components/Records.tsx +45 -18
- data/src/components/calendar-browser.scss +14 -4
- data/src/components/form/Login.tsx +12 -6
- data/src/components/form/auth.scss +44 -130
- data/src/components/form/forms.scss +9 -8
- data/src/components/form/types.ts +2 -0
- data/src/components/image.scss +10 -7
- data/src/components/records.scss +4 -0
- data/src/components/theme-palettes/dark.scss +1 -0
- data/src/concern/application.ts +3 -2
- data/src/concern/spansViewProps.tsx +14 -1
- data/src/concern/useRecordsResource.ts +2 -0
- data/src/decorators/withField.tsx +10 -7
- data/src/decorators/withForm.tsx +12 -6
- data/src/schema/Schema.ts +10 -0
- data/src/services/calendar/daylight.ts +31 -4
- data/src/services/methods.ts +1 -1
- data/src/services/records/useRecordPages.ts +23 -3
- data/src/services/session/renewal.ts +69 -6
- data/src/services/useAppearance.ts +22 -11
- data/src/services/useSwitch.ts +23 -17
- data/src/theme/configuration.ts +21 -7
- metadata +2 -2
|
@@ -37,9 +37,9 @@ export interface LoginProps<User extends SessionUser> {
|
|
|
37
37
|
/** HTTP client for requests. Defaults to axios. */
|
|
38
38
|
readonly client?: AxiosInstance;
|
|
39
39
|
/** Receives the user record with session data after a valid response. */
|
|
40
|
-
readonly onLogin: (user: User) => void
|
|
41
|
-
/** Clears the user in the host after
|
|
42
|
-
readonly onLogout: () => void
|
|
40
|
+
readonly onLogin: (user: User) => void | Promise<void>;
|
|
41
|
+
/** Clears the user in the host after sign-out succeeds. */
|
|
42
|
+
readonly onLogout: () => void | Promise<void>;
|
|
43
43
|
/** Browser path for the signed-in user link. */
|
|
44
44
|
readonly userPath?: string;
|
|
45
45
|
/** Opens the configured user view through host navigation. */
|
|
@@ -65,7 +65,7 @@ export function Login<User extends SessionUser>(props: LoginProps<User>) {
|
|
|
65
65
|
config = props.configuration ?? {},
|
|
66
66
|
[localMode, setLocalMode] = useState<LoginMode | null>(null),
|
|
67
67
|
[notice, setNotice] = useState(""),
|
|
68
|
-
mode = props.activeForm === undefined ? localMode : props.activeForm,
|
|
68
|
+
mode = props.user ? null : props.activeForm === undefined ? localMode : props.activeForm,
|
|
69
69
|
setMode = props.onFormChange ?? setLocalMode,
|
|
70
70
|
[pending, setPending] = useState(false),
|
|
71
71
|
transportAbortRef = useRef<AbortController | null>(null),
|
|
@@ -155,6 +155,10 @@ export function Login<User extends SessionUser>(props: LoginProps<User>) {
|
|
|
155
155
|
setMode(value);
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Signs out of the active session and updates the host after the server confirms it.
|
|
160
|
+
* @returns Completion of the sign-out request.
|
|
161
|
+
*/
|
|
158
162
|
async function logout(): Promise<void> {
|
|
159
163
|
if (workingRef.current) {
|
|
160
164
|
return;
|
|
@@ -169,6 +173,9 @@ export function Login<User extends SessionUser>(props: LoginProps<User>) {
|
|
|
169
173
|
await client.delete(authResource(props.meta, config.session_resource, "delete", SESSION_PATH), {
|
|
170
174
|
signal: controller.signal,
|
|
171
175
|
});
|
|
176
|
+
if (!controller.signal.aborted && activeRevision === versionRef.current) {
|
|
177
|
+
await props.onLogout();
|
|
178
|
+
}
|
|
172
179
|
} catch {
|
|
173
180
|
if (!controller.signal.aborted && activeRevision === versionRef.current) {
|
|
174
181
|
setNotice(t("tiun.components.login.errors.logout"));
|
|
@@ -177,7 +184,6 @@ export function Login<User extends SessionUser>(props: LoginProps<User>) {
|
|
|
177
184
|
if (!controller.signal.aborted && activeRevision === versionRef.current) {
|
|
178
185
|
workingRef.current = false;
|
|
179
186
|
setPending(false);
|
|
180
|
-
props.onLogout();
|
|
181
187
|
}
|
|
182
188
|
}
|
|
183
189
|
}
|
|
@@ -368,7 +374,7 @@ export function Login<User extends SessionUser>(props: LoginProps<User>) {
|
|
|
368
374
|
) {
|
|
369
375
|
throw new Error("Invalid auth response");
|
|
370
376
|
}
|
|
371
|
-
props.onLogin(response.data as User);
|
|
377
|
+
await props.onLogin(response.data as User);
|
|
372
378
|
} else if (configuredMode.labels?.success) {
|
|
373
379
|
setNotice(label(configuredMode.labels?.success, ""));
|
|
374
380
|
}
|
|
@@ -121,7 +121,7 @@ html[data-theme="dark"] .tiun-auth-wechat {
|
|
|
121
121
|
outline: 0.12rem solid currentColor;
|
|
122
122
|
outline-offset: 0.12rem;
|
|
123
123
|
}
|
|
124
|
-
|
|
124
|
+
.tiun-auth-modes button,
|
|
125
125
|
.tiun-modal:has(.tiun-auth-modes) .tiun-modal-footer button {
|
|
126
126
|
min-inline-size: 0;
|
|
127
127
|
max-inline-size: 100%;
|
|
@@ -163,40 +163,20 @@ html[data-theme="dark"] .tiun-auth-wechat {
|
|
|
163
163
|
|
|
164
164
|
.tiun-modal.tiun-auth {
|
|
165
165
|
--tiun-auth-tab: #075c83;
|
|
166
|
-
--tiun-auth-tab-
|
|
167
|
-
--tiun-auth-
|
|
168
|
-
|
|
169
|
-
--tiun-modal-border: 0.0625rem solid var(--tiun-auth-tab);
|
|
170
|
-
--tiun-modal-padding: 0;
|
|
171
|
-
--tiun-modal-radius: 0.25rem;
|
|
172
|
-
--tiun-modal-shadow: 0 0 0.375rem #15030a;
|
|
173
|
-
--tiun-modal-font: 0.875rem Arial, sans-serif;
|
|
174
|
-
--tiun-field-gap: 1rem;
|
|
175
|
-
--tiun-auth-submit-gap: 0.9375rem;
|
|
176
|
-
width: 26.5rem;
|
|
177
|
-
max-width: calc(100% - 2rem);
|
|
178
|
-
max-height: calc(100% - 1.875rem);
|
|
179
|
-
|
|
180
|
-
&::backdrop {
|
|
181
|
-
background: rgba(49, 70, 93, 0.6);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
a {
|
|
185
|
-
text-decoration: none;
|
|
186
|
-
}
|
|
166
|
+
--tiun-auth-tab-text: #fff;
|
|
167
|
+
--tiun-auth-inset: var(--tiun-modal-padding, 1.5rem);
|
|
168
|
+
width: 33rem;
|
|
187
169
|
|
|
188
170
|
.tiun-form > fieldset {
|
|
189
171
|
display: flex;
|
|
190
172
|
flex-direction: column;
|
|
191
|
-
min-inline-size: 0;
|
|
192
|
-
margin: 0;
|
|
193
|
-
padding: 1.25rem 1.875rem;
|
|
194
173
|
}
|
|
195
174
|
|
|
196
175
|
.tiun-auth-tabs {
|
|
197
|
-
order: -2;
|
|
198
176
|
display: flex;
|
|
199
|
-
margin:
|
|
177
|
+
margin-block: calc(-1 * var(--tiun-auth-inset)) var(--tiun-form-gap, 1.25rem);
|
|
178
|
+
margin-inline: calc(-1 * var(--tiun-auth-inset));
|
|
179
|
+
background: var(--tiun-auth-tab);
|
|
200
180
|
}
|
|
201
181
|
|
|
202
182
|
.tiun-auth-tabs > * {
|
|
@@ -206,13 +186,20 @@ html[data-theme="dark"] .tiun-auth-wechat {
|
|
|
206
186
|
}
|
|
207
187
|
|
|
208
188
|
.tiun-auth-tabs a {
|
|
209
|
-
--tiun-auth-tab-ink: var(--tiun-auth-
|
|
210
|
-
flex: 1
|
|
211
|
-
min-
|
|
212
|
-
padding:
|
|
189
|
+
--tiun-auth-tab-ink: var(--tiun-auth-tab-text);
|
|
190
|
+
flex: 1;
|
|
191
|
+
min-inline-size: 0;
|
|
192
|
+
padding: 1.45rem 0.3125rem;
|
|
213
193
|
background: var(--tiun-auth-tab);
|
|
214
194
|
color: var(--tiun-auth-tab-ink);
|
|
195
|
+
font:
|
|
196
|
+
0.875rem/1.5 Arial,
|
|
197
|
+
sans-serif;
|
|
215
198
|
text-align: center;
|
|
199
|
+
text-decoration: none;
|
|
200
|
+
overflow: hidden;
|
|
201
|
+
text-overflow: ellipsis;
|
|
202
|
+
white-space: nowrap;
|
|
216
203
|
box-shadow:
|
|
217
204
|
0 0.2rem 0.8rem #0003,
|
|
218
205
|
inset 0 -0.1rem 0 #0004;
|
|
@@ -220,51 +207,28 @@ html[data-theme="dark"] .tiun-auth-wechat {
|
|
|
220
207
|
&[aria-current="location"] {
|
|
221
208
|
--tiun-auth-tab-ink: #fff;
|
|
222
209
|
background: color-mix(in srgb, var(--tiun-auth-tab), black 35%);
|
|
223
|
-
box-shadow:
|
|
210
|
+
box-shadow: inset 0 0.15rem 0.35rem #0007;
|
|
211
|
+
outline: none;
|
|
224
212
|
}
|
|
225
213
|
|
|
226
214
|
&:hover {
|
|
227
215
|
color: color-mix(in srgb, var(--tiun-auth-tab-ink), var(--tiun-auth-tab) 25%);
|
|
228
216
|
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
> .tiun-column {
|
|
232
|
-
padding-block-end: 1.25rem;
|
|
233
|
-
|
|
234
|
-
&:has(> .tiun-auth-providers:last-child) {
|
|
235
|
-
padding-block-end: 0;
|
|
236
|
-
}
|
|
237
217
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
218
|
+
&:focus-visible:not([aria-current="location"]) {
|
|
219
|
+
outline: 0.12rem solid var(--tiun-auth-tab-ink);
|
|
220
|
+
outline-offset: -0.2rem;
|
|
241
221
|
}
|
|
222
|
+
}
|
|
242
223
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
> * {
|
|
247
|
-
min-inline-size: 0;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
.tiun-form > fieldset {
|
|
251
|
-
padding: 0;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
> .tiun-auth-providers {
|
|
256
|
-
margin: 0;
|
|
257
|
-
padding-inline: 1.875rem;
|
|
258
|
-
|
|
259
|
-
&:last-child {
|
|
260
|
-
padding-block: 1.5rem;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
224
|
+
.tiun-auth-providers {
|
|
225
|
+
margin-inline: calc(-1 * var(--tiun-auth-inset));
|
|
226
|
+
padding-inline: var(--tiun-auth-inset);
|
|
263
227
|
}
|
|
264
228
|
|
|
265
229
|
.tiun-auth-title-wrap {
|
|
266
230
|
order: -1;
|
|
267
|
-
margin-block-end:
|
|
231
|
+
margin-block-end: var(--tiun-form-gap, 1.25rem);
|
|
268
232
|
}
|
|
269
233
|
|
|
270
234
|
.tiun-auth-title {
|
|
@@ -273,94 +237,44 @@ html[data-theme="dark"] .tiun-auth-wechat {
|
|
|
273
237
|
background: none;
|
|
274
238
|
color: inherit;
|
|
275
239
|
box-shadow: none;
|
|
276
|
-
font:
|
|
277
|
-
|
|
278
|
-
|
|
240
|
+
font-size: var(--tiun-modal-title-size, 1.25rem);
|
|
241
|
+
font-weight: 600;
|
|
242
|
+
line-height: 1.3;
|
|
279
243
|
}
|
|
280
244
|
|
|
281
|
-
.tiun-field-caption {
|
|
245
|
+
.tiun-text-field:has(> input[placeholder]:not([placeholder=""])) > .tiun-field-caption {
|
|
282
246
|
position: absolute;
|
|
283
|
-
|
|
284
|
-
|
|
247
|
+
inline-size: 0.0625rem;
|
|
248
|
+
block-size: 0.0625rem;
|
|
285
249
|
overflow: hidden;
|
|
286
250
|
clip-path: inset(50%);
|
|
287
251
|
white-space: nowrap;
|
|
288
252
|
}
|
|
289
253
|
|
|
290
|
-
.tiun-text-
|
|
291
|
-
display: none;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
.tiun-form input:is([type="email"], [type="password"]) {
|
|
295
|
-
box-sizing: border-box;
|
|
296
|
-
width: 100%;
|
|
254
|
+
.tiun-text-field > input:is([type="text"], [type="email"], [type="password"]) {
|
|
297
255
|
height: 3rem;
|
|
298
|
-
margin: 0;
|
|
299
|
-
padding: 0.375rem 1rem;
|
|
300
|
-
border: 0.0625rem solid #ccc;
|
|
301
|
-
border-radius: 0.25rem;
|
|
302
|
-
background: var(--site-background, #fff);
|
|
303
|
-
color: var(--site-text, #555);
|
|
304
|
-
font: inherit;
|
|
305
|
-
box-shadow: inset 0 0.0625rem 0.0625rem #0001;
|
|
306
|
-
|
|
307
|
-
&::placeholder {
|
|
308
|
-
color: #767676;
|
|
309
|
-
}
|
|
310
256
|
}
|
|
311
257
|
|
|
312
|
-
.tiun-text-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
.tiun-form-actions {
|
|
318
|
-
margin-block-start: 0;
|
|
258
|
+
.tiun-text-field > input:not([aria-invalid="true"])::placeholder {
|
|
259
|
+
color: var(--tiun-placeholder, color-mix(in srgb, currentColor 65%, transparent));
|
|
260
|
+
opacity: 1;
|
|
319
261
|
}
|
|
320
262
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
margin-block-start: var(--tiun-auth-submit-gap);
|
|
324
|
-
padding-block: 0.375rem;
|
|
325
|
-
border: 0;
|
|
326
|
-
border-radius: 0.25rem;
|
|
327
|
-
background: var(--tiun-auth-tab);
|
|
328
|
-
color: var(--tiun-auth-ink);
|
|
329
|
-
cursor: pointer;
|
|
330
|
-
|
|
331
|
-
&:hover {
|
|
332
|
-
background: var(--tiun-auth-tab-hover);
|
|
333
|
-
}
|
|
263
|
+
.tiun-text-feedback:has(> .tiun-error:empty:only-child) {
|
|
264
|
+
display: none;
|
|
334
265
|
}
|
|
335
266
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
.tiun-auth-tabs {
|
|
342
|
-
margin: 0 -0.9375rem 0.75rem;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
> .tiun-column {
|
|
346
|
-
> .tiun-row:has(.tiun-form) {
|
|
347
|
-
padding-block-start: 1.4375rem;
|
|
348
|
-
padding-inline: 0.9375rem;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
> .tiun-auth-providers {
|
|
352
|
-
padding-inline: 0.9375rem;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
267
|
+
.tiun-text-feedback[data-counter="false"]:has(> .tiun-error:empty) {
|
|
268
|
+
block-size: 0;
|
|
269
|
+
min-block-size: 0;
|
|
355
270
|
}
|
|
356
271
|
}
|
|
357
272
|
|
|
358
273
|
html[data-theme="dark"] .tiun-modal.tiun-auth {
|
|
359
274
|
--tiun-auth-tab: #245b58;
|
|
360
|
-
--tiun-modal-background: var(--site-background);
|
|
361
275
|
}
|
|
362
276
|
|
|
363
277
|
html[data-palette="compat"]:not([data-theme="dark"]) .tiun-modal.tiun-auth {
|
|
364
278
|
--tiun-auth-tab: #df6066;
|
|
365
|
-
--tiun-auth-
|
|
279
|
+
--tiun-auth-tab-text: #2f105f;
|
|
366
280
|
}
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
@include withClose.styles;
|
|
10
10
|
/* Стили компонентов формы; Materialize и стили приложения не требуются. */
|
|
11
|
+
html:has(.tiun-modal:modal) {
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
}
|
|
14
|
+
|
|
11
15
|
.tiun-modal {
|
|
12
16
|
box-sizing: border-box;
|
|
13
17
|
position: fixed;
|
|
@@ -91,8 +95,7 @@
|
|
|
91
95
|
margin: 0;
|
|
92
96
|
accent-color: var(--tiun-accent, #285b57);
|
|
93
97
|
}
|
|
94
|
-
.tiun-modal .tiun-modal-footer button,
|
|
95
|
-
.tiun-modal .tiun-confirm button,
|
|
98
|
+
.tiun-modal :is(.tiun-modal-footer, .tiun-form-actions, .tiun-confirm) button,
|
|
96
99
|
.tiun-attachment-control > button,
|
|
97
100
|
.tiun-record-confirm-actions button {
|
|
98
101
|
box-sizing: border-box;
|
|
@@ -110,21 +113,18 @@
|
|
|
110
113
|
box-shadow: none;
|
|
111
114
|
cursor: pointer;
|
|
112
115
|
}
|
|
113
|
-
.tiun-modal .tiun-modal-footer button[type="submit"]
|
|
114
|
-
.tiun-modal .tiun-confirm button[type="submit"] {
|
|
116
|
+
.tiun-modal :is(.tiun-modal-footer, .tiun-form-actions, .tiun-confirm) button[type="submit"] {
|
|
115
117
|
color: var(--tiun-action-color, #fff);
|
|
116
118
|
background: var(--tiun-accent, #285b57);
|
|
117
119
|
border-color: var(--tiun-accent, #285b57);
|
|
118
120
|
}
|
|
119
|
-
.tiun-modal .tiun-modal-footer button:focus-visible,
|
|
120
|
-
.tiun-modal .tiun-confirm button:focus-visible,
|
|
121
|
+
.tiun-modal :is(.tiun-modal-footer, .tiun-form-actions, .tiun-confirm) button:focus-visible,
|
|
121
122
|
.tiun-attachment-control > button:focus-visible,
|
|
122
123
|
.tiun-record-confirm-actions button:focus-visible {
|
|
123
124
|
outline: 0.12rem solid var(--tiun-accent, #285b57);
|
|
124
125
|
outline-offset: 0.12rem;
|
|
125
126
|
}
|
|
126
|
-
.tiun-modal .tiun-modal-footer button:disabled,
|
|
127
|
-
.tiun-modal .tiun-confirm button:disabled,
|
|
127
|
+
.tiun-modal :is(.tiun-modal-footer, .tiun-form-actions, .tiun-confirm) button:disabled,
|
|
128
128
|
.tiun-attachment-control > button:disabled {
|
|
129
129
|
opacity: 0.6;
|
|
130
130
|
cursor: wait;
|
|
@@ -1423,6 +1423,7 @@ button[data-action-state="saved"] {
|
|
|
1423
1423
|
padding-inline-end: 5rem;
|
|
1424
1424
|
}
|
|
1425
1425
|
|
|
1426
|
+
.tiun-form > fieldset:disabled .tiun-field,
|
|
1426
1427
|
fieldset[data-tiun-disabled="true"] > .tiun-field {
|
|
1427
1428
|
opacity: 0.6;
|
|
1428
1429
|
}
|
|
@@ -38,6 +38,8 @@ export interface FieldMeta {
|
|
|
38
38
|
readonly onBlur?: boolean;
|
|
39
39
|
readonly onEnter?: boolean;
|
|
40
40
|
readonly onSwitch?: SwitchMethod;
|
|
41
|
+
/** The appearance form displays the active theme from its context. */
|
|
42
|
+
readonly sharedTheme?: boolean;
|
|
41
43
|
readonly values?: readonly [string, string, string];
|
|
42
44
|
readonly pics?: readonly [StockeeAsset, StockeeAsset];
|
|
43
45
|
readonly min?: number;
|
data/src/components/image.scss
CHANGED
|
@@ -41,12 +41,16 @@
|
|
|
41
41
|
.tiun-image-description {
|
|
42
42
|
margin-top: 0.5rem;
|
|
43
43
|
}
|
|
44
|
-
.tiun-image-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
.tiun-image-quiet[data-image-state="loading"],
|
|
45
|
+
.tiun-image[data-image-reserve="true"]:not([data-image-state="loaded"]) {
|
|
46
|
+
visibility: hidden;
|
|
47
|
+
}
|
|
48
|
+
.tiun-image[data-image-reserve="false"][data-image-state="loading"],
|
|
49
|
+
.tiun-record-stack .tiun-image-quiet[data-image-state="loading"]:has(img:not([loading="lazy"])) {
|
|
50
|
+
display: none;
|
|
47
51
|
}
|
|
48
|
-
.tiun-image-
|
|
49
|
-
|
|
52
|
+
.tiun-image[data-image-reserve="true"][data-image-state="loading"] img {
|
|
53
|
+
position: absolute;
|
|
50
54
|
}
|
|
51
55
|
.tiun-image-link:focus-visible {
|
|
52
56
|
outline: 0.15rem solid currentColor;
|
|
@@ -60,8 +64,7 @@
|
|
|
60
64
|
position: absolute;
|
|
61
65
|
inset: 0;
|
|
62
66
|
}
|
|
63
|
-
.tiun-image-card figcaption :is(a, button)
|
|
64
|
-
.tiun-image-card .tiun-image-retry {
|
|
67
|
+
.tiun-image-card figcaption :is(a, button) {
|
|
65
68
|
position: relative;
|
|
66
69
|
z-index: 1;
|
|
67
70
|
}
|
data/src/components/records.scss
CHANGED
|
@@ -84,6 +84,10 @@
|
|
|
84
84
|
display: grid;
|
|
85
85
|
grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--tiun-record-width, 10rem)), 1fr));
|
|
86
86
|
}
|
|
87
|
+
// Keep the viewport at the previous tiles when quiet images reflow the stack.
|
|
88
|
+
body:has(.tiun-record-stack :is(.tiun-image-quiet, [data-image-reserve])) {
|
|
89
|
+
overflow-anchor: none;
|
|
90
|
+
}
|
|
87
91
|
.tiun-record-stack {
|
|
88
92
|
position: relative;
|
|
89
93
|
}
|
|
@@ -219,6 +219,7 @@ html[data-theme="dark"] {
|
|
|
219
219
|
--tiun-calendar-active-type: #18645e;
|
|
220
220
|
--tiun-calendar-today: #235b80;
|
|
221
221
|
--tiun-calendar-selected: #22695e;
|
|
222
|
+
--tiun-calendar-today-selected-ring: #7ed9cc;
|
|
222
223
|
--tiun-calendar-focus: #8bd1c1;
|
|
223
224
|
.tiun-calendar-types button {
|
|
224
225
|
background-color: #29434e;
|
data/src/concern/application.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { useI18n } from "./i18n.js";
|
|
|
9
9
|
|
|
10
10
|
export interface ApplicationState<User extends SessionUser = SessionUser> {
|
|
11
11
|
readonly user: User | null;
|
|
12
|
+
readonly sessionPending?: boolean;
|
|
12
13
|
readonly meta: ServerMeta;
|
|
13
14
|
readonly ready: boolean;
|
|
14
15
|
readonly configuration: ApplicationConfiguration;
|
|
@@ -19,8 +20,8 @@ export interface ApplicationState<User extends SessionUser = SessionUser> {
|
|
|
19
20
|
readonly recordCache?: Map<string, FormData>;
|
|
20
21
|
readonly storeUser: (owner: string, record: FormData) => void;
|
|
21
22
|
readonly renewSession: () => Promise<void>;
|
|
22
|
-
readonly login: (user: User) => void
|
|
23
|
-
readonly logout: () => void
|
|
23
|
+
readonly login: (user: User) => void | Promise<void>;
|
|
24
|
+
readonly logout: () => void | Promise<void>;
|
|
24
25
|
readonly reload: () => void;
|
|
25
26
|
readonly notify?: (message: string) => void;
|
|
26
27
|
}
|
|
@@ -36,6 +36,7 @@ function selectPageRows<T>(payload: unknown): readonly T[] {
|
|
|
36
36
|
* @param list Prepared list definition.
|
|
37
37
|
* @param record Source data passed to the list's preparation method.
|
|
38
38
|
* @param props Optional pagination and rendering properties.
|
|
39
|
+
* @param instancePagination Optional pagination mode and loading indicator from the component reference.
|
|
39
40
|
* @returns Effective list properties when the item definition is valid.
|
|
40
41
|
*/
|
|
41
42
|
export function spansViewProps<T>(
|
|
@@ -43,6 +44,7 @@ export function spansViewProps<T>(
|
|
|
43
44
|
list: SchemaViewMeta<T>,
|
|
44
45
|
record: T,
|
|
45
46
|
props: ListOptions<T>,
|
|
47
|
+
instancePagination?: unknown,
|
|
46
48
|
): SpansProps<T> | undefined {
|
|
47
49
|
const prepared = schema.prepare(list.prepare, record);
|
|
48
50
|
const data = (Array.isArray(prepared) ? { items: prepared } : prepared) as PreparedPage<T> | undefined;
|
|
@@ -78,6 +80,17 @@ export function spansViewProps<T>(
|
|
|
78
80
|
source: { config: { params: data.params }, select: selectPageRows<T>, url: data.path },
|
|
79
81
|
};
|
|
80
82
|
}
|
|
83
|
+
const pagination = { ...page, ...list.pagination };
|
|
84
|
+
if (object(instancePagination)) {
|
|
85
|
+
const { kind, showLoading } = instancePagination;
|
|
86
|
+
if (kind === "button" || kind === "hidden") {
|
|
87
|
+
pagination.kind = kind;
|
|
88
|
+
}
|
|
89
|
+
if (typeof showLoading === "boolean") {
|
|
90
|
+
pagination.showLoading = showLoading;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
81
94
|
return {
|
|
82
95
|
...props,
|
|
83
96
|
...expansion,
|
|
@@ -94,7 +107,7 @@ export function spansViewProps<T>(
|
|
|
94
107
|
getKey,
|
|
95
108
|
headerClassName: list.headerClassName ?? props.headerClassName ?? "",
|
|
96
109
|
hideIfEmpty: list.hideIfEmpty ?? data.hideIfEmpty ?? props.hideIfEmpty ?? false,
|
|
97
|
-
pagination
|
|
110
|
+
pagination,
|
|
98
111
|
renderBody: (value) => (item.body?.length ? <Row value={value} columns={item.body} flow_kind="flex" /> : null),
|
|
99
112
|
rowClassName: list.rowClassName ?? "",
|
|
100
113
|
span: (value) => spanOptions(schema, item, value),
|
|
@@ -31,6 +31,7 @@ const inactive: RecordsRequest = {
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Loads the configured list and refreshes it when the parent revision changes.
|
|
34
|
+
* - Retains table rows for replacement reads of the current resource.
|
|
34
35
|
* @param request The configured resource, filters and page settings.
|
|
35
36
|
* @param onPage Receives accepted records and indicates whether to replace them.
|
|
36
37
|
* @returns Request state and pagination controls.
|
|
@@ -46,6 +47,7 @@ export function useRecordsResource(
|
|
|
46
47
|
const pages = useRecordPages<unknown>({
|
|
47
48
|
...(operation ? { source: { config: { params }, url: recordPath(operation, undefined, parameters) } } : {}),
|
|
48
49
|
enabled: Boolean(operation),
|
|
50
|
+
keepPreviousOnReload: node.view === "table",
|
|
49
51
|
onPage,
|
|
50
52
|
pageSize,
|
|
51
53
|
queryKey: query,
|
|
@@ -62,6 +62,8 @@ export function withField<P extends FieldProps>(Component: ComponentType<P>): Co
|
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* Подключает поле к форме, наследует её блокировку и применяет явный обработчик.
|
|
65
|
+
* - Форма блокирует поля общим fieldset и сохраняет их положение в сетке.
|
|
66
|
+
* - Явно заблокированное одиночное поле получает собственный fieldset.
|
|
65
67
|
* @param props Свойства поля.
|
|
66
68
|
* @returns Поле с действующим контекстом.
|
|
67
69
|
*/
|
|
@@ -77,13 +79,14 @@ export function withField<P extends FieldProps>(Component: ComponentType<P>): Co
|
|
|
77
79
|
) : (
|
|
78
80
|
<Component {...fieldProps} />
|
|
79
81
|
);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
if (disabled && context?.disabled !== true) {
|
|
83
|
+
return (
|
|
84
|
+
<fieldset disabled data-tiun-disabled="true" style={{ display: "contents" }}>
|
|
85
|
+
{field}
|
|
86
|
+
</fieldset>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
return field;
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
Field.displayName = `Field(${Component.displayName ?? Component.name ?? "Field"})`;
|
data/src/decorators/withForm.tsx
CHANGED
|
@@ -89,13 +89,19 @@ export function withForm(Form: ComponentType<FormProps>) {
|
|
|
89
89
|
}
|
|
90
90
|
throw new TypeError(`${name}.form: unknown form ${String(form)}`);
|
|
91
91
|
}, [schema, form, fields, name]),
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
// eslint-disable-next-line sort-vars -- Resolve the theme control before using it to select the write path.
|
|
93
|
+
isThemeSwitch =
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers -- Only the dedicated one-field form autosaves.
|
|
95
|
+
Object.keys(suppliedFields).length === 1 &&
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types -- Field metadata contains React render callbacks.
|
|
97
|
+
Object.values(suppliedFields).some(({ onSwitch }) => onSwitch === methods.change_theme.onSwitch),
|
|
95
98
|
isAppearanceSwitch = Boolean(isThemeSwitch && relatedTheme?.configuration.resource && profile),
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
// eslint-disable-next-line sort-vars -- Keep the persisted baseline separate from the theme preview.
|
|
100
|
+
formAppearance =
|
|
101
|
+
// eslint-disable-next-line no-ternary -- An appearance resource owns the persisted baseline.
|
|
102
|
+
typeof relatedTheme?.configuration.resource === "string"
|
|
103
|
+
? relatedTheme.savedAppearance
|
|
104
|
+
: appearanceTheme?.appearance,
|
|
99
105
|
transitionData = object(currentRoute?.location.state) ? currentRoute.location.state : empty,
|
|
100
106
|
value =
|
|
101
107
|
definition.data === undefined
|
data/src/schema/Schema.ts
CHANGED
|
@@ -161,6 +161,7 @@ export interface SchemaViewMeta<T> {
|
|
|
161
161
|
readonly openCommand?: string;
|
|
162
162
|
readonly source?: string;
|
|
163
163
|
readonly viewAs?: "plain" | "card";
|
|
164
|
+
readonly reserveSpace?: boolean;
|
|
164
165
|
readonly description?: string;
|
|
165
166
|
readonly width?: string | number;
|
|
166
167
|
readonly height?: string | number;
|
|
@@ -205,6 +206,7 @@ export interface SchemaViewMeta<T> {
|
|
|
205
206
|
readonly body?: readonly RecordColumn<T>[];
|
|
206
207
|
readonly pagination?: {
|
|
207
208
|
readonly kind?: "hidden" | "button";
|
|
209
|
+
readonly showLoading?: boolean;
|
|
208
210
|
readonly autoloadUpto?: number;
|
|
209
211
|
readonly pageSize?: number;
|
|
210
212
|
readonly buttonStyle?: "text" | "circle";
|
|
@@ -934,6 +936,7 @@ export class Schema<T> {
|
|
|
934
936
|
minHeight: typeof view.minHeight === "number" ? view.minHeight : undefined,
|
|
935
937
|
native: typeof view.native === "boolean" ? view.native : undefined,
|
|
936
938
|
path: typeof targetBinding === "string" && !usesAbsoluteUrl ? targetBinding : undefined,
|
|
939
|
+
reserveSpace: typeof view.reserveSpace === "boolean" ? view.reserveSpace : undefined,
|
|
937
940
|
src: viewSource,
|
|
938
941
|
title,
|
|
939
942
|
tooltip: tooltip.content,
|
|
@@ -1828,6 +1831,9 @@ export class Schema<T> {
|
|
|
1828
1831
|
result.props = value.props;
|
|
1829
1832
|
}
|
|
1830
1833
|
if (element === "image") {
|
|
1834
|
+
if (typeof value.reserve_space === "boolean") {
|
|
1835
|
+
result.reserveSpace = value.reserve_space;
|
|
1836
|
+
}
|
|
1831
1837
|
if (value.view_as === "plain" || value.view_as === "card") {
|
|
1832
1838
|
result.viewAs = value.view_as;
|
|
1833
1839
|
}
|
|
@@ -1902,6 +1908,7 @@ export class Schema<T> {
|
|
|
1902
1908
|
if (isData(value.pagination)) {
|
|
1903
1909
|
const pagination: {
|
|
1904
1910
|
kind?: "hidden" | "button";
|
|
1911
|
+
showLoading?: boolean;
|
|
1905
1912
|
autoloadUpto?: number;
|
|
1906
1913
|
pageSize?: number;
|
|
1907
1914
|
buttonStyle?: "text" | "circle";
|
|
@@ -1910,6 +1917,9 @@ export class Schema<T> {
|
|
|
1910
1917
|
if (value.pagination.kind === "hidden" || value.pagination.kind === "button") {
|
|
1911
1918
|
pagination.kind = value.pagination.kind;
|
|
1912
1919
|
}
|
|
1920
|
+
if (typeof value.pagination.show_loading === "boolean") {
|
|
1921
|
+
pagination.showLoading = value.pagination.show_loading;
|
|
1922
|
+
}
|
|
1913
1923
|
if (Number.isSafeInteger(value.pagination.autoload_upto) && Number(value.pagination.autoload_upto) > 0) {
|
|
1914
1924
|
pagination.autoloadUpto = Number(value.pagination.autoload_upto);
|
|
1915
1925
|
}
|