@blueprint-ts/core 1.1.0 → 1.1.2

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 (58) hide show
  1. package/.editorconfig +508 -508
  2. package/CHANGELOG.md +12 -0
  3. package/LICENSE +20 -20
  4. package/examples/index.html +14 -14
  5. package/examples/js/app.js +8 -8
  6. package/examples/js/router.js +21 -21
  7. package/examples/js/view/App.vue +48 -48
  8. package/examples/js/view/layout/DemoPage.vue +27 -27
  9. package/examples/js/view/pagination/Pagination.vue +27 -27
  10. package/examples/js/view/pagination/components/errorPagination/ErrorPagination.vue +70 -70
  11. package/examples/js/view/pagination/components/errorPagination/GetProductsRequest.ts +53 -53
  12. package/examples/js/view/pagination/components/infiniteScrolling/GetProductsRequest.ts +49 -49
  13. package/examples/js/view/pagination/components/infiniteScrolling/InfiniteScrolling.vue +56 -56
  14. package/examples/js/view/pagination/components/tablePagination/GetProductsRequest.ts +49 -49
  15. package/examples/js/view/pagination/components/tablePagination/TablePagination.vue +62 -62
  16. package/examples/js/view/requests/Requests.vue +33 -33
  17. package/examples/js/view/requests/components/abortableRequest/AbortableRequest.vue +35 -35
  18. package/examples/js/view/requests/components/abortableRequest/GetProductsRequest.ts +24 -24
  19. package/examples/js/view/requests/components/fileDownloadRequest/DownloadFileRequest.ts +14 -14
  20. package/examples/js/view/requests/components/fileDownloadRequest/FileDownloadRequest.vue +43 -43
  21. package/examples/js/view/requests/components/getRequestWithDynamicParams/GetProductsRequest.ts +33 -33
  22. package/examples/js/view/requests/components/getRequestWithDynamicParams/GetRequestWithDynamicParams.vue +58 -58
  23. package/examples/js/view/requests/components/serverErrorRequest/ServerErrorRequest.ts +20 -20
  24. package/examples/js/view/requests/components/serverErrorRequest/ServerErrorRequest.vue +52 -52
  25. package/package.json +2 -1
  26. package/src/helpers.ts +78 -78
  27. package/src/service/pagination/InfiniteScroller.ts +21 -21
  28. package/src/service/pagination/Paginator.ts +149 -149
  29. package/src/service/pagination/contracts/PaginatorLoadDataOptions.ts +4 -4
  30. package/src/service/pagination/contracts/ViewDriverContract.ts +12 -12
  31. package/src/service/pagination/contracts/ViewDriverFactoryContract.ts +5 -5
  32. package/src/service/pagination/dtos/PaginationDataDto.ts +14 -14
  33. package/src/service/pagination/factories/VuePaginationDriverFactory.ts +9 -9
  34. package/src/service/pagination/frontendDrivers/VuePaginationDriver.ts +61 -61
  35. package/src/service/pagination/index.ts +16 -16
  36. package/src/service/requests/ErrorHandler.ts +64 -64
  37. package/src/service/requests/contracts/RequestDriverContract.ts +15 -15
  38. package/src/service/requests/exceptions/NoResponseReceivedException.ts +3 -3
  39. package/src/service/requests/exceptions/NotFoundException.ts +3 -3
  40. package/src/service/requests/exceptions/PageExpiredException.ts +3 -3
  41. package/src/service/requests/exceptions/ServerErrorException.ts +3 -3
  42. package/src/service/requests/exceptions/UnauthorizedException.ts +3 -3
  43. package/src/service/requests/exceptions/ValidationException.ts +3 -3
  44. package/src/service/requests/exceptions/index.ts +19 -19
  45. package/src/service/requests/index.ts +50 -50
  46. package/src/service/requests/responses/BlobResponse.ts +19 -19
  47. package/src/service/requests/responses/JsonResponse.ts +15 -15
  48. package/src/service/requests/responses/PlainTextResponse.ts +15 -15
  49. package/src/vue/composables/useIsOpen.ts +37 -37
  50. package/src/vue/composables/useIsOpenFromVar.ts +61 -61
  51. package/src/vue/composables/useModelWrapper.ts +24 -24
  52. package/src/vue/composables/useOnOpen.ts +34 -34
  53. package/src/vue/forms/BaseForm.ts +10 -11
  54. package/src/vue/forms/PropertyAwareArray.ts +4 -4
  55. package/src/vue/forms/validation/rules/ConfirmedRule.ts +1 -1
  56. package/src/vue/index.ts +14 -14
  57. package/src/vue/router/routeResourceBinding/installRouteInjection.ts +2 -0
  58. package/src/vue/state/State.ts +1 -0
