@anzusystems/common-admin 2.0.0-rc.21 → 2.0.0-rc.23

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 (153) hide show
  1. package/dist/AnzuSystemsCommonAdmin.d.ts +2 -0
  2. package/dist/AnzuSystemsCommonAdmin.js.map +1 -1
  3. package/dist/common-admin.css +1 -1
  4. package/dist/common-admin.js +33 -29
  5. package/dist/domains/dam/api/damAssetApi.d.ts +12 -5
  6. package/dist/domains/dam/api/damAssetApi.js +66 -55
  7. package/dist/domains/dam/api/damAssetApi.js.map +1 -1
  8. package/dist/domains/dam/assetDetail/components/AssetDetailSidebarMetadata.vue_vue_type_script_setup_true_lang.js +1 -1
  9. package/dist/domains/dam/assetDetail/components/AssetDetailSidebarMetadata.vue_vue_type_script_setup_true_lang.js.map +1 -1
  10. package/dist/domains/dam/assetDetail/components/AssetMetadata.vue_vue_type_script_setup_true_lang.js +100 -108
  11. package/dist/domains/dam/assetDetail/components/AssetMetadata.vue_vue_type_script_setup_true_lang.js.map +1 -1
  12. package/dist/domains/dam/assetDetail/store/assetDetailStore.d.ts +2 -0
  13. package/dist/domains/dam/assetSelect/components/AAssetListInner.vue.d.ts +2 -0
  14. package/dist/domains/dam/assetSelect/components/AAssetSelect.vue.d.ts +1 -0
  15. package/dist/domains/dam/assetSelect/composables/assetSelectListActions.js +1 -1
  16. package/dist/domains/dam/assetSelect/composables/assetSelectListActions.js.map +1 -1
  17. package/dist/domains/dam/assetSelect/store/assetSelectStore.d.ts +112 -0
  18. package/dist/domains/dam/author/components/AuthorCreateButton.vue.d.ts +6 -0
  19. package/dist/domains/dam/author/components/AuthorCreateButton.vue_vue_type_script_setup_true_lang.js +13 -5
  20. package/dist/domains/dam/author/components/AuthorCreateButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
  21. package/dist/domains/dam/author/components/AuthorRemoteAutocompleteCachedAuthorChip.js +4 -2
  22. package/dist/domains/dam/author/components/AuthorRemoteAutocompleteCachedAuthorChip.js.map +1 -1
  23. package/dist/domains/dam/author/components/AuthorRemoteAutocompleteCachedAuthorChip.vue_vue_type_script_setup_true_lang.js +45 -39
  24. package/dist/domains/dam/author/components/AuthorRemoteAutocompleteCachedAuthorChip.vue_vue_type_script_setup_true_lang.js.map +1 -1
  25. package/dist/domains/dam/author/components/AuthorRemoteAutocompleteWithCached.js +1 -1
  26. package/dist/domains/dam/author/components/AuthorRemoteAutocompleteWithCached.vue.d.ts +15 -2
  27. package/dist/domains/dam/author/components/AuthorRemoteAutocompleteWithCached.vue_vue_type_script_setup_true_lang.js +118 -96
  28. package/dist/domains/dam/author/components/AuthorRemoteAutocompleteWithCached.vue_vue_type_script_setup_true_lang.js.map +1 -1
  29. package/dist/domains/dam/author/components/DamAuthorFilterRemoteAutocomplete.vue.d.ts +3 -0
  30. package/dist/domains/dam/author/components/DamAuthorFilterRemoteAutocomplete.vue_vue_type_script_setup_true_lang.js +5 -1
  31. package/dist/domains/dam/author/components/DamAuthorFilterRemoteAutocomplete.vue_vue_type_script_setup_true_lang.js.map +1 -1
  32. package/dist/domains/dam/author/components/DamSourcesAuthorsFields.js +8 -0
  33. package/dist/domains/dam/author/components/DamSourcesAuthorsFields.js.map +1 -0
  34. package/dist/domains/dam/author/components/DamSourcesAuthorsFields.vue.d.ts +67 -0
  35. package/dist/domains/dam/author/components/DamSourcesAuthorsFields.vue_vue_type_script_setup_true_lang.js +144 -0
  36. package/dist/domains/dam/author/components/DamSourcesAuthorsFields.vue_vue_type_script_setup_true_lang.js.map +1 -0
  37. package/dist/domains/dam/author/components/DamSourcesAuthorsRow.js +8 -0
  38. package/dist/domains/dam/author/components/DamSourcesAuthorsRow.js.map +1 -0
  39. package/dist/domains/dam/author/components/DamSourcesAuthorsRow.vue.d.ts +27 -0
  40. package/dist/domains/dam/author/components/DamSourcesAuthorsRow.vue_vue_type_script_setup_true_lang.js +47 -0
  41. package/dist/domains/dam/author/components/DamSourcesAuthorsRow.vue_vue_type_script_setup_true_lang.js.map +1 -0
  42. package/dist/domains/dam/author/composables/authorActions.js +2 -1
  43. package/dist/domains/dam/author/composables/authorActions.js.map +1 -1
  44. package/dist/domains/dam/author/composables/authorFieldRouting.d.ts +15 -0
  45. package/dist/domains/dam/author/composables/authorFieldRouting.js +18 -0
  46. package/dist/domains/dam/author/composables/authorFieldRouting.js.map +1 -0
  47. package/dist/domains/dam/author/composables/authorValidation.js +1 -1
  48. package/dist/domains/dam/author/composables/authorValidation.js.map +1 -1
  49. package/dist/domains/dam/author/composables/cachedAuthors.js +4 -2
  50. package/dist/domains/dam/author/composables/cachedAuthors.js.map +1 -1
  51. package/dist/domains/dam/author/composables/damAuthorConfig.d.ts +5 -0
  52. package/dist/domains/dam/author/composables/damAuthorConfig.js +5 -2
  53. package/dist/domains/dam/author/composables/damAuthorConfig.js.map +1 -1
  54. package/dist/domains/dam/author/composables/damCredit.d.ts +35 -0
  55. package/dist/domains/dam/author/composables/damCredit.js +44 -0
  56. package/dist/domains/dam/author/composables/damCredit.js.map +1 -0
  57. package/dist/domains/dam/author/composables/damSourceConfig.d.ts +15 -0
  58. package/dist/domains/dam/author/composables/damSourceConfig.js +19 -0
  59. package/dist/domains/dam/author/composables/damSourceConfig.js.map +1 -0
  60. package/dist/domains/dam/author/factory/AuthorFactory.js +3 -1
  61. package/dist/domains/dam/author/factory/AuthorFactory.js.map +1 -1
  62. package/dist/domains/dam/author/filter/AuthorFilter.d.ts +38 -4
  63. package/dist/domains/dam/author/filter/AuthorFilter.js +20 -6
  64. package/dist/domains/dam/author/filter/AuthorFilter.js.map +1 -1
  65. package/dist/domains/dam/author/types/DamAuthor.d.ts +4 -0
  66. package/dist/domains/dam/composables/commonAdminCoreDamOptions.d.ts +1 -0
  67. package/dist/domains/dam/composables/commonAdminCoreDamOptions.js +1 -0
  68. package/dist/domains/dam/composables/commonAdminCoreDamOptions.js.map +1 -1
  69. package/dist/domains/dam/imageWidget/components/ImageDetailDialogMetadata.vue.d.ts +9 -1
  70. package/dist/domains/dam/imageWidget/components/ImageDetailDialogMetadata.vue_vue_type_script_setup_true_lang.js +206 -204
  71. package/dist/domains/dam/imageWidget/components/ImageDetailDialogMetadata.vue_vue_type_script_setup_true_lang.js.map +1 -1
  72. package/dist/domains/dam/imageWidget/components/ImageMassOperations.vue_vue_type_script_setup_true_lang.js +165 -131
  73. package/dist/domains/dam/imageWidget/components/ImageMassOperations.vue_vue_type_script_setup_true_lang.js.map +1 -1
  74. package/dist/domains/dam/imageWidget/components/ImageMediaWidgetInner.vue_vue_type_script_setup_true_lang.js +344 -335
  75. package/dist/domains/dam/imageWidget/components/ImageMediaWidgetInner.vue_vue_type_script_setup_true_lang.js.map +1 -1
  76. package/dist/domains/dam/imageWidget/components/ImageWidgetInner.vue.d.ts +1 -0
  77. package/dist/domains/dam/imageWidget/components/ImageWidgetInner.vue_vue_type_script_setup_true_lang.js +251 -242
  78. package/dist/domains/dam/imageWidget/components/ImageWidgetInner.vue_vue_type_script_setup_true_lang.js.map +1 -1
  79. package/dist/domains/dam/imageWidget/components/ImageWidgetMultipleInner.vue.d.ts +1 -0
  80. package/dist/domains/dam/imageWidget/components/ImageWidgetMultipleInner.vue_vue_type_script_setup_true_lang.js +308 -303
  81. package/dist/domains/dam/imageWidget/components/ImageWidgetMultipleInner.vue_vue_type_script_setup_true_lang.js.map +1 -1
  82. package/dist/domains/dam/imageWidget/components/ImageWidgetMultipleItem.vue.d.ts +1 -0
  83. package/dist/domains/dam/imageWidget/components/ImageWidgetMultipleItem.vue_vue_type_script_setup_true_lang.js +84 -87
  84. package/dist/domains/dam/imageWidget/components/ImageWidgetMultipleItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
  85. package/dist/domains/dam/imageWidget/composables/imageDialogDamAuthors.d.ts +6 -3
  86. package/dist/domains/dam/imageWidget/composables/imageDialogDamAuthors.js +82 -77
  87. package/dist/domains/dam/imageWidget/composables/imageDialogDamAuthors.js.map +1 -1
  88. package/dist/domains/dam/imageWidget/composables/useImageMassOperations.d.ts +2 -0
  89. package/dist/domains/dam/imageWidget/composables/useImageMassOperations.js +59 -37
  90. package/dist/domains/dam/imageWidget/composables/useImageMassOperations.js.map +1 -1
  91. package/dist/domains/dam/imageWidget/store/imageStore.d.ts +2 -0
  92. package/dist/domains/dam/imageWidget/utils/metadataToImageMap.d.ts +3 -1
  93. package/dist/domains/dam/imageWidget/utils/metadataToImageMap.js +13 -22
  94. package/dist/domains/dam/imageWidget/utils/metadataToImageMap.js.map +1 -1
  95. package/dist/domains/dam/types/Asset.d.ts +1 -0
  96. package/dist/domains/dam/types/Asset.js.map +1 -1
  97. package/dist/domains/dam/types/DamConfig.d.ts +6 -0
  98. package/dist/domains/dam/types/DamConfig.js.map +1 -1
  99. package/dist/domains/dam/types/ImageAware.d.ts +1 -0
  100. package/dist/domains/dam/types/UploadQueue.d.ts +1 -0
  101. package/dist/domains/dam/types/UploadQueue.js.map +1 -1
  102. package/dist/domains/dam/uploadQueue/components/AssetQueueSelectedSidebar.vue_vue_type_script_setup_true_lang.js +204 -175
  103. package/dist/domains/dam/uploadQueue/components/AssetQueueSelectedSidebar.vue_vue_type_script_setup_true_lang.js.map +1 -1
  104. package/dist/domains/dam/uploadQueue/components/UploadQueueDialog.vue_vue_type_script_setup_true_lang.js +67 -65
  105. package/dist/domains/dam/uploadQueue/components/UploadQueueDialog.vue_vue_type_script_setup_true_lang.js.map +1 -1
  106. package/dist/domains/dam/uploadQueue/components/UploadQueueDialogSingle.vue_vue_type_script_setup_true_lang.js +71 -70
  107. package/dist/domains/dam/uploadQueue/components/UploadQueueDialogSingle.vue_vue_type_script_setup_true_lang.js.map +1 -1
  108. package/dist/domains/dam/uploadQueue/components/UploadQueueDialogSingleSidebarMetadataContent.vue_vue_type_script_setup_true_lang.js +83 -91
  109. package/dist/domains/dam/uploadQueue/components/UploadQueueDialogSingleSidebarMetadataContent.vue_vue_type_script_setup_true_lang.js.map +1 -1
  110. package/dist/domains/dam/uploadQueue/components/UploadQueueEditable.vue_vue_type_script_setup_true_lang.js +4 -0
  111. package/dist/domains/dam/uploadQueue/components/UploadQueueEditable.vue_vue_type_script_setup_true_lang.js.map +1 -1
  112. package/dist/domains/dam/uploadQueue/components/UploadQueueItemEditable.vue.d.ts +10 -2
  113. package/dist/domains/dam/uploadQueue/components/UploadQueueItemEditable.vue_vue_type_script_setup_true_lang.js +178 -177
  114. package/dist/domains/dam/uploadQueue/components/UploadQueueItemEditable.vue_vue_type_script_setup_true_lang.js.map +1 -1
  115. package/dist/domains/dam/uploadQueue/components/uploadQueueBindings.d.ts +2 -0
  116. package/dist/domains/dam/uploadQueue/components/uploadQueueBindings.js +4 -3
  117. package/dist/domains/dam/uploadQueue/components/uploadQueueBindings.js.map +1 -1
  118. package/dist/domains/dam/uploadQueue/composables/uploadQueueMassOperations.d.ts +1 -0
  119. package/dist/domains/dam/uploadQueue/composables/uploadQueueMassOperations.js +11 -8
  120. package/dist/domains/dam/uploadQueue/composables/uploadQueueMassOperations.js.map +1 -1
  121. package/dist/domains/dam/uploadQueue/core/uploadQueueFill.d.ts +2 -0
  122. package/dist/domains/dam/uploadQueue/core/uploadQueueFill.js +4 -1
  123. package/dist/domains/dam/uploadQueue/core/uploadQueueFill.js.map +1 -1
  124. package/dist/domains/dam/uploadQueue/factory/UploadQueueItemFactory.js +1 -0
  125. package/dist/domains/dam/uploadQueue/factory/UploadQueueItemFactory.js.map +1 -1
  126. package/dist/domains/dam/uploadQueue/settlement/uploadSettle.js +4 -4
  127. package/dist/domains/dam/uploadQueue/settlement/uploadSettle.js.map +1 -1
  128. package/dist/domains/dam/uploadQueue/store/uploadQueuesStore.d.ts +1 -0
  129. package/dist/domains/dam/uploadQueue/store/uploadQueuesStore.js +7 -4
  130. package/dist/domains/dam/uploadQueue/store/uploadQueuesStore.js.map +1 -1
  131. package/dist/domains/filters/datatable/components/ADatatableSidePanel.vue_vue_type_script_setup_true_lang.js.map +1 -1
  132. package/dist/domains/filters/datatable/components/ALiveListingPill.vue_vue_type_script_setup_true_lang.js +12 -12
  133. package/dist/domains/filters/datatable/components/ALiveListingPill.vue_vue_type_script_setup_true_lang.js.map +1 -1
  134. package/dist/domains/filters/datatable/composables/useLiveListing.js +14 -11
  135. package/dist/domains/filters/datatable/composables/useLiveListing.js.map +1 -1
  136. package/dist/domains/remoteAutocomplete/components/AFormRemoteAutocompleteWithCached.vue.d.ts +3 -0
  137. package/dist/domains/remoteAutocomplete/components/AFormRemoteAutocompleteWithCached.vue_vue_type_script_setup_true_lang.js +6 -2
  138. package/dist/domains/remoteAutocomplete/components/AFormRemoteAutocompleteWithCached.vue_vue_type_script_setup_true_lang.js.map +1 -1
  139. package/dist/lib.d.ts +5 -1
  140. package/dist/locales/cs/common/assetSelect.js +1 -1
  141. package/dist/locales/cs/common/damImage.js +84 -10
  142. package/dist/locales/cs/common/damImage.js.map +1 -1
  143. package/dist/locales/cs.d.ts +6 -0
  144. package/dist/locales/en/common/assetSelect.js +1 -1
  145. package/dist/locales/en/common/damImage.js +84 -10
  146. package/dist/locales/en/common/damImage.js.map +1 -1
  147. package/dist/locales/en.d.ts +6 -0
  148. package/dist/locales/sk/common/assetSelect.js +1 -1
  149. package/dist/locales/sk/common/damImage.js +84 -10
  150. package/dist/locales/sk/common/damImage.js.map +1 -1
  151. package/dist/locales/sk.d.ts +6 -0
  152. package/dist/plugins/i18n.d.ts +6 -0
  153. package/package.json +26 -26
