@blueprint-ts/core 4.1.0-beta.6 → 5.0.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.
Files changed (62) hide show
  1. package/dist/bulkRequests/BulkRequestSender.js +81 -102
  2. package/dist/bulkRequests/BulkRequestWrapper.js +16 -26
  3. package/dist/laravel/pagination/dataDrivers/RequestDriver.js +1 -0
  4. package/dist/pagination/BasePaginator.js +4 -4
  5. package/dist/pagination/PageAwarePaginator.js +4 -1
  6. package/dist/pagination/StatePaginator.js +6 -3
  7. package/dist/pagination/dataDrivers/ArrayDriver.js +1 -0
  8. package/dist/pagination/dtos/PaginationDataDto.js +2 -0
  9. package/dist/pagination/dtos/StatePaginationDataDto.js +1 -0
  10. package/dist/pagination/frontendDrivers/VueBaseViewDriver.js +2 -0
  11. package/dist/pagination/frontendDrivers/VuePaginationDriver.js +6 -0
  12. package/dist/persistenceDrivers/LocalStorageDriver.js +1 -0
  13. package/dist/persistenceDrivers/MemoryPersistenceDriver.js +2 -1
  14. package/dist/persistenceDrivers/SessionStorageDriver.js +1 -0
  15. package/dist/requests/BaseRequest.js +93 -100
  16. package/dist/requests/ErrorHandler.js +21 -31
  17. package/dist/requests/RequestErrorRouter.js +12 -25
  18. package/dist/requests/bodies/BinaryBody.js +2 -0
  19. package/dist/requests/bodies/FormDataBody.js +1 -0
  20. package/dist/requests/bodies/JsonBody.js +1 -0
  21. package/dist/requests/drivers/fetch/FetchDriver.js +26 -26
  22. package/dist/requests/drivers/fetch/FetchResponse.js +7 -21
  23. package/dist/requests/drivers/mock/MockRequestDriver.js +190 -169
  24. package/dist/requests/drivers/mock/MockRequestTestHelpers.js +10 -4
  25. package/dist/requests/drivers/mock/MockResponseHandler.js +12 -23
  26. package/dist/requests/drivers/xhr/XMLHttpRequestDriver.js +68 -74
  27. package/dist/requests/drivers/xhr/XMLHttpRequestResponse.js +9 -21
  28. package/dist/requests/exceptions/InvalidJsonException.js +1 -0
  29. package/dist/requests/exceptions/ResponseBodyException.js +1 -0
  30. package/dist/requests/exceptions/ResponseException.js +1 -0
  31. package/dist/requests/exceptions/StaleResponseException.js +1 -0
  32. package/dist/requests/factories/BinaryBodyFactory.js +1 -0
  33. package/dist/requests/responses/BaseResponse.js +9 -21
  34. package/dist/requests/responses/BlobResponse.js +1 -0
  35. package/dist/support/DeferredPromise.js +5 -4
  36. package/dist/vue/composables/useConfirmDialog.js +7 -18
  37. package/dist/vue/composables/useGlobalCheckbox.js +55 -66
  38. package/dist/vue/forms/BaseForm.d.ts +11 -8
  39. package/dist/vue/forms/BaseForm.js +153 -149
  40. package/dist/vue/forms/PropertyAwareArray.js +0 -1
  41. package/dist/vue/forms/PropertyAwareObject.js +4 -2
  42. package/dist/vue/forms/index.d.ts +2 -2
  43. package/dist/vue/forms/persistence/types.d.ts +2 -0
  44. package/dist/vue/forms/validation/rules/BaseRule.js +3 -16
  45. package/dist/vue/forms/validation/rules/ConfirmedRule.js +2 -0
  46. package/dist/vue/forms/validation/rules/EmailRule.js +1 -0
  47. package/dist/vue/forms/validation/rules/JsonRule.js +2 -1
  48. package/dist/vue/forms/validation/rules/MinRule.js +2 -0
  49. package/dist/vue/forms/validation/rules/PrecognitiveRule.js +21 -31
  50. package/dist/vue/forms/validation/rules/RequiredRule.js +1 -0
  51. package/dist/vue/forms/validation/rules/UrlRule.js +2 -1
  52. package/dist/vue/requests/loaders/VueRequestBatchLoader.js +3 -3
  53. package/dist/vue/requests/loaders/VueRequestLoader.js +1 -0
  54. package/dist/vue/router/routeResourceBinding/RouteResourceBoundView.js +8 -18
  55. package/dist/vue/router/routeResourceBinding/RouteResourceRequestResolver.js +4 -14
  56. package/dist/vue/router/routeResourceBinding/defineRoute.js +8 -7
  57. package/dist/vue/router/routeResourceBinding/installRouteInjection.js +12 -21
  58. package/dist/vue/router/routeResourceBinding/useRouteResource.js +5 -17
  59. package/dist/vue/state/State.d.ts +2 -0
  60. package/dist/vue/state/State.js +24 -11
  61. package/dist/vue/state/index.d.ts +2 -1
  62. package/package.json +27 -27