@@ -1,64 +1,64 @@
1
- import { PageExpiredException } from './exceptions/PageExpiredException'
2
- import { NotFoundException } from './exceptions/NotFoundException'
3
- import { UnauthorizedException } from './exceptions/UnauthorizedException'
4
- import { ValidationException } from './exceptions/ValidationException'
5
- import { ResponseException } from './exceptions/ResponseException'
6
- import { NoResponseReceivedException } from './exceptions/NoResponseReceivedException'
7
- import { ServerErrorException } from './exceptions/ServerErrorException'
8
- import { type ResponseHandlerContract } from './drivers/contracts/ResponseHandlerContract'
9
-
10
- export type ErrorHandlerCallback = ((response: ResponseHandlerContract) => boolean | void) | undefined
11
-
12
- export class ErrorHandler<ResponseErrorBody> {
13
- protected body: ResponseErrorBody | undefined = undefined
14
- protected static handler: ErrorHandlerCallback = undefined
15
-
16
- public constructor(protected response: ResponseHandlerContract) {
17
- // Check if there is a global error handler set
18
- if (ErrorHandler.handler !== undefined) {
19
- // If handler returns false, we don't process the error further
20
- if (ErrorHandler.handler(response) === false) {
21
- console.debug('Skipping further error handling due to global handler returning false.')
22
- return
23
- }
24
- }
25
- }
26
-
27
- public async handle() {
28
- this.body = await this.response.json<ResponseErrorBody>()
29
-
30
- if (this.body === undefined) {
31
- throw new NoResponseReceivedException(this.response)
32
- }
33
-
34
- this.handleResponseError(this.response, this.body)
35
- }
36
-
37
- public static registerHandler(callback: ErrorHandlerCallback) {
38
- ErrorHandler.handler = callback
39
- }
40
-
41
- protected handleResponseError(response: ResponseHandlerContract, body: ResponseErrorBody) {
42
- if (response.getStatusCode() === 401) {
43
- throw new UnauthorizedException<ResponseErrorBody>(response, body)
44
- }
45
-
46
- if (response.getStatusCode() === 404) {
47
- throw new NotFoundException<ResponseErrorBody>(response, body)
48
- }
49
-
50
- if (response.getStatusCode() === 419) {
51
- throw new PageExpiredException<ResponseErrorBody>(response, body)
52
- }
53
-
54
- if (response.getStatusCode() === 422) {
55
- throw new ValidationException<ResponseErrorBody>(response, body)
56
- }
57
-
58
- if (response.getStatusCode() === 500) {
59
- throw new ServerErrorException<ResponseErrorBody>(response, body)
60
- }
61
-
62
- throw new ResponseException(response)
63
- }
64
- }
1
+ import { PageExpiredException } from './exceptions/PageExpiredException'
2
+ import { NotFoundException } from './exceptions/NotFoundException'
3
+ import { UnauthorizedException } from './exceptions/UnauthorizedException'
4
+ import { ValidationException } from './exceptions/ValidationException'
5
+ import { ResponseException } from './exceptions/ResponseException'
6
+ import { NoResponseReceivedException } from './exceptions/NoResponseReceivedException'
7
+ import { ServerErrorException } from './exceptions/ServerErrorException'
8
+ import { type ResponseHandlerContract } from './drivers/contracts/ResponseHandlerContract'
9
+
10
+ export type ErrorHandlerCallback = ((response: ResponseHandlerContract) => boolean | void) | undefined
11
+
12
+ export class ErrorHandler<ResponseErrorBody> {
13
+ protected body: ResponseErrorBody | undefined = undefined
14
+ protected static handler: ErrorHandlerCallback = undefined
15
+
16
+ public constructor(protected response: ResponseHandlerContract) {
17
+ // Check if there is a global error handler set
18
+ if (ErrorHandler.handler !== undefined) {
19
+ // If handler returns false, we don't process the error further
20
+ if (ErrorHandler.handler(response) === false) {
21
+ console.debug('Skipping further error handling due to global handler returning false.')
22
+ return
23
+ }
24
+ }
25
+ }
26
+
27
+ public async handle() {
28
+ this.body = await this.response.json<ResponseErrorBody>()
29
+
30
+ if (this.body === undefined) {
31
+ throw new NoResponseReceivedException(this.response)
32
+ }
33
+
34
+ this.handleResponseError(this.response, this.body)
35
+ }
36
+
37
+ public static registerHandler(callback: ErrorHandlerCallback) {
38
+ ErrorHandler.handler = callback
39
+ }
40
+
41
+ protected handleResponseError(response: ResponseHandlerContract, body: ResponseErrorBody) {
42
+ if (response.getStatusCode() === 401) {
43
+ throw new UnauthorizedException<ResponseErrorBody>(response, body)
44
+ }
45
+
46
+ if (response.getStatusCode() === 404) {
47
+ throw new NotFoundException<ResponseErrorBody>(response, body)
48
+ }
49
+
50
+ if (response.getStatusCode() === 419) {
51
+ throw new PageExpiredException<ResponseErrorBody>(response, body)
52
+ }
53
+
54
+ if (response.getStatusCode() === 422) {
55
+ throw new ValidationException<ResponseErrorBody>(response, body)
56
+ }
57
+
58
+ if (response.getStatusCode() === 500) {
59
+ throw new ServerErrorException<ResponseErrorBody>(response, body)
60
+ }
61
+
62
+ throw new ResponseException(response)
63
+ }
64
+ }
@@ -1,15 +1,15 @@
1
- import { RequestMethodEnum } from '../RequestMethod.enum'
2
- import { type HeadersContract } from './HeadersContract'
3
- import { type BodyContract } from './BodyContract'
4
- import { type ResponseHandlerContract } from '../drivers/contracts/ResponseHandlerContract'
5
- import { type DriverConfigContract } from './DriverConfigContract'
6
-
7
- export interface RequestDriverContract {
8
- send(
9
- url: URL | string,
10
- method: RequestMethodEnum,
11
- headers: HeadersContract,
12
- body?: BodyContract,
13
- requestConfig?: DriverConfigContract
14
- ): Promise<ResponseHandlerContract>
15
- }
1
+ import { RequestMethodEnum } from '../RequestMethod.enum'
2
+ import { type HeadersContract } from './HeadersContract'
3
+ import { type BodyContract } from './BodyContract'
4
+ import { type ResponseHandlerContract } from '../drivers/contracts/ResponseHandlerContract'
5
+ import { type DriverConfigContract } from './DriverConfigContract'
6
+
7
+ export interface RequestDriverContract {
8
+ send(
9
+ url: URL | string,
10
+ method: RequestMethodEnum,
11
+ headers: HeadersContract,
12
+ body?: BodyContract,
13
+ requestConfig?: DriverConfigContract
14
+ ): Promise<ResponseHandlerContract>
15
+ }
@@ -1,3 +1,3 @@
1
- import { ResponseException } from './ResponseException'
2
-
3
- export class NoResponseReceivedException extends ResponseException {}
1
+ import { ResponseException } from './ResponseException'
2
+
3
+ export class NoResponseReceivedException extends ResponseException {}
@@ -1,3 +1,3 @@
1
- import { ResponseBodyException } from './ResponseBodyException'
2
-
3
- export class NotFoundException<ResponseErrorBody> extends ResponseBodyException<ResponseErrorBody> {}
1
+ import { ResponseBodyException } from './ResponseBodyException'
2
+
3
+ export class NotFoundException<ResponseErrorBody> extends ResponseBodyException<ResponseErrorBody> {}
@@ -1,3 +1,3 @@
1
- import { ResponseBodyException } from './ResponseBodyException'
2
-
3
- export class PageExpiredException<ResponseErrorBody> extends ResponseBodyException<ResponseErrorBody> {}
1
+ import { ResponseBodyException } from './ResponseBodyException'
2
+
3
+ export class PageExpiredException<ResponseErrorBody> extends ResponseBodyException<ResponseErrorBody> {}
@@ -1,3 +1,3 @@
1
- import { ResponseBodyException } from './ResponseBodyException'
2
-
3
- export class ServerErrorException<ResponseErrorBody> extends ResponseBodyException<ResponseErrorBody> {}
1
+ import { ResponseBodyException } from './ResponseBodyException'
2
+
3
+ export class ServerErrorException<ResponseErrorBody> extends ResponseBodyException<ResponseErrorBody> {}
@@ -1,3 +1,3 @@
1
- import { ResponseBodyException } from './ResponseBodyException'
2
-
3
- export class UnauthorizedException<ResponseErrorBody> extends ResponseBodyException<ResponseErrorBody> {}
1
+ import { ResponseBodyException } from './ResponseBodyException'
2
+
3
+ export class UnauthorizedException<ResponseErrorBody> extends ResponseBodyException<ResponseErrorBody> {}
@@ -1,3 +1,3 @@
1
- import { ResponseBodyException } from './ResponseBodyException'
2
-
3
- export class ValidationException<ResponseErrorBody> extends ResponseBodyException<ResponseErrorBody> {}
1
+ import { ResponseBodyException } from './ResponseBodyException'
2
+
3
+ export class ValidationException<ResponseErrorBody> extends ResponseBodyException<ResponseErrorBody> {}
@@ -1,19 +1,19 @@
1
- import { ValidationException } from './ValidationException'
2
- import { NotFoundException } from './NotFoundException'
3
- import { NoResponseReceivedException } from './NoResponseReceivedException'
4
- import { UnauthorizedException } from './UnauthorizedException'
5
- import { PageExpiredException } from './PageExpiredException'
6
- import { ServerErrorException } from './ServerErrorException'
7
- import { ResponseException } from './ResponseException'
8
- import { ResponseBodyException } from './ResponseBodyException'
9
-
10
- export {
11
- ValidationException,
12
- NotFoundException,
13
- NoResponseReceivedException,
14
- UnauthorizedException,
15
- PageExpiredException,
16
- ServerErrorException,
17
- ResponseException,
18
- ResponseBodyException
19
- }
1
+ import { ValidationException } from './ValidationException'
2
+ import { NotFoundException } from './NotFoundException'
3
+ import { NoResponseReceivedException } from './NoResponseReceivedException'
4
+ import { UnauthorizedException } from './UnauthorizedException'
5
+ import { PageExpiredException } from './PageExpiredException'
6
+ import { ServerErrorException } from './ServerErrorException'
7
+ import { ResponseException } from './ResponseException'
8
+ import { ResponseBodyException } from './ResponseBodyException'
9
+
10
+ export {
11
+ ValidationException,
12
+ NotFoundException,
13
+ NoResponseReceivedException,
14
+ UnauthorizedException,
15
+ PageExpiredException,
16
+ ServerErrorException,
17
+ ResponseException,
18
+ ResponseBodyException
19
+ }
@@ -1,50 +1,50 @@
1
- import { FetchDriver } from './drivers/fetch/FetchDriver'
2
- import { BaseResponse } from './responses/BaseResponse'
3
- import { JsonResponse } from './responses/JsonResponse'
4
- import { PlainTextResponse } from './responses/PlainTextResponse'
5
- import { BlobResponse } from './responses/BlobResponse'
6
- import { BaseRequest } from './BaseRequest'
7
- import { ErrorHandler } from './ErrorHandler'
8
- import { RequestEvents } from './RequestEvents.enum'
9
- import { RequestMethodEnum } from './RequestMethod.enum'
10
- import { JsonBodyFactory } from './factories/JsonBodyFactory'
11
- import { FormDataFactory } from './factories/FormDataFactory'
12
- import { type BodyContract } from './contracts/BodyContract'
13
- import { type RequestLoaderContract } from './contracts/RequestLoaderContract'
14
- import { type RequestDriverContract } from './contracts/RequestDriverContract'
15
- import { type PaginationParamsContract } from '../laravel/pagination/contracts/PaginationParamsContract'
16
- import { type RequestLoaderFactoryContract } from './contracts/RequestLoaderFactoryContract'
17
- import { type DriverConfigContract } from './contracts/DriverConfigContract'
18
- import { type BodyFactoryContract } from './contracts/BodyFactoryContract'
19
- import { type ResponseHandlerContract } from './drivers/contracts/ResponseHandlerContract'
20
- import { type BaseRequestContract } from './contracts/BaseRequestContract'
21
- import { ResponseException } from './exceptions/ResponseException'
22
- import { type HeadersContract } from './contracts/HeadersContract'
23
-
24
- export {
25
- FetchDriver,
26
- BaseResponse,
27
- JsonResponse,
28
- BlobResponse,
29
- PlainTextResponse,
30
- BaseRequest,
31
- ErrorHandler,
32
- RequestEvents,
33
- RequestMethodEnum,
34
- ResponseException,
35
- JsonBodyFactory,
36
- FormDataFactory
37
- }
38
-
39
- export type {
40
- PaginationParamsContract,
41
- RequestDriverContract,
42
- RequestLoaderContract,
43
- BodyContract,
44
- RequestLoaderFactoryContract,
45
- DriverConfigContract,
46
- BodyFactoryContract,
47
- ResponseHandlerContract,
48
- BaseRequestContract,
49
- HeadersContract
50
- }
1
+ import { FetchDriver } from './drivers/fetch/FetchDriver'
2
+ import { BaseResponse } from './responses/BaseResponse'
3
+ import { JsonResponse } from './responses/JsonResponse'
4
+ import { PlainTextResponse } from './responses/PlainTextResponse'
5
+ import { BlobResponse } from './responses/BlobResponse'
6
+ import { BaseRequest } from './BaseRequest'
7
+ import { ErrorHandler } from './ErrorHandler'
8
+ import { RequestEvents } from './RequestEvents.enum'
9
+ import { RequestMethodEnum } from './RequestMethod.enum'
10
+ import { JsonBodyFactory } from './factories/JsonBodyFactory'
11
+ import { FormDataFactory } from './factories/FormDataFactory'
12
+ import { type BodyContract } from './contracts/BodyContract'
13
+ import { type RequestLoaderContract } from './contracts/RequestLoaderContract'
14
+ import { type RequestDriverContract } from './contracts/RequestDriverContract'
15
+ import { type PaginationParamsContract } from '../laravel/pagination/contracts/PaginationParamsContract'
16
+ import { type RequestLoaderFactoryContract } from './contracts/RequestLoaderFactoryContract'
17
+ import { type DriverConfigContract } from './contracts/DriverConfigContract'
18
+ import { type BodyFactoryContract } from './contracts/BodyFactoryContract'
19
+ import { type ResponseHandlerContract } from './drivers/contracts/ResponseHandlerContract'
20
+ import { type BaseRequestContract } from './contracts/BaseRequestContract'
21
+ import { ResponseException } from './exceptions/ResponseException'
22
+ import { type HeadersContract } from './contracts/HeadersContract'
23
+
24
+ export {
25
+ FetchDriver,
26
+ BaseResponse,
27
+ JsonResponse,
28
+ BlobResponse,
29
+ PlainTextResponse,
30
+ BaseRequest,
31
+ ErrorHandler,
32
+ RequestEvents,
33
+ RequestMethodEnum,
34
+ ResponseException,
35
+ JsonBodyFactory,
36
+ FormDataFactory
37
+ }
38
+
39
+ export type {
40
+ PaginationParamsContract,
41
+ RequestDriverContract,
42
+ RequestLoaderContract,
43
+ BodyContract,
44
+ RequestLoaderFactoryContract,
45
+ DriverConfigContract,
46
+ BodyFactoryContract,
47
+ ResponseHandlerContract,
48
+ BaseRequestContract,
49
+ HeadersContract
50
+ }
@@ -1,19 +1,19 @@
1
- import { BaseResponse } from './BaseResponse'
2
-
3
- export class BlobResponse extends BaseResponse<Blob> {
4
- public constructor(protected mimeType: string = 'application/octet-stream') {
5
- super()
6
- }
7
-
8
- public getAcceptHeader(): string {
9
- return this.mimeType
10
- }
11
-
12
- protected resolveBody(): Promise<Blob> {
13
- if (!this.response) {
14
- throw new Error('Response is not set')
15
- }
16
-
17
- return this.response.blob()
18
- }
19
- }
1
+ import { BaseResponse } from './BaseResponse'
2
+
3
+ export class BlobResponse extends BaseResponse<Blob> {
4
+ public constructor(protected mimeType: string = 'application/octet-stream') {
5
+ super()
6
+ }
7
+
8
+ public getAcceptHeader(): string {
9
+ return this.mimeType
10
+ }
11
+
12
+ protected resolveBody(): Promise<Blob> {
13
+ if (!this.response) {
14
+ throw new Error('Response is not set')
15
+ }
16
+
17
+ return this.response.blob()
18
+ }
19
+ }
@@ -1,15 +1,15 @@
1
- import { BaseResponse } from './BaseResponse'
2
-
3
- export class JsonResponse<ResponseBodyInterface> extends BaseResponse<ResponseBodyInterface> {
4
- public getAcceptHeader(): string {
5
- return 'application/json'
6
- }
7
-
8
- protected resolveBody(): Promise<ResponseBodyInterface> {
9
- if (!this.response) {
10
- throw new Error('Response is not set')
11
- }
12
-
13
- return this.response.json<ResponseBodyInterface>()
14
- }
15
- }
1
+ import { BaseResponse } from './BaseResponse'
2
+
3
+ export class JsonResponse<ResponseBodyInterface> extends BaseResponse<ResponseBodyInterface> {
4
+ public getAcceptHeader(): string {
5
+ return 'application/json'
6
+ }
7
+
8
+ protected resolveBody(): Promise<ResponseBodyInterface> {
9
+ if (!this.response) {
10
+ throw new Error('Response is not set')
11
+ }
12
+
13
+ return this.response.json<ResponseBodyInterface>()
14
+ }
15
+ }
@@ -1,15 +1,15 @@
1
- import { BaseResponse } from './BaseResponse'
2
-
3
- export class PlainTextResponse extends BaseResponse<string> {
4
- public getAcceptHeader(): string {
5
- return 'text/plain'
6
- }
7
-
8
- protected resolveBody(): Promise<string> {
9
- if (!this.response) {
10
- throw new Error('Response is not set')
11
- }
12
-
13
- return this.response.text()
14
- }
15
- }
1
+ import { BaseResponse } from './BaseResponse'
2
+
3
+ export class PlainTextResponse extends BaseResponse<string> {
4
+ public getAcceptHeader(): string {
5
+ return 'text/plain'
6
+ }
7
+
8
+ protected resolveBody(): Promise<string> {
9
+ if (!this.response) {
10
+ throw new Error('Response is not set')
11
+ }
12
+
13
+ return this.response.text()
14
+ }
15
+ }
@@ -1,37 +1,37 @@
1
- import { ref, computed, type Ref, type WritableComputedRef } from 'vue'
2
-
3
- export default function (
4
- callback: (value: boolean) => void = () => {},
5
- delay: number = 500
6
- ): {
7
- isOpenKey: Ref<number>
8
- isOpen: WritableComputedRef<boolean>
9
- } {
10
- const internalIsOpen = ref<boolean>(false)
11
-
12
- const isOpenKey = ref<number>(0)
13
-
14
- const isOpen = computed({
15
- get(): boolean {
16
- return internalIsOpen.value
17
- },
18
- set(value: boolean): void {
19
- // False means we close, so we increment the key
20
- // Add delay to preserve the closing animation.
21
- setTimeout(() => {
22
- if (!value) {
23
- isOpenKey.value++
24
- }
25
- }, delay)
26
-
27
- internalIsOpen.value = value
28
-
29
- callback(value)
30
- }
31
- })
32
-
33
- return {
34
- isOpenKey,
35
- isOpen
36
- }
37
- }
1
+ import { ref, computed, type Ref, type WritableComputedRef } from 'vue'
2
+
3
+ export default function (
4
+ callback: (value: boolean) => void = () => {},
5
+ delay: number = 500
6
+ ): {
7
+ isOpenKey: Ref<number>
8
+ isOpen: WritableComputedRef<boolean>
9
+ } {
10
+ const internalIsOpen = ref<boolean>(false)
11
+
12
+ const isOpenKey = ref<number>(0)
13
+
14
+ const isOpen = computed({
15
+ get(): boolean {
16
+ return internalIsOpen.value
17
+ },
18
+ set(value: boolean): void {
19
+ // False means we close, so we increment the key
20
+ // Add delay to preserve the closing animation.
21
+ setTimeout(() => {
22
+ if (!value) {
23
+ isOpenKey.value++
24
+ }
25
+ }, delay)
26
+
27
+ internalIsOpen.value = value
28
+
29
+ callback(value)
30
+ }
31
+ })
32
+
33
+ return {
34
+ isOpenKey,
35
+ isOpen
36
+ }
37
+ }
@@ -1,61 +1,61 @@
1
- import { ref, computed, type Ref, type ComputedRef } from 'vue'
2
- import useIsEmpty from './useIsEmpty'
3
-
4
- export default function <FromVarType>(
5
- defaultValue: FromVarType | undefined = undefined,
6
- delay: number = 500
7
- ): {
8
- fromVar: ComputedRef<FromVarType | undefined>
9
- isOpenFromVar: ComputedRef<boolean>
10
- isOpenFromVarKey: Ref<number>
11
- } {
12
- const isOpenFromVarKey = ref<number>(0)
13
-
14
- const { isNotEmpty } = useIsEmpty()
15
-
16
- const internalIsOpen = ref<boolean>(false)
17
-
18
- const internalFromVar = ref<FromVarType | undefined>(defaultValue)
19
-
20
- const isOpenFromVar = computed({
21
- get(): boolean {
22
- return internalIsOpen.value
23
- },
24
- set(value): void {
25
- if (value) {
26
- internalIsOpen.value = true
27
-
28
- internalFromVar.value = value
29
- } else {
30
- internalIsOpen.value = false
31
-
32
- setTimeout((): void => {
33
- internalFromVar.value = defaultValue
34
-
35
- isOpenFromVarKey.value++
36
- }, delay)
37
- }
38
- }
39
- })
40
-
41
- const fromVar = computed({
42
- get(): FromVarType | undefined {
43
- return internalFromVar.value
44
- },
45
- set(value): void {
46
- if (isNotEmpty(value)) {
47
- isOpenFromVar.value = true
48
-
49
- internalFromVar.value = value
50
- } else {
51
- isOpenFromVar.value = false
52
- }
53
- }
54
- })
55
-
56
- return {
57
- fromVar,
58
- isOpenFromVar,
59
- isOpenFromVarKey
60
- }
61
- }
1
+ import { ref, computed, type Ref, type ComputedRef } from 'vue'
2
+ import useIsEmpty from './useIsEmpty'
3
+
4
+ export default function <FromVarType>(
5
+ defaultValue: FromVarType | undefined = undefined,
6
+ delay: number = 500
7
+ ): {
8
+ fromVar: ComputedRef<FromVarType | undefined>
9
+ isOpenFromVar: ComputedRef<boolean>
10
+ isOpenFromVarKey: Ref<number>
11
+ } {
12
+ const isOpenFromVarKey = ref<number>(0)
13
+
14
+ const { isNotEmpty } = useIsEmpty()
15
+
16
+ const internalIsOpen = ref<boolean>(false)
17
+
18
+ const internalFromVar = ref<FromVarType | undefined>(defaultValue)
19
+
20
+ const isOpenFromVar = computed({
21
+ get(): boolean {
22
+ return internalIsOpen.value
23
+ },
24
+ set(value): void {
25
+ if (value) {
26
+ internalIsOpen.value = true
27
+
28
+ internalFromVar.value = value
29
+ } else {
30
+ internalIsOpen.value = false
31
+
32
+ setTimeout((): void => {
33
+ internalFromVar.value = defaultValue
34
+
35
+ isOpenFromVarKey.value++
36
+ }, delay)
37
+ }
38
+ }
39
+ })
40
+
41
+ const fromVar = computed({
42
+ get(): FromVarType | undefined {
43
+ return internalFromVar.value
44
+ },
45
+ set(value): void {
46
+ if (isNotEmpty(value)) {
47
+ isOpenFromVar.value = true
48
+
49
+ internalFromVar.value = value
50
+ } else {
51
+ isOpenFromVar.value = false
52
+ }
53
+ }
54
+ })
55
+
56
+ return {
57
+ fromVar,
58
+ isOpenFromVar,
59
+ isOpenFromVarKey
60
+ }
61
+ }