@@ -1 +1 @@
1
- {"version":3,"file":"ALiveListingPill.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createBlock","_component_VChip","_withCtx","_createTextVNode","_toDisplayString","_unref","_component_VBtn","_withModifiers","_hoisted_1","ALiveListingPill_vue_vue_type_script_setup_true_lang_default","__emit","props","__props","emit","useI18n","text","computed","overflow","count","t","openBlock","createElementBlock","createBlock","VChip","withCtx","createTextVNode","toDisplayString","unref","VBtn","_cache","withModifiers","createCommentVNode"],"sources":["../../../../../src/domains/filters/datatable/components/ALiveListingPill.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed } from 'vue'\nimport { useI18n } from 'vue-i18n'\n\nconst props = withDefaults(\n defineProps<{\n count: number\n max?: number\n failed?: boolean\n /** Records already listed changed: the pill offers a reload while nothing new is counted. */\n changed?: boolean\n /** New records are looked for less promptly than usual, e.g. while backend signals are down. */\n degraded?: boolean\n /** Key with the plural forms `1 | 2–4 | 5+`; `{count}` is the number, or `max+` above `max`. */\n textKey?: string\n }>(),\n {\n max: 9,\n failed: false,\n changed: false,\n degraded: false,\n textKey: 'common.system.datatable.liveListing.newRecords',\n }\n)\nconst emit = defineEmits<{\n (e: 'click'): void\n}>()\n\nconst { t } = useI18n()\n\nconst text = computed(() => {\n const overflow = props.count > props.max\n const count = overflow ? `${props.max}+` : props.count\n return t(props.textKey, { count }, overflow ? props.max + 1 : props.count)\n})\n</script>\n\n<template>\n <div class=\"a-live-listing-pill\">\n <VChip\n v-if=\"failed\"\n color=\"warning\"\n variant=\"flat\"\n size=\"small\"\n prepend-icon=\"mdi-alert-outline\"\n class=\"a-live-listing-pill__item\"\n >\n {{ t('common.system.datatable.liveListing.failed') }}\n </VChip>\n <VBtn\n v-else-if=\"count > 0\"\n color=\"primary\"\n size=\"small\"\n rounded=\"pill\"\n prepend-icon=\"mdi-arrow-up\"\n class=\"a-live-listing-pill__item\"\n @click.stop=\"emit('click')\"\n >\n {{ text }}\n </VBtn>\n <VBtn\n v-else-if=\"changed\"\n color=\"primary\"\n size=\"small\"\n rounded=\"pill\"\n prepend-icon=\"mdi-refresh\"\n class=\"a-live-listing-pill__item\"\n @click.stop=\"emit('click')\"\n >\n {{ t('common.system.datatable.liveListing.changes') }}\n </VBtn>\n <VChip\n v-else-if=\"degraded\"\n color=\"warning\"\n variant=\"flat\"\n size=\"small\"\n prepend-icon=\"mdi-lan-disconnect\"\n class=\"a-live-listing-pill__item\"\n >\n {{ t('common.system.datatable.liveListing.degraded') }}\n </VChip>\n </div>\n</template>\n\n<style lang=\"scss\">\n// Floats over the top of the list and stays there while it scrolls; it takes no height, so no row moves.\n.a-live-listing-pill {\n position: sticky;\n top: calc(var(--v-layout-top, 0px) + 0.25rem);\n z-index: 3;\n display: flex;\n justify-content: center;\n height: 0;\n overflow: visible;\n\n &__item {\n margin-top: 0.25rem;\n }\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;EAIA,IAAMa,IAAQC,GAoBRC,IAAOH,GAIP,EAAE,SAAMI,EAAQ,GAEhBC,IAAOC,QAAe;GAC1B,IAAMC,IAAWN,EAAM,QAAQA,EAAM,KAC/BO,IAAQD,IAAW,GAAGN,EAAM,IAAI,KAAKA,EAAM;GACjD,OAAOQ,EAAER,EAAM,SAAS,EAAE,SAAM,GAAGM,IAAWN,EAAM,MAAM,IAAIA,EAAM,KAAK;EAC3E,CAAC;E,kBAICb,EAAA,GAAAC,EA2CM,OA3CNS,GA2CM,CAzCII,EAAA,UADRd,EAAA,GAAAE,EASQC,GAAA;;GAPN,OAAM;GACN,SAAQ;GACR,MAAK;GACL,gBAAa;GACb,OAAM;;GAEN,SAAAC,QAAqD,CAAlDC,EAAAC,EAAAC,EAAAc,CAAA,CAAC,CAAA,4CAAA,CAAA,GAAA,CAAA,C;;E,MAGOP,EAAA,QAAK,KADlBd,EAAA,GAAAE,EAUOM,GAAA;;GARL,OAAM;GACN,MAAK;GACL,SAAQ;GACR,gBAAa;GACb,OAAM;GACL,SAAK,AAAAuB,EAAA,OAAAtB,GAAA,MAAOM,EAAI,OAAA,GAAA,CAAA,MAAA,CAAA;;GAEjB,SAAAX,QAAU,CAAPC,EAAAC,EAAAW,EAAA,KAAI,GAAA,CAAA,C;;E,MAGIH,EAAA,WADbd,EAAA,GAAAE,EAUOM,GAAA;;GARL,OAAM;GACN,MAAK;GACL,SAAQ;GACR,gBAAa;GACb,OAAM;GACL,SAAK,AAAAuB,EAAA,OAAAtB,GAAA,MAAOM,EAAI,OAAA,GAAA,CAAA,MAAA,CAAA;;GAEjB,SAAAX,QAAsD,CAAnDC,EAAAC,EAAAC,EAAAc,CAAA,CAAC,CAAA,6CAAA,CAAA,GAAA,CAAA,C;;E,MAGOP,EAAA,YADbd,EAAA,GAAAE,EASQC,GAAA;;GAPN,OAAM;GACN,SAAQ;GACR,MAAK;GACL,gBAAa;GACb,OAAM;;GAEN,SAAAC,QAAuD,CAApDC,EAAAC,EAAAC,EAAAc,CAAA,CAAC,CAAA,8CAAA,CAAA,GAAA,CAAA,C"}
1
+ {"version":3,"file":"ALiveListingPill.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createBlock","_component_VBtn","_withModifiers","_withCtx","_createTextVNode","_toDisplayString","_unref","_component_VChip","_hoisted_1","ALiveListingPill_vue_vue_type_script_setup_true_lang_default","__emit","props","__props","emit","useI18n","text","computed","overflow","count","t","openBlock","createElementBlock","createBlock","VBtn","_cache","withModifiers","withCtx","createTextVNode","toDisplayString","unref","VChip","createCommentVNode"],"sources":["../../../../../src/domains/filters/datatable/components/ALiveListingPill.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed } from 'vue'\nimport { useI18n } from 'vue-i18n'\n\nconst props = withDefaults(\n defineProps<{\n count: number\n max?: number\n failed?: boolean\n /** Records already listed changed: the pill offers a reload while nothing new is counted. */\n changed?: boolean\n /** New records are looked for less promptly than usual, e.g. while backend signals are down. */\n degraded?: boolean\n /** Key with the plural forms `1 | 2–4 | 5+`; `{count}` is the number, or `max+` above `max`. */\n textKey?: string\n }>(),\n {\n max: 9,\n failed: false,\n changed: false,\n degraded: false,\n textKey: 'common.system.datatable.liveListing.newRecords',\n }\n)\nconst emit = defineEmits<{\n (e: 'click'): void\n}>()\n\nconst { t } = useI18n()\n\nconst text = computed(() => {\n const overflow = props.count > props.max\n const count = overflow ? `${props.max}+` : props.count\n return t(props.textKey, { count }, overflow ? props.max + 1 : props.count)\n})\n</script>\n\n<template>\n <div class=\"a-live-listing-pill\">\n <!-- An offered reload stays clickable after a failed probe: the click loads the list anyway. -->\n <VBtn\n v-if=\"count > 0\"\n color=\"primary\"\n size=\"small\"\n rounded=\"pill\"\n prepend-icon=\"mdi-arrow-up\"\n class=\"a-live-listing-pill__item\"\n @click.stop=\"emit('click')\"\n >\n {{ text }}\n </VBtn>\n <VBtn\n v-else-if=\"changed\"\n color=\"primary\"\n size=\"small\"\n rounded=\"pill\"\n prepend-icon=\"mdi-refresh\"\n class=\"a-live-listing-pill__item\"\n @click.stop=\"emit('click')\"\n >\n {{ t('common.system.datatable.liveListing.changes') }}\n </VBtn>\n <VChip\n v-else-if=\"failed\"\n color=\"warning\"\n variant=\"flat\"\n size=\"small\"\n prepend-icon=\"mdi-alert-outline\"\n class=\"a-live-listing-pill__item\"\n >\n {{ t('common.system.datatable.liveListing.failed') }}\n </VChip>\n <VChip\n v-else-if=\"degraded\"\n color=\"warning\"\n variant=\"flat\"\n size=\"small\"\n prepend-icon=\"mdi-lan-disconnect\"\n class=\"a-live-listing-pill__item\"\n >\n {{ t('common.system.datatable.liveListing.degraded') }}\n </VChip>\n </div>\n</template>\n\n<style lang=\"scss\">\n// Floats over the top of the list and stays there while it scrolls; it takes no height, so no row moves.\n.a-live-listing-pill {\n position: sticky;\n top: calc(var(--v-layout-top, 0px) + 0.25rem);\n z-index: 3;\n display: flex;\n justify-content: center;\n height: 0;\n overflow: visible;\n\n &__item {\n margin-top: 0.25rem;\n }\n}\n\n// A card clips its content with overflow: hidden, which also makes it the box the pill sticks in, so the pill would\n// scroll away with the list; clip cuts the same edges and leaves the pill stuck to the window.\n.v-card:has(.a-live-listing-pill) {\n overflow: clip;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;EAIA,IAAMa,IAAQC,GAoBRC,IAAOH,GAIP,EAAE,SAAMI,EAAQ,GAEhBC,IAAOC,QAAe;GAC1B,IAAMC,IAAWN,EAAM,QAAQA,EAAM,KAC/BO,IAAQD,IAAW,GAAGN,EAAM,IAAI,KAAKA,EAAM;GACjD,OAAOQ,EAAER,EAAM,SAAS,EAAE,SA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e4, c = (e, t) => {
8
8
  if (typeof e == "number" && typeof t == "number") return e - t;
9
9
  let n = String(e), r = String(t);
10
10
  return n === r ? 0 : n < r ? -1 : 1;
11
- }, ne = (e) => {
11
+ }, l = (e) => {
12
12
  try {
13
13
  return JSON.stringify(e) ?? "";
14
14
  } catch {
@@ -18,14 +18,14 @@ var s = {
18
18
  function u(s) {
19
19
  let u = s.max ?? 9, d = s.minIntervalMs ?? 1e4, re = s.debounceMs ?? 1500, f = s.newness ?? "newer", p = Math.max(s.probeLimit ?? u + 1, u + 1), m = () => a(s.interval) ?? !1, h = r(0), g = r(!1), _ = r(!1), v = e(() => h.value > u), ie = e(() => h.value === 0 ? "" : v.value ? `${u}+` : String(h.value)), y, b = i(void 0), x = (e) => {
20
20
  y = e, b.value = e;
21
- }, S, C = /* @__PURE__ */ new Set(), w, T = 0, E, D, O = !1, k = 0, A, j, M, N = 0, P = !1, F = 0, I = 0, L, R, z, B = !1, V = ee(), ae = (e) => f === "unseen" ? y !== void 0 && !C.has(e) && (w === void 0 || l(e, w) > 0) : y === null || y !== void 0 && l(e, y) > 0, H = (e, t) => {
22
- S !== t && C.clear(), (S !== t || y == null || e !== null && l(e, y) > 0) && x(e), S = t;
21
+ }, S, C = /* @__PURE__ */ new Set(), w, T = 0, E, D, O = !1, k = 0, A, j, M, N = 0, P = !1, F = 0, I = 0, L, R, z, B = !1, V = ee(), ae = (e) => f === "unseen" ? y !== void 0 && !C.has(e) && (w === void 0 || c(e, w) > 0) : y === null || y !== void 0 && c(e, y) > 0, H = (e, t) => {
22
+ S !== t && C.clear(), (S !== t || y == null || e !== null && c(e, y) > 0) && x(e), S = t;
23
23
  }, U = (e) => e.reduce((e, t) => {
24
24
  let n = s.key(t);
25
- return e === null || l(n, e) > 0 ? n : e;
25
+ return e === null || c(n, e) > 0 ? n : e;
26
26
  }, null), oe = (e) => e.reduce((e, t) => {
27
27
  let n = s.key(t);
28
- return e === void 0 || l(n, e) < 0 ? n : e;
28
+ return e === void 0 || c(n, e) < 0 ? n : e;
29
29
  }, void 0), W = (e) => {
30
30
  f === "unseen" && (e.forEach((e) => C.add(s.key(e))), w = e.length >= p ? oe(e) : void 0);
31
31
  }, G = () => {
@@ -34,7 +34,7 @@ function u(s) {
34
34
  clearTimeout(A), clearTimeout(j), clearTimeout(M), A = void 0, j = void 0, M = void 0;
35
35
  }, q = (e) => {
36
36
  if (clearTimeout(M), B) return;
37
- let t = Math.min(d * 2 ** N, c);
37
+ let t = Math.min(d * 2 ** N, ne);
38
38
  N += 1, M = setTimeout(() => {
39
39
  M = void 0, e();
40
40
  }, t);
@@ -106,10 +106,10 @@ function u(s) {
106
106
  T += 1, ce() && (P = !0);
107
107
  let n = L !== void 0 && R !== void 0 ? Math.min(L, R) : L ?? R;
108
108
  _.value = n !== void 0 && I > n, a(s.loading) || (R = void 0), G(), K(), h.value = 0, N = 0, g.value = !1;
109
- let r = ne(a(s.scope)), i = t.newestFirst ? e : t.newest;
109
+ let r = l(a(s.scope)), i = t.newestFirst ? e : t.newest;
110
110
  i ? (H(U(i), r), W(i), X(), Y()) : (x(void 0), X(), $(r, T));
111
111
  }, ue = () => {
112
- B || T === 0 || (F += 1, I = F, _.value = !0);
112
+ B || T === 0 && R === void 0 || (F += 1, I = F, T > 0 && (_.value = !0));
113
113
  }, de = async () => {
114
114
  (j !== void 0 || O || D !== void 0) && (P = !0), D &&= (D.abort(), E === D && (E = void 0), void 0), O = !1, clearTimeout(A), clearTimeout(j), A = void 0, j = void 0;
115
115
  let e = T;
@@ -122,7 +122,10 @@ function u(s) {
122
122
  };
123
123
  return s.loading !== void 0 && o(() => !!a(s.loading), (e, t) => {
124
124
  e && !t && (R = F);
125
- }, { flush: "sync" }), o(() => a(s.interval), () => {
125
+ }, {
126
+ flush: "sync",
127
+ immediate: !0
128
+ }), o(() => a(s.interval), () => {
126
129
  !B && y !== void 0 && X();
127
130
  }), o(V, (e) => {
128
131
  B || y === void 0 || (e === "visible" && !v.value && Date.now() - k > te && Z(), X());
@@ -144,6 +147,6 @@ function u(s) {
144
147
  }), z)
145
148
  };
146
149
  }
147
- export { s as LIVE_LISTING_INTERVAL, l as compareLiveListingKeys, u as useLiveListing };
150
+ export { s as LIVE_LISTING_INTERVAL, c as compareLiveListingKeys, u as useLiveListing };
148
151
 
149
152
  //# sourceMappingURL=useLiveListing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLiveListing.js","names":["LIVE_LISTING_INTERVAL","RETURN_PROBE_GAP_MS","MAX_RETRY_MS","compareLiveListingKeys","a","b","sa","sb","serializeScope","scope","useLiveListing","max","options","minIntervalMs","debounceMs","newness","probeLimit","currentInterval","toValue","count","ref","failed","changed","overflow","computed","label","baseline","baselineState","shallowRef","setBaseline","value","baselineScope","seenKeys","seenFloor","generation","controller","probeInFlight","rerun","lastProbeAt","intervalTimer","signalTimer","retryTimer","failures","probeWanted","signals","changedAtSignal","applyingFrom","loadingFrom","applying","disposed","visibility","useDocumentVisibility","isNew","key","raiseBaseline","newestKey","items","item","newest","oldestKey","oldest","see","abortProbe","clearTimers","scheduleRetry","ms","run","succeeded","runWantedProbe","scheduleProbe","scheduleInterval","interval","runProbe","myGeneration","myController","wait","requestProbe","fetchBaseline","limit","signalPending","markLoaded","loadFrom","seenNewest","loaded","markChanged","reloadOnClick","loadsBefore","watch","before","onScopeDispose","readonly"],"sources":["../../../../../src/domains/filters/datatable/composables/useLiveListing.ts"],"sourcesContent":["import { useDocumentVisibility } from '@vueuse/core'\nimport { computed, onScopeDispose, readonly, ref, shallowRef, toValue, watch, type MaybeRefOrGetter } from 'vue'\n\nexport type LiveListingKey = number | string\n\nexport interface LiveListingProbeOptions {\n limit: number\n signal: AbortSignal\n}\n\nexport interface LiveListingInterval {\n /** Probe period while the browser tab is visible. */\n visibleMs: number\n /** Probe period while the browser tab is hidden, so a count in the browser title stays fresh. */\n hiddenMs: number\n}\n\n/**\n * How often a list without backend signals probes for new records: every 10 s while the browser tab is visible,\n * every minute while it is hidden, so a count in the browser title stays fresh.\n */\nexport const LIVE_LISTING_INTERVAL: LiveListingInterval = { visibleMs: 10_000, hiddenMs: 60_000 }\n\n/**\n * How a record counts as new: `newer` than the newest record the user has seen, or `unseen`, a record of the probe\n * the user has not seen listed, for listings where a record can enter with a key older than the newest one.\n */\nexport type LiveListingNewness = 'newer' | 'unseen'\n\nexport interface UseLiveListingOptions<T> {\n /**\n * Newest records under the current filters, newest first by `key`, at most `limit` of them.\n * It must leave the shown list alone and load nothing else for the rows.\n */\n probe: (options: LiveListingProbeOptions) => Promise<T[]>\n /** Newness key: an autoincrement id, or a UTC datetime string in one format. */\n key: (item: T) => LiveListingKey\n /** Fetches the list on the click of the pill and reports it back with `markLoaded`. */\n reload: () => Promise<void>\n /** What the user filters by. When it changes, the baseline is set anew; otherwise it never decreases. */\n scope?: MaybeRefOrGetter<unknown>\n /** Probes on a timer, for listings without a backend signal, or while it is down. */\n interval?: MaybeRefOrGetter<LiveListingInterval | false>\n newness?: LiveListingNewness\n /**\n * How many of the newest records a probe asks for. Default `max + 1`; with `unseen` newness give the page size,\n * as an unseen record can enter anywhere on the first page.\n */\n probeLimit?: number\n /** Highest count shown as a number, more is shown as `max+`. */\n max?: number\n /** Shortest gap between the start of two probes requested by signals. */\n minIntervalMs?: number\n /** Wait after a signal, so a burst of signals ends in one probe. */\n debounceMs?: number\n /**\n * Whether the list is loading, for loads not started by the pill (a filter, the user's own change): a change\n * signalled after such a load started stays offered after its `markLoaded`, as the load may have read the record\n * before it changed. Without it such a load forgets every change offered.\n */\n loading?: MaybeRefOrGetter<boolean>\n}\n\nconst RETURN_PROBE_GAP_MS = 2000\nconst MAX_RETRY_MS = 60_000\n\n/** Orders newness keys: numbers by value, strings (UTC datetimes in one format) as text. */\nexport const compareLiveListingKeys = (a: LiveListingKey, b: LiveListingKey) => {\n if (typeof a === 'number' && typeof b === 'number') return a - b\n const sa = String(a)\n const sb = String(b)\n if (sa === sb) return 0\n return sa < sb ? -1 : 1\n}\n\nconst serializeScope = (scope: unknown) => {\n try {\n return JSON.stringify(scope) ?? ''\n } catch {\n return String(scope)\n }\n}\n\n/**\n * Tells the user that new records exist under the current filters, without changing the list until they click.\n * A probe (a small list request, newest first) runs on a signal, on a timer or when the user returns to the\n * browser tab; its records newer than the baseline are the count. The baseline is the newest record the user\n * has seen, taken from every full load reported through `markLoaded`.\n */\nexport function useLiveListing<T>(options: UseLiveListingOptions<T>) {\n const max = options.max ?? 9\n const minIntervalMs = options.minIntervalMs ?? 10_000\n const debounceMs = options.debounceMs ?? 1500\n const newness = options.newness ?? 'newer'\n const probeLimit = Math.max(options.probeLimit ?? max + 1, max + 1)\n const currentInterval = () => toValue(options.interval) ?? false\n\n const count = ref(0)\n const failed = ref(false)\n const changed = ref(false)\n const overflow = computed(() => count.value > max)\n const label = computed(() => {\n if (count.value === 0) return ''\n return overflow.value ? `${max}+` : String(count.value)\n })\n\n // undefined: not known yet, nothing is probed; null: the filtered list was empty, every record is new.\n let baseline: LiveListingKey | null | undefined = undefined\n // The same, for callers that keep what the user has seen, e.g. for a count on an inactive tab.\n const baselineState = shallowRef<LiveListingKey | null | undefined>(undefined)\n const setBaseline = (value: LiveListingKey | null | undefined) => {\n baseline = value\n baselineState.value = value\n }\n let baselineScope: string | undefined = undefined\n // With `unseen` newness: the keys the user has seen listed under the baseline scope.\n const seenKeys = new Set<LiveListingKey>()\n // With `unseen` newness: the oldest record of the last full load when it filled the probe. An unseen record below\n // it reached the first page because listed ones left the filter, not because it entered.\n let seenFloor: LiveListingKey | undefined = undefined\n // Bumped by every full load: answers of probes started before it are dropped.\n let generation = 0\n let controller: AbortController | undefined = undefined\n // The controller of a probe in flight, as opposed to a baseline fetch.\n let probeInFlight: AbortController | undefined = undefined\n let rerun = false\n let lastProbeAt = 0\n let intervalTimer: ReturnType<typeof setTimeout> | undefined = undefined\n let signalTimer: ReturnType<typeof setTimeout> | undefined = undefined\n // A failed probe or baseline fetch is tried again, less and less often, also when no interval runs.\n let retryTimer: ReturnType<typeof setTimeout> | undefined = undefined\n let failures = 0\n // A probe asked for while no baseline is known, or while a full load replaces the list: it runs once the list is.\n let probeWanted = false\n // Signals (`requestProbe`, `markChanged`) counted, so the pill's reload can tell those that came while it ran.\n let signals = 0\n let changedAtSignal = 0\n let applyingFrom: number | undefined = undefined\n // The signals counted when the current or last load given by `loading` started.\n let loadingFrom: number | undefined = undefined\n let applying: Promise<void> | undefined = undefined\n let disposed = false\n\n const visibility = useDocumentVisibility()\n\n const isNew = (key: LiveListingKey) => {\n if (newness === 'unseen') {\n return (\n baseline !== undefined &&\n !seenKeys.has(key) &&\n (seenFloor === undefined || compareLiveListingKeys(key, seenFloor) > 0)\n )\n }\n return baseline === null || (baseline !== undefined && compareLiveListingKeys(key, baseline) > 0)\n }\n\n const raiseBaseline = (key: LiveListingKey | null, scope: string) => {\n if (baselineScope !== scope) seenKeys.clear()\n if (baselineScope !== scope || baseline === undefined || baseline === null) {\n setBaseline(key)\n } else if (key !== null && compareLiveListingKeys(key, baseline) > 0) {\n setBaseline(key)\n }\n baselineScope = scope\n }\n\n const newestKey = (items: T[]) =>\n items.reduce<LiveListingKey | null>((newest, item) => {\n const key = options.key(item)\n return newest === null || compareLiveListingKeys(key, newest) > 0 ? key : newest\n }, null)\n\n const oldestKey = (items: T[]) =>\n items.reduce<LiveListingKey | undefined>((oldest, item) => {\n const key = options.key(item)\n return oldest === undefined || compareLiveListingKeys(key, oldest) < 0 ? key : oldest\n }, undefined)\n\n const see = (items: T[]) => {\n if (newness !== 'unseen') return\n items.forEach((item) => seenKeys.add(options.key(item)))\n // Fewer records than the probe asks for were all there were under the filter, so nothing can slide in.\n seenFloor = items.length >= probeLimit ? oldestKey(items) : undefined\n }\n\n const abortProbe = () => {\n controller?.abort()\n controller = undefined\n probeInFlight = undefined\n rerun = false\n }\n\n const clearTimers = () => {\n clearTimeout(intervalTimer)\n clearTimeout(signalTimer)\n clearTimeout(retryTimer)\n intervalTimer = undefined\n signalTimer = undefined\n retryTimer = undefined\n }\n\n const scheduleRetry = (run: () => void) => {\n clearTimeout(retryTimer)\n if (disposed) return\n const ms = Math.min(minIntervalMs * 2 ** failures, MAX_RETRY_MS)\n failures += 1\n retryTimer = setTimeout(() => {\n retryTimer = undefined\n run()\n }, ms)\n }\n\n const succeeded = () => {\n failures = 0\n clearTimeout(retryTimer)\n retryTimer = undefined\n failed.value = false\n }\n\n const runWantedProbe = () => {\n if (!probeWanted) return\n probeWanted = false\n scheduleProbe()\n }\n\n const scheduleInterval = () => {\n clearTimeout(intervalTimer)\n intervalTimer = undefined\n const interval = currentInterval()\n if (!interval || disposed || overflow.value || baseline === undefined) return\n const ms = visibility.value === 'hidden' ? interval.hiddenMs : interval.visibleMs\n intervalTimer = setTimeout(async () => {\n intervalTimer = undefined\n await runProbe()\n scheduleInterval()\n }, ms)\n }\n\n const runProbe = async () => {\n if (disposed || baseline === undefined || overflow.value) return\n if (controller) {\n rerun = true\n return\n }\n const myGeneration = generation\n const myController = new AbortController()\n controller = myController\n probeInFlight = myController\n lastProbeAt = Date.now()\n try {\n const items = await options.probe({ limit: probeLimit, signal: myController.signal })\n if (myController.signal.aborted || myGeneration !== generation) return\n count.value = items.filter((item) => isNew(options.key(item))).length\n succeeded()\n if (overflow.value) clearTimers()\n } catch {\n if (myController.signal.aborted || myGeneration !== generation) return\n failed.value = true\n // The interval tries again on its own; signals may not come for long.\n if (!currentInterval()) scheduleRetry(() => void runProbe())\n } finally {\n if (controller === myController) controller = undefined\n if (probeInFlight === myController) probeInFlight = undefined\n if (rerun && !myController.signal.aborted) {\n rerun = false\n scheduleProbe()\n }\n }\n }\n\n const scheduleProbe = () => {\n if (disposed || overflow.value) return\n if (baseline === undefined) {\n probeWanted = true\n return\n }\n if (signalTimer) return\n const wait = Math.max(debounceMs, lastProbeAt + minIntervalMs - Date.now())\n signalTimer = setTimeout(() => {\n signalTimer = undefined\n void runProbe()\n }, wait)\n }\n\n /** Asks for a probe, e.g. on a backend signal. A burst of requests ends in one probe. */\n const requestProbe = () => {\n if (disposed) return\n signals += 1\n scheduleProbe()\n }\n\n const fetchBaseline = async (scope: string, myGeneration: number) => {\n const myController = new AbortController()\n controller = myController\n try {\n // With `unseen` newness, what the probe would count is seen: the list the user looks at holds it.\n const limit = newness === 'unseen' ? probeLimit : 1\n const items = await options.probe({ limit, signal: myController.signal })\n if (myController.signal.aborted || myGeneration !== generation) return\n raiseBaseline(newestKey(items), scope)\n see(items)\n succeeded()\n scheduleInterval()\n runWantedProbe()\n } catch {\n if (myController.signal.aborted || myGeneration !== generation) return\n failed.value = true\n // Without a baseline nothing is probed, so the fetch itself is tried again.\n scheduleRetry(() => {\n if (myGeneration === generation) void fetchBaseline(scope, myGeneration)\n })\n } finally {\n if (controller === myController) controller = undefined\n if (rerun && !myController.signal.aborted) {\n rerun = false\n scheduleProbe()\n }\n }\n }\n\n // A probe still to run or running may announce records the load did not see; so may one that counted records\n // while the load ran, unknown outside the pill's reload, which knows when it started.\n const signalPending = () =>\n signalTimer !== undefined ||\n rerun ||\n probeInFlight !== undefined ||\n (applyingFrom !== undefined ? signals > applyingFrom : count.value > 0)\n\n /**\n * Reports a successful full load of the list: a filter, a sort, page 1 or a reload after the click.\n * `newestFirst`: the items are page 1 sorted newest first, so the newest of them is the baseline.\n * Otherwise `newest` gives it: what the probe returns under the loaded filters (one record, with `unseen` newness\n * `probeLimit`), asked for when the load started, so a record created while the list loaded is counted, at worst\n * one the list shows. Without it one probe after the load finds the baseline and takes such a record as seen.\n * A switch to another page needs no report. The changes offered end, except those signalled while the pill's\n * reload or a load given by `loading` ran.\n */\n const markLoaded = (items: T[], loaded: { newestFirst: boolean; newest?: T[] }) => {\n generation += 1\n if (signalPending()) probeWanted = true\n // A change signalled while the load ran (the pill's reload, or one given by `loading`) may be newer than what it\n // loaded.\n const loadFrom =\n applyingFrom !== undefined && loadingFrom !== undefined\n ? Math.min(applyingFrom, loadingFrom)\n : (applyingFrom ?? loadingFrom)\n changed.value = loadFrom !== undefined && changedAtSignal > loadFrom\n if (!toValue(options.loading)) loadingFrom = undefined\n abortProbe()\n clearTimers()\n count.value = 0\n failures = 0\n failed.value = false\n const scope = serializeScope(toValue(options.scope))\n const seenNewest = loaded.newestFirst ? items : loaded.newest\n if (seenNewest) {\n raiseBaseline(newestKey(seenNewest), scope)\n see(seenNewest)\n scheduleInterval()\n runWantedProbe()\n return\n }\n // No probe runs until the new baseline is known: under other filters the old one means nothing, under the same\n // ones it may be older than the rows shown, so a probe would count them.\n setBaseline(undefined)\n scheduleInterval()\n void fetchBaseline(scope, generation)\n }\n\n /**\n * Asks the user to reload the list because records already in it changed, e.g. moved to another tab or got\n * another status, which no count shows. The pill offers it while nothing new is counted.\n */\n const markChanged = () => {\n // Before the first load nothing is shown that could change.\n if (disposed || generation === 0) return\n signals += 1\n changedAtSignal = signals\n changed.value = true\n }\n\n const reloadOnClick = async () => {\n if (signalTimer !== undefined || rerun || probeInFlight !== undefined) probeWanted = true\n // Only probes stop: a baseline still being fetched is needed when the reload fails.\n if (probeInFlight) {\n probeInFlight.abort()\n if (controller === probeInFlight) controller = undefined\n probeInFlight = undefined\n }\n rerun = false\n clearTimeout(intervalTimer)\n clearTimeout(signalTimer)\n intervalTimer = undefined\n signalTimer = undefined\n const loadsBefore = generation\n applyingFrom = signals\n // The start of an earlier load that reported nothing says nothing about this one.\n if (!toValue(options.loading)) loadingFrom = undefined\n try {\n await options.reload()\n } finally {\n applyingFrom = undefined\n // A fetched list reported itself through `markLoaded`, which started the counting anew. Without one nothing\n // was shown: the pill keeps what it offered and the looking goes on.\n if (generation === loadsBefore) {\n scheduleInterval()\n runWantedProbe()\n }\n }\n }\n\n /**\n * The click on the pill: reloads the list and starts counting again from it. A click while the reload runs\n * waits for the same reload.\n */\n const apply = () => {\n applying ??= reloadOnClick().finally(() => {\n applying = undefined\n })\n return applying\n }\n\n if (options.loading !== undefined) {\n watch(\n () => Boolean(toValue(options.loading)),\n (value, before) => {\n if (value && !before) loadingFrom = signals\n },\n { flush: 'sync' }\n )\n }\n\n watch(\n () => toValue(options.interval),\n () => {\n if (!disposed && baseline !== undefined) scheduleInterval()\n }\n )\n\n watch(visibility, (value) => {\n if (disposed || baseline === undefined) return\n if (value === 'visible' && !overflow.value && Date.now() - lastProbeAt > RETURN_PROBE_GAP_MS) {\n void runProbe()\n }\n scheduleInterval()\n })\n\n onScopeDispose(() => {\n disposed = true\n abortProbe()\n clearTimers()\n })\n\n return {\n count: readonly(count),\n overflow,\n label,\n failed: readonly(failed),\n /** Records already listed changed; see `markChanged`. */\n changed: readonly(changed),\n /** The newest record the user has seen: `null` for an empty list, `undefined` before the first load. */\n baseline: readonly(baselineState),\n max,\n markLoaded,\n requestProbe,\n markChanged,\n apply,\n }\n}\n"],"mappings":";;;AAqBA,IAAaA,IAA6C;CAAE,WAAW;CAAQ,UAAU;AAAO,GA0C1FC,KAAsB,KACtBC,IAAe,KAGRC,KAA0B,GAAmB,MAAsB;CAC9E,IAAI,OAAOC,KAAM,YAAY,OAAOC,KAAM,UAAU,OAAOD,IAAIC;CAC/D,IAAMC,IAAK,OAAOF,CAAC,GACbG,IAAK,OAAOF,CAAC;CAEnB,OADIC,MAAOC,IAAW,IACfD,IAAKC,IAAK,KAAK;AACxB,GAEMC,MAAkB,MAAmB;CACzC,IAAI;EACF,OAAO,KAAK,UAAUC,CAAK,KAAK;CAClC,QAAQ;EACN,OAAO,OAAOA,CAAK;CACrB;AACF;AAQA,SAAgBC,EAAkB,GAAmC;CACnE,IAAMC,IAAMC,EAAQ,OAAO,GACrBC,IAAgBD,EAAQ,iBAAiB,KACzCE,KAAaF,EAAQ,cAAc,MACnCG,IAAUH,EAAQ,WAAW,SAC7BI,IAAa,KAAK,IAAIJ,EAAQ,cAAcD,IAAM,GAAGA,IAAM,CAAC,GAC5DM,UAAwBC,EAAQN,EAAQ,QAAQ,KAAK,IAErDO,IAAQC,EAAI,CAAC,GACbC,IAASD,EAAI,EAAK,GAClBE,IAAUF,EAAI,EAAK,GACnBG,IAAWC,QAAeL,EAAM,QAAQR,CAAG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ACA;EACA;EACA;EACA,cAlDA,MAAa0D,GAAc,CAAC,CAAC,cAAc;GACzC,IAAW,KAAA;EACb,CAAC,GACMrC;CAgDT;AACF"}
1
+ {"version":3,"file":"useLiveListing.js","names":["LIVE_LISTING_INTERVAL","RETURN_PROBE_GAP_MS","MAX_RETRY_MS","compareLiveListingKeys","a","b","sa","sb","serializeScope","scope","useLiveListing","max","options","minIntervalMs","debounceMs","newness","probeLimit","currentInterval","toValue","count","ref","failed","changed","overflow","computed","label","baseline","baselineState","shallowRef","setBaseline","value","baselineScope","seenKeys","seenFloor","generation","controller","probeInFlight","rerun","lastProbeAt","intervalTimer","signalTimer","retryTimer","failures","probeWanted","signals","changedAtSignal","applyingFrom","loadingFrom","applying","disposed","visibility","useDocumentVisibility","isNew","key","raiseBaseline","newestKey","items","item","newest","oldestKey","oldest","see","abortProbe","clearTimers","scheduleRetry","ms","run","succeeded","runWantedProbe","scheduleProbe","scheduleInterval","interval","runProbe","myGeneration","myController","wait","requestProbe","fetchBaseline","limit","signalPending","markLoaded","loadFrom","seenNewest","loaded","markChanged","reloadOnClick","loadsBefore","watch","before","onScopeDispose","readonly"],"sources":["../../../../../src/domains/filters/datatable/composables/useLiveListing.ts"],"sourcesContent":["import { useDocumentVisibility } from '@vueuse/core'\nimport { computed, onScopeDispose, readonly, ref, shallowRef, toValue, watch, type MaybeRefOrGetter } from 'vue'\n\nexport type LiveListingKey = number | string\n\nexport interface LiveListingProbeOptions {\n limit: number\n signal: AbortSignal\n}\n\nexport interface LiveListingInterval {\n /** Probe period while the browser tab is visible. */\n visibleMs: number\n /** Probe period while the browser tab is hidden, so a count in the browser title stays fresh. */\n hiddenMs: number\n}\n\n/**\n * How often a list without backend signals probes for new records: every 10 s while the browser tab is visible,\n * every minute while it is hidden, so a count in the browser title stays fresh.\n */\nexport const LIVE_LISTING_INTERVAL: LiveListingInterval = { visibleMs: 10_000, hiddenMs: 60_000 }\n\n/**\n * How a record counts as new: `newer` than the newest record the user has seen, or `unseen`, a record of the probe\n * the user has not seen listed, for listings where a record can enter with a key older than the newest one.\n */\nexport type LiveListingNewness = 'newer' | 'unseen'\n\nexport interface UseLiveListingOptions<T> {\n /**\n * Newest records under the current filters, newest first by `key`, at most `limit` of them.\n * It must leave the shown list alone and load nothing else for the rows.\n */\n probe: (options: LiveListingProbeOptions) => Promise<T[]>\n /** Newness key: an autoincrement id, or a UTC datetime string in one format. */\n key: (item: T) => LiveListingKey\n /** Fetches the list on the click of the pill and reports it back with `markLoaded`. */\n reload: () => Promise<void>\n /** What the user filters by. When it changes, the baseline is set anew; otherwise it never decreases. */\n scope?: MaybeRefOrGetter<unknown>\n /** Probes on a timer, for listings without a backend signal, or while it is down. */\n interval?: MaybeRefOrGetter<LiveListingInterval | false>\n newness?: LiveListingNewness\n /**\n * How many of the newest records a probe asks for. Default `max + 1`; with `unseen` newness give the page size,\n * as an unseen record can enter anywhere on the first page.\n */\n probeLimit?: number\n /** Highest count shown as a number, more is shown as `max+`. */\n max?: number\n /** Shortest gap between the start of two probes requested by signals. */\n minIntervalMs?: number\n /** Wait after a signal, so a burst of signals ends in one probe. */\n debounceMs?: number\n /**\n * Whether the list is loading, for loads not started by the pill (a filter, the user's own change): a change\n * signalled after such a load started stays offered after its `markLoaded`, as the load may have read the record\n * before it changed. Without it such a load forgets every change offered.\n */\n loading?: MaybeRefOrGetter<boolean>\n}\n\nconst RETURN_PROBE_GAP_MS = 2000\nconst MAX_RETRY_MS = 60_000\n\n/** Orders newness keys: numbers by value, strings (UTC datetimes in one format) as text. */\nexport const compareLiveListingKeys = (a: LiveListingKey, b: LiveListingKey) => {\n if (typeof a === 'number' && typeof b === 'number') return a - b\n const sa = String(a)\n const sb = String(b)\n if (sa === sb) return 0\n return sa < sb ? -1 : 1\n}\n\nconst serializeScope = (scope: unknown) => {\n try {\n return JSON.stringify(scope) ?? ''\n } catch {\n return String(scope)\n }\n}\n\n/**\n * Tells the user that new records exist under the current filters, without changing the list until they click.\n * A probe (a small list request, newest first) runs on a signal, on a timer or when the user returns to the\n * browser tab; its records newer than the baseline are the count. The baseline is the newest record the user\n * has seen, taken from every full load reported through `markLoaded`.\n */\nexport function useLiveListing<T>(options: UseLiveListingOptions<T>) {\n const max = options.max ?? 9\n const minIntervalMs = options.minIntervalMs ?? 10_000\n const debounceMs = options.debounceMs ?? 1500\n const newness = options.newness ?? 'newer'\n const probeLimit = Math.max(options.probeLimit ?? max + 1, max + 1)\n const currentInterval = () => toValue(options.interval) ?? false\n\n const count = ref(0)\n const failed = ref(false)\n const changed = ref(false)\n const overflow = computed(() => count.value > max)\n const label = computed(() => {\n if (count.value === 0) return ''\n return overflow.value ? `${max}+` : String(count.value)\n })\n\n // undefined: not known yet, nothing is probed; null: the filtered list was empty, every record is new.\n let baseline: LiveListingKey | null | undefined = undefined\n // The same, for callers that keep what the user has seen, e.g. for a count on an inactive tab.\n const baselineState = shallowRef<LiveListingKey | null | undefined>(undefined)\n const setBaseline = (value: LiveListingKey | null | undefined) => {\n baseline = value\n baselineState.value = value\n }\n let baselineScope: string | undefined = undefined\n // With `unseen` newness: the keys the user has seen listed under the baseline scope.\n const seenKeys = new Set<LiveListingKey>()\n // With `unseen` newness: the oldest record of the last full load when it filled the probe. An unseen record below\n // it reached the first page because listed ones left the filter, not because it entered.\n let seenFloor: LiveListingKey | undefined = undefined\n // Bumped by every full load: answers of probes started before it are dropped.\n let generation = 0\n let controller: AbortController | undefined = undefined\n // The controller of a probe in flight, as opposed to a baseline fetch.\n let probeInFlight: AbortController | undefined = undefined\n let rerun = false\n let lastProbeAt = 0\n let intervalTimer: ReturnType<typeof setTimeout> | undefined = undefined\n let signalTimer: ReturnType<typeof setTimeout> | undefined = undefined\n // A failed probe or baseline fetch is tried again, less and less often, also when no interval runs.\n let retryTimer: ReturnType<typeof setTimeout> | undefined = undefined\n let failures = 0\n // A probe asked for while no baseline is known, or while a full load replaces the list: it runs once the list is.\n let probeWanted = false\n // Signals (`requestProbe`, `markChanged`) counted, so the pill's reload can tell those that came while it ran.\n let signals = 0\n let changedAtSignal = 0\n let applyingFrom: number | undefined = undefined\n // The signals counted when the current or last load given by `loading` started.\n let loadingFrom: number | undefined = undefined\n let applying: Promise<void> | undefined = undefined\n let disposed = false\n\n const visibility = useDocumentVisibility()\n\n const isNew = (key: LiveListingKey) => {\n if (newness === 'unseen') {\n return (\n baseline !== undefined &&\n !seenKeys.has(key) &&\n (seenFloor === undefined || compareLiveListingKeys(key, seenFloor) > 0)\n )\n }\n return baseline === null || (baseline !== undefined && compareLiveListingKeys(key, baseline) > 0)\n }\n\n const raiseBaseline = (key: LiveListingKey | null, scope: string) => {\n if (baselineScope !== scope) seenKeys.clear()\n if (baselineScope !== scope || baseline === undefined || baseline === null) {\n setBaseline(key)\n } else if (key !== null && compareLiveListingKeys(key, baseline) > 0) {\n setBaseline(key)\n }\n baselineScope = scope\n }\n\n const newestKey = (items: T[]) =>\n items.reduce<LiveListingKey | null>((newest, item) => {\n const key = options.key(item)\n return newest === null || compareLiveListingKeys(key, newest) > 0 ? key : newest\n }, null)\n\n const oldestKey = (items: T[]) =>\n items.reduce<LiveListingKey | undefined>((oldest, item) => {\n const key = options.key(item)\n return oldest === undefined || compareLiveListingKeys(key, oldest) < 0 ? key : oldest\n }, undefined)\n\n const see = (items: T[]) => {\n if (newness !== 'unseen') return\n items.forEach((item) => seenKeys.add(options.key(item)))\n // Fewer records than the probe asks for were all there were under the filter, so nothing can slide in.\n seenFloor = items.length >= probeLimit ? oldestKey(items) : undefined\n }\n\n const abortProbe = () => {\n controller?.abort()\n controller = undefined\n probeInFlight = undefined\n rerun = false\n }\n\n const clearTimers = () => {\n clearTimeout(intervalTimer)\n clearTimeout(signalTimer)\n clearTimeout(retryTimer)\n intervalTimer = undefined\n signalTimer = undefined\n retryTimer = undefined\n }\n\n const scheduleRetry = (run: () => void) => {\n clearTimeout(retryTimer)\n if (disposed) return\n const ms = Math.min(minIntervalMs * 2 ** failures, MAX_RETRY_MS)\n failures += 1\n retryTimer = setTimeout(() => {\n retryTimer = undefined\n run()\n }, ms)\n }\n\n const succeeded = () => {\n failures = 0\n clearTimeout(retryTimer)\n retryTimer = undefined\n failed.value = false\n }\n\n const runWantedProbe = () => {\n if (!probeWanted) return\n probeWanted = false\n scheduleProbe()\n }\n\n const scheduleInterval = () => {\n clearTimeout(intervalTimer)\n intervalTimer = undefined\n const interval = currentInterval()\n if (!interval || disposed || overflow.value || baseline === undefined) return\n const ms = visibility.value === 'hidden' ? interval.hiddenMs : interval.visibleMs\n intervalTimer = setTimeout(async () => {\n intervalTimer = undefined\n await runProbe()\n scheduleInterval()\n }, ms)\n }\n\n const runProbe = async () => {\n if (disposed || baseline === undefined || overflow.value) return\n if (controller) {\n rerun = true\n return\n }\n const myGeneration = generation\n const myController = new AbortController()\n controller = myController\n probeInFlight = myController\n lastProbeAt = Date.now()\n try {\n const items = await options.probe({ limit: probeLimit, signal: myController.signal })\n if (myController.signal.aborted || myGeneration !== generation) return\n count.value = items.filter((item) => isNew(options.key(item))).length\n succeeded()\n if (overflow.value) clearTimers()\n } catch {\n if (myController.signal.aborted || myGeneration !== generation) return\n failed.value = true\n // The interval tries again on its own; signals may not come for long.\n if (!currentInterval()) scheduleRetry(() => void runProbe())\n } finally {\n if (controller === myController) controller = undefined\n if (probeInFlight === myController) probeInFlight = undefined\n if (rerun && !myController.signal.aborted) {\n rerun = false\n scheduleProbe()\n }\n }\n }\n\n const scheduleProbe = () => {\n if (disposed || overflow.value) return\n if (baseline === undefined) {\n probeWanted = true\n return\n }\n if (signalTimer) return\n const wait = Math.max(debounceMs, lastProbeAt + minIntervalMs - Date.now())\n signalTimer = setTimeout(() => {\n signalTimer = undefined\n void runProbe()\n }, wait)\n }\n\n /** Asks for a probe, e.g. on a backend signal. A burst of requests ends in one probe. */\n const requestProbe = () => {\n if (disposed) return\n signals += 1\n scheduleProbe()\n }\n\n const fetchBaseline = async (scope: string, myGeneration: number) => {\n const myController = new AbortController()\n controller = myController\n try {\n // With `unseen` newness, what the probe would count is seen: the list the user looks at holds it.\n const limit = newness === 'unseen' ? probeLimit : 1\n const items = await options.probe({ limit, signal: myController.signal })\n if (myController.signal.aborted || myGeneration !== generation) return\n raiseBaseline(newestKey(items), scope)\n see(items)\n succeeded()\n scheduleInterval()\n runWantedProbe()\n } catch {\n if (myController.signal.aborted || myGeneration !== generation) return\n failed.value = true\n // Without a baseline nothing is probed, so the fetch itself is tried again.\n scheduleRetry(() => {\n if (myGeneration === generation) void fetchBaseline(scope, myGeneration)\n })\n } finally {\n if (controller === myController) controller = undefined\n if (rerun && !myController.signal.aborted) {\n rerun = false\n scheduleProbe()\n }\n }\n }\n\n // A probe still to run or running may announce records the load did not see; so may one that counted records\n // while the load ran, unknown outside the pill's reload, which knows when it started.\n const signalPending = () =>\n signalTimer !== undefined ||\n rerun ||\n probeInFlight !== undefined ||\n (applyingFrom !== undefined ? signals > applyingFrom : count.value > 0)\n\n /**\n * Reports a successful full load of the list: a filter, a sort, page 1 or a reload after the click.\n * `newestFirst`: the items are page 1 sorted newest first, so the newest of them is the baseline.\n * Otherwise `newest` gives it: what the probe returns under the loaded filters (one record, with `unseen` newness\n * `probeLimit`), asked for when the load started, so a record created while the list loaded is counted, at worst\n * one the list shows. Without it one probe after the load finds the baseline and takes such a record as seen.\n * A switch to another page needs no report. The changes offered end, except those signalled while the pill's\n * reload or a load given by `loading` ran.\n */\n const markLoaded = (items: T[], loaded: { newestFirst: boolean; newest?: T[] }) => {\n generation += 1\n if (signalPending()) probeWanted = true\n // A change signalled while the load ran (the pill's reload, or one given by `loading`) may be newer than what it\n // loaded.\n const loadFrom =\n applyingFrom !== undefined && loadingFrom !== undefined\n ? Math.min(applyingFrom, loadingFrom)\n : (applyingFrom ?? loadingFrom)\n changed.value = loadFrom !== undefined && changedAtSignal > loadFrom\n if (!toValue(options.loading)) loadingFrom = undefined\n abortProbe()\n clearTimers()\n count.value = 0\n failures = 0\n failed.value = false\n const scope = serializeScope(toValue(options.scope))\n const seenNewest = loaded.newestFirst ? items : loaded.newest\n if (seenNewest) {\n raiseBaseline(newestKey(seenNewest), scope)\n see(seenNewest)\n scheduleInterval()\n runWantedProbe()\n return\n }\n // No probe runs until the new baseline is known: under other filters the old one means nothing, under the same\n // ones it may be older than the rows shown, so a probe would count them.\n setBaseline(undefined)\n scheduleInterval()\n void fetchBaseline(scope, generation)\n }\n\n /**\n * Asks the user to reload the list because records already in it changed, e.g. moved to another tab or got\n * another status, which no count shows. The pill offers it while nothing new is counted.\n */\n const markChanged = () => {\n // Before the first load nothing is shown that could change, but a change signalled while that load runs (given\n // by `loading`) may be missing from what it reads: the first `markLoaded` offers it.\n if (disposed || (generation === 0 && loadingFrom === undefined)) return\n signals += 1\n changedAtSignal = signals\n if (generation > 0) changed.value = true\n }\n\n const reloadOnClick = async () => {\n if (signalTimer !== undefined || rerun || probeInFlight !== undefined) probeWanted = true\n // Only probes stop: a baseline still being fetched is needed when the reload fails.\n if (probeInFlight) {\n probeInFlight.abort()\n if (controller === probeInFlight) controller = undefined\n probeInFlight = undefined\n }\n rerun = false\n clearTimeout(intervalTimer)\n clearTimeout(signalTimer)\n intervalTimer = undefined\n signalTimer = undefined\n const loadsBefore = generation\n applyingFrom = signals\n // The start of an earlier load that reported nothing says nothing about this one.\n if (!toValue(options.loading)) loadingFrom = undefined\n try {\n await options.reload()\n } finally {\n applyingFrom = undefined\n // A fetched list reported itself through `markLoaded`, which started the counting anew. Without one nothing\n // was shown: the pill keeps what it offered and the looking goes on.\n if (generation === loadsBefore) {\n scheduleInterval()\n runWantedProbe()\n }\n }\n }\n\n /**\n * The click on the pill: reloads the list and starts counting again from it. A click while the reload runs\n * waits for the same reload.\n */\n const apply = () => {\n applying ??= reloadOnClick().finally(() => {\n applying = undefined\n })\n return applying\n }\n\n if (options.loading !== undefined) {\n watch(\n () => Boolean(toValue(options.loading)),\n (value, before) => {\n if (value && !before) loadingFrom = signals\n },\n // A list may start its first load before it creates the live listing.\n { flush: 'sync', immediate: true }\n )\n }\n\n watch(\n () => toValue(options.interval),\n () => {\n if (!disposed && baseline !== undefined) scheduleInterval()\n }\n )\n\n watch(visibility, (value) => {\n if (disposed || baseline === undefined) return\n if (value === 'visible' && !overflow.value && Date.now() - lastProbeAt > RETURN_PROBE_GAP_MS) {\n void runProbe()\n }\n scheduleInterval()\n })\n\n onScopeDispose(() => {\n disposed = true\n abortProbe()\n clearTimers()\n })\n\n return {\n count: readonly(count),\n overflow,\n label,\n failed: readonly(failed),\n /** Records already listed changed; see `markChanged`. */\n changed: readonly(changed),\n /** The newest record the user has seen: `null` for an empty list, `undefined` before the first load. */\n baseline: readonly(baselineState),\n max,\n markLoaded,\n requestProbe,\n markChanged,\n apply,\n }\n}\n"],"mappings":";;;AAqBA,IAAaA,IAA6C;CAAE,WAAW;CAAQ,UAAU;AAAO,GA0C1FC,KAAsB,KACtBC,KAAe,KAGRC,KAA0B,GAAmB,MAAsB;CAC9E,IAAI,OAAOC,KAAM,YAAY,OAAOC,KAAM,UAAU,OAAOD,IAAIC;CAC/D,IAAMC,IAAK,OAAOF,CAAC,GACbG,IAAK,OAAOF,CAAC;CAEnB,OADIC,MAAOC,IAAW,IACfD,IAAKC,IAAK,KAAK;AACxB,GAEMC,KAAkB,MAAmB;CACzC,IAAI;EACF,OAAO,KAAK,UAAUC,CAAK,KAAK;CAClC,QAAQ;EACN,OAAO,OAAOA,CAAK;CACrB;AACF;AAQA,SAAgBC,EAAkB,GAAmC;CACnE,IAAMC,IAAMC,EAAQ,OAAO,GACrBC,IAAgBD,EAAQ,iBAAiB,KACzCE,KAAaF,EAAQ,cAAc,MACnCG,IAAUH,EAAQ,WAAW,SAC7BI,IAAa,KAAK,IAAIJ,EAAQ,cAAcD,IAAM,GAAGA,IAAM,CAAC,GAC5DM,UAAwBC,EAAQN,EAAQ,QAAQ,KAAK,IAErDO,IAAQC,EAAI,CAAC,GACbC,IAASD,EAAI,EAAK,GAClBE,IAAUF,EAAI,EAAK,GACnBG,IAAWC,QAAeL,EAAM,QAAQR,CAAG,GAC3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O;EAEzB,UAAUoE,EAAS/D,CAAa;EAChC;EACA;EACA;EACA;EACA,cAnDA,MAAa0D,GAAc,CAAC,CAAC,cAAc;GACzC,IAAW,KAAA;EACb,CAAC,GACMrC;CAiDT;AACF"}
@@ -28,6 +28,8 @@ type __VLS_Props = {
28
28
  itemValue?: string;
29
29
  minSearchChars?: number;
30
30
  minSearchText?: string | undefined;
31
+ /** `focus`: searches on focus while nothing is loaded, for short lists offered without typing. */
32
+ prefetch?: 'focus' | false;
31
33
  };
32
34
  type __VLS_ModelProps = {
33
35
  'search'?: string;
@@ -76,6 +78,7 @@ declare const __VLS_base: import('vue').DefineComponent<__VLS_PublicProps, {}, {
76
78
  key: string;
77
79
  order: import('../../../lib').SortOrderType;
78
80
  } | null;
81
+ prefetch: false | "focus";
79
82
  minSearchChars: number;
80
83
  minSearchText: string;
81
84
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
@@ -48,7 +48,11 @@ var M = {
48
48
  itemTitle: { default: "name" },
49
49
  itemValue: { default: "id" },
50
50
  minSearchChars: { default: 2 },
51
- minSearchText: { default: void 0 }
51
+ minSearchText: { default: void 0 },
52
+ prefetch: {
53
+ type: [String, Boolean],
54
+ default: !1
55
+ }
52
56
  }, {
53
57
  search: {
54
58
  default: "",
@@ -90,7 +94,7 @@ var M = {
90
94
  P("update:modelValue", t(e));
91
95
  }
92
96
  }), { t: K } = ee(), q = b(o, void 0), J = b(a, void 0), Y = w(!1), { pagination: ie } = e(r(N.filterSortBy) ? null : N.filterSortBy.key, N.filterSortBy?.order), ae = () => {
93
- Y.value = !0, P("focus", G.value);
97
+ Y.value = !0, N.prefetch === "focus" && L.value.size === 0 && !I.value && $(F.value), P("focus", G.value);
94
98
  }, oe = () => {
95
99
  Y.value = !1, N.v?.$touch(), P("blur", G.value);
96
100
  }, se = d(() => i(N.errorMessage) ? N.v?.$errors?.length ? N.v.$errors.map((e) => D(e.$message)) : [] : [N.errorMessage]), ce = d(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"AFormRemoteAutocompleteWithCached.vue_vue_type_script_setup_true_lang.js","names":["_useModel","oldValue","_openBlock","_createBlock","_component_VAutocomplete","_withCtx","_createElementBlock","_createTextVNode","_toDisplayString","_renderSlot","_createVNode","_component_VChip","_mergeProps","_component_VListItem","_hoisted_1","AFormRemoteAutocompleteWithCached_vue_vue_type_script_setup_true_lang_default","\"search\"","\"searchModifiers\"","\"loadingLocal\"","\"loadingLocalModifiers\"","\"fetchedItemsMinimal\"","\"fetchedItemsMinimalModifiers\"","__emit","props","__props","emit","search","useModel","loadingLocal","fetchedItemsMinimal","filterInnerConfig","inject","FilterInnerConfigKey","filterInnerData","FilterInnerDataKey","componentName","getCurrentInstance","isUndefined","noDataText","computed","t","modelValue","cloneDeep","newValue","useI18n","system","SystemScopeKey","subject","SubjectScopeKey","isFocused","ref","usePagination","isNull","onFocus","onBlur","errorMessageComputed","unref","item","labelComputed","path","stringSplitOnFirstOccurrence","requiredComputed","useAlerts","searchCounter","apiSearch","requestId","query","res","pagination","showErrorsDefault","allItems","final","finalRaw","isArray","value","key","tryToAddFromFetchedItems","ids","addManualMinimal","resolve","onClickClear","watchDebounced","newValueBug","oldValueBug","watch","oldValue","values","idsToFetch","add","fetch","openBlock","createBlock","VAutocomplete","_cache","$event","createSlots","withCtx","createCommentVNode","createElementBlock","createTextVNode","toDisplayString","renderSlot","_ctx","chipProps","chipItem","createVNode","VChip","mergeProps","itemProps","itemItem","VListItem"],"sources":["../../../../src/domains/remoteAutocomplete/components/AFormRemoteAutocompleteWithCached.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AFormFieldValidation } from '@/shared/types/Validation'\nimport { watchDebounced } from '@vueuse/core'\nimport { computed, getCurrentInstance, inject, type Ref, ref, watch, unref } from 'vue'\nimport { useI18n } from 'vue-i18n'\nimport type { Pagination } from '@/domains/api/composables/pagination'\nimport { usePagination } from '@/domains/api/composables/pagination'\nimport type { DocId, IntegerId } from '@/shared/types/common'\nimport { cloneDeep, isArray, isNull, isUndefined } from '@/shared/utils/common'\nimport { SubjectScopeKey, SystemScopeKey } from '@/shared/injectionKeys'\nimport { stringSplitOnFirstOccurrence } from '@/shared/utils/string'\nimport type { ValueObjectOption } from '@/shared/types/ValueObject'\nimport type { FilterConfig, FilterData } from '@/domains/filters/composables/filterFactory'\nimport { FilterInnerConfigKey, FilterInnerDataKey } from '@/domains/filters/utils/filterInjectionKeys'\nimport type { DatatableSortBy } from '@/domains/filters/datatable/utils/datatableColumns'\nimport { useAlerts } from '@/domains/system/composables/alerts'\n\ntype FetchItemsMinimalType = (\n pagination: Ref<Pagination>,\n filterData: FilterData,\n filterConfig: FilterConfig\n) => Promise<any[]>\n\ntype UseCachedType = () => {\n fetch: any\n add: any\n addManualMinimal: any\n}\n\nconst props = withDefaults(\n defineProps<{\n modelValue: any\n label?: string | undefined\n required?: boolean\n multiple?: boolean\n clearable?: boolean\n v?: AFormFieldValidation | null\n errorMessage?: string\n hideLabel?: boolean\n fetchItemsMinimal: FetchItemsMinimalType\n filterByField?: string\n filterSortBy?: DatatableSortBy\n loading?: boolean\n useCached: UseCachedType\n itemTitle?: string\n itemValue?: string\n minSearchChars?: number\n minSearchText?: string | undefined\n }>(),\n {\n label: undefined,\n required: undefined,\n multiple: false,\n clearable: false,\n v: null,\n errorMessage: undefined,\n hideLabel: false,\n filterByField: 'name',\n filterSortBy: null,\n loading: false,\n itemTitle: 'name',\n itemValue: 'id',\n minSearchChars: 2,\n minSearchText: undefined,\n }\n)\nconst emit = defineEmits<{\n (e: 'update:modelValue', data: DocId | IntegerId | DocId[] | IntegerId[] | null | undefined): void\n (e: 'blur', data: DocId | IntegerId | DocId[] | IntegerId[] | null | undefined): void\n (e: 'focus', data: DocId | IntegerId | DocId[] | IntegerId[] | null | undefined): void\n (e: 'searchChange', data: string): void\n (e: 'searchChangeDebounced', data: string): void\n}>()\n\nconst search = defineModel<string>('search', { default: '', required: false })\nconst loadingLocal = defineModel<boolean>('loadingLocal', { default: false, required: false })\nconst fetchedItemsMinimal = defineModel<Map<IntegerId | DocId, any>>('fetchedItemsMinimal', {\n required: true,\n})\n\nconst filterInnerConfig = inject(FilterInnerConfigKey)\nconst filterInnerData = inject(FilterInnerDataKey)\n\nconst componentName = getCurrentInstance()?.type.__name\n\nif (isUndefined(filterInnerConfig) || isUndefined(filterInnerData)) {\n throw new Error(`[${componentName}] Incorrect provide/inject config.`)\n}\n\nif (\n // eslint-disable-next-line vue/no-setup-props-reactivity-loss\n isUndefined(filterInnerConfig.fields[props.filterByField]) ||\n // eslint-disable-next-line vue/no-setup-props-reactivity-loss\n isUndefined(filterInnerData[props.filterByField])\n) {\n throw new Error(\n `[${componentName}] Incorrect filter inner config. ` +\n `FilterByField is '${props.filterByField}' and available options are ${Object.keys(filterInnerData).join(', ')}.`\n )\n}\n\n// eslint-disable-next-line vue/no-setup-props-reactivity-loss\nconst { fetch, add, addManualMinimal } = props.useCached()\n\nconst noDataText = computed(() => {\n if (loadingLocal.value) {\n return '$vuetify.loading'\n }\n if (fetchedItemsMinimal.value.size === 0 && search.value.length < props.minSearchChars) {\n return isUndefined(props.minSearchText)\n ? t('common.filter.filterMinChars', { min: props.minSearchChars })\n : props.minSearchText\n }\n return undefined\n})\n\nconst modelValue = computed({\n get() {\n return props.modelValue\n },\n set(newValue: DocId | IntegerId | DocId[] | IntegerId[] | null | undefined) {\n emit('update:modelValue', cloneDeep<DocId | IntegerId | DocId[] | IntegerId[] | null | undefined>(newValue))\n },\n})\n\nconst { t } = useI18n()\nconst system = inject<string | undefined>(SystemScopeKey, undefined)\nconst subject = inject<string | undefined>(SubjectScopeKey, undefined)\n\nconst isFocused = ref(false)\n// eslint-disable-next-line vue/no-setup-props-reactivity-loss\nconst { pagination } = usePagination(\n // eslint-disable-next-line vue/no-setup-props-reactivity-loss\n isNull(props.filterSortBy) ? null : props.filterSortBy.key,\n props.filterSortBy?.order\n)\n\nconst onFocus = () => {\n isFocused.value = true\n emit('focus', modelValue.value)\n}\n\nconst onBlur = () => {\n isFocused.value = false\n props.v?.$touch()\n emit('blur', modelValue.value)\n}\n\nconst errorMessageComputed = computed(() => {\n if (!isUndefined(props.errorMessage)) return [props.errorMessage]\n if (props.v?.$errors?.length) return props.v.$errors.map((item) => unref(item.$message))\n return []\n})\n\nconst labelComputed = computed(() => {\n if (!isUndefined(props.label)) return props.label\n if (isUndefined(system) || isUndefined(subject) || isUndefined(props.v?.$path)) return ''\n const { end: path } = stringSplitOnFirstOccurrence(props.v?.$path, '.')\n return t(system + '.' + subject + '.model.' + path)\n})\n\nconst requiredComputed = computed(() => {\n if (!isUndefined(props.required)) return props.required\n return (props.v?.required as { $params?: { type?: string } } | undefined)?.$params?.type === 'required'\n})\n\nconst { showErrorsDefault } = useAlerts()\n\nlet searchCounter = 0\nconst apiSearch = async (query: string | null) => {\n const requestId = ++searchCounter\n if (isNull(query) || query.length < props.minSearchChars) {\n fetchedItemsMinimal.value.clear()\n // The request in flight, if any, is stale now and leaves the loader alone.\n loadingLocal.value = false\n return\n }\n loadingLocal.value = true\n filterInnerData[props.filterByField] = query\n fetchedItemsMinimal.value.clear()\n try {\n const res = await props.fetchItemsMinimal(pagination, filterInnerData, filterInnerConfig)\n if (requestId !== searchCounter) return\n res.forEach((item: any) => {\n fetchedItemsMinimal.value.set(item[props.itemValue], item)\n })\n } catch (e) {\n if (requestId === searchCounter) showErrorsDefault(e)\n } finally {\n if (requestId === searchCounter) loadingLocal.value = false\n }\n}\n\nconst allItems = computed<ValueObjectOption<DocId | IntegerId>[]>(() => {\n const final: Map<IntegerId | DocId, string> = new Map()\n const finalRaw: Map<IntegerId | DocId, any> = new Map()\n if (isArray(modelValue.value)) {\n modelValue.value.forEach((value: any) => {\n final.set(value, '')\n })\n } else if (modelValue.value) {\n final.set(modelValue.value, '')\n }\n fetchedItemsMinimal.value.forEach((value) => {\n final.set(value[props.itemValue], value[props.itemTitle])\n finalRaw.set(value[props.itemValue], cloneDeep(value))\n })\n return Array.from(final, ([key, value]) => {\n return { value: key, title: value, raw: finalRaw.get(key) }\n })\n})\n\nconst tryToAddFromFetchedItems = (ids: Set<DocId | IntegerId>) => {\n return new Promise<boolean>((resolve) => {\n fetchedItemsMinimal.value.forEach((value, key) => {\n if (ids.has(key)) {\n addManualMinimal(cloneDeep(value))\n }\n })\n return resolve(true)\n })\n}\n\nconst onClickClear = () => {\n search.value = ''\n apiSearch('')\n if (props.multiple) {\n modelValue.value = []\n return\n }\n modelValue.value = null\n}\n\nwatchDebounced(\n search,\n (newValueBug, oldValueBug) => {\n // todo rollback fix when fixed on vuetify/vue use side\n const newValue = newValueBug as unknown as string\n const oldValue = oldValueBug as unknown as string | undefined\n if (newValue !== oldValue) {\n apiSearch(newValue)\n emit('searchChangeDebounced', newValue)\n }\n },\n { debounce: 300 }\n)\n\nwatch(search, (newValue, oldValue) => {\n if (newValue !== oldValue) {\n emit('searchChange', newValue)\n }\n})\n\nwatch(\n modelValue,\n async (newValue) => {\n if (isNull(newValue) || isUndefined(newValue) || (isArray(newValue) && newValue.length === 0)) {\n return\n }\n const values = isArray(newValue) ? newValue : [newValue]\n const idsToFetch = new Set(values)\n await tryToAddFromFetchedItems(idsToFetch)\n\n if (idsToFetch.size > 0) {\n add(Array.from(idsToFetch) as Array<DocId & IntegerId>)\n fetch()\n }\n },\n { immediate: true }\n)\n</script>\n\n<template>\n <VAutocomplete\n v-model=\"modelValue\"\n v-model:search=\"search\"\n chips\n :items=\"allItems\"\n no-filter\n :multiple=\"multiple\"\n :clearable=\"clearable\"\n :error-messages=\"errorMessageComputed\"\n :loading=\"loadingLocal\"\n :no-data-text=\"noDataText\"\n autocomplete=\"off\"\n @blur=\"onBlur\"\n @focus=\"onFocus\"\n @click:clear=\"onClickClear\"\n >\n <template #label>\n <span\n v-if=\"!hideLabel\"\n :key=\"requiredComputed + ''\"\n >\n {{ labelComputed }}\n <span\n v-if=\"requiredComputed\"\n class=\"a-required-mark\"\n />\n </span>\n </template>\n <template #append-item>\n <slot name=\"append-item\" />\n </template>\n <template\n v-if=\"!multiple\"\n #selection\n />\n <!-- @vue-skip -->\n <template #chip=\"{ props: chipProps, internalItem: chipItem }\">\n <slot\n name=\"chip\"\n :props=\"chipProps\"\n :item=\"chipItem\"\n >\n <VChip\n v-bind=\"chipProps\"\n close-label=\"common.button.remove\"\n :text=\"chipItem.title\"\n />\n </slot>\n </template>\n <!-- @vue-skip -->\n <template #item=\"{ props: itemProps, internalItem: itemItem }\">\n <slot\n name=\"item\"\n :props=\"itemProps\"\n :item=\"itemItem\"\n >\n <VListItem :props=\"itemProps\" />\n </slot>\n </template>\n </VAutocomplete>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BA,IAAMuB,IAAQC,GAqCRC,IAAOH,GAQPI,IAAS1B,EAAmBwB,GAAC,QAA0C,GACvEI,IAAe5B,EAAoBwB,GAAC,cAAmD,GACvFK,IAAsB7B,EAAwCwB,GAAC,qBAEpE,GAEKM,IAAoBC,EAAOC,CAAoB,GAC/CC,IAAkBF,EAAOG,CAAkB,GAE3CC,IAAgBC,EAAmB,CAAC,EAAE,KAAK;EAEjD,IAAIC,EAAYP,CAAiB,KAAKO,EAAYJ,CAAe,GAC/D,MAAU,MAAM,IAAIE,EAAc,mCAAmC;EAGvE,IAEEE,EAAYP,EAAkB,OAAOP,EAAM,cAAc,KAEzDc,EAAYJ,EAAgBV,EAAM,cAAc,GAEhD,MAAU,MACR,IAAIY,EAAc,qDACKZ,EAAM,cAAc,8BAA8B,OAAO,KAAKU,CAAe,CAAC,CAAC,KAAK,IAAI,EAAE,EACnH;EAIF,IAAM,EAAE,UAAO,QAAK,wBAAqBV,EAAM,UAAU,GAEnDe,IAAaC,QAAe;GAChC,IAAIX,EAAa,OACf,OAAO;GAET,IAAIC,EAAoB,MAAM,SAAS,KAAKH,EAAO,MAAM,SAASH,EAAM,gBACtE,OAAOc,EAAYd,EAA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AS3B,EAAA;GACT,gBAAcU,EAAA;GACf,cAAa;GACN;GACC;GACP,iBAAa0C;;GAEH,OAAK3E,QAUP,CAREmB,EAAA,Y,aADTtB,EAAA,GAAAI,EASO,QAAA,EAPJ,KAAKuD,EAAA,QAAgB,G,IAEnBtD,EAAAC,EAAAkD,GAAA,KAAa,IAAG,KACnB,CAAA,GACQG,EAAA,SADR3D,EAAA,GAAAI,EAGE,QAHFQ,CAGE,K;GAGK,eAAWT,QACO,CAA3BI,EAA2B6F,EAAA,QAAA,aAAA,C;GAOlB,MAAIjG,GAWN,EAAA,OAXiBkG,GAAS,cAAgBC,QAAQ,CACzD/F,EAUO6F,EAAA,QAAA,QAAA;IARJ,OAAOC;IACP,MAAMC;GAHT,SAUO,CALL9F,EAIEC,IAJFC,EACU2F,GAAS;IACjB,eAAY;IACX,MAAMC,EAAS;;GAKX,MAAInG,GAON,EAAA,OAPiBuG,GAAS,cAAgBC,QAAQ,CACzDpG,EAMO6F,EAAA,QAAA,QAAA;IAJJ,OAAOM;IACP,MAAMC;GAHT,SAMO,CADLnG,EAAgCG,IAAA,EAApB,OAAO+F,EAAS,GAAA,MAAA,GAAA,CAAA,OAAA,CAAA,C;;E,IAxBvBpF,EAAA,W;GACN,MAAA;GAFH,IAAAnB,QAGE,CAAA,CAAA"}
1
+ {"version":3,"file":"AFormRemoteAutocompleteWithCached.vue_vue_type_script_setup_true_lang.js","names":["_useModel","oldValue","_openBlock","_createBlock","_component_VAutocomplete","_withCtx","_createElementBlock","_createTextVNode","_toDisplayString","_renderSlot","_createVNode","_component_VChip","_mergeProps","_component_VListItem","_hoisted_1","AFormRemoteAutocompleteWithCached_vue_vue_type_script_setup_true_lang_default","\"search\"","\"searchModifiers\"","\"loadingLocal\"","\"loadingLocalModifiers\"","\"fetchedItemsMinimal\"","\"fetchedItemsMinimalModifiers\"","__emit","props","__props","emit","search","useModel","loadingLocal","fetchedItemsMinimal","filterInnerConfig","inject","FilterInnerConfigKey","filterInnerData","FilterInnerDataKey","componentName","getCurrentInstance","isUndefined","noDataText","computed","t","modelValue","cloneDeep","newValue","useI18n","system","SystemScopeKey","subject","SubjectScopeKey","isFocused","ref","usePagination","isNull","onFocus","apiSearch","onBlur","errorMessageComputed","unref","item","labelComputed","path","stringSplitOnFirstOccurrence","requiredComputed","useAlerts","searchCounter","requestId","query","res","pagination","showErrorsDefault","allItems","final","finalRaw","isArray","value","key","tryToAddFromFetchedItems","ids","addManualMinimal","resolve","onClickClear","watchDebounced","newValueBug","oldValueBug","watch","oldValue","values","idsToFetch","add","fetch","openBlock","createBlock","VAutocomplete","_cache","$event","createSlots","withCtx","createCommentVNode","createElementBlock","createTextVNode","toDisplayString","renderSlot","_ctx","chipProps","chipItem","createVNode","VChip","mergeProps","itemProps","itemItem","VListItem"],"sources":["../../../../src/domains/remoteAutocomplete/components/AFormRemoteAutocompleteWithCached.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AFormFieldValidation } from '@/shared/types/Validation'\nimport { watchDebounced } from '@vueuse/core'\nimport { computed, getCurrentInstance, inject, type Ref, ref, watch, unref } from 'vue'\nimport { useI18n } from 'vue-i18n'\nimport type { Pagination } from '@/domains/api/composables/pagination'\nimport { usePagination } from '@/domains/api/composables/pagination'\nimport type { DocId, IntegerId } from '@/shared/types/common'\nimport { cloneDeep, isArray, isNull, isUndefined } from '@/shared/utils/common'\nimport { SubjectScopeKey, SystemScopeKey } from '@/shared/injectionKeys'\nimport { stringSplitOnFirstOccurrence } from '@/shared/utils/string'\nimport type { ValueObjectOption } from '@/shared/types/ValueObject'\nimport type { FilterConfig, FilterData } from '@/domains/filters/composables/filterFactory'\nimport { FilterInnerConfigKey, FilterInnerDataKey } from '@/domains/filters/utils/filterInjectionKeys'\nimport type { DatatableSortBy } from '@/domains/filters/datatable/utils/datatableColumns'\nimport { useAlerts } from '@/domains/system/composables/alerts'\n\ntype FetchItemsMinimalType = (\n pagination: Ref<Pagination>,\n filterData: FilterData,\n filterConfig: FilterConfig\n) => Promise<any[]>\n\ntype UseCachedType = () => {\n fetch: any\n add: any\n addManualMinimal: any\n}\n\nconst props = withDefaults(\n defineProps<{\n modelValue: any\n label?: string | undefined\n required?: boolean\n multiple?: boolean\n clearable?: boolean\n v?: AFormFieldValidation | null\n errorMessage?: string\n hideLabel?: boolean\n fetchItemsMinimal: FetchItemsMinimalType\n filterByField?: string\n filterSortBy?: DatatableSortBy\n loading?: boolean\n useCached: UseCachedType\n itemTitle?: string\n itemValue?: string\n minSearchChars?: number\n minSearchText?: string | undefined\n /** `focus`: searches on focus while nothing is loaded, for short lists offered without typing. */\n prefetch?: 'focus' | false\n }>(),\n {\n label: undefined,\n required: undefined,\n multiple: false,\n clearable: false,\n v: null,\n errorMessage: undefined,\n hideLabel: false,\n filterByField: 'name',\n filterSortBy: null,\n loading: false,\n itemTitle: 'name',\n itemValue: 'id',\n minSearchChars: 2,\n minSearchText: undefined,\n prefetch: false,\n }\n)\nconst emit = defineEmits<{\n (e: 'update:modelValue', data: DocId | IntegerId | DocId[] | IntegerId[] | null | undefined): void\n (e: 'blur', data: DocId | IntegerId | DocId[] | IntegerId[] | null | undefined): void\n (e: 'focus', data: DocId | IntegerId | DocId[] | IntegerId[] | null | undefined): void\n (e: 'searchChange', data: string): void\n (e: 'searchChangeDebounced', data: string): void\n}>()\n\nconst search = defineModel<string>('search', { default: '', required: false })\nconst loadingLocal = defineModel<boolean>('loadingLocal', { default: false, required: false })\nconst fetchedItemsMinimal = defineModel<Map<IntegerId | DocId, any>>('fetchedItemsMinimal', {\n required: true,\n})\n\nconst filterInnerConfig = inject(FilterInnerConfigKey)\nconst filterInnerData = inject(FilterInnerDataKey)\n\nconst componentName = getCurrentInstance()?.type.__name\n\nif (isUndefined(filterInnerConfig) || isUndefined(filterInnerData)) {\n throw new Error(`[${componentName}] Incorrect provide/inject config.`)\n}\n\nif (\n // eslint-disable-next-line vue/no-setup-props-reactivity-loss\n isUndefined(filterInnerConfig.fields[props.filterByField]) ||\n // eslint-disable-next-line vue/no-setup-props-reactivity-loss\n isUndefined(filterInnerData[props.filterByField])\n) {\n throw new Error(\n `[${componentName}] Incorrect filter inner config. ` +\n `FilterByField is '${props.filterByField}' and available options are ${Object.keys(filterInnerData).join(', ')}.`\n )\n}\n\n// eslint-disable-next-line vue/no-setup-props-reactivity-loss\nconst { fetch, add, addManualMinimal } = props.useCached()\n\nconst noDataText = computed(() => {\n if (loadingLocal.value) {\n return '$vuetify.loading'\n }\n if (fetchedItemsMinimal.value.size === 0 && search.value.length < props.minSearchChars) {\n return isUndefined(props.minSearchText)\n ? t('common.filter.filterMinChars', { min: props.minSearchChars })\n : props.minSearchText\n }\n return undefined\n})\n\nconst modelValue = computed({\n get() {\n return props.modelValue\n },\n set(newValue: DocId | IntegerId | DocId[] | IntegerId[] | null | undefined) {\n emit('update:modelValue', cloneDeep<DocId | IntegerId | DocId[] | IntegerId[] | null | undefined>(newValue))\n },\n})\n\nconst { t } = useI18n()\nconst system = inject<string | undefined>(SystemScopeKey, undefined)\nconst subject = inject<string | undefined>(SubjectScopeKey, undefined)\n\nconst isFocused = ref(false)\n// eslint-disable-next-line vue/no-setup-props-reactivity-loss\nconst { pagination } = usePagination(\n // eslint-disable-next-line vue/no-setup-props-reactivity-loss\n isNull(props.filterSortBy) ? null : props.filterSortBy.key,\n props.filterSortBy?.order\n)\n\nconst onFocus = () => {\n isFocused.value = true\n if (props.prefetch === 'focus' && fetchedItemsMinimal.value.size === 0 && !loadingLocal.value) {\n apiSearch(search.value)\n }\n emit('focus', modelValue.value)\n}\n\nconst onBlur = () => {\n isFocused.value = false\n props.v?.$touch()\n emit('blur', modelValue.value)\n}\n\nconst errorMessageComputed = computed(() => {\n if (!isUndefined(props.errorMessage)) return [props.errorMessage]\n if (props.v?.$errors?.length) return props.v.$errors.map((item) => unref(item.$message))\n return []\n})\n\nconst labelComputed = computed(() => {\n if (!isUndefined(props.label)) return props.label\n if (isUndefined(system) || isUndefined(subject) || isUndefined(props.v?.$path)) return ''\n const { end: path } = stringSplitOnFirstOccurrence(props.v?.$path, '.')\n return t(system + '.' + subject + '.model.' + path)\n})\n\nconst requiredComputed = computed(() => {\n if (!isUndefined(props.required)) return props.required\n return (props.v?.required as { $params?: { type?: string } } | undefined)?.$params?.type === 'required'\n})\n\nconst { showErrorsDefault } = useAlerts()\n\nlet searchCounter = 0\nconst apiSearch = async (query: string | null) => {\n const requestId = ++searchCounter\n if (isNull(query) || query.length < props.minSearchChars) {\n fetchedItemsMinimal.value.clear()\n // The request in flight, if any, is stale now and leaves the loader alone.\n loadingLocal.value = false\n return\n }\n loadingLocal.value = true\n filterInnerData[props.filterByField] = query\n fetchedItemsMinimal.value.clear()\n try {\n const res = await props.fetchItemsMinimal(pagination, filterInnerData, filterInnerConfig)\n if (requestId !== searchCounter) return\n res.forEach((item: any) => {\n fetchedItemsMinimal.value.set(item[props.itemValue], item)\n })\n } catch (e) {\n if (requestId === searchCounter) showErrorsDefault(e)\n } finally {\n if (requestId === searchCounter) loadingLocal.value = false\n }\n}\n\nconst allItems = computed<ValueObjectOption<DocId | IntegerId>[]>(() => {\n const final: Map<IntegerId | DocId, string> = new Map()\n const finalRaw: Map<IntegerId | DocId, any> = new Map()\n if (isArray(modelValue.value)) {\n modelValue.value.forEach((value: any) => {\n final.set(value, '')\n })\n } else if (modelValue.value) {\n final.set(modelValue.value, '')\n }\n fetchedItemsMinimal.value.forEach((value) => {\n final.set(value[props.itemValue], value[props.itemTitle])\n finalRaw.set(value[props.itemValue], cloneDeep(value))\n })\n return Array.from(final, ([key, value]) => {\n return { value: key, title: value, raw: finalRaw.get(key) }\n })\n})\n\nconst tryToAddFromFetchedItems = (ids: Set<DocId | IntegerId>) => {\n return new Promise<boolean>((resolve) => {\n fetchedItemsMinimal.value.forEach((value, key) => {\n if (ids.has(key)) {\n addManualMinimal(cloneDeep(value))\n }\n })\n return resolve(true)\n })\n}\n\nconst onClickClear = () => {\n search.value = ''\n apiSearch('')\n if (props.multiple) {\n modelValue.value = []\n return\n }\n modelValue.value = null\n}\n\nwatchDebounced(\n search,\n (newValueBug, oldValueBug) => {\n // todo rollback fix when fixed on vuetify/vue use side\n const newValue = newValueBug as unknown as string\n const oldValue = oldValueBug as unknown as string | undefined\n if (newValue !== oldValue) {\n apiSearch(newValue)\n emit('searchChangeDebounced', newValue)\n }\n },\n { debounce: 300 }\n)\n\nwatch(search, (newValue, oldValue) => {\n if (newValue !== oldValue) {\n emit('searchChange', newValue)\n }\n})\n\nwatch(\n modelValue,\n async (newValue) => {\n if (isNull(newValue) || isUndefined(newValue) || (isArray(newValue) && newValue.length === 0)) {\n return\n }\n const values = isArray(newValue) ? newValue : [newValue]\n const idsToFetch = new Set(values)\n await tryToAddFromFetchedItems(idsToFetch)\n\n if (idsToFetch.size > 0) {\n add(Array.from(idsToFetch) as Array<DocId & IntegerId>)\n fetch()\n }\n },\n { immediate: true }\n)\n</script>\n\n<template>\n <VAutocomplete\n v-model=\"modelValue\"\n v-model:search=\"search\"\n chips\n :items=\"allItems\"\n no-filter\n :multiple=\"multiple\"\n :clearable=\"clearable\"\n :error-messages=\"errorMessageComputed\"\n :loading=\"loadingLocal\"\n :no-data-text=\"noDataText\"\n autocomplete=\"off\"\n @blur=\"onBlur\"\n @focus=\"onFocus\"\n @click:clear=\"onClickClear\"\n >\n <template #label>\n <span\n v-if=\"!hideLabel\"\n :key=\"requiredComputed + ''\"\n >\n {{ labelComputed }}\n <span\n v-if=\"requiredComputed\"\n class=\"a-required-mark\"\n />\n </span>\n </template>\n <template #append-item>\n <slot name=\"append-item\" />\n </template>\n <template\n v-if=\"!multiple\"\n #selection\n />\n <!-- @vue-skip -->\n <template #chip=\"{ props: chipProps, internalItem: chipItem }\">\n <slot\n name=\"chip\"\n :props=\"chipProps\"\n :item=\"chipItem\"\n >\n <VChip\n v-bind=\"chipProps\"\n close-label=\"common.button.remove\"\n :text=\"chipItem.title\"\n />\n </slot>\n </template>\n <!-- @vue-skip -->\n <template #item=\"{ props: itemProps, internalItem: itemItem }\">\n <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AAAmD,GAAA,KAAa,IAAG,KACnB,CAAA,GACQG,EAAA,SADR5D,EAAA,GAAAI,EAGE,QAHFQ,CAGE,K;GAGK,eAAWT,QACO,CAA3BI,EAA2B6F,EAAA,QAAA,aAAA,C;GAOlB,MAAIjG,GAWN,EAAA,OAXiBkG,GAAS,cAAgBC,QAAQ,CACzD/F,EAUO6F,EAAA,QAAA,QAAA;IARJ,OAAOC;IACP,MAAMC;GAHT,SAUO,CALL9F,EAIEC,IAJFC,EACU2F,GAAS;IACjB,eAAY;IACX,MAAMC,EAAS;;GAKX,MAAInG,GAON,EAAA,OAPiBuG,GAAS,cAAgBC,QAAQ,CACzDpG,EAMO6F,EAAA,QAAA,QAAA;IAJJ,OAAOM;IACP,MAAMC;GAHT,SAMO,CADLnG,EAAgCG,IAAA,EAApB,OAAO+F,EAAS,GAAA,MAAA,GAAA,CAAA,OAAA,CAAA,C;;E,IAxBvBpF,EAAA,W;GACN,MAAA;GAFH,IAAAnB,QAGE,CAAA,CAAA"}
package/dist/lib.d.ts CHANGED
@@ -321,7 +321,7 @@ export { adminDamUploadPreset } from './domains/dam/uploadQueue/presets/uploadPr
321
321
  export type { UploadHash, UploadMessages, UploadPreset, UploadProgressCallback, UploadRun, UploadRunRequests, UploadSide, } from './domains/dam/uploadQueue/presets/uploadPresets';
322
322
  export { createUploadQueueCore, UPLOAD_QUEUE_ITEM_CHUNK_SIZE } from './domains/dam/uploadQueue/core/uploadQueueCore';
323
323
  export { adminDamImportRun, adminDamQueuePreset } from './domains/dam/uploadQueue/presets/queuePresets';
324
- export { fillAuthors as uploadQueueFillAuthors, fillCustomDataValue as uploadQueueFillCustomDataValue, fillKeywords as uploadQueueFillKeywords, } from './domains/dam/uploadQueue/core/uploadQueueFill';
324
+ export { fillAuthors as uploadQueueFillAuthors, fillCustomDataValue as uploadQueueFillCustomDataValue, fillKeywords as uploadQueueFillKeywords, fillSources as uploadQueueFillSources, } from './domains/dam/uploadQueue/core/uploadQueueFill';
325
325
  export type { UploadQueueCore, UploadQueuePreset, UploadQueueSettlementProfile, } from './domains/dam/uploadQueue/core/uploadQueueCoreTypes';
326
326
  export { default as ADamAssetImage } from './domains/dam/assetDetail/components/AssetImage.vue';
327
327
  export { default as ADamAssetImageMetaIcons } from './domains/dam/assetDetail/components/AssetImageMetaIcons.vue';
@@ -339,6 +339,10 @@ export { useImageRoiStore as useDamImageRoiStore } from './domains/dam/cropper/s
339
339
  export { useExtSystemIdForCached } from './domains/dam/composables/extSystemIdForCached';
340
340
  export { useDamKeywordAssetTypeConfig } from './domains/dam/keyword/composables/damKeywordConfig';
341
341
  export { useDamAuthorAssetTypeConfig } from './domains/dam/author/composables/damAuthorConfig';
342
+ export { isDamSourceEnabled, useDamSourceAssetTypeConfig } from './domains/dam/author/composables/damSourceConfig';
343
+ export { useDamCreditPreview } from './domains/dam/author/composables/damCredit';
344
+ export { useDamAuthorFieldRouting } from './domains/dam/author/composables/authorFieldRouting';
345
+ export { default as ADamSourcesAuthorsRow } from './domains/dam/author/components/DamSourcesAuthorsRow.vue';
342
346
  export { useFormatAndSizeCheck } from './domains/ui/file/composables/formatAndSizeCheck';
343
347
  export { UploadQueueSuggestionsKey } from './domains/dam/uploadQueue/components/uploadQueueBindings';
344
348
  export type { DamFieldsDisabledAs, UploadQueueSuggestionsLookup, } from './domains/dam/uploadQueue/components/uploadQueueBindings';
@@ -260,7 +260,7 @@ var e = {
260
260
  b: {
261
261
  t: 2,
262
262
  i: [{ t: 3 }],
263
- s: "Autoři"
263
+ s: "Autoři a zdroje"
264
264
  }
265
265
  },
266
266
  createdByIds: {
@@ -16,7 +16,7 @@ var e = {
16
16
  b: {
17
17
  t: 2,
18
18
  i: [{ t: 3 }],
19
- s: "Zdroj"
19
+ s: "Kredit"
20
20
  }
21
21
  }
22
22
  },
@@ -25,7 +25,7 @@ var e = {
25
25
  b: {
26
26
  t: 2,
27
27
  i: [{ t: 3 }],
28
- s: "Zobrazit zdroj"
28
+ s: "Zobrazit kredit"
29
29
  }
30
30
  } }
31
31
  },
@@ -43,7 +43,7 @@ var e = {
43
43
  b: {
44
44
  t: 2,
45
45
  i: [{ t: 3 }],
46
- s: "Asset mezitím dostal autory v DAM. Pokud obrázek neměl vlastní zdroj, má nyní jejich jména; vybraní autoři se neuložili. Zkontrolujte a potvrďte znovu."
46
+ s: "Asset mezitím dostal zdroje nebo autory v DAM. Pokud obrázek neměl vlastní kredit, má nyní jejich kredit; vybrané zdroje a autoři se neuložili. Zkontrolujte a potvrďte znovu."
47
47
  }
48
48
  },
49
49
  galleryAuthorsGivenMeanwhile: {
@@ -51,7 +51,7 @@ var e = {
51
51
  b: {
52
52
  t: 2,
53
53
  i: [{ t: 3 }],
54
- s: "Assety některých obrázků mezitím dostaly autory v DAM. Obrázky bez vlastního zdroje mají nyní jejich jména; vybraní autoři se neuložili a nic se neuložilo. Zkontrolujte a uložte znovu."
54
+ s: "Assety některých obrázků mezitím dostaly zdroje nebo autory v DAM. Obrázky bez vlastního kreditu mají nyní jejich kredit; vybrané zdroje a autoři se neuložili a nic se neuložilo. Zkontrolujte a uložte znovu."
55
55
  }
56
56
  }
57
57
  },
@@ -292,6 +292,22 @@ var e = {
292
292
  s: "Autoři"
293
293
  }
294
294
  },
295
+ sources: {
296
+ t: 0,
297
+ b: {
298
+ t: 2,
299
+ i: [{ t: 3 }],
300
+ s: "Zdroje"
301
+ }
302
+ },
303
+ sourcesEmpty: {
304
+ t: 0,
305
+ b: {
306
+ t: 2,
307
+ i: [{ t: 3 }],
308
+ s: "Žádné zdroje"
309
+ }
310
+ },
295
311
  keywords: {
296
312
  t: 0,
297
313
  b: {
@@ -1194,6 +1210,14 @@ var e = {
1194
1210
  s: "Přidat nového autora"
1195
1211
  }
1196
1212
  },
1213
+ addSource: {
1214
+ t: 0,
1215
+ b: {
1216
+ t: 2,
1217
+ i: [{ t: 3 }],
1218
+ s: "Přidat nový zdroj"
1219
+ }
1220
+ },
1197
1221
  addConflict: {
1198
1222
  t: 0,
1199
1223
  b: {
@@ -1216,20 +1240,70 @@ var e = {
1216
1240
  }
1217
1241
  }
1218
1242
  },
1219
- meta: { create: {
1243
+ meta: {
1244
+ create: {
1245
+ t: 0,
1246
+ b: {
1247
+ t: 2,
1248
+ i: [{ t: 3 }],
1249
+ s: "Vytvoření autora"
1250
+ }
1251
+ },
1252
+ createSource: {
1253
+ t: 0,
1254
+ b: {
1255
+ t: 2,
1256
+ i: [{ t: 3 }],
1257
+ s: "Vytvoření zdroje"
1258
+ }
1259
+ }
1260
+ },
1261
+ conflicts: {
1220
1262
  t: 0,
1221
1263
  b: {
1222
1264
  t: 2,
1223
1265
  i: [{ t: 3 }],
1224
- s: "Vytvoření autora"
1266
+ s: "Konflikt autorů"
1225
1267
  }
1226
- } },
1227
- conflicts: {
1268
+ },
1269
+ sourceFound: {
1228
1270
  t: 0,
1229
1271
  b: {
1230
1272
  t: 2,
1231
- i: [{ t: 3 }],
1232
- s: "Konflikt autorů"
1273
+ i: [
1274
+ {
1275
+ t: 3,
1276
+ v: "„"
1277
+ },
1278
+ {
1279
+ t: 4,
1280
+ k: "name"
1281
+ },
1282
+ {
1283
+ t: 3,
1284
+ v: "“ je zdroj, přidali jsme ho do Zdrojů"
1285
+ }
1286
+ ]
1287
+ }
1288
+ },
1289
+ authorFound: {
1290
+ t: 0,
1291
+ b: {
1292
+ t: 2,
1293
+ i: [
1294
+ {
1295
+ t: 3,
1296
+ v: "„"
1297
+ },
1298
+ {
1299
+ t: 4,
1300
+ k: "name"
1301
+ },
1302
+ {
1303
+ t: 3,
1304
+ v: "“ je autor, přidali jsme ho do Autorů"
1305
+ }
1306
+ ]
1233
1307
  }
1234
1308
  },
1235
1309
  filterMinChars: {
@@ -1 +1 @@
1
- {"version":3,"file":"damImage.js","names":["resource","\"image\"","\"model\"","\"texts\"","\"description\"","\"t\"","\"b\"","\"i\"","\"s\"","\"source\"","\"flags\"","\"showSource\"","\"meta\"","\"edit\"","\"authorsGivenMeanwhile\"","\"galleryAuthorsGivenMeanwhile\"","\"button\"","\"options\"","\"editAsset\"","\"upload\"","\"addFromDam\"","\"replaceFromDam\"","\"removeImage\"","\"help\"","\"media\"","\"damMedia\"","\"assetId\"","\"licenceId\"","\"title\"","\"authorNames\"","\"episodeName\"","\"episodeNumber\"","\"seriesName\"","\"preview\"","\"notPlayable\"","\"remove\"","\"queueItem\"","\"displayTitle\"","\"error\"","\"copyAssetId\"","\"stillUploadingOrProcessing\"","\"refreshFailed\"","\"assetGone\"","\"duplicateOriginalUnread\"","\"removeFromQueue\"","\"errorUnableToCopyToLicence\"","\"asset\"","\"authors\"","\"keywords\"","\"mainFileSingleUse\"","\"autoDelete\"","\"assetType\"","\"audio\"","\"video\"","\"document\"","\"list\"","\"noTitle\"","\"detail\"","\"sourceSystem\"","\"toggleInfo\"","\"metadataToggle\"","\"show\"","\"hide\"","\"tabs\"","\"info\"","\"roi\"","\"status\"","\"duplicate\"","\"draft\"","\"deleting\"","\"failed\"","\"metadata\"","\"file\"","\"field\"","\"id\"","\"mainFileId\"","\"type\"","\"mimeType\"","\"size\"","\"dominantColor\"","\"width\"","\"height\"","\"ratio\"","\"animated\"","\"licence\"","\"refresh\"","\"rotate\"","\"rotateMainFileImage\"","\"rotateClockwise\"","\"rotateCounterclockwise\"","\"massOperations\"","\"fillOneEmpty\"","\"fillAllEmpty\"","\"replaceOne\"","\"fillOneEmptyField\"","\"v\"","\"k\"","\"replaceOneField\"","\"replaceAll\"","\"clearForm\"","\"general\"","\"metaIcons\"","\"low\"","\"slots\"","\"rss\"","\"tts\"","\"fullHd\"","\"qhd\"","\"autoDeleteAt\"","\"assetFileFailReason\"","\"none\"","\"unknown\"","\"invalidChecksum\"","\"invalidMimeType\"","\"downloadFailed\"","\"invalidSize\"","\"waiting\"","\"processing\"","\"uploading\"","\"done\"","\"stop\"","\"add\"","\"save\"","\"saveAndApply\"","\"apply\"","\"titleDone\"","\"stopConfirmQuestion\"","\"stopConfirm\"","\"onlyOneFile\"","\"metadataJustLoaded\"","\"limits\"","\"uploadWarning\"","\"onUploadLimit\"","\"addingOverLimit\"","\"countAlreadyInProgress\"","\"onlyAllowedAtOnce\"","\"cancelOrUploadFirst\"","\"actionAddFirstItems\"","\"keyword\"","\"name\"","\"create\"","\"filterMinChars\"","\"author\"","\"identifier\"","\"reviewed\"","\"authorType\"","\"internal\"","\"external\"","\"agency\"","\"addConflict\"","\"addConflictNamed\"","\"conflicts\"","\"uploadErrors\"","\"unknownError\"","\"systemError\"","\"offset\"","\"chunkValidationFailed\"","\"processingTooLong\"","\"readFailed\"","\"notificationsNotConnected\"","\"public\"","\"idOrUrl\"","\"inputError\"","\"imagePreview\"","\"loadingConfig\"","\"accessRights\"","\"unableToLock\""],"sources":[],"mappings":""}
1
+ {"version":3,"file":"damImage.js","names":["resource","\"image\"","\"model\"","\"texts\"","\"description\"","\"t\"","\"b\"","\"i\"","\"s\"","\"source\"","\"flags\"","\"showSource\"","\"meta\"","\"edit\"","\"authorsGivenMeanwhile\"","\"galleryAuthorsGivenMeanwhile\"","\"button\"","\"options\"","\"editAsset\"","\"upload\"","\"addFromDam\"","\"replaceFromDam\"","\"removeImage\"","\"help\"","\"media\"","\"damMedia\"","\"assetId\"","\"licenceId\"","\"title\"","\"authorNames\"","\"episodeName\"","\"episodeNumber\"","\"seriesName\"","\"preview\"","\"notPlayable\"","\"remove\"","\"queueItem\"","\"displayTitle\"","\"error\"","\"copyAssetId\"","\"stillUploadingOrProcessing\"","\"refreshFailed\"","\"assetGone\"","\"duplicateOriginalUnread\"","\"removeFromQueue\"","\"errorUnableToCopyToLicence\"","\"asset\"","\"authors\"","\"sources\"","\"sourcesEmpty\"","\"keywords\"","\"mainFileSingleUse\"","\"autoDelete\"","\"assetType\"","\"audio\"","\"video\"","\"document\"","\"list\"","\"noTitle\"","\"detail\"","\"sourceSystem\"","\"toggleInfo\"","\"metadataToggle\"","\"show\"","\"hide\"","\"tabs\"","\"info\"","\"roi\"","\"status\"","\"duplicate\"","\"draft\"","\"deleting\"","\"failed\"","\"metadata\"","\"file\"","\"field\"","\"id\"","\"mainFileId\"","\"type\"","\"mimeType\"","\"size\"","\"dominantColor\"","\"width\"","\"height\"","\"ratio\"","\"animated\"","\"licence\"","\"refresh\"","\"rotate\"","\"rotateMainFileImage\"","\"rotateClockwise\"","\"rotateCounterclockwise\"","\"massOperations\"","\"fillOneEmpty\"","\"fillAllEmpty\"","\"replaceOne\"","\"fillOneEmptyField\"","\"v\"","\"k\"","\"replaceOneField\"","\"replaceAll\"","\"clearForm\"","\"general\"","\"metaIcons\"","\"low\"","\"slots\"","\"rss\"","\"tts\"","\"fullHd\"","\"qhd\"","\"autoDeleteAt\"","\"assetFileFailReason\"","\"none\"","\"unknown\"","\"invalidChecksum\"","\"invalidMimeType\"","\"downloadFailed\"","\"invalidSize\"","\"waiting\"","\"processing\"","\"uploading\"","\"done\"","\"stop\"","\"add\"","\"save\"","\"saveAndApply\"","\"apply\"","\"titleDone\"","\"stopConfirmQuestion\"","\"stopConfirm\"","\"onlyOneFile\"","\"metadataJustLoaded\"","\"limits\"","\"uploadWarning\"","\"onUploadLimit\"","\"addingOverLimit\"","\"countAlreadyInProgress\"","\"onlyAllowedAtOnce\"","\"cancelOrUploadFirst\"","\"actionAddFirstItems\"","\"keyword\"","\"name\"","\"create\"","\"filterMinChars\"","\"author\"","\"identifier\"","\"reviewed\"","\"authorType\"","\"internal\"","\"external\"","\"agency\"","\"addSource\"","\"addConflict\"","\"addConflictNamed\"","\"createSource\"","\"conflicts\"","\"sourceFound\"","\"authorFound\"","\"uploadErrors\"","\"unknownError\"","\"systemError\"","\"offset\"","\"chunkValidationFailed\"","\"processingTooLong\"","\"readFailed\"","\"notificationsNotConnected\"","\"public\"","\"idOrUrl\"","\"inputError\"","\"imagePreview\"","\"loadingConfig\"","\"accessRights\"","\"unableToLock\""],"sources":[],"mappings":""}
@@ -661,6 +661,8 @@ declare const _default: {
661
661
  asset: {
662
662
  model: {
663
663
  authors: string;
664
+ sources: string;
665
+ sourcesEmpty: string;
664
666
  keywords: string;
665
667
  mainFileSingleUse: string;
666
668
  autoDelete: string;
@@ -807,13 +809,17 @@ declare const _default: {
807
809
  };
808
810
  button: {
809
811
  add: string;
812
+ addSource: string;
810
813
  addConflict: string;
811
814
  addConflictNamed: string;
812
815
  };
813
816
  meta: {
814
817
  create: string;
818
+ createSource: string;
815
819
  };
816
820
  conflicts: string;
821
+ sourceFound: string;
822
+ authorFound: string;
817
823
  filterMinChars: string;
818
824
  };
819
825
  uploadErrors: {
@@ -260,7 +260,7 @@ var e = {
260
260
  b: {
261
261
  t: 2,
262
262
  i: [{ t: 3 }],
263
- s: "Authors"
263
+ s: "Authors and sources"
264
264
  }
265
265
  },
266
266
  createdByIds: {