adminforth 4.7.5 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/styles.js +4 -4
- package/dist/spa/package-lock.json +1 -52
- package/dist/spa/package.json +2 -2
- package/dist/spa/pnpm-lock.yaml +0 -44
- package/dist/spa/src/afcl/Calendar.vue +211 -0
- package/dist/spa/src/afcl/DateField.vue +257 -0
- package/dist/spa/src/afcl/DatePicker.vue +103 -245
- package/dist/spa/src/afcl/JsonViewer.vue +165 -18
- package/dist/spa/src/afcl/JsonViewerNode.vue +102 -0
- package/dist/spa/src/afcl/TimeField.vue +52 -0
- package/dist/spa/src/afcl/jsonFormat.ts +85 -0
- package/dist/spa/src/afcl/pickerStyles.ts +25 -0
- package/dist/spa/src/afcl/shadowRoot.ts +1 -2
- package/dist/spa/src/components/ColumnValueInput.vue +9 -7
- package/dist/spa/src/components/ColumnValueInputWrapper.vue +1 -1
- package/dist/spa/src/components/CustomDateRangePicker.vue +47 -165
- package/dist/spa/src/components/Filters.vue +7 -4
- package/dist/spa/src/components/GroupsTable.vue +23 -43
- package/dist/spa/src/components/ShowTable.vue +21 -31
- package/dist/spa/src/components/ValueRenderer.vue +8 -27
- package/dist/spa/src/types/Common.ts +6 -5
- package/dist/spa/src/utils/dateUtils.ts +33 -21
- package/dist/spa/src/views/CreateEditSkeleton.vue +6 -17
- package/dist/spa/src/views/ShowView.vue +14 -24
- package/dist/spa/tailwind.config.js +1 -1
- package/dist/types/Common.d.ts +4 -3
- package/dist/types/Common.d.ts.map +1 -1
- package/dist/types/Common.js.map +1 -1
- package/package.json +1 -1
package/dist/modules/styles.js
CHANGED
|
@@ -78,11 +78,11 @@ export const styles = () => ({
|
|
|
78
78
|
/* Show View Table */
|
|
79
79
|
/*----------------------------------------*/
|
|
80
80
|
lightShowTableHeadingBackground: "#FAFAFA",
|
|
81
|
-
lightShowTableHeadingText: "#
|
|
81
|
+
lightShowTableHeadingText: "#18181B",
|
|
82
82
|
lightShowTableUnderHeadingBackground: "#FAFAFA",
|
|
83
83
|
lightShowTableUnderHeadingText: "#696973",
|
|
84
84
|
lightShowTablesBodyBackground: "alias:lightForm",
|
|
85
|
-
lightShowTableBodyText: "#
|
|
85
|
+
lightShowTableBodyText: "#18181B",
|
|
86
86
|
lightShowTableBodyBorder: "#F0F0F2",
|
|
87
87
|
/* Show View buttons*/
|
|
88
88
|
lightShowViewButtonBackground: "#FFFFFF",
|
|
@@ -396,11 +396,11 @@ export const styles = () => ({
|
|
|
396
396
|
/* Show View Table */
|
|
397
397
|
/*----------------------------------------*/
|
|
398
398
|
darkShowTableHeadingBackground: "alias:darkFormHeading",
|
|
399
|
-
darkShowTableHeadingText: "#
|
|
399
|
+
darkShowTableHeadingText: "#F4F4F5",
|
|
400
400
|
darkShowTableUnderHeadingBackground: "alias:darkFormHeading",
|
|
401
401
|
darkShowTableUnderHeadingText: "#A1A1AA",
|
|
402
402
|
darkShowTablesBodyBackground: "alias:darkForm",
|
|
403
|
-
darkShowTableBodyText: "#
|
|
403
|
+
darkShowTableBodyText: "#F4F4F5",
|
|
404
404
|
darkShowTableBodyBorder: "#202024",
|
|
405
405
|
/* Show View buttons*/
|
|
406
406
|
darkShowViewButtonBackground: "#1F2937",
|
|
@@ -31,8 +31,7 @@
|
|
|
31
31
|
"vue": "^3.5.44",
|
|
32
32
|
"vue-diff": "^1.2.4",
|
|
33
33
|
"vue-i18n": "^11.4.14",
|
|
34
|
-
"vue-router": "^5.4.0"
|
|
35
|
-
"vue3-json-viewer": "^2.2.2"
|
|
34
|
+
"vue-router": "^5.4.0"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
38
37
|
"@rushstack/eslint-patch": "^1.8.0",
|
|
@@ -2357,17 +2356,6 @@
|
|
|
2357
2356
|
"url": "https://paulmillr.com/funding/"
|
|
2358
2357
|
}
|
|
2359
2358
|
},
|
|
2360
|
-
"node_modules/clipboard": {
|
|
2361
|
-
"version": "2.0.11",
|
|
2362
|
-
"resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.11.tgz",
|
|
2363
|
-
"integrity": "sha512-C+0bbOqkezLIsmWSvlsXS0Q0bmkugu7jcfMIACB+RDEntIzQIkdr148we28AfSloQLRdZlYL/QYyrq05j/3Faw==",
|
|
2364
|
-
"license": "MIT",
|
|
2365
|
-
"dependencies": {
|
|
2366
|
-
"good-listener": "^1.2.2",
|
|
2367
|
-
"select": "^1.1.2",
|
|
2368
|
-
"tiny-emitter": "^2.0.0"
|
|
2369
|
-
}
|
|
2370
|
-
},
|
|
2371
2359
|
"node_modules/color-convert": {
|
|
2372
2360
|
"version": "2.0.1",
|
|
2373
2361
|
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
|
@@ -2497,12 +2485,6 @@
|
|
|
2497
2485
|
"node": ">=0.10.0"
|
|
2498
2486
|
}
|
|
2499
2487
|
},
|
|
2500
|
-
"node_modules/delegate": {
|
|
2501
|
-
"version": "3.2.0",
|
|
2502
|
-
"resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz",
|
|
2503
|
-
"integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==",
|
|
2504
|
-
"license": "MIT"
|
|
2505
|
-
},
|
|
2506
2488
|
"node_modules/detect-libc": {
|
|
2507
2489
|
"version": "2.1.2",
|
|
2508
2490
|
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
|
|
@@ -3271,15 +3253,6 @@
|
|
|
3271
3253
|
"url": "https://github.com/sponsors/sindresorhus"
|
|
3272
3254
|
}
|
|
3273
3255
|
},
|
|
3274
|
-
"node_modules/good-listener": {
|
|
3275
|
-
"version": "1.2.2",
|
|
3276
|
-
"resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz",
|
|
3277
|
-
"integrity": "sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw==",
|
|
3278
|
-
"license": "MIT",
|
|
3279
|
-
"dependencies": {
|
|
3280
|
-
"delegate": "^3.1.2"
|
|
3281
|
-
}
|
|
3282
|
-
},
|
|
3283
3256
|
"node_modules/graphemer": {
|
|
3284
3257
|
"version": "1.4.0",
|
|
3285
3258
|
"resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz",
|
|
@@ -4979,12 +4952,6 @@
|
|
|
4979
4952
|
"integrity": "sha512-6FtHJEvt+pVMIB9IBY+IcCJ6Z5f1iQnytgyfKMhDKgmzYG+TeH/wx1y3l27rshSbLiSanrR9ffZDrEsmjlQF2g==",
|
|
4980
4953
|
"license": "MIT"
|
|
4981
4954
|
},
|
|
4982
|
-
"node_modules/select": {
|
|
4983
|
-
"version": "1.1.2",
|
|
4984
|
-
"resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz",
|
|
4985
|
-
"integrity": "sha512-OwpTSOfy6xSs1+pwcNrv0RBMOzI39Lp3qQKUTPVVPRjCdNa5JH/oPRiqsesIskK8TVgmRiHwO4KXlV2Li9dANA==",
|
|
4986
|
-
"license": "MIT"
|
|
4987
|
-
},
|
|
4988
4955
|
"node_modules/semver": {
|
|
4989
4956
|
"version": "7.7.4",
|
|
4990
4957
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
|
|
@@ -5283,12 +5250,6 @@
|
|
|
5283
5250
|
"node": ">=0.8"
|
|
5284
5251
|
}
|
|
5285
5252
|
},
|
|
5286
|
-
"node_modules/tiny-emitter": {
|
|
5287
|
-
"version": "2.1.0",
|
|
5288
|
-
"resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz",
|
|
5289
|
-
"integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==",
|
|
5290
|
-
"license": "MIT"
|
|
5291
|
-
},
|
|
5292
5253
|
"node_modules/tinyglobby": {
|
|
5293
5254
|
"version": "0.2.17",
|
|
5294
5255
|
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
|
|
@@ -5920,18 +5881,6 @@
|
|
|
5920
5881
|
"typescript": ">=5.0.0"
|
|
5921
5882
|
}
|
|
5922
5883
|
},
|
|
5923
|
-
"node_modules/vue3-json-viewer": {
|
|
5924
|
-
"version": "2.4.1",
|
|
5925
|
-
"resolved": "https://registry.npmjs.org/vue3-json-viewer/-/vue3-json-viewer-2.4.1.tgz",
|
|
5926
|
-
"integrity": "sha512-Z1sunvS58lJ3ZcpNhl3jYQapBVw2wjnXbemigfMWm3QnjCeg3CPMq8R6pxHUYahxMfPKLvrbGve6mUXqhWyLaQ==",
|
|
5927
|
-
"license": "ISC",
|
|
5928
|
-
"dependencies": {
|
|
5929
|
-
"clipboard": "^2.0.10"
|
|
5930
|
-
},
|
|
5931
|
-
"peerDependencies": {
|
|
5932
|
-
"vue": "^3.5.16"
|
|
5933
|
-
}
|
|
5934
|
-
},
|
|
5935
5884
|
"node_modules/webpack-virtual-modules": {
|
|
5936
5885
|
"version": "0.6.2",
|
|
5937
5886
|
"resolved": "https://registry.npmjs.org/webpack-virtual-modules/-/webpack-virtual-modules-0.6.2.tgz",
|
package/dist/spa/package.json
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
|
|
13
13
|
"i18n:extract": "echo {} > i18n-empty.json && vue-i18n-extract report --vueFiles \"./src/**/*.{js,vue,ts}\" --output ./i18n-messages.json --languageFiles \"i18n-empty.json\" --add"
|
|
14
14
|
},
|
|
15
|
+
"//": "TODO next major: remove flowbite-datepicker (with it flowbite), core does not import it, only @adminforth/i18n up to 3.1.7 does",
|
|
15
16
|
"dependencies": {
|
|
16
17
|
"@fontsource-variable/geist": "^5.3.0",
|
|
17
18
|
"@fontsource-variable/geist-mono": "^5.3.0",
|
|
@@ -36,8 +37,7 @@
|
|
|
36
37
|
"vue": "^3.5.44",
|
|
37
38
|
"vue-diff": "^1.2.4",
|
|
38
39
|
"vue-i18n": "^11.4.14",
|
|
39
|
-
"vue-router": "^5.4.0"
|
|
40
|
-
"vue3-json-viewer": "^2.2.2"
|
|
40
|
+
"vue-router": "^5.4.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@rushstack/eslint-patch": "^1.8.0",
|
package/dist/spa/pnpm-lock.yaml
CHANGED
|
@@ -80,9 +80,6 @@ importers:
|
|
|
80
80
|
vue-router:
|
|
81
81
|
specifier: ^5.4.0
|
|
82
82
|
version: 5.4.0(@vue/compiler-sfc@3.5.44)(pinia@4.1.0(@vue/devtools-api@8.2.1)(typescript@5.9.3)(vue@3.5.44(typescript@5.9.3)))(rolldown@1.2.14)(rollup@4.60.2)(vite@8.3.4(@types/node@20.19.39)(jiti@1.21.7)(sass@1.105.2))(vue@3.5.44(typescript@5.9.3))
|
|
83
|
-
vue3-json-viewer:
|
|
84
|
-
specifier: ^2.2.2
|
|
85
|
-
version: 2.4.1(vue@3.5.44(typescript@5.9.3))
|
|
86
83
|
devDependencies:
|
|
87
84
|
'@rushstack/eslint-patch':
|
|
88
85
|
specifier: ^1.8.0
|
|
@@ -1068,9 +1065,6 @@ packages:
|
|
|
1068
1065
|
resolution: {integrity: sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==}
|
|
1069
1066
|
engines: {node: '>= 20.19.0'}
|
|
1070
1067
|
|
|
1071
|
-
clipboard@2.0.11:
|
|
1072
|
-
resolution: {integrity: sha512-C+0bbOqkezLIsmWSvlsXS0Q0bmkugu7jcfMIACB+RDEntIzQIkdr148we28AfSloQLRdZlYL/QYyrq05j/3Faw==}
|
|
1073
|
-
|
|
1074
1068
|
color-convert@2.0.1:
|
|
1075
1069
|
resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}
|
|
1076
1070
|
engines: {node: '>=7.0.0'}
|
|
@@ -1130,9 +1124,6 @@ packages:
|
|
|
1130
1124
|
resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==}
|
|
1131
1125
|
engines: {node: '>=0.10.0'}
|
|
1132
1126
|
|
|
1133
|
-
delegate@3.2.0:
|
|
1134
|
-
resolution: {integrity: sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==}
|
|
1135
|
-
|
|
1136
1127
|
detect-libc@2.1.2:
|
|
1137
1128
|
resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==}
|
|
1138
1129
|
engines: {node: '>=8'}
|
|
@@ -1344,9 +1335,6 @@ packages:
|
|
|
1344
1335
|
resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==}
|
|
1345
1336
|
engines: {node: '>=10'}
|
|
1346
1337
|
|
|
1347
|
-
good-listener@1.2.2:
|
|
1348
|
-
resolution: {integrity: sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw==}
|
|
1349
|
-
|
|
1350
1338
|
graphemer@1.4.0:
|
|
1351
1339
|
resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==}
|
|
1352
1340
|
|
|
@@ -1888,9 +1876,6 @@ packages:
|
|
|
1888
1876
|
scule@1.3.0:
|
|
1889
1877
|
resolution: {integrity: sha512-6FtHJEvt+pVMIB9IBY+IcCJ6Z5f1iQnytgyfKMhDKgmzYG+TeH/wx1y3l27rshSbLiSanrR9ffZDrEsmjlQF2g==}
|
|
1890
1878
|
|
|
1891
|
-
select@1.1.2:
|
|
1892
|
-
resolution: {integrity: sha512-OwpTSOfy6xSs1+pwcNrv0RBMOzI39Lp3qQKUTPVVPRjCdNa5JH/oPRiqsesIskK8TVgmRiHwO4KXlV2Li9dANA==}
|
|
1893
|
-
|
|
1894
1879
|
semver@7.7.4:
|
|
1895
1880
|
resolution: {integrity: sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==}
|
|
1896
1881
|
engines: {node: '>=10'}
|
|
@@ -1955,9 +1940,6 @@ packages:
|
|
|
1955
1940
|
thenify@3.3.1:
|
|
1956
1941
|
resolution: {integrity: sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==}
|
|
1957
1942
|
|
|
1958
|
-
tiny-emitter@2.1.0:
|
|
1959
|
-
resolution: {integrity: sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==}
|
|
1960
|
-
|
|
1961
1943
|
tinyglobby@0.2.17:
|
|
1962
1944
|
resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==}
|
|
1963
1945
|
engines: {node: '>=12.0.0'}
|
|
@@ -2152,11 +2134,6 @@ packages:
|
|
|
2152
2134
|
peerDependencies:
|
|
2153
2135
|
typescript: '>=5.0.0'
|
|
2154
2136
|
|
|
2155
|
-
vue3-json-viewer@2.4.1:
|
|
2156
|
-
resolution: {integrity: sha512-Z1sunvS58lJ3ZcpNhl3jYQapBVw2wjnXbemigfMWm3QnjCeg3CPMq8R6pxHUYahxMfPKLvrbGve6mUXqhWyLaQ==}
|
|
2157
|
-
peerDependencies:
|
|
2158
|
-
vue: ^3.5.16
|
|
2159
|
-
|
|
2160
2137
|
vue@3.5.44:
|
|
2161
2138
|
resolution: {integrity: sha512-dvvmaOCG7lAMkJTPqPwWeGMsPS6DIsFsfZDUgBp9V6mHf9b3+/wyVwYR4Es+WV6uJC0FKRxp81Obcq0ZwUcGFQ==}
|
|
2162
2139
|
peerDependencies:
|
|
@@ -3000,12 +2977,6 @@ snapshots:
|
|
|
3000
2977
|
dependencies:
|
|
3001
2978
|
readdirp: 5.1.1
|
|
3002
2979
|
|
|
3003
|
-
clipboard@2.0.11:
|
|
3004
|
-
dependencies:
|
|
3005
|
-
good-listener: 1.2.2
|
|
3006
|
-
select: 1.1.2
|
|
3007
|
-
tiny-emitter: 2.1.0
|
|
3008
|
-
|
|
3009
2980
|
color-convert@2.0.1:
|
|
3010
2981
|
dependencies:
|
|
3011
2982
|
color-name: 1.1.4
|
|
@@ -3046,8 +3017,6 @@ snapshots:
|
|
|
3046
3017
|
|
|
3047
3018
|
deepmerge@4.3.1: {}
|
|
3048
3019
|
|
|
3049
|
-
delegate@3.2.0: {}
|
|
3050
|
-
|
|
3051
3020
|
detect-libc@2.1.2: {}
|
|
3052
3021
|
|
|
3053
3022
|
diacritics@1.3.0: {}
|
|
@@ -3304,10 +3273,6 @@ snapshots:
|
|
|
3304
3273
|
merge2: 1.4.1
|
|
3305
3274
|
slash: 3.0.0
|
|
3306
3275
|
|
|
3307
|
-
good-listener@1.2.2:
|
|
3308
|
-
dependencies:
|
|
3309
|
-
delegate: 3.2.0
|
|
3310
|
-
|
|
3311
3276
|
graphemer@1.4.0: {}
|
|
3312
3277
|
|
|
3313
3278
|
has-flag@4.0.0: {}
|
|
@@ -3810,8 +3775,6 @@ snapshots:
|
|
|
3810
3775
|
|
|
3811
3776
|
scule@1.3.0: {}
|
|
3812
3777
|
|
|
3813
|
-
select@1.1.2: {}
|
|
3814
|
-
|
|
3815
3778
|
semver@7.7.4: {}
|
|
3816
3779
|
|
|
3817
3780
|
shebang-command@2.0.0:
|
|
@@ -3888,8 +3851,6 @@ snapshots:
|
|
|
3888
3851
|
dependencies:
|
|
3889
3852
|
any-promise: 1.3.0
|
|
3890
3853
|
|
|
3891
|
-
tiny-emitter@2.1.0: {}
|
|
3892
|
-
|
|
3893
3854
|
tinyglobby@0.2.17:
|
|
3894
3855
|
dependencies:
|
|
3895
3856
|
fdir: 6.5.0(picomatch@4.0.7)
|
|
@@ -4050,11 +4011,6 @@ snapshots:
|
|
|
4050
4011
|
'@vue/language-core': 3.3.13
|
|
4051
4012
|
typescript: 5.9.3
|
|
4052
4013
|
|
|
4053
|
-
vue3-json-viewer@2.4.1(vue@3.5.44(typescript@5.9.3)):
|
|
4054
|
-
dependencies:
|
|
4055
|
-
clipboard: 2.0.11
|
|
4056
|
-
vue: 3.5.44(typescript@5.9.3)
|
|
4057
|
-
|
|
4058
4014
|
vue@3.5.44(typescript@5.9.3):
|
|
4059
4015
|
dependencies:
|
|
4060
4016
|
'@vue/compiler-dom': 3.5.44
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="afcl-calendar w-[16.5rem] p-3 text-lightDatePickerCalendarText dark:text-darkDatePickerCalendarMainText">
|
|
3
|
+
<div class="afcl-calendar-header flex items-center justify-between gap-1 mb-2">
|
|
4
|
+
<button type="button" :class="NAV_BUTTON_CLASSES" :aria-label="$t(VIEW_STEPS[view].previousLabel)" @click="turnPage(-1)">
|
|
5
|
+
<IconChevronLeft class="w-4 h-4 rtl:rotate-180" aria-hidden="true" />
|
|
6
|
+
</button>
|
|
7
|
+
<button
|
|
8
|
+
type="button"
|
|
9
|
+
class="afcl-calendar-title h-7 px-2 rounded-md text-sm font-semibold capitalize tabular-nums focus:outline-none focus-visible:ring-[3px] focus-visible:ring-lightFocusRing dark:focus-visible:ring-darkFocusRing enabled:hover:bg-lightDatePickerCalendarArrowButtonBackgroundHover dark:enabled:hover:bg-darkDatePickerCalendarArrowButtonBackgroundHover"
|
|
10
|
+
:disabled="view === 'years'"
|
|
11
|
+
@click="view = view === 'days' ? 'months' : 'years'"
|
|
12
|
+
>
|
|
13
|
+
{{ title }}
|
|
14
|
+
</button>
|
|
15
|
+
<button type="button" :class="NAV_BUTTON_CLASSES" :aria-label="$t(VIEW_STEPS[view].nextLabel)" @click="turnPage(1)">
|
|
16
|
+
<IconChevronRight class="w-4 h-4 rtl:rotate-180" aria-hidden="true" />
|
|
17
|
+
</button>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<div
|
|
21
|
+
ref="gridEl"
|
|
22
|
+
class="afcl-calendar-grid grid gap-0.5 text-center"
|
|
23
|
+
:class="view === 'days' ? 'grid-cols-7' : MONTHS_GRID_CLASSES"
|
|
24
|
+
@keydown="onGridKeydown"
|
|
25
|
+
>
|
|
26
|
+
<template v-if="view === 'days'">
|
|
27
|
+
<span
|
|
28
|
+
v-for="name in weekdayNames"
|
|
29
|
+
:key="name"
|
|
30
|
+
class="h-6 leading-6 text-[11px] font-medium capitalize text-lightDatePickerCalendarDaysOfWeekText dark:text-darkDatePickerCalendarDaysOfWeekText"
|
|
31
|
+
>{{ name }}</span>
|
|
32
|
+
<span v-for="n in leadingBlanks" :key="`lead-${n}`" class="h-7" aria-hidden="true"></span>
|
|
33
|
+
</template>
|
|
34
|
+
<button
|
|
35
|
+
v-for="cell in cells"
|
|
36
|
+
:key="cell.value"
|
|
37
|
+
type="button"
|
|
38
|
+
:tabindex="cell.value === activeValue ? 0 : -1"
|
|
39
|
+
:aria-label="cell.ariaLabel"
|
|
40
|
+
:aria-pressed="cell.value === selectedValue"
|
|
41
|
+
:aria-current="cell.value === todayValue ? 'date' : undefined"
|
|
42
|
+
:class="[
|
|
43
|
+
'afcl-calendar-cell rounded-md tabular-nums capitalize focus:outline-none focus-visible:relative focus-visible:ring-[3px] focus-visible:ring-lightFocusRing dark:focus-visible:ring-darkFocusRing',
|
|
44
|
+
view === 'days' ? 'h-7 text-[12.5px]' : 'h-full text-sm',
|
|
45
|
+
cell.value === selectedValue
|
|
46
|
+
? 'font-medium bg-lightDatePickerCalendarDateActiveButtonBackground text-lightDatePickerCalendarDateActiveButtonText dark:bg-darkDatePickerCalendarDateActiveButtonBackground dark:text-darkDatePickerCalendarDateActiveButtonText'
|
|
47
|
+
: 'text-lightDatePickerCalendarDateButtonText hover:bg-lightDatePickerCalendarDateButtonBackgroundHover dark:text-darkDatePickerCalendarDateButtonText dark:hover:bg-darkDatePickerCalendarDateButtonBackgroundHover',
|
|
48
|
+
cell.value === todayValue && cell.value !== selectedValue && 'ring-1 ring-inset ring-lightInputBorder dark:ring-darkInputBorder',
|
|
49
|
+
]"
|
|
50
|
+
@click="pick(cell.date)"
|
|
51
|
+
>{{ cell.label }}</button>
|
|
52
|
+
<span v-for="n in trailingBlanks" :key="`trail-${n}`" class="h-7" aria-hidden="true"></span>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<div class="afcl-calendar-footer flex justify-between mt-2.5 pt-2.5 border-t border-lightDialogBreakLine dark:border-darkDialogBreakLine">
|
|
56
|
+
<Button type="button" variant="ghost" size="sm" :shadow="false" @click="emit('update:modelValue', null)">{{ $t('Clear') }}</Button>
|
|
57
|
+
<Button type="button" variant="secondary" size="sm" @click="emit('update:modelValue', todayValue)">{{ $t('Today') }}</Button>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</template>
|
|
61
|
+
|
|
62
|
+
<script setup lang="ts">
|
|
63
|
+
import { computed, nextTick, ref, watch } from 'vue';
|
|
64
|
+
import dayjs, { type Dayjs, type ManipulateType } from 'dayjs';
|
|
65
|
+
import { IconChevronLeft, IconChevronRight } from '@iconify-prerendered/vue-lucide';
|
|
66
|
+
import { PICKER_DAY_FORMAT } from '@/utils/dateUtils';
|
|
67
|
+
import { activeElementIn } from './shadowRoot';
|
|
68
|
+
import Button from './Button.vue';
|
|
69
|
+
|
|
70
|
+
type CalendarView = 'days' | 'months' | 'years';
|
|
71
|
+
|
|
72
|
+
const props = defineProps<{
|
|
73
|
+
// the picked day in PICKER_DAY_FORMAT
|
|
74
|
+
modelValue: string | null,
|
|
75
|
+
}>();
|
|
76
|
+
|
|
77
|
+
const emit = defineEmits<{
|
|
78
|
+
'update:modelValue': [day: string | null],
|
|
79
|
+
}>();
|
|
80
|
+
|
|
81
|
+
const NAV_BUTTON_CLASSES = `flex items-center justify-center w-7 h-7 rounded-md focus:outline-none focus-visible:ring-[3px]
|
|
82
|
+
bg-lightDatePickerCalendarArrowButtonBackground hover:bg-lightDatePickerCalendarArrowButtonBackgroundHover focus-visible:ring-lightFocusRing
|
|
83
|
+
dark:bg-darkDatePickerCalendarArrowButtonBackground dark:hover:bg-darkDatePickerCalendarArrowButtonBackgroundHover dark:focus-visible:ring-darkFocusRing`;
|
|
84
|
+
|
|
85
|
+
// months and years fill the height of six weeks of days (a row of names, six rows of days, gaps), so the calendar
|
|
86
|
+
// does not jump when its view changes
|
|
87
|
+
const MONTHS_GRID_CLASSES = 'grid-cols-3 grid-rows-4 h-[12.75rem]';
|
|
88
|
+
const YEARS_PER_PAGE = 12;
|
|
89
|
+
// six weeks, so the calendar keeps its height while paging through months
|
|
90
|
+
const DAY_CELLS = 42;
|
|
91
|
+
// Shift+PageUp/PageDown jump by this many pages
|
|
92
|
+
const BIG_PAGE = 12;
|
|
93
|
+
|
|
94
|
+
interface ViewSteps {
|
|
95
|
+
unit: ManipulateType, // what one cell is
|
|
96
|
+
row: number, // cells in a row, the step of ArrowUp and ArrowDown
|
|
97
|
+
pageUnit: ManipulateType, // what the prev and next buttons and PageUp/PageDown turn
|
|
98
|
+
pageSize: number,
|
|
99
|
+
key: string, // format which tells cells of the view apart
|
|
100
|
+
cellLabel: string,
|
|
101
|
+
cellAriaLabel: string,
|
|
102
|
+
previousLabel: string,
|
|
103
|
+
nextLabel: string,
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const VIEW_STEPS: Record<CalendarView, ViewSteps> = {
|
|
107
|
+
days: {
|
|
108
|
+
unit: 'day', row: 7, pageUnit: 'month', pageSize: 1, key: PICKER_DAY_FORMAT,
|
|
109
|
+
cellLabel: 'D', cellAriaLabel: 'D MMMM YYYY', previousLabel: 'Previous month', nextLabel: 'Next month',
|
|
110
|
+
},
|
|
111
|
+
months: {
|
|
112
|
+
unit: 'month', row: 3, pageUnit: 'year', pageSize: 1, key: 'YYYY-MM',
|
|
113
|
+
cellLabel: 'MMM', cellAriaLabel: 'MMMM YYYY', previousLabel: 'Previous year', nextLabel: 'Next year',
|
|
114
|
+
},
|
|
115
|
+
years: {
|
|
116
|
+
unit: 'year', row: 3, pageUnit: 'year', pageSize: YEARS_PER_PAGE, key: 'YYYY',
|
|
117
|
+
cellLabel: 'YYYY', cellAriaLabel: 'YYYY', previousLabel: 'Previous years', nextLabel: 'Next years',
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const view = ref<CalendarView>('days');
|
|
122
|
+
// the cell which takes keyboard focus, the shown month, year or block of years follows it
|
|
123
|
+
const cursor = ref(dayjs(props.modelValue ?? undefined).startOf('day'));
|
|
124
|
+
const gridEl = ref<HTMLElement>();
|
|
125
|
+
|
|
126
|
+
watch(() => props.modelValue, (day) => {
|
|
127
|
+
if (day) {
|
|
128
|
+
cursor.value = dayjs(day);
|
|
129
|
+
view.value = 'days';
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const todayValue = dayjs().format(PICKER_DAY_FORMAT);
|
|
134
|
+
const steps = computed(() => VIEW_STEPS[view.value]);
|
|
135
|
+
const activeValue = computed(() => cursor.value.format(steps.value.key));
|
|
136
|
+
const selectedValue = computed(() => props.modelValue && dayjs(props.modelValue).format(steps.value.key));
|
|
137
|
+
const yearsStart = computed(() => Math.floor(cursor.value.year() / YEARS_PER_PAGE) * YEARS_PER_PAGE);
|
|
138
|
+
|
|
139
|
+
const title = computed(() => {
|
|
140
|
+
if (view.value === 'days') {
|
|
141
|
+
return cursor.value.format('MMMM YYYY');
|
|
142
|
+
}
|
|
143
|
+
if (view.value === 'months') {
|
|
144
|
+
return cursor.value.format('YYYY');
|
|
145
|
+
}
|
|
146
|
+
return `${yearsStart.value} – ${yearsStart.value + YEARS_PER_PAGE - 1}`;
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
const weekdayNames = computed(() => dayjs.weekdaysMin(true));
|
|
150
|
+
const leadingBlanks = computed(() => (cursor.value.startOf('month').day() - dayjs.localeData().firstDayOfWeek() + 7) % 7);
|
|
151
|
+
const trailingBlanks = computed(() => view.value === 'days' ? DAY_CELLS - leadingBlanks.value - cursor.value.daysInMonth() : 0);
|
|
152
|
+
|
|
153
|
+
const cells = computed(() => {
|
|
154
|
+
const firstByView: Record<CalendarView, Dayjs> = {
|
|
155
|
+
days: cursor.value.startOf('month'),
|
|
156
|
+
months: cursor.value.startOf('year'),
|
|
157
|
+
years: cursor.value.year(yearsStart.value).startOf('year'),
|
|
158
|
+
};
|
|
159
|
+
const count = view.value === 'days' ? cursor.value.daysInMonth() : 12;
|
|
160
|
+
const { unit, key, cellLabel, cellAriaLabel } = steps.value;
|
|
161
|
+
return Array.from({ length: count }, (_, i) => {
|
|
162
|
+
const date = firstByView[view.value].add(i, unit);
|
|
163
|
+
return { date, value: date.format(key), label: date.format(cellLabel), ariaLabel: date.format(cellAriaLabel) };
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
function turnPage(direction: number) {
|
|
168
|
+
const { pageUnit, pageSize } = steps.value;
|
|
169
|
+
cursor.value = cursor.value.add(direction * pageSize, pageUnit);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function pick(date: Dayjs) {
|
|
173
|
+
if (view.value === 'days') {
|
|
174
|
+
emit('update:modelValue', date.format(PICKER_DAY_FORMAT));
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
cursor.value = view.value === 'months' ? cursor.value.month(date.month()) : cursor.value.year(date.year());
|
|
178
|
+
view.value = view.value === 'months' ? 'days' : 'months';
|
|
179
|
+
// a click keeps the focus in the field, only a keyboard user is already inside the calendar
|
|
180
|
+
if (gridEl.value!.contains(activeElementIn(gridEl.value!))) {
|
|
181
|
+
focus();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function onGridKeydown(e: KeyboardEvent) {
|
|
186
|
+
const { unit, row, pageUnit, pageSize } = steps.value;
|
|
187
|
+
const page = (e.shiftKey ? BIG_PAGE : 1) * pageSize;
|
|
188
|
+
const moves: Record<string, () => Dayjs> = {
|
|
189
|
+
ArrowLeft: () => cursor.value.add(-1, unit),
|
|
190
|
+
ArrowRight: () => cursor.value.add(1, unit),
|
|
191
|
+
ArrowUp: () => cursor.value.add(-row, unit),
|
|
192
|
+
ArrowDown: () => cursor.value.add(row, unit),
|
|
193
|
+
PageUp: () => cursor.value.add(-page, pageUnit),
|
|
194
|
+
PageDown: () => cursor.value.add(page, pageUnit),
|
|
195
|
+
};
|
|
196
|
+
if (!moves[e.key]) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
e.preventDefault();
|
|
200
|
+
cursor.value = moves[e.key]();
|
|
201
|
+
focus();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// moves the keyboard focus to the active cell
|
|
205
|
+
async function focus() {
|
|
206
|
+
await nextTick();
|
|
207
|
+
gridEl.value!.querySelector<HTMLButtonElement>('[tabindex="0"]')!.focus();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
defineExpose({ focus });
|
|
211
|
+
</script>
|