@@ -1,97 +1,91 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { ResponseException } from '../../exceptions/ResponseException';
11
2
  import { RequestMethodEnum } from '../../RequestMethod.enum';
12
3
  import { XMLHttpRequestResponse } from './XMLHttpRequestResponse';
13
4
  export class XMLHttpRequestDriver {
5
+ config;
14
6
  constructor(config) {
15
7
  this.config = config;
16
8
  }
17
- send(url, method, headers, body, requestConfig) {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- var _a;
20
- const mergedConfig = Object.assign(Object.assign({}, this.config), (requestConfig !== null && requestConfig !== void 0 ? requestConfig : {}));
21
- const mergedHeaders = Object.assign(Object.assign(Object.assign({}, (_a = this.config) === null || _a === void 0 ? void 0 : _a.headers), headers), body === null || body === void 0 ? void 0 : body.getHeaders());
22
- const resolvedHeaders = this.resolveHeaders(mergedHeaders);
23
- return yield new Promise((resolve, reject) => {
24
- const request = new XMLHttpRequest();
25
- const requestUrl = url instanceof URL ? url.toString() : url;
26
- const requestBody = [RequestMethodEnum.GET, RequestMethodEnum.HEAD].includes(method) ? undefined : body === null || body === void 0 ? void 0 : body.getContent();
27
- const abortSignal = mergedConfig.abortSignal;
28
- const handleAbortSignal = () => request.abort();
29
- const cleanup = () => {
30
- request.onload = null;
31
- request.onerror = null;
32
- request.onabort = null;
33
- if (request.upload) {
34
- request.upload.onprogress = null;
35
- }
36
- abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.removeEventListener('abort', handleAbortSignal);
37
- };
38
- request.open(method, requestUrl, true);
39
- request.responseType = 'blob';
40
- request.withCredentials = this.getCorsWithCredentials(mergedConfig.corsWithCredentials);
41
- for (const key in resolvedHeaders) {
42
- request.setRequestHeader(key, resolvedHeaders[key]);
43
- }
44
- request.onload = () => {
45
- cleanup();
46
- if (request.status === 0) {
47
- reject(new Error('No response received.'));
48
- return;
49
- }
50
- const response = new XMLHttpRequestResponse(request);
51
- if (request.status < 200 || request.status >= 300) {
52
- reject(new ResponseException(response));
53
- return;
54
- }
55
- resolve(response);
56
- };
57
- request.onerror = () => {
58
- cleanup();
59
- reject(new Error('Network request failed.'));
60
- };
61
- request.onabort = () => {
62
- cleanup();
63
- reject(new DOMException('The operation was aborted.', 'AbortError'));
64
- };
9
+ async send(url, method, headers, body, requestConfig) {
10
+ const mergedConfig = {
11
+ ...this.config,
12
+ ...(requestConfig ?? {})
13
+ };
14
+ const mergedHeaders = {
15
+ ...this.config?.headers,
16
+ ...headers,
17
+ ...body?.getHeaders()
18
+ };
19
+ const resolvedHeaders = this.resolveHeaders(mergedHeaders);
20
+ return await new Promise((resolve, reject) => {
21
+ const request = new XMLHttpRequest();
22
+ const requestUrl = url instanceof URL ? url.toString() : url;
23
+ const requestBody = [RequestMethodEnum.GET, RequestMethodEnum.HEAD].includes(method) ? undefined : body?.getContent();
24
+ const abortSignal = mergedConfig.abortSignal;
25
+ const handleAbortSignal = () => request.abort();
26
+ const cleanup = () => {
27
+ request.onload = null;
28
+ request.onerror = null;
29
+ request.onabort = null;
65
30
  if (request.upload) {
66
- request.upload.onprogress = (event) => {
67
- var _a;
68
- const total = event.lengthComputable ? event.total : undefined;
69
- (_a = mergedConfig.onUploadProgress) === null || _a === void 0 ? void 0 : _a.call(mergedConfig, {
70
- loaded: event.loaded,
71
- total: total,
72
- lengthComputable: event.lengthComputable,
73
- progress: total === undefined || total === 0 ? undefined : event.loaded / total
74
- });
75
- };
31
+ request.upload.onprogress = null;
76
32
  }
77
- if (abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted) {
78
- handleAbortSignal();
33
+ abortSignal?.removeEventListener('abort', handleAbortSignal);
34
+ };
35
+ request.open(method, requestUrl, true);
36
+ request.responseType = 'blob';
37
+ request.withCredentials = this.getCorsWithCredentials(mergedConfig.corsWithCredentials);
38
+ for (const key in resolvedHeaders) {
39
+ request.setRequestHeader(key, resolvedHeaders[key]);
40
+ }
41
+ request.onload = () => {
42
+ cleanup();
43
+ if (request.status === 0) {
44
+ reject(new Error('No response received.'));
79
45
  return;
80
46
  }
81
- abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.addEventListener('abort', handleAbortSignal, { once: true });
82
- request.send(requestBody);
83
- });
47
+ const response = new XMLHttpRequestResponse(request);
48
+ if (request.status < 200 || request.status >= 300) {
49
+ reject(new ResponseException(response));
50
+ return;
51
+ }
52
+ resolve(response);
53
+ };
54
+ request.onerror = () => {
55
+ cleanup();
56
+ reject(new Error('Network request failed.'));
57
+ };
58
+ request.onabort = () => {
59
+ cleanup();
60
+ reject(new DOMException('The operation was aborted.', 'AbortError'));
61
+ };
62
+ if (request.upload) {
63
+ request.upload.onprogress = (event) => {
64
+ const total = event.lengthComputable ? event.total : undefined;
65
+ mergedConfig.onUploadProgress?.({
66
+ loaded: event.loaded,
67
+ total: total,
68
+ lengthComputable: event.lengthComputable,
69
+ progress: total === undefined || total === 0 ? undefined : event.loaded / total
70
+ });
71
+ };
72
+ }
73
+ if (abortSignal?.aborted) {
74
+ handleAbortSignal();
75
+ return;
76
+ }
77
+ abortSignal?.addEventListener('abort', handleAbortSignal, { once: true });
78
+ request.send(requestBody);
84
79
  });
85
80
  }
86
81
  getCorsWithCredentials(corsWithCredentials) {
87
- var _a, _b;
88
82
  if (corsWithCredentials === true) {
89
83
  return true;
90
84
  }
91
85
  if (corsWithCredentials === false) {
92
86
  return false;
93
87
  }
94
- return (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.corsWithCredentials) !== null && _b !== void 0 ? _b : false;
88
+ return this.config?.corsWithCredentials ?? false;
95
89
  }
96
90
  resolveHeaders(headers) {
97
91
  const resolved = {};
@@ -1,13 +1,7 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  export class XMLHttpRequestResponse {
2
+ request;
3
+ response;
4
+ headers;
11
5
  constructor(request) {
12
6
  this.request = request;
13
7
  this.headers = this.parseHeaders(request.getAllResponseHeaders());
@@ -26,20 +20,14 @@ export class XMLHttpRequestResponse {
26
20
  getRawResponse() {
27
21
  return this.response;
28
22
  }
29
- json() {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- return yield this.response.json();
32
- });
23
+ async json() {
24
+ return await this.response.json();
33
25
  }
34
- text() {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- return yield this.response.text();
37
- });
26
+ async text() {
27
+ return await this.response.text();
38
28
  }
39
- blob() {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- return yield this.response.blob();
42
- });
29
+ async blob() {
30
+ return await this.response.blob();
43
31
  }
44
32
  getResponseBody() {
45
33
  if ([204, 205, 304].includes(this.request.status)) {
@@ -1,5 +1,6 @@
1
1
  import { ResponseException } from './ResponseException';
2
2
  export class InvalidJsonException extends ResponseException {
3
+ cause;
3
4
  constructor(response, cause) {
4
5
  super(response);
5
6
  this.cause = cause;
@@ -1,5 +1,6 @@
1
1
  import { ResponseException } from './ResponseException';
2
2
  export class ResponseBodyException extends ResponseException {
3
+ body;
3
4
  constructor(response, body) {
4
5
  super(response);
5
6
  this.body = body;
@@ -1,4 +1,5 @@
1
1
  export class ResponseException extends Error {
2
+ response;
2
3
  constructor(response) {
3
4
  super();
4
5
  this.response = response;
@@ -1,4 +1,5 @@
1
1
  export class StaleResponseException extends Error {
2
+ cause;
2
3
  constructor(message = 'Stale response ignored', cause) {
3
4
  super(message);
4
5
  this.name = 'StaleResponseException';
@@ -1,5 +1,6 @@
1
1
  import { BinaryBody } from '../bodies/BinaryBody';
2
2
  export class BinaryBodyFactory {
3
+ contentType;
3
4
  constructor(contentType) {
4
5
  this.contentType = contentType;
5
6
  }
@@ -1,31 +1,19 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  export class BaseResponse {
11
- setResponse(response) {
12
- return __awaiter(this, void 0, void 0, function* () {
13
- this.response = response;
14
- this.body = yield this.resolveBody();
15
- return this.body;
16
- });
2
+ body;
3
+ response;
4
+ async setResponse(response) {
5
+ this.response = response;
6
+ this.body = await this.resolveBody();
7
+ return this.body;
17
8
  }
18
9
  getRawResponse() {
19
- var _a;
20
- return (_a = this.response) === null || _a === void 0 ? void 0 : _a.getRawResponse();
10
+ return this.response?.getRawResponse();
21
11
  }
22
12
  getStatusCode() {
23
- var _a;
24
- return (_a = this.response) === null || _a === void 0 ? void 0 : _a.getStatusCode();
13
+ return this.response?.getStatusCode();
25
14
  }
26
15
  getHeaders() {
27
- var _a;
28
- return (_a = this.response) === null || _a === void 0 ? void 0 : _a.getHeaders();
16
+ return this.response?.getHeaders();
29
17
  }
30
18
  getBody() {
31
19
  if (this.body === undefined) {
@@ -1,5 +1,6 @@
1
1
  import { BaseResponse } from './BaseResponse';
2
2
  export class BlobResponse extends BaseResponse {
3
+ mimeType;
3
4
  constructor(mimeType = 'application/octet-stream') {
4
5
  super();
5
6
  this.mimeType = mimeType;
@@ -1,4 +1,3 @@
1
- var _a;
2
1
  /**
3
2
  * A new instance of deferred is constructed by calling `new DeferredPromse<T>()`.
4
3
  * The purpose of the deferred object is to expose the associated Promise
@@ -23,12 +22,15 @@ var _a;
23
22
  * https://gist.github.com/GFoley83/5877f6c09fbcfd62569c51dc91444cf0
24
23
  */
25
24
  export class DeferredPromise {
25
+ [Symbol.toStringTag] = 'Promise';
26
+ _promise;
27
+ _resolve;
28
+ _reject;
29
+ _state = 'pending';
26
30
  get state() {
27
31
  return this._state;
28
32
  }
29
33
  constructor() {
30
- this[_a] = 'Promise';
31
- this._state = 'pending';
32
34
  this._promise = new Promise((resolve, reject) => {
33
35
  this._resolve = resolve;
34
36
  this._reject = reject;
@@ -52,4 +54,3 @@ export class DeferredPromise {
52
54
  this._state = 'rejected';
53
55
  }
54
56
  }
55
- _a = Symbol.toStringTag;
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { getCurrentInstance, h, onUnmounted, render } from 'vue';
11
2
  export var ConfirmDialogSeverity;
12
3
  (function (ConfirmDialogSeverity) {
@@ -24,7 +15,7 @@ export default function (confirmDialogComponent, querySelector = 'body') {
24
15
  * https://stackoverflow.com/a/78448128
25
16
  */
26
17
  function mountConfirmDialog(options) {
27
- if (!(self === null || self === void 0 ? void 0 : self.appContext)) {
18
+ if (!self?.appContext) {
28
19
  throw new Error('ConfirmationDialog: useConfirmDialog must be called inside a setup function');
29
20
  }
30
21
  const vNode = h(confirmDialogComponent, { options });
@@ -39,14 +30,12 @@ export default function (confirmDialogComponent, querySelector = 'body') {
39
30
  onUnmounted(() => {
40
31
  unmountConfirmDialog();
41
32
  });
42
- function openConfirmDialog(options) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- const dialogComponent = mountConfirmDialog(options);
45
- if ((dialogComponent === null || dialogComponent === void 0 ? void 0 : dialogComponent.exposed) == undefined || (dialogComponent === null || dialogComponent === void 0 ? void 0 : dialogComponent.exposed['open']) === undefined) {
46
- throw new Error('ConfirmationDialog: Provided component does not expose an "open" method');
47
- }
48
- return dialogComponent === null || dialogComponent === void 0 ? void 0 : dialogComponent.exposed['open'];
49
- });
33
+ async function openConfirmDialog(options) {
34
+ const dialogComponent = mountConfirmDialog(options);
35
+ if (dialogComponent?.exposed == undefined || dialogComponent?.exposed['open'] === undefined) {
36
+ throw new Error('ConfirmationDialog: Provided component does not expose an "open" method');
37
+ }
38
+ return dialogComponent?.exposed['open'];
50
39
  }
51
40
  return { openConfirmDialog };
52
41
  }
@@ -1,18 +1,9 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { getCurrentInstance, shallowRef, computed, h, render, onUnmounted } from 'vue';
11
2
  export default function (dialog, options, querySelector = 'body') {
12
3
  const self = getCurrentInstance();
13
4
  const selectedRows = shallowRef([]);
14
5
  function mountDialog() {
15
- if (!(self === null || self === void 0 ? void 0 : self.appContext)) {
6
+ if (!self?.appContext) {
16
7
  throw new Error('useGlobalCheckbox must be called inside a setup function');
17
8
  }
18
9
  const vNode = h(dialog, {
@@ -49,70 +40,68 @@ export default function (dialog, options, querySelector = 'body') {
49
40
  const isAllElementsOnCurrentPage = () => {
50
41
  return options.getPage().length === options.totalCount();
51
42
  };
52
- function handleGlobalCheckboxChange(event) {
53
- return __awaiter(this, void 0, void 0, function* () {
54
- if (!(event.target instanceof HTMLInputElement)) {
43
+ async function handleGlobalCheckboxChange(event) {
44
+ if (!(event.target instanceof HTMLInputElement)) {
45
+ return;
46
+ }
47
+ const pageData = options.getPage();
48
+ // If all elements are on the current page, we can skip the dialog
49
+ // as both options would result in the same selection
50
+ const allElementsOnPage = isAllElementsOnCurrentPage();
51
+ // Case 1: Nothing is selected (unchecked state)
52
+ if (!checked.value && !indeterminate.value) {
53
+ if (allElementsOnPage) {
54
+ // All elements are already on the current page, just select them
55
+ selectedRows.value = [...pageData];
55
56
  return;
56
57
  }
57
- const pageData = options.getPage();
58
- // If all elements are on the current page, we can skip the dialog
59
- // as both options would result in the same selection
60
- const allElementsOnPage = isAllElementsOnCurrentPage();
61
- // Case 1: Nothing is selected (unchecked state)
62
- if (!checked.value && !indeterminate.value) {
63
- if (allElementsOnPage) {
64
- // All elements are already on the current page, just select them
65
- selectedRows.value = [...pageData];
66
- return;
67
- }
68
- // We need preventDefault() here because we're showing a dialog
69
- // and don't want the checkbox to be checked until the user makes a choice
70
- event.preventDefault();
71
- const mountedDialog = mountDialog();
72
- if (!(mountedDialog === null || mountedDialog === void 0 ? void 0 : mountedDialog.exposed))
73
- return;
74
- // When clicking the empty checkbox, ask if user wants current page or all entries
75
- if (yield mountedDialog.exposed['open']) {
76
- // User clicked "All Elements" button
77
- selectedRows.value = yield options.getAll();
78
- }
79
- else {
80
- // User clicked "Current Page" button
81
- selectedRows.value = [...pageData];
82
- }
58
+ // We need preventDefault() here because we're showing a dialog
59
+ // and don't want the checkbox to be checked until the user makes a choice
60
+ event.preventDefault();
61
+ const mountedDialog = mountDialog();
62
+ if (!mountedDialog?.exposed)
83
63
  return;
64
+ // When clicking the empty checkbox, ask if user wants current page or all entries
65
+ if (await mountedDialog.exposed['open']) {
66
+ // User clicked "All Elements" button
67
+ selectedRows.value = await options.getAll();
68
+ }
69
+ else {
70
+ // User clicked "Current Page" button
71
+ selectedRows.value = [...pageData];
84
72
  }
85
- // Case 2: Indeterminate state (some items selected, not all)
86
- if (indeterminate.value) {
87
- if (allElementsOnPage) {
88
- // If all elements are on the page, just select them all
89
- selectedRows.value = [...pageData];
90
- return;
91
- }
92
- // We need preventDefault() here because we're showing a dialog
93
- // and don't want the checkbox to be checked until the user makes a choice
94
- event.preventDefault();
95
- const mountedDialog = mountDialog();
96
- if (!(mountedDialog === null || mountedDialog === void 0 ? void 0 : mountedDialog.exposed))
97
- return;
98
- // When clicking the indeterminate checkbox, ask if the user wants all entries or unselect all
99
- if (yield mountedDialog.exposed['open']) {
100
- // User clicked "All Elements" button
101
- selectedRows.value = yield options.getAll();
102
- }
103
- else {
104
- // User clicked "Discard" button
105
- selectedRows.value = [];
106
- }
73
+ return;
74
+ }
75
+ // Case 2: Indeterminate state (some items selected, not all)
76
+ if (indeterminate.value) {
77
+ if (allElementsOnPage) {
78
+ // If all elements are on the page, just select them all
79
+ selectedRows.value = [...pageData];
107
80
  return;
108
81
  }
109
- // Case 3: Checked state (all items selected)
110
- if (checked.value) {
111
- // When all items are selected, we just clear the selection without a dialog
112
- selectedRows.value = [];
82
+ // We need preventDefault() here because we're showing a dialog
83
+ // and don't want the checkbox to be checked until the user makes a choice
84
+ event.preventDefault();
85
+ const mountedDialog = mountDialog();
86
+ if (!mountedDialog?.exposed)
113
87
  return;
88
+ // When clicking the indeterminate checkbox, ask if the user wants all entries or unselect all
89
+ if (await mountedDialog.exposed['open']) {
90
+ // User clicked "All Elements" button
91
+ selectedRows.value = await options.getAll();
114
92
  }
115
- });
93
+ else {
94
+ // User clicked "Discard" button
95
+ selectedRows.value = [];
96
+ }
97
+ return;
98
+ }
99
+ // Case 3: Checked state (all items selected)
100
+ if (checked.value) {
101
+ // When all items are selected, we just clear the selection without a dialog
102
+ selectedRows.value = [];
103
+ return;
104
+ }
116
105
  }
117
106
  return {
118
107
  selectedRows,
@@ -42,6 +42,11 @@ interface AsyncValidationContext extends ValidationContext {
42
42
  skipSyncValidation?: boolean;
43
43
  skipAsyncValidation?: boolean;
44
44
  }
45
+ export interface BaseFormOptions {
46
+ persist?: boolean;
47
+ persistKey?: string;
48
+ persistSuffix?: string;
49
+ }
45
50
  export declare function propertyAwareToRaw<T>(propertyAwareObject: T): PropertyAwareToRaw<T>;
46
51
  /**
47
52
  * A generic base class for forms.
@@ -52,10 +57,7 @@ export declare function propertyAwareToRaw<T>(propertyAwareObject: T): PropertyA
52
57
  * (We assume that for every key in RequestBody there is a corresponding key in FormBody.)
53
58
  */
54
59
  export declare abstract class BaseForm<RequestBody extends object, FormBody extends object> {
55
- protected options?: {
56
- persist?: boolean;
57
- persistSuffix?: string;
58
- } | undefined;
60
+ protected options?: BaseFormOptions | undefined;
59
61
  protected readonly state: FormBody;
60
62
  private readonly dirty;
61
63
  private readonly touched;
@@ -77,12 +79,14 @@ export declare abstract class BaseForm<RequestBody extends object, FormBody exte
77
79
  private readonly asyncValidationDebouncers;
78
80
  private readonly pendingAsyncValidationContexts;
79
81
  private readonly asyncValidationTokens;
82
+ private readonly persistKey;
80
83
  /**
81
84
  * Returns the persistence driver to use.
82
85
  * The default is a NonPersistentDriver.
83
86
  * Child classes can override this method to return a different driver.
84
87
  */
85
88
  protected getPersistenceDriver(_suffix: string | undefined): PersistenceDriver;
89
+ private getActivePersistenceDriver;
86
90
  protected getPersistenceRestorePolicy(): PersistenceRestorePolicy<FormBody>;
87
91
  protected shouldLogPersistenceDebug(): boolean;
88
92
  protected logPersistenceDebug(event: PersistenceDebugEvent<FormBody>): void;
@@ -105,10 +109,9 @@ export declare abstract class BaseForm<RequestBody extends object, FormBody exte
105
109
  * Validate fields that depend on the changed field
106
110
  */
107
111
  private validateDependentFields;
108
- protected constructor(defaults: FormBody, options?: {
109
- persist?: boolean;
110
- persistSuffix?: string;
111
- } | undefined);
112
+ protected constructor(defaults: FormBody, options?: BaseFormOptions | undefined);
113
+ private requirePersistKey;
114
+ private resolvePersistKey;
112
115
  protected defineRules(): ValidationRules<FormBody>;
113
116
  protected defineValidationGroups(): ValidationGroups<FormBody>;
114
117
  private clearErrorBag;