@dealpos-npm/ng-dealpos-library 22.0.3 → 22.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/dealpos-npm-ng-dealpos-library-components-modal-news.mjs +3 -15
- package/fesm2022/dealpos-npm-ng-dealpos-library-components-modal-news.mjs.map +1 -1
- package/fesm2022/dealpos-npm-ng-dealpos-library-dexie-data-access.mjs.map +1 -1
- package/fesm2022/dealpos-npm-ng-dealpos-library-sell-models.mjs +1095 -0
- package/fesm2022/dealpos-npm-ng-dealpos-library-sell-models.mjs.map +1 -0
- package/fesm2022/dealpos-npm-ng-dealpos-library-sell.mjs +12089 -764
- package/fesm2022/dealpos-npm-ng-dealpos-library-sell.mjs.map +1 -1
- package/fesm2022/dealpos-npm-ng-dealpos-library-services-http.mjs +2 -1
- package/fesm2022/dealpos-npm-ng-dealpos-library-services-http.mjs.map +1 -1
- package/package.json +10 -6
- package/types/dealpos-npm-ng-dealpos-library-components-modal-news.d.ts +0 -3
- package/types/dealpos-npm-ng-dealpos-library-dexie-data-access.d.ts +2 -2
- package/types/dealpos-npm-ng-dealpos-library-sell-models.d.ts +2803 -0
- package/types/dealpos-npm-ng-dealpos-library-sell.d.ts +6010 -1414
- package/types/dealpos-npm-ng-dealpos-library-services-http.d.ts +4 -1
- package/fesm2022/dealpos-npm-ng-dealpos-library-components-search-option.mjs +0 -236
- package/fesm2022/dealpos-npm-ng-dealpos-library-components-search-option.mjs.map +0 -1
- package/types/dealpos-npm-ng-dealpos-library-components-search-option.d.ts +0 -80
|
@@ -3,7 +3,6 @@ import { ChangeDetectionStrategy, Component, HostListener, Injectable, computed,
|
|
|
3
3
|
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from "@angular/material/dialog";
|
|
4
4
|
import { NewlinesPipe } from "@dealpos-npm/ng-dealpos-library/pipes/newlines";
|
|
5
5
|
import { BrokenImageIconFailSafeDirective } from "@dealpos-npm/ng-dealpos-library/directives/broken-image-fail-save";
|
|
6
|
-
import { DOCUMENT } from "@angular/common";
|
|
7
6
|
import { NavigationEnd, Router } from "@angular/router";
|
|
8
7
|
import { filter } from "rxjs";
|
|
9
8
|
const DEFAULT_LABELS = {
|
|
@@ -129,7 +128,7 @@ var ModalNewsComponent = class ModalNewsComponent {
|
|
|
129
128
|
host: { listeners: { "keydown": "onKeydown($event)" } },
|
|
130
129
|
ngImport: i0,
|
|
131
130
|
template: "<div class=\"news-card\" (touchstart)=\"onTouchStart($event)\" (touchend)=\"onTouchEnd($event)\">\r\n @if (item(); as news) {\r\n <div class=\"news-header\">\r\n <i class=\"fa-regular fa-newspaper news-header-icon\" aria-hidden=\"true\"></i>\r\n <h2 class=\"news-header-title\">{{ labels().headerTitle }}</h2>\r\n <button\r\n type=\"button\"\r\n class=\"btn-close news-close\"\r\n [attr.aria-label]=\"labels().close\"\r\n (click)=\"dismiss()\"\r\n ></button>\r\n </div>\r\n\r\n <div class=\"news-hero\">\r\n @if (isMulti()) {\r\n <button\r\n type=\"button\"\r\n class=\"news-nav news-prev\"\r\n [disabled]=\"index() === 0 && slideIndex() === 0\"\r\n [attr.aria-label]=\"labels().prev\"\r\n (click)=\"prev()\"\r\n >\r\n <i class=\"fa fa-chevron-left\" aria-hidden=\"true\"></i>\r\n </button>\r\n <button\r\n type=\"button\"\r\n class=\"news-nav news-next\"\r\n [disabled]=\"index() === total() - 1 && slideIndex() === slides().length - 1\"\r\n [attr.aria-label]=\"labels().next\"\r\n (click)=\"next()\"\r\n >\r\n <i class=\"fa fa-chevron-right\" aria-hidden=\"true\"></i>\r\n </button>\r\n }\r\n\r\n @if (slide()?.image || news.image) {\r\n <a\r\n class=\"news-image-link\"\r\n [attr.href]=\"news.actionUrl || null\"\r\n [attr.target]=\"news.actionUrl ? '_blank' : null\"\r\n [attr.rel]=\"news.actionUrl ? 'noopener noreferrer' : null\"\r\n tabindex=\"-1\"\r\n aria-hidden=\"true\"\r\n (click)=\"onLinkClick()\"\r\n >\r\n <img\r\n class=\"news-image\"\r\n [src]=\"slide()?.image || news.image\"\r\n [alt]=\"slide()?.imageAlt || slide()?.title || news.imageAlt || news.title\"\r\n draggable=\"false\"\r\n brokenImageIconFailSafe\r\n (dragstart)=\"$event.preventDefault()\"\r\n (contextmenu)=\"$event.preventDefault()\"\r\n />\r\n </a>\r\n } @else {\r\n <div class=\"news-placeholder\" aria-hidden=\"true\">\r\n <i class=\"fa fa-image\"></i>\r\n </div>\r\n }\r\n\r\n @if (isMultiSlide()) {\r\n <div class=\"news-slide-nav\">\r\n <button\r\n type=\"button\"\r\n class=\"news-slide-btn\"\r\n [disabled]=\"slideIndex() === 0\"\r\n [attr.aria-label]=\"labels().prevImage\"\r\n (click)=\"prevSlide()\"\r\n >\r\n <i class=\"fa fa-chevron-left\" aria-hidden=\"true\"></i>\r\n </button>\r\n <span class=\"news-slide-count\" aria-hidden=\"true\">{{ slideIndex() + 1 }} / {{ slides().length }}</span>\r\n <button\r\n type=\"button\"\r\n class=\"news-slide-btn\"\r\n [disabled]=\"slideIndex() === slides().length - 1\"\r\n [attr.aria-label]=\"labels().nextImage\"\r\n (click)=\"nextSlide()\"\r\n >\r\n <i class=\"fa fa-chevron-right\" aria-hidden=\"true\"></i>\r\n </button>\r\n </div>\r\n }\r\n\r\n @if (isMulti()) {\r\n <div class=\"news-indicator\">\r\n <div class=\"news-dots\">\r\n @for (dot of data.items; track dot.id; let i = $index) {\r\n <button\r\n type=\"button\"\r\n class=\"news-dot\"\r\n [class.active]=\"i === index()\"\r\n [attr.aria-label]=\"labels().goToNews + ' #' + (i + 1)\"\r\n [attr.aria-current]=\"i === index() ? 'true' : null\"\r\n (click)=\"goTo(i)\"\r\n ></button>\r\n }\r\n </div>\r\n <span class=\"news-count\">{{ index() + 1 }} / {{ total() }}</span>\r\n </div>\r\n }\r\n </div>\r\n\r\n <div class=\"news-body\">\r\n <a\r\n class=\"news-link\"\r\n [attr.href]=\"news.actionUrl || null\"\r\n [attr.target]=\"news.actionUrl ? '_blank' : null\"\r\n [attr.rel]=\"news.actionUrl ? 'noopener noreferrer' : null\"\r\n (click)=\"onLinkClick()\"\r\n >\r\n <h5 class=\"news-title\" [id]=\"titleId\">{{ slide()?.title || news.title }}</h5>\r\n </a>\r\n <p class=\"news-text\" [innerHTML]=\"(slide()?.body || news.body) | newlines\"></p>\r\n </div>\r\n\r\n <p class=\"visually-hidden\" aria-live=\"polite\">\r\n {{ index() + 1 }} / {{ total() }}@if (isMultiSlide()) { · {{ slideIndex() + 1 }} / {{ slides().length }} } —\r\n {{ slide()?.title || news.title }}\r\n </p>\r\n }\r\n</div>\r\n",
|
|
132
|
-
styles: [":host{display:block
|
|
131
|
+
styles: [":host{display:block}.news-card{border-radius:16px;overflow:hidden;background:#fff;position:relative}.news-header{display:flex;align-items:center;gap:8px;padding:14px 14px 14px 16px;background:#f1f2f4}.news-header-icon{font-size:14px;color:#111418}.news-header-title{flex:1;margin:0;font-size:15px;font-weight:600;line-height:1.2;color:#111418}.news-hero{position:relative;background:#fef3e8;padding:28px 24px}.news-close{flex:none;width:26px;height:26px;padding:0;border-radius:50%;background-color:#fff;background-size:8px;box-shadow:0 2px 8px #0000001f;opacity:1}.news-nav{position:absolute;top:50%;transform:translateY(-50%);z-index:3;width:34px;height:34px;border:none;border-radius:50%;background:#ffffffeb;color:#343a40;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:background-color .15s ease,opacity .15s ease}.news-nav:hover:not(:disabled){background:#fff}.news-nav:disabled{opacity:.35;cursor:default}.news-prev{left:14px}.news-next{right:14px}.news-slide-nav{position:absolute;top:12px;left:12px;z-index:3;display:flex;align-items:center;gap:4px;padding:4px 8px;border-radius:999px;background:#0000008c;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);color:#fff}.news-slide-btn{display:flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;border:none;background:none;color:inherit;font-size:10px;cursor:pointer}.news-slide-btn:disabled{opacity:.4;cursor:default}.news-slide-count{font-size:11px;font-weight:700;white-space:nowrap}.news-indicator{position:absolute;bottom:14px;left:50%;transform:translate(-50%);display:flex;align-items:center;gap:10px;padding:6px 12px;border-radius:999px;background:#0000008c;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);z-index:3}.news-dots{display:flex;align-items:center;gap:6px}.news-dot{width:8px;height:8px;padding:0;border:none;border-radius:999px;background:#ffffff8c;cursor:pointer;transition:width .2s ease,background-color .2s ease}.news-dot.active{width:20px;background:#fff}.news-count{font-size:12px;font-weight:700;color:#fff;white-space:nowrap}.news-image-link{display:block}.news-image-link[href]{cursor:pointer}.news-link{display:inline-block;color:inherit;text-decoration:none}.news-link[href]{cursor:pointer}.news-link[href]:hover .news-title{text-decoration:underline}.news-image{display:block;width:100%;height:auto;border-radius:14px;background:#fff;pointer-events:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;-webkit-user-drag:none}.news-placeholder{display:flex;align-items:center;justify-content:center;min-height:180px;border:1px dashed #ced4da;border-radius:14px;background:#fff}.news-placeholder i{font-size:28px;color:#adb5bd}.news-body{padding:22px 24px 24px;background:#fff;max-height:60vh;overflow-y:auto}.news-title{margin:0 0 8px;font-size:18px;font-weight:800;color:#111418!important}.news-text{margin:0;font-size:14px;color:#343a40!important}.visually-hidden{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}::ng-deep .news-modal-panel .mat-mdc-dialog-container{padding:0}::ng-deep .news-modal-panel .mdc-dialog__surface{padding:0;border-radius:16px;overflow:hidden;max-width:475px;background:transparent;box-shadow:0 18px 48px #00000047}::ng-deep .news-modal-backdrop{background:#000;opacity:.5}@media(max-width:768px){.news-header{padding:8px 8px 8px 12px}.news-header-title{font-size:14px}.news-close{width:24px;height:24px}.news-body{max-height:52vh;padding:18px 18px 20px}.news-hero{padding:22px 16px}.news-indicator{bottom:10px}}@media(prefers-reduced-motion:reduce){.news-nav,.news-dot{transition:none!important}}\n"],
|
|
133
132
|
dependencies: [{
|
|
134
133
|
kind: "directive",
|
|
135
134
|
type: BrokenImageIconFailSafeDirective,
|
|
@@ -161,7 +160,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
161
160
|
imports: [NewlinesPipe, BrokenImageIconFailSafeDirective],
|
|
162
161
|
changeDetection: ChangeDetectionStrategy.Eager,
|
|
163
162
|
template: "<div class=\"news-card\" (touchstart)=\"onTouchStart($event)\" (touchend)=\"onTouchEnd($event)\">\r\n @if (item(); as news) {\r\n <div class=\"news-header\">\r\n <i class=\"fa-regular fa-newspaper news-header-icon\" aria-hidden=\"true\"></i>\r\n <h2 class=\"news-header-title\">{{ labels().headerTitle }}</h2>\r\n <button\r\n type=\"button\"\r\n class=\"btn-close news-close\"\r\n [attr.aria-label]=\"labels().close\"\r\n (click)=\"dismiss()\"\r\n ></button>\r\n </div>\r\n\r\n <div class=\"news-hero\">\r\n @if (isMulti()) {\r\n <button\r\n type=\"button\"\r\n class=\"news-nav news-prev\"\r\n [disabled]=\"index() === 0 && slideIndex() === 0\"\r\n [attr.aria-label]=\"labels().prev\"\r\n (click)=\"prev()\"\r\n >\r\n <i class=\"fa fa-chevron-left\" aria-hidden=\"true\"></i>\r\n </button>\r\n <button\r\n type=\"button\"\r\n class=\"news-nav news-next\"\r\n [disabled]=\"index() === total() - 1 && slideIndex() === slides().length - 1\"\r\n [attr.aria-label]=\"labels().next\"\r\n (click)=\"next()\"\r\n >\r\n <i class=\"fa fa-chevron-right\" aria-hidden=\"true\"></i>\r\n </button>\r\n }\r\n\r\n @if (slide()?.image || news.image) {\r\n <a\r\n class=\"news-image-link\"\r\n [attr.href]=\"news.actionUrl || null\"\r\n [attr.target]=\"news.actionUrl ? '_blank' : null\"\r\n [attr.rel]=\"news.actionUrl ? 'noopener noreferrer' : null\"\r\n tabindex=\"-1\"\r\n aria-hidden=\"true\"\r\n (click)=\"onLinkClick()\"\r\n >\r\n <img\r\n class=\"news-image\"\r\n [src]=\"slide()?.image || news.image\"\r\n [alt]=\"slide()?.imageAlt || slide()?.title || news.imageAlt || news.title\"\r\n draggable=\"false\"\r\n brokenImageIconFailSafe\r\n (dragstart)=\"$event.preventDefault()\"\r\n (contextmenu)=\"$event.preventDefault()\"\r\n />\r\n </a>\r\n } @else {\r\n <div class=\"news-placeholder\" aria-hidden=\"true\">\r\n <i class=\"fa fa-image\"></i>\r\n </div>\r\n }\r\n\r\n @if (isMultiSlide()) {\r\n <div class=\"news-slide-nav\">\r\n <button\r\n type=\"button\"\r\n class=\"news-slide-btn\"\r\n [disabled]=\"slideIndex() === 0\"\r\n [attr.aria-label]=\"labels().prevImage\"\r\n (click)=\"prevSlide()\"\r\n >\r\n <i class=\"fa fa-chevron-left\" aria-hidden=\"true\"></i>\r\n </button>\r\n <span class=\"news-slide-count\" aria-hidden=\"true\">{{ slideIndex() + 1 }} / {{ slides().length }}</span>\r\n <button\r\n type=\"button\"\r\n class=\"news-slide-btn\"\r\n [disabled]=\"slideIndex() === slides().length - 1\"\r\n [attr.aria-label]=\"labels().nextImage\"\r\n (click)=\"nextSlide()\"\r\n >\r\n <i class=\"fa fa-chevron-right\" aria-hidden=\"true\"></i>\r\n </button>\r\n </div>\r\n }\r\n\r\n @if (isMulti()) {\r\n <div class=\"news-indicator\">\r\n <div class=\"news-dots\">\r\n @for (dot of data.items; track dot.id; let i = $index) {\r\n <button\r\n type=\"button\"\r\n class=\"news-dot\"\r\n [class.active]=\"i === index()\"\r\n [attr.aria-label]=\"labels().goToNews + ' #' + (i + 1)\"\r\n [attr.aria-current]=\"i === index() ? 'true' : null\"\r\n (click)=\"goTo(i)\"\r\n ></button>\r\n }\r\n </div>\r\n <span class=\"news-count\">{{ index() + 1 }} / {{ total() }}</span>\r\n </div>\r\n }\r\n </div>\r\n\r\n <div class=\"news-body\">\r\n <a\r\n class=\"news-link\"\r\n [attr.href]=\"news.actionUrl || null\"\r\n [attr.target]=\"news.actionUrl ? '_blank' : null\"\r\n [attr.rel]=\"news.actionUrl ? 'noopener noreferrer' : null\"\r\n (click)=\"onLinkClick()\"\r\n >\r\n <h5 class=\"news-title\" [id]=\"titleId\">{{ slide()?.title || news.title }}</h5>\r\n </a>\r\n <p class=\"news-text\" [innerHTML]=\"(slide()?.body || news.body) | newlines\"></p>\r\n </div>\r\n\r\n <p class=\"visually-hidden\" aria-live=\"polite\">\r\n {{ index() + 1 }} / {{ total() }}@if (isMultiSlide()) { · {{ slideIndex() + 1 }} / {{ slides().length }} } —\r\n {{ slide()?.title || news.title }}\r\n </p>\r\n }\r\n</div>\r\n",
|
|
164
|
-
styles: [":host{display:block
|
|
163
|
+
styles: [":host{display:block}.news-card{border-radius:16px;overflow:hidden;background:#fff;position:relative}.news-header{display:flex;align-items:center;gap:8px;padding:14px 14px 14px 16px;background:#f1f2f4}.news-header-icon{font-size:14px;color:#111418}.news-header-title{flex:1;margin:0;font-size:15px;font-weight:600;line-height:1.2;color:#111418}.news-hero{position:relative;background:#fef3e8;padding:28px 24px}.news-close{flex:none;width:26px;height:26px;padding:0;border-radius:50%;background-color:#fff;background-size:8px;box-shadow:0 2px 8px #0000001f;opacity:1}.news-nav{position:absolute;top:50%;transform:translateY(-50%);z-index:3;width:34px;height:34px;border:none;border-radius:50%;background:#ffffffeb;color:#343a40;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:background-color .15s ease,opacity .15s ease}.news-nav:hover:not(:disabled){background:#fff}.news-nav:disabled{opacity:.35;cursor:default}.news-prev{left:14px}.news-next{right:14px}.news-slide-nav{position:absolute;top:12px;left:12px;z-index:3;display:flex;align-items:center;gap:4px;padding:4px 8px;border-radius:999px;background:#0000008c;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);color:#fff}.news-slide-btn{display:flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;border:none;background:none;color:inherit;font-size:10px;cursor:pointer}.news-slide-btn:disabled{opacity:.4;cursor:default}.news-slide-count{font-size:11px;font-weight:700;white-space:nowrap}.news-indicator{position:absolute;bottom:14px;left:50%;transform:translate(-50%);display:flex;align-items:center;gap:10px;padding:6px 12px;border-radius:999px;background:#0000008c;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);z-index:3}.news-dots{display:flex;align-items:center;gap:6px}.news-dot{width:8px;height:8px;padding:0;border:none;border-radius:999px;background:#ffffff8c;cursor:pointer;transition:width .2s ease,background-color .2s ease}.news-dot.active{width:20px;background:#fff}.news-count{font-size:12px;font-weight:700;color:#fff;white-space:nowrap}.news-image-link{display:block}.news-image-link[href]{cursor:pointer}.news-link{display:inline-block;color:inherit;text-decoration:none}.news-link[href]{cursor:pointer}.news-link[href]:hover .news-title{text-decoration:underline}.news-image{display:block;width:100%;height:auto;border-radius:14px;background:#fff;pointer-events:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;-webkit-user-drag:none}.news-placeholder{display:flex;align-items:center;justify-content:center;min-height:180px;border:1px dashed #ced4da;border-radius:14px;background:#fff}.news-placeholder i{font-size:28px;color:#adb5bd}.news-body{padding:22px 24px 24px;background:#fff;max-height:60vh;overflow-y:auto}.news-title{margin:0 0 8px;font-size:18px;font-weight:800;color:#111418!important}.news-text{margin:0;font-size:14px;color:#343a40!important}.visually-hidden{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}::ng-deep .news-modal-panel .mat-mdc-dialog-container{padding:0}::ng-deep .news-modal-panel .mdc-dialog__surface{padding:0;border-radius:16px;overflow:hidden;max-width:475px;background:transparent;box-shadow:0 18px 48px #00000047}::ng-deep .news-modal-backdrop{background:#000;opacity:.5}@media(max-width:768px){.news-header{padding:8px 8px 8px 12px}.news-header-title{font-size:14px}.news-close{width:24px;height:24px}.news-body{max-height:52vh;padding:18px 18px 20px}.news-hero{padding:22px 16px}.news-indicator{bottom:10px}}@media(prefers-reduced-motion:reduce){.news-nav,.news-dot{transition:none!important}}\n"]
|
|
165
164
|
}]
|
|
166
165
|
}],
|
|
167
166
|
propDecorators: { onKeydown: [{
|
|
@@ -172,10 +171,9 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
172
171
|
var NewsModalService = class NewsModalService {
|
|
173
172
|
constructor() {
|
|
174
173
|
this.dialog = inject(MatDialog);
|
|
175
|
-
this.document = inject(DOCUMENT);
|
|
176
174
|
}
|
|
177
175
|
open(items, options) {
|
|
178
|
-
|
|
176
|
+
return this.dialog.open(ModalNewsComponent, {
|
|
179
177
|
data: {
|
|
180
178
|
items,
|
|
181
179
|
startIndex: options?.startIndex ?? 0,
|
|
@@ -189,16 +187,6 @@ var NewsModalService = class NewsModalService {
|
|
|
189
187
|
restoreFocus: true,
|
|
190
188
|
ariaLabel: options?.labels?.dialogLabel ?? "New feature announcement"
|
|
191
189
|
});
|
|
192
|
-
this.lockPageScroll(ref);
|
|
193
|
-
return ref;
|
|
194
|
-
}
|
|
195
|
-
lockPageScroll(ref) {
|
|
196
|
-
const body = this.document.body;
|
|
197
|
-
const previousOverflow = body.style.overflow;
|
|
198
|
-
body.style.overflow = "hidden";
|
|
199
|
-
ref.afterClosed().subscribe(() => {
|
|
200
|
-
body.style.overflow = previousOverflow;
|
|
201
|
-
});
|
|
202
190
|
}
|
|
203
191
|
static {
|
|
204
192
|
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dealpos-npm-ng-dealpos-library-components-modal-news.mjs","names":[],"sources":["../../../projects/dealpos-npm/ng-dealpos-library/components/modal-news/src/news-modal.component.ts","../../../projects/dealpos-npm/ng-dealpos-library/components/modal-news/src/news-modal.component.html","../../../projects/dealpos-npm/ng-dealpos-library/components/modal-news/src/news-modal.service.ts","../../../projects/dealpos-npm/ng-dealpos-library/components/modal-news/src/news-modal-route.util.ts","../../../projects/dealpos-npm/ng-dealpos-library/components/modal-news/src/news-modal-router.service.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, HostListener, computed, inject, signal } from '@angular/core';\r\nimport { MatDialogRef } from '@angular/material/dialog';\r\nimport { MAT_DIALOG_DATA } from '@angular/material/dialog';\r\nimport { NewlinesPipe } from '@dealpos-npm/ng-dealpos-library/pipes/newlines';\r\nimport { BrokenImageIconFailSafeDirective } from '@dealpos-npm/ng-dealpos-library/directives/broken-image-fail-save';\r\nimport { NewsModalData, NewsModalItem, NewsModalLabels, NewsModalResult, NewsModalSlide } from './news-modal.types';\r\n\r\nconst DEFAULT_LABELS: Required<NewsModalLabels> = {\r\n headerTitle: \"What's New\",\r\n close: 'Close',\r\n prev: 'Previous',\r\n next: 'Next',\r\n prevImage: 'Previous image',\r\n nextImage: 'Next image',\r\n gotIt: 'Got it',\r\n goToNews: 'Go to news',\r\n dialogLabel: 'New feature announcement',\r\n};\r\n\r\nconst SWIPE_THRESHOLD = 40;\r\n\r\n@Component({\r\n selector: 'lib-modal-news',\r\n standalone: true,\r\n imports: [NewlinesPipe, BrokenImageIconFailSafeDirective],\r\n templateUrl: './news-modal.component.html',\r\n styleUrls: ['./news-modal.component.scss'],\r\n changeDetection: ChangeDetectionStrategy.Eager,\r\n})\r\nexport class ModalNewsComponent {\r\n readonly data = inject<NewsModalData>(MAT_DIALOG_DATA);\r\n private readonly dialogRef = inject<MatDialogRef<ModalNewsComponent, NewsModalResult>>(MatDialogRef);\r\n\r\n readonly labels = computed<Required<NewsModalLabels>>(() => ({ ...DEFAULT_LABELS, ...this.data.labels }));\r\n readonly index = signal(this.data.startIndex ?? 0);\r\n readonly total = computed(() => this.data.items.length);\r\n readonly isMulti = computed(() => this.data.items.length > 1);\r\n readonly item = computed<NewsModalItem | null>(() => this.data.items[this.index()] ?? null);\r\n readonly slides = computed<NewsModalSlide[]>(() => {\r\n const item = this.item();\r\n if (!item) {\r\n return [];\r\n }\r\n return item.slides?.length ? item.slides : [item];\r\n });\r\n readonly slideIndex = signal(0);\r\n readonly slide = computed<NewsModalSlide | null>(() => this.slides()[this.slideIndex()] ?? null);\r\n readonly isMultiSlide = computed(() => this.slides().length > 1);\r\n\r\n private touchStartX = 0;\r\n\r\n readonly titleId = 'lib-modal-news-title';\r\n\r\n next(): void {\r\n this.advance(1);\r\n }\r\n\r\n prev(): void {\r\n this.advance(-1);\r\n }\r\n\r\n nextSlide(): void {\r\n this.moveSlide(1);\r\n }\r\n\r\n prevSlide(): void {\r\n this.moveSlide(-1);\r\n }\r\n\r\n goTo(i: number): void {\r\n this.move(i - this.index());\r\n }\r\n\r\n /** Close button and article links both end the same way: the item counts as read. */\r\n dismiss(): void {\r\n const item = this.item();\r\n if (!item) {\r\n this.dialogRef.close();\r\n return;\r\n }\r\n this.dialogRef.close({ action: 'dismiss', index: this.index(), item, url: item.actionUrl });\r\n }\r\n\r\n onLinkClick(): void {\r\n if (this.item()?.actionUrl) {\r\n this.dismiss();\r\n }\r\n }\r\n\r\n onTouchStart(event: TouchEvent): void {\r\n this.touchStartX = event.changedTouches[0]?.clientX ?? 0;\r\n }\r\n\r\n onTouchEnd(event: TouchEvent): void {\r\n const endX = event.changedTouches[0]?.clientX ?? 0;\r\n const dx = endX - this.touchStartX;\r\n this.touchStartX = 0;\r\n if (Math.abs(dx) < SWIPE_THRESHOLD) {\r\n return;\r\n }\r\n this.advance(dx < 0 ? 1 : -1);\r\n }\r\n\r\n @HostListener('keydown', ['$event'])\r\n onKeydown(event: KeyboardEvent): void {\r\n if (event.key === 'ArrowRight') {\r\n event.preventDefault();\r\n this.advance(1);\r\n } else if (event.key === 'ArrowLeft') {\r\n event.preventDefault();\r\n this.advance(-1);\r\n }\r\n }\r\n\r\n private advance(steps: number): void {\r\n const target = this.slideIndex() + steps;\r\n if (this.isMultiSlide() && target >= 0 && target < this.slides().length) {\r\n this.slideIndex.set(target);\r\n return;\r\n }\r\n this.move(steps);\r\n }\r\n\r\n private moveSlide(steps: number): void {\r\n const target = this.slideIndex() + steps;\r\n if (target < 0 || target >= this.slides().length) {\r\n return;\r\n }\r\n this.slideIndex.set(target);\r\n }\r\n\r\n private move(steps: number): void {\r\n const target = this.index() + steps;\r\n if (target < 0 || target >= this.total() || target === this.index()) {\r\n return;\r\n }\r\n this.index.set(target);\r\n this.slideIndex.set(0);\r\n }\r\n}\r\n","<div class=\"news-card\" (touchstart)=\"onTouchStart($event)\" (touchend)=\"onTouchEnd($event)\">\r\n @if (item(); as news) {\r\n <div class=\"news-header\">\r\n <i class=\"fa-regular fa-newspaper news-header-icon\" aria-hidden=\"true\"></i>\r\n <h2 class=\"news-header-title\">{{ labels().headerTitle }}</h2>\r\n <button\r\n type=\"button\"\r\n class=\"btn-close news-close\"\r\n [attr.aria-label]=\"labels().close\"\r\n (click)=\"dismiss()\"\r\n ></button>\r\n </div>\r\n\r\n <div class=\"news-hero\">\r\n @if (isMulti()) {\r\n <button\r\n type=\"button\"\r\n class=\"news-nav news-prev\"\r\n [disabled]=\"index() === 0 && slideIndex() === 0\"\r\n [attr.aria-label]=\"labels().prev\"\r\n (click)=\"prev()\"\r\n >\r\n <i class=\"fa fa-chevron-left\" aria-hidden=\"true\"></i>\r\n </button>\r\n <button\r\n type=\"button\"\r\n class=\"news-nav news-next\"\r\n [disabled]=\"index() === total() - 1 && slideIndex() === slides().length - 1\"\r\n [attr.aria-label]=\"labels().next\"\r\n (click)=\"next()\"\r\n >\r\n <i class=\"fa fa-chevron-right\" aria-hidden=\"true\"></i>\r\n </button>\r\n }\r\n\r\n @if (slide()?.image || news.image) {\r\n <a\r\n class=\"news-image-link\"\r\n [attr.href]=\"news.actionUrl || null\"\r\n [attr.target]=\"news.actionUrl ? '_blank' : null\"\r\n [attr.rel]=\"news.actionUrl ? 'noopener noreferrer' : null\"\r\n tabindex=\"-1\"\r\n aria-hidden=\"true\"\r\n (click)=\"onLinkClick()\"\r\n >\r\n <img\r\n class=\"news-image\"\r\n [src]=\"slide()?.image || news.image\"\r\n [alt]=\"slide()?.imageAlt || slide()?.title || news.imageAlt || news.title\"\r\n draggable=\"false\"\r\n brokenImageIconFailSafe\r\n (dragstart)=\"$event.preventDefault()\"\r\n (contextmenu)=\"$event.preventDefault()\"\r\n />\r\n </a>\r\n } @else {\r\n <div class=\"news-placeholder\" aria-hidden=\"true\">\r\n <i class=\"fa fa-image\"></i>\r\n </div>\r\n }\r\n\r\n @if (isMultiSlide()) {\r\n <div class=\"news-slide-nav\">\r\n <button\r\n type=\"button\"\r\n class=\"news-slide-btn\"\r\n [disabled]=\"slideIndex() === 0\"\r\n [attr.aria-label]=\"labels().prevImage\"\r\n (click)=\"prevSlide()\"\r\n >\r\n <i class=\"fa fa-chevron-left\" aria-hidden=\"true\"></i>\r\n </button>\r\n <span class=\"news-slide-count\" aria-hidden=\"true\">{{ slideIndex() + 1 }} / {{ slides().length }}</span>\r\n <button\r\n type=\"button\"\r\n class=\"news-slide-btn\"\r\n [disabled]=\"slideIndex() === slides().length - 1\"\r\n [attr.aria-label]=\"labels().nextImage\"\r\n (click)=\"nextSlide()\"\r\n >\r\n <i class=\"fa fa-chevron-right\" aria-hidden=\"true\"></i>\r\n </button>\r\n </div>\r\n }\r\n\r\n @if (isMulti()) {\r\n <div class=\"news-indicator\">\r\n <div class=\"news-dots\">\r\n @for (dot of data.items; track dot.id; let i = $index) {\r\n <button\r\n type=\"button\"\r\n class=\"news-dot\"\r\n [class.active]=\"i === index()\"\r\n [attr.aria-label]=\"labels().goToNews + ' #' + (i + 1)\"\r\n [attr.aria-current]=\"i === index() ? 'true' : null\"\r\n (click)=\"goTo(i)\"\r\n ></button>\r\n }\r\n </div>\r\n <span class=\"news-count\">{{ index() + 1 }} / {{ total() }}</span>\r\n </div>\r\n }\r\n </div>\r\n\r\n <div class=\"news-body\">\r\n <a\r\n class=\"news-link\"\r\n [attr.href]=\"news.actionUrl || null\"\r\n [attr.target]=\"news.actionUrl ? '_blank' : null\"\r\n [attr.rel]=\"news.actionUrl ? 'noopener noreferrer' : null\"\r\n (click)=\"onLinkClick()\"\r\n >\r\n <h5 class=\"news-title\" [id]=\"titleId\">{{ slide()?.title || news.title }}</h5>\r\n </a>\r\n <p class=\"news-text\" [innerHTML]=\"(slide()?.body || news.body) | newlines\"></p>\r\n </div>\r\n\r\n <p class=\"visually-hidden\" aria-live=\"polite\">\r\n {{ index() + 1 }} / {{ total() }}@if (isMultiSlide()) { · {{ slideIndex() + 1 }} / {{ slides().length }} } —\r\n {{ slide()?.title || news.title }}\r\n </p>\r\n }\r\n</div>\r\n","import { DOCUMENT } from '@angular/common';\r\nimport { inject, Injectable } from '@angular/core';\r\nimport { MatDialog, MatDialogRef } from '@angular/material/dialog';\r\nimport { ModalNewsComponent } from './news-modal.component';\r\nimport { NewsModalData, NewsModalItem, NewsModalLabels, NewsModalResult } from './news-modal.types';\r\n\r\nexport interface NewsModalOpenOptions {\r\n startIndex?: number;\r\n labels?: NewsModalLabels;\r\n}\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class NewsModalService {\r\n private readonly dialog = inject(MatDialog);\r\n private readonly document = inject(DOCUMENT);\r\n\r\n open(\r\n items: NewsModalItem[],\r\n options?: NewsModalOpenOptions,\r\n ): MatDialogRef<ModalNewsComponent, NewsModalResult | undefined> {\r\n const ref = this.dialog.open<ModalNewsComponent, NewsModalData, NewsModalResult | undefined>(\r\n ModalNewsComponent,\r\n {\r\n data: { items, startIndex: options?.startIndex ?? 0, labels: options?.labels },\r\n panelClass: 'news-modal-panel',\r\n backdropClass: 'news-modal-backdrop',\r\n width: '475px',\r\n maxWidth: '95vw',\r\n autoFocus: 'dialog',\r\n restoreFocus: true,\r\n ariaLabel: options?.labels?.dialogLabel ?? 'New feature announcement',\r\n },\r\n );\r\n\r\n this.lockPageScroll(ref);\r\n\r\n return ref;\r\n }\r\n\r\n /** Material's block strategy only locks a document-scrolled page, so lock the body as well. */\r\n private lockPageScroll<T, R>(ref: MatDialogRef<T, R>): void {\r\n const body = this.document.body;\r\n const previousOverflow = body.style.overflow;\r\n body.style.overflow = 'hidden';\r\n ref.afterClosed().subscribe(() => {\r\n body.style.overflow = previousOverflow;\r\n });\r\n }\r\n}\r\n","/**\r\n * Case-insensitive, per-segment prefix match between a router URL and a target route.\r\n * Query string and fragment are ignored. An empty target matches everything.\r\n */\r\nexport function matchesNewsTarget(currentUrl: string, target: string): boolean {\r\n const segments = (value: string): string[] =>\r\n value\r\n .split(/[?#]/, 1)[0]\r\n .toLowerCase()\r\n .split('/')\r\n .filter((part) => part.length > 0);\r\n\r\n const current = segments(currentUrl);\r\n const wanted = segments(target);\r\n if (!wanted.length) return true;\r\n if (wanted.length > current.length) return false;\r\n return wanted.every((segment, index) => current[index] === segment);\r\n}\r\n","import { Injectable, inject, signal } from '@angular/core';\r\nimport { NavigationEnd, Router } from '@angular/router';\r\nimport { filter } from 'rxjs';\r\nimport { NewsModalItem, NewsModalLabels } from './news-modal.types';\r\nimport { NewsModalService } from './news-modal.service';\r\nimport { matchesNewsTarget } from './news-modal-route.util';\r\n\r\nexport interface NewsModalAutoOpenOptions {\r\n startIndex?: number;\r\n labels?: NewsModalLabels;\r\n onOpen?: (items: NewsModalItem[]) => void;\r\n}\r\n\r\n/**\r\n * Opens the news modal automatically when the current route matches the `targets` of any\r\n * supplied item. Persisting \"already seen\" state is deliberately NOT handled here — the host\r\n * owns that, and can pass a getter that returns only items the user has not seen yet.\r\n */\r\n@Injectable({ providedIn: 'root' })\r\nexport class NewsModalRouterService {\r\n private readonly router = inject(Router);\r\n private readonly newsModal = inject(NewsModalService);\r\n private readonly dialogOpen = signal(false);\r\n\r\n /**\r\n * Evaluates the items against the current URL immediately and again on every navigation.\r\n * Returns a teardown function that stops watching; it does not close an open dialog.\r\n */\r\n autoOpen(\r\n source: NewsModalItem[] | (() => NewsModalItem[]),\r\n options?: NewsModalAutoOpenOptions,\r\n ): () => void {\r\n const resolve = (): NewsModalItem[] => (typeof source === 'function' ? source() : source);\r\n\r\n const evaluate = (): void => {\r\n if (this.dialogOpen()) return;\r\n const url = this.router.url;\r\n const matched = resolve().filter(\r\n (item) => !item.targets?.length || item.targets.some((target) => matchesNewsTarget(url, target)),\r\n );\r\n if (!matched.length) return;\r\n this.dialogOpen.set(true);\r\n options?.onOpen?.(matched);\r\n this.newsModal.open(matched, options).afterClosed().subscribe(() => this.dialogOpen.set(false));\r\n };\r\n\r\n evaluate();\r\n const subscription = this.router.events.pipe(filter((event) => event instanceof NavigationEnd)).subscribe(evaluate);\r\n\r\n return () => subscription.unsubscribe();\r\n }\r\n}\r\n"],"mappings":";;;;;;;;AAOA,MAAM,iBAA4C;CAChD,aAAa;CACb,OAAO;CACP,MAAM;CACN,MAAM;CACN,WAAW;CACX,WAAW;CACX,OAAO;CACP,UAAU;CACV,aAAa;AACd;AAED,MAAM,kBAAkB;AAUxB,IAAa,qBAAb,MAAa,mBAAkB;CAR/B,cAAA;EASW,KAAA,OAAO,OAAsB,eAAe;EACpC,KAAA,YAAY,OAA0D,YAAY;EAE1F,KAAA,SAAS,gBAA2C;GAAE,GAAG;GAAgB,GAAG,KAAK,KAAK;EAAM,IAAI,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;EAChG,KAAA,QAAQ,OAAO,KAAK,KAAK,cAAc,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;EACzC,KAAA,QAAQ,eAAe,KAAK,KAAK,MAAM,QAAO,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;EAC9C,KAAA,UAAU,eAAe,KAAK,KAAK,MAAM,SAAS,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;EACpD,KAAA,OAAO,eAAqC,KAAK,KAAK,MAAM,KAAK,MAAK,MAAO,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;EAClF,KAAA,SAAS,eAAgC;GAChD,MAAM,OAAO,KAAK,KAAI;GACtB,IAAI,CAAC,MACH,OAAO,CAAA;GAET,OAAO,KAAK,QAAQ,SAAS,KAAK,SAAS,CAAC,IAAI;EAClD,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,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,OAAO,OAAO,KAAK,QAAQ,UAAU,iBAAiB,aAAa,CAAC,CAAC,CAAC,UAAU,QAAQ;EAElH,aAAa,aAAa,YAAW;CACvC;CA/BW;EAAA,KAAA,OAAA,GAAA,mBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAsB,MAAA,CAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAAtB;EAAA,KAAA,QAAA,GAAA,sBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAsB,YADT;EAAM,CAAA;CAAA;;AACnB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAsB,YAAA,CAAA;EADlC,MAAA;EAAW,MAAA,CAAA,EAAE,YAAY,OAAM,CAAE"}
|
|
1
|
+
{"version":3,"file":"dealpos-npm-ng-dealpos-library-components-modal-news.mjs","names":[],"sources":["../../../projects/dealpos-npm/ng-dealpos-library/components/modal-news/src/news-modal.component.ts","../../../projects/dealpos-npm/ng-dealpos-library/components/modal-news/src/news-modal.component.html","../../../projects/dealpos-npm/ng-dealpos-library/components/modal-news/src/news-modal.service.ts","../../../projects/dealpos-npm/ng-dealpos-library/components/modal-news/src/news-modal-route.util.ts","../../../projects/dealpos-npm/ng-dealpos-library/components/modal-news/src/news-modal-router.service.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, HostListener, computed, inject, signal } from '@angular/core';\r\nimport { MatDialogRef } from '@angular/material/dialog';\r\nimport { MAT_DIALOG_DATA } from '@angular/material/dialog';\r\nimport { NewlinesPipe } from '@dealpos-npm/ng-dealpos-library/pipes/newlines';\r\nimport { BrokenImageIconFailSafeDirective } from '@dealpos-npm/ng-dealpos-library/directives/broken-image-fail-save';\r\nimport { NewsModalData, NewsModalItem, NewsModalLabels, NewsModalResult, NewsModalSlide } from './news-modal.types';\r\n\r\nconst DEFAULT_LABELS: Required<NewsModalLabels> = {\r\n headerTitle: \"What's New\",\r\n close: 'Close',\r\n prev: 'Previous',\r\n next: 'Next',\r\n prevImage: 'Previous image',\r\n nextImage: 'Next image',\r\n gotIt: 'Got it',\r\n goToNews: 'Go to news',\r\n dialogLabel: 'New feature announcement',\r\n};\r\n\r\nconst SWIPE_THRESHOLD = 40;\r\n\r\n@Component({\r\n selector: 'lib-modal-news',\r\n standalone: true,\r\n imports: [NewlinesPipe, BrokenImageIconFailSafeDirective],\r\n templateUrl: './news-modal.component.html',\r\n styleUrls: ['./news-modal.component.scss'],\r\n changeDetection: ChangeDetectionStrategy.Eager,\r\n})\r\nexport class ModalNewsComponent {\r\n readonly data = inject<NewsModalData>(MAT_DIALOG_DATA);\r\n private readonly dialogRef = inject<MatDialogRef<ModalNewsComponent, NewsModalResult>>(MatDialogRef);\r\n\r\n readonly labels = computed<Required<NewsModalLabels>>(() => ({ ...DEFAULT_LABELS, ...this.data.labels }));\r\n readonly index = signal(this.data.startIndex ?? 0);\r\n readonly total = computed(() => this.data.items.length);\r\n readonly isMulti = computed(() => this.data.items.length > 1);\r\n readonly item = computed<NewsModalItem | null>(() => this.data.items[this.index()] ?? null);\r\n readonly slides = computed<NewsModalSlide[]>(() => {\r\n const item = this.item();\r\n if (!item) {\r\n return [];\r\n }\r\n return item.slides?.length ? item.slides : [item];\r\n });\r\n readonly slideIndex = signal(0);\r\n readonly slide = computed<NewsModalSlide | null>(() => this.slides()[this.slideIndex()] ?? null);\r\n readonly isMultiSlide = computed(() => this.slides().length > 1);\r\n\r\n private touchStartX = 0;\r\n\r\n readonly titleId = 'lib-modal-news-title';\r\n\r\n next(): void {\r\n this.advance(1);\r\n }\r\n\r\n prev(): void {\r\n this.advance(-1);\r\n }\r\n\r\n nextSlide(): void {\r\n this.moveSlide(1);\r\n }\r\n\r\n prevSlide(): void {\r\n this.moveSlide(-1);\r\n }\r\n\r\n goTo(i: number): void {\r\n this.move(i - this.index());\r\n }\r\n\r\n /** Close button and article links both end the same way: the item counts as read. */\r\n dismiss(): void {\r\n const item = this.item();\r\n if (!item) {\r\n this.dialogRef.close();\r\n return;\r\n }\r\n this.dialogRef.close({ action: 'dismiss', index: this.index(), item, url: item.actionUrl });\r\n }\r\n\r\n onLinkClick(): void {\r\n if (this.item()?.actionUrl) {\r\n this.dismiss();\r\n }\r\n }\r\n\r\n onTouchStart(event: TouchEvent): void {\r\n this.touchStartX = event.changedTouches[0]?.clientX ?? 0;\r\n }\r\n\r\n onTouchEnd(event: TouchEvent): void {\r\n const endX = event.changedTouches[0]?.clientX ?? 0;\r\n const dx = endX - this.touchStartX;\r\n this.touchStartX = 0;\r\n if (Math.abs(dx) < SWIPE_THRESHOLD) {\r\n return;\r\n }\r\n this.advance(dx < 0 ? 1 : -1);\r\n }\r\n\r\n @HostListener('keydown', ['$event'])\r\n onKeydown(event: KeyboardEvent): void {\r\n if (event.key === 'ArrowRight') {\r\n event.preventDefault();\r\n this.advance(1);\r\n } else if (event.key === 'ArrowLeft') {\r\n event.preventDefault();\r\n this.advance(-1);\r\n }\r\n }\r\n\r\n private advance(steps: number): void {\r\n const target = this.slideIndex() + steps;\r\n if (this.isMultiSlide() && target >= 0 && target < this.slides().length) {\r\n this.slideIndex.set(target);\r\n return;\r\n }\r\n this.move(steps);\r\n }\r\n\r\n private moveSlide(steps: number): void {\r\n const target = this.slideIndex() + steps;\r\n if (target < 0 || target >= this.slides().length) {\r\n return;\r\n }\r\n this.slideIndex.set(target);\r\n }\r\n\r\n private move(steps: number): void {\r\n const target = this.index() + steps;\r\n if (target < 0 || target >= this.total() || target === this.index()) {\r\n return;\r\n }\r\n this.index.set(target);\r\n this.slideIndex.set(0);\r\n }\r\n}\r\n","<div class=\"news-card\" (touchstart)=\"onTouchStart($event)\" (touchend)=\"onTouchEnd($event)\">\r\n @if (item(); as news) {\r\n <div class=\"news-header\">\r\n <i class=\"fa-regular fa-newspaper news-header-icon\" aria-hidden=\"true\"></i>\r\n <h2 class=\"news-header-title\">{{ labels().headerTitle }}</h2>\r\n <button\r\n type=\"button\"\r\n class=\"btn-close news-close\"\r\n [attr.aria-label]=\"labels().close\"\r\n (click)=\"dismiss()\"\r\n ></button>\r\n </div>\r\n\r\n <div class=\"news-hero\">\r\n @if (isMulti()) {\r\n <button\r\n type=\"button\"\r\n class=\"news-nav news-prev\"\r\n [disabled]=\"index() === 0 && slideIndex() === 0\"\r\n [attr.aria-label]=\"labels().prev\"\r\n (click)=\"prev()\"\r\n >\r\n <i class=\"fa fa-chevron-left\" aria-hidden=\"true\"></i>\r\n </button>\r\n <button\r\n type=\"button\"\r\n class=\"news-nav news-next\"\r\n [disabled]=\"index() === total() - 1 && slideIndex() === slides().length - 1\"\r\n [attr.aria-label]=\"labels().next\"\r\n (click)=\"next()\"\r\n >\r\n <i class=\"fa fa-chevron-right\" aria-hidden=\"true\"></i>\r\n </button>\r\n }\r\n\r\n @if (slide()?.image || news.image) {\r\n <a\r\n class=\"news-image-link\"\r\n [attr.href]=\"news.actionUrl || null\"\r\n [attr.target]=\"news.actionUrl ? '_blank' : null\"\r\n [attr.rel]=\"news.actionUrl ? 'noopener noreferrer' : null\"\r\n tabindex=\"-1\"\r\n aria-hidden=\"true\"\r\n (click)=\"onLinkClick()\"\r\n >\r\n <img\r\n class=\"news-image\"\r\n [src]=\"slide()?.image || news.image\"\r\n [alt]=\"slide()?.imageAlt || slide()?.title || news.imageAlt || news.title\"\r\n draggable=\"false\"\r\n brokenImageIconFailSafe\r\n (dragstart)=\"$event.preventDefault()\"\r\n (contextmenu)=\"$event.preventDefault()\"\r\n />\r\n </a>\r\n } @else {\r\n <div class=\"news-placeholder\" aria-hidden=\"true\">\r\n <i class=\"fa fa-image\"></i>\r\n </div>\r\n }\r\n\r\n @if (isMultiSlide()) {\r\n <div class=\"news-slide-nav\">\r\n <button\r\n type=\"button\"\r\n class=\"news-slide-btn\"\r\n [disabled]=\"slideIndex() === 0\"\r\n [attr.aria-label]=\"labels().prevImage\"\r\n (click)=\"prevSlide()\"\r\n >\r\n <i class=\"fa fa-chevron-left\" aria-hidden=\"true\"></i>\r\n </button>\r\n <span class=\"news-slide-count\" aria-hidden=\"true\">{{ slideIndex() + 1 }} / {{ slides().length }}</span>\r\n <button\r\n type=\"button\"\r\n class=\"news-slide-btn\"\r\n [disabled]=\"slideIndex() === slides().length - 1\"\r\n [attr.aria-label]=\"labels().nextImage\"\r\n (click)=\"nextSlide()\"\r\n >\r\n <i class=\"fa fa-chevron-right\" aria-hidden=\"true\"></i>\r\n </button>\r\n </div>\r\n }\r\n\r\n @if (isMulti()) {\r\n <div class=\"news-indicator\">\r\n <div class=\"news-dots\">\r\n @for (dot of data.items; track dot.id; let i = $index) {\r\n <button\r\n type=\"button\"\r\n class=\"news-dot\"\r\n [class.active]=\"i === index()\"\r\n [attr.aria-label]=\"labels().goToNews + ' #' + (i + 1)\"\r\n [attr.aria-current]=\"i === index() ? 'true' : null\"\r\n (click)=\"goTo(i)\"\r\n ></button>\r\n }\r\n </div>\r\n <span class=\"news-count\">{{ index() + 1 }} / {{ total() }}</span>\r\n </div>\r\n }\r\n </div>\r\n\r\n <div class=\"news-body\">\r\n <a\r\n class=\"news-link\"\r\n [attr.href]=\"news.actionUrl || null\"\r\n [attr.target]=\"news.actionUrl ? '_blank' : null\"\r\n [attr.rel]=\"news.actionUrl ? 'noopener noreferrer' : null\"\r\n (click)=\"onLinkClick()\"\r\n >\r\n <h5 class=\"news-title\" [id]=\"titleId\">{{ slide()?.title || news.title }}</h5>\r\n </a>\r\n <p class=\"news-text\" [innerHTML]=\"(slide()?.body || news.body) | newlines\"></p>\r\n </div>\r\n\r\n <p class=\"visually-hidden\" aria-live=\"polite\">\r\n {{ index() + 1 }} / {{ total() }}@if (isMultiSlide()) { · {{ slideIndex() + 1 }} / {{ slides().length }} } —\r\n {{ slide()?.title || news.title }}\r\n </p>\r\n }\r\n</div>\r\n","import { inject, Injectable } from '@angular/core';\r\nimport { MatDialog, MatDialogRef } from '@angular/material/dialog';\r\nimport { ModalNewsComponent } from './news-modal.component';\r\nimport { NewsModalData, NewsModalItem, NewsModalLabels, NewsModalResult } from './news-modal.types';\r\n\r\nexport interface NewsModalOpenOptions {\r\n startIndex?: number;\r\n labels?: NewsModalLabels;\r\n}\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class NewsModalService {\r\n private readonly dialog = inject(MatDialog);\r\n\r\n open(\r\n items: NewsModalItem[],\r\n options?: NewsModalOpenOptions,\r\n ): MatDialogRef<ModalNewsComponent, NewsModalResult | undefined> {\r\n return this.dialog.open<ModalNewsComponent, NewsModalData, NewsModalResult | undefined>(ModalNewsComponent, {\r\n data: { items, startIndex: options?.startIndex ?? 0, labels: options?.labels },\r\n panelClass: 'news-modal-panel',\r\n backdropClass: 'news-modal-backdrop',\r\n width: '475px',\r\n maxWidth: '95vw',\r\n autoFocus: 'dialog',\r\n restoreFocus: true,\r\n ariaLabel: options?.labels?.dialogLabel ?? 'New feature announcement',\r\n });\r\n }\r\n}\r\n","/**\r\n * Case-insensitive, per-segment prefix match between a router URL and a target route.\r\n * Query string and fragment are ignored. An empty target matches everything.\r\n */\r\nexport function matchesNewsTarget(currentUrl: string, target: string): boolean {\r\n const segments = (value: string): string[] =>\r\n value\r\n .split(/[?#]/, 1)[0]\r\n .toLowerCase()\r\n .split('/')\r\n .filter((part) => part.length > 0);\r\n\r\n const current = segments(currentUrl);\r\n const wanted = segments(target);\r\n if (!wanted.length) return true;\r\n if (wanted.length > current.length) return false;\r\n return wanted.every((segment, index) => current[index] === segment);\r\n}\r\n","import { Injectable, inject, signal } from '@angular/core';\r\nimport { NavigationEnd, Router } from '@angular/router';\r\nimport { filter } from 'rxjs';\r\nimport { NewsModalItem, NewsModalLabels } from './news-modal.types';\r\nimport { NewsModalService } from './news-modal.service';\r\nimport { matchesNewsTarget } from './news-modal-route.util';\r\n\r\nexport interface NewsModalAutoOpenOptions {\r\n startIndex?: number;\r\n labels?: NewsModalLabels;\r\n onOpen?: (items: NewsModalItem[]) => void;\r\n}\r\n\r\n/**\r\n * Opens the news modal automatically when the current route matches the `targets` of any\r\n * supplied item. Persisting \"already seen\" state is deliberately NOT handled here — the host\r\n * owns that, and can pass a getter that returns only items the user has not seen yet.\r\n */\r\n@Injectable({ providedIn: 'root' })\r\nexport class NewsModalRouterService {\r\n private readonly router = inject(Router);\r\n private readonly newsModal = inject(NewsModalService);\r\n private readonly dialogOpen = signal(false);\r\n\r\n /**\r\n * Evaluates the items against the current URL immediately and again on every navigation.\r\n * Returns a teardown function that stops watching; it does not close an open dialog.\r\n */\r\n autoOpen(\r\n source: NewsModalItem[] | (() => NewsModalItem[]),\r\n options?: NewsModalAutoOpenOptions,\r\n ): () => void {\r\n const resolve = (): NewsModalItem[] => (typeof source === 'function' ? source() : source);\r\n\r\n const evaluate = (): void => {\r\n if (this.dialogOpen()) return;\r\n const url = this.router.url;\r\n const matched = resolve().filter(\r\n (item) => !item.targets?.length || item.targets.some((target) => matchesNewsTarget(url, target)),\r\n );\r\n if (!matched.length) return;\r\n this.dialogOpen.set(true);\r\n options?.onOpen?.(matched);\r\n this.newsModal.open(matched, options).afterClosed().subscribe(() => this.dialogOpen.set(false));\r\n };\r\n\r\n evaluate();\r\n const subscription = this.router.events.pipe(filter((event) => event instanceof NavigationEnd)).subscribe(evaluate);\r\n\r\n return () => subscription.unsubscribe();\r\n }\r\n}\r\n"],"mappings":";;;;;;;AAOA,MAAM,iBAA4C;CAChD,aAAa;CACb,OAAO;CACP,MAAM;CACN,MAAM;CACN,WAAW;CACX,WAAW;CACX,OAAO;CACP,UAAU;CACV,aAAa;AACd;AAED,MAAM,kBAAkB;AAUxB,IAAa,qBAAb,MAAa,mBAAkB;CAR/B,cAAA;EASW,KAAA,OAAO,OAAsB,eAAe;EACpC,KAAA,YAAY,OAA0D,YAAY;EAE1F,KAAA,SAAS,gBAA2C;GAAE,GAAG;GAAgB,GAAG,KAAK,KAAK;EAAM,IAAI,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;EAChG,KAAA,QAAQ,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,KAAK,OAAO;GACxB,MAAM,UAAU,QAAO,CAAE,CAAC,QACvB,SAAS,CAAC,KAAK,SAAS,UAAU,KAAK,QAAQ,MAAM,WAAW,kBAAkB,KAAK,MAAM,CAAC,CAAC;GAElG,IAAI,CAAC,QAAQ,QAAQ;GACrB,KAAK,WAAW,IAAI,IAAI;GACxB,SAAS,SAAS,OAAO;GACzB,KAAK,UAAU,KAAK,SAAS,OAAO,CAAC,CAAC,YAAW,CAAE,CAAC,gBAAgB,KAAK,WAAW,IAAI,KAAK,CAAC;EAChG;EAEA,SAAQ;EACR,MAAM,eAAe,KAAK,OAAO,OAAO,KAAK,QAAQ,UAAU,iBAAiB,aAAa,CAAC,CAAC,CAAC,UAAU,QAAQ;EAElH,aAAa,aAAa,YAAW;CACvC;CA/BW;EAAA,KAAA,OAAA,GAAA,mBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAsB,MAAA,CAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAAtB;EAAA,KAAA,QAAA,GAAA,sBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAsB,YADT;EAAM,CAAA;CAAA;;AACnB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAsB,YAAA,CAAA;EADlC,MAAA;EAAW,MAAA,CAAA,EAAE,YAAY,OAAM,CAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dealpos-npm-ng-dealpos-library-dexie-data-access.mjs","names":["uuidv4"],"sources":["../../../projects/dealpos-npm/ng-dealpos-library/dexie-data-access/src/db/pos-database.base.ts","../../../projects/dealpos-npm/ng-dealpos-library/dexie-data-access/src/di/pos-database.token.ts","../../../projects/dealpos-npm/ng-dealpos-library/dexie-data-access/src/repositories/order-queue.repository.ts","../../../projects/dealpos-npm/ng-dealpos-library/dexie-data-access/src/repositories/orders.repository.ts","../../../projects/dealpos-npm/ng-dealpos-library/dexie-data-access/src/search/fuzzy-search.ts","../../../projects/dealpos-npm/ng-dealpos-library/dexie-data-access/src/repositories/keyed-table.repository.ts","../../../projects/dealpos-npm/ng-dealpos-library/dexie-data-access/src/repositories/products.repository.ts","../../../projects/dealpos-npm/ng-dealpos-library/dexie-data-access/src/repositories/key-value.repository.ts","../../../projects/dealpos-npm/ng-dealpos-library/dexie-data-access/src/repositories/settings.repository.ts","../../../projects/dealpos-npm/ng-dealpos-library/dexie-data-access/src/di/provide-pos-dexie-data-access.ts"],"sourcesContent":["import Dexie, { type EntityTable, type IndexableType } from 'dexie';\r\nimport type {\r\n\tSalesOrderDataModel,\r\n\tVariantByIDHttpResponse,\r\n} from '@dealpos-npm/ng-dealpos-library/sell';\r\nimport type { OrderRecord, SettingRecord } from './records.model';\r\n\r\nexport abstract class PosDatabaseBase<\r\n\tTProduct extends { ID: IndexableType } = VariantByIDHttpResponse,\r\n\tTOrder = SalesOrderDataModel,\r\n> extends Dexie {\r\n\tproducts!: EntityTable<TProduct, 'ID'>;\r\n\torders!: EntityTable<OrderRecord<TOrder>, 'id', OrderRecord<TOrder>>;\r\n\tsettings!: EntityTable<SettingRecord, 'key'>;\r\n\r\n\tprotected constructor(name: string) {\r\n\t\tsuper(name);\r\n\t\tthis.version(1).stores({\r\n\t\t\tproducts: 'ID, Code',\r\n\t\t\torders: '++id, status',\r\n\t\t\tsettings: 'key',\r\n\t\t});\r\n\r\n\t\t// v2 replaces the auto-increment `orders` primary key with a UUID string.\r\n\t\t// The schema change already drops the object store, so this explicit clear\r\n\t\t// only states the intent: old numeric-key order rows are not migrated.\r\n\t\tthis.version(2)\r\n\t\t\t.stores({\r\n\t\t\t\torders: 'id, status',\r\n\t\t\t})\r\n\t\t\t.upgrade((tx) => tx.table('orders').clear());\r\n\t}\r\n}\r\n","import { InjectionToken } from '@angular/core';\r\nimport type { PosDatabaseBase } from '../db/pos-database.base';\r\n\r\nexport const POS_DATABASE = new InjectionToken<PosDatabaseBase>('POS_DATABASE');\r\n","import { liveQuery, type EntityTable } from 'dexie';\r\nimport { Observable } from 'rxjs';\r\nimport { v4 as uuidv4 } from 'uuid';\r\nimport type { SalesOrderDataModel } from '@dealpos-npm/ng-dealpos-library/sell';\r\nimport type { OrderRecord, OrderStatus } from '../db/records.model';\r\n\r\n/** Orders table keyed by a UUID string primary key (`id`). */\r\nexport type OrderTable<TOrder> = EntityTable<\r\n\tOrderRecord<TOrder>,\r\n\t'id',\r\n\tOrderRecord<TOrder>\r\n>;\r\n\r\nexport type StoredEntity<T> = T & { id?: string };\r\n\r\nexport class OrderQueueRepository<TOrder = SalesOrderDataModel> {\r\n\tconstructor(\r\n\t\tprotected readonly table: OrderTable<TOrder>,\r\n\t\tprotected readonly options: {\r\n\t\t\torderIdExtractor: (order: TOrder) => string | number;\r\n\t\t},\r\n\t) {}\r\n\r\n\tprivate toPayload(order: TOrder): TOrder {\r\n\t\tconst payload = JSON.parse(JSON.stringify(order)) as TOrder & { id?: string };\r\n\t\tdelete payload.id;\r\n\t\treturn payload as TOrder;\r\n\t}\r\n\r\n\tprivate toStored(record: OrderRecord<TOrder>): StoredEntity<TOrder> {\r\n\t\treturn Object.assign(record.order as object, { id: record.id }) as StoredEntity<TOrder>;\r\n\t}\r\n\r\n\t/**\r\n\t * Queues an order. Pass `id` to make the save idempotent — re-saving the same\r\n\t * order overwrites the existing record instead of creating a duplicate.\r\n\t * When omitted, a fresh UUID is generated.\r\n\t */\r\n\tsaveUnsent(order: TOrder, id?: string): Promise<string> {\r\n\t\treturn this.table.add({\r\n\t\t\tid: id ?? uuidv4(),\r\n\t\t\tstatus: 'unsent',\r\n\t\t\torder: this.toPayload(order),\r\n\t\t}) as Promise<string>;\r\n\t}\r\n\r\n\tobserveByStatus(status: OrderStatus): Observable<Array<StoredEntity<TOrder>>> {\r\n\t\treturn new Observable((subscriber) => {\r\n\t\t\tconst live = liveQuery(() => this.table.where('status').equals(status).toArray());\r\n\t\t\tconst subscription = live.subscribe({\r\n\t\t\t\tnext: (records) => subscriber.next(records.map((record) => this.toStored(record))),\r\n\t\t\t\terror: (error) => subscriber.error(error),\r\n\t\t\t});\r\n\t\t\treturn () => subscription.unsubscribe();\r\n\t\t});\r\n\t}\r\n\r\n\tasync listByStatus(status: OrderStatus): Promise<Array<StoredEntity<TOrder>>> {\r\n\t\tconst records = await this.table.where('status').equals(status).toArray();\r\n\t\treturn records.map((record) => this.toStored(record));\r\n\t}\r\n\r\n\tlistUnsent(): Promise<Array<StoredEntity<TOrder>>> {\r\n\t\treturn this.listByStatus('unsent');\r\n\t}\r\n\r\n\tlistFailed(): Promise<Array<StoredEntity<TOrder>>> {\r\n\t\treturn this.listByStatus('failed');\r\n\t}\r\n\r\n\tlistSuccess(): Promise<Array<StoredEntity<TOrder>>> {\r\n\t\treturn this.listByStatus('success');\r\n\t}\r\n\r\n\tasync findUnsentByOrderId(\r\n\t\torderId: string | number,\r\n\t): Promise<StoredEntity<TOrder> | undefined> {\r\n\t\tconst records = await this.table.where('status').equals('unsent').toArray();\r\n\t\tconst match = records.find(\r\n\t\t\t(record) => this.options.orderIdExtractor(record.order) == orderId,\r\n\t\t);\r\n\t\treturn match ? this.toStored(match) : undefined;\r\n\t}\r\n\r\n\tasync remove(id: string): Promise<void> {\r\n\t\tawait this.table.delete(id);\r\n\t}\r\n\r\n\tmarkFailed(id: string, order: TOrder): Promise<string> {\r\n\t\treturn this.table.put({\r\n\t\t\tid,\r\n\t\t\tstatus: 'failed',\r\n\t\t\torder: this.toPayload(order),\r\n\t\t}) as Promise<string>;\r\n\t}\r\n\r\n\tmarkSuccess(id: string, order: TOrder): Promise<string> {\r\n\t\treturn this.table.put({\r\n\t\t\tid,\r\n\t\t\tstatus: 'success',\r\n\t\t\torder: this.toPayload(order),\r\n\t\t}) as Promise<string>;\r\n\t}\r\n\r\n\tclearFailed(): Promise<number> {\r\n\t\treturn this.table.where('status').equals('failed').delete();\r\n\t}\r\n\r\n\tclearSuccess(): Promise<number> {\r\n\t\treturn this.table.where('status').equals('success').delete();\r\n\t}\r\n}\r\n","import { Inject, Injectable } from '@angular/core';\r\nimport type { SalesOrderDataModel } from '@dealpos-npm/ng-dealpos-library/sell';\r\nimport { OrderQueueRepository } from './order-queue.repository';\r\nimport { POS_DATABASE } from '../di/pos-database.token';\r\nimport type { PosDatabaseBase } from '../db/pos-database.base';\r\n\r\nexport type StoredOrder = SalesOrderDataModel & { id?: string };\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class OrdersRepository extends OrderQueueRepository<SalesOrderDataModel> {\r\n\tconstructor(@Inject(POS_DATABASE) db: PosDatabaseBase) {\r\n\t\tsuper(db.orders, { orderIdExtractor: (o) => o.Order?.ID });\r\n\t}\r\n}\r\n","import Fuse from 'fuse.js';\r\nimport type {\r\n\tFuseOptionKey,\r\n\tFuseResultMatch,\r\n\tFuseSearchOptions,\r\n\tFuseSortFunction,\r\n\tFuseSortFunctionArg,\r\n\tIFuseOptions,\r\n} from 'fuse.js';\r\n\r\nexport interface FuzzyMatch<T> {\r\n\titem: T;\r\n\tscore: number;\r\n\tmatches: readonly FuseResultMatch[];\r\n}\r\n\r\nconst UNRANKED = Number.MAX_SAFE_INTEGER;\r\n\r\nfunction escapeContainsToken(token: string): string {\r\n\treturn token.replace(/\"/g, '').replace(/\\|/g, '\\\\|');\r\n}\r\n\r\n/**\r\n * Builds an extended-search pattern that matches by **substring** (\"contains\")\r\n * instead of the default fuzzy bitap algorithm. Each word becomes one `include`\r\n * matcher (`'word`) and words are AND-ed because extended search treats\r\n * space-separated tokens as a conjunction.\r\n */\r\nexport function toContainsPattern(query: string): string {\r\n\treturn query\r\n\t\t.trim()\r\n\t\t.split(/\\s+/)\r\n\t\t.map(escapeContainsToken)\r\n\t\t.filter((token) => token.length > 0)\r\n\t\t.map((token) => `'${token}`)\r\n\t\t.join(' ');\r\n}\r\n\r\nfunction firstMatchIndex(arg: FuseSortFunctionArg): number {\r\n\tlet first = UNRANKED;\r\n\tfor (const match of arg.matches ?? []) {\r\n\t\tconst start = match.indices?.[0]?.[0];\r\n\t\tif (typeof start === 'number' && start < first) {\r\n\t\t\tfirst = start;\r\n\t\t}\r\n\t}\r\n\treturn first;\r\n}\r\n\r\nfunction lastMatchIndex(arg: FuseSortFunctionArg): number {\r\n\tlet last = -1;\r\n\tfor (const match of arg.matches ?? []) {\r\n\t\tfor (const range of match.indices ?? []) {\r\n\t\t\tif (range[0] > last) {\r\n\t\t\t\tlast = range[0];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn last;\r\n}\r\n\r\nfunction shortestMatchedValue(arg: FuseSortFunctionArg): number {\r\n\tlet shortest = UNRANKED;\r\n\tfor (const match of arg.matches ?? []) {\r\n\t\tshortest = Math.min(shortest, match.value?.length ?? 0);\r\n\t}\r\n\treturn shortest;\r\n}\r\n\r\n/**\r\n * Substring matches all score 0 in extended search, so relevance is restored\r\n * here: earliest hit first (prefix beats mid-word), then tightest span, then\r\n * shortest matched field, then catalog order as the stable tie-break.\r\n */\r\nexport const matchPositionSortFn: FuseSortFunction = (a, b) => {\r\n\tconst first = firstMatchIndex(a) - firstMatchIndex(b);\r\n\tif (first !== 0) {\r\n\t\treturn first;\r\n\t}\r\n\tconst last = lastMatchIndex(a) - lastMatchIndex(b);\r\n\tif (last !== 0) {\r\n\t\treturn last;\r\n\t}\r\n\tconst length = shortestMatchedValue(a) - shortestMatchedValue(b);\r\n\tif (length !== 0) {\r\n\t\treturn length;\r\n\t}\r\n\treturn a.idx - b.idx;\r\n};\r\n\r\nexport function createFuzzyIndex<T>(\r\n\titems: ReadonlyArray<T>,\r\n\tkeys: ReadonlyArray<FuseOptionKey<T>>,\r\n\toptions?: IFuseOptions<T>,\r\n): Fuse<T> {\r\n\treturn new Fuse([...items], {\r\n\t\tincludeScore: true,\r\n\t\tincludeMatches: true,\r\n\t\tfindAllMatches: true,\r\n\t\tuseExtendedSearch: true,\r\n\t\tsortFn: matchPositionSortFn,\r\n\t\tkeys: [...keys],\r\n\t\t...(options ?? {}),\r\n\t});\r\n}\r\n\r\nexport function fuzzySearch<T>(\r\n\tindex: Fuse<T>,\r\n\tquery: string,\r\n\topts?: FuseSearchOptions,\r\n): Array<FuzzyMatch<T>> {\r\n\tconst pattern =\r\n\t\tindex.options.useExtendedSearch !== false ? toContainsPattern(query) : query.trim();\r\n\tif (!pattern) {\r\n\t\treturn [];\r\n\t}\r\n\treturn index\r\n\t\t.search(pattern, opts)\r\n\t\t.map((r) => ({\r\n\t\t\titem: r.item,\r\n\t\t\tscore: r.score ?? 0,\r\n\t\t\tmatches: r.matches ?? [],\r\n\t\t}));\r\n}\r\n","import type { EntityTable, IDType } from 'dexie';\r\nimport type { default as Fuse, FuseOptionKey, FuseSearchOptions, IFuseOptions } from 'fuse.js';\r\nimport { createFuzzyIndex, fuzzySearch } from '../search/fuzzy-search';\r\nimport type { FuzzyMatch } from '../search/fuzzy-search';\r\n\r\nexport class KeyedTableRepository<T, K extends keyof T & string> {\r\n\tprivate fuzzyIndex: Fuse<T> | undefined;\r\n\r\n\tconstructor(\r\n\t\tprotected readonly table: EntityTable<T, K>,\r\n\t\tprotected readonly options?: {\r\n\t\t\tcodeIndex?: string;\r\n\t\t\tfuzzyKeys?: ReadonlyArray<FuseOptionKey<T>>;\r\n\t\t\tfuzzyOptions?: IFuseOptions<T>;\r\n\t\t},\r\n\t) {}\r\n\r\n\tgetAll(): Promise<T[]> {\r\n\t\treturn this.table.toArray();\r\n\t}\r\n\r\n\tgetById(id: T[K]): Promise<T | undefined> {\r\n\t\treturn this.table.get(id as IDType<T, K>);\r\n\t}\r\n\r\n\tgetByIndex(index: string, value: unknown): Promise<T | undefined> {\r\n\t\treturn this.table.where(index).equals(value as never).first();\r\n\t}\r\n\r\n\tasync searchFuzzy(\r\n\t\tquery: string,\r\n\t\topts?: FuseSearchOptions,\r\n\t): Promise<Array<FuzzyMatch<T>>> {\r\n\t\tconst keys = this.options?.fuzzyKeys;\r\n\t\tif (!keys || keys.length === 0 || !query) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\t\tif (!this.fuzzyIndex) {\r\n\t\t\tthis.fuzzyIndex = createFuzzyIndex(\r\n\t\t\t\tawait this.getAll(),\r\n\t\t\t\tkeys,\r\n\t\t\t\tthis.options?.fuzzyOptions,\r\n\t\t\t);\r\n\t\t}\r\n\t\treturn fuzzySearch(this.fuzzyIndex, query, opts);\r\n\t}\r\n\r\n\treplaceAll(items: T[]): Promise<void> {\r\n\t\tthis.fuzzyIndex = undefined;\r\n\t\treturn this.table.db.transaction('rw', this.table, async () => {\r\n\t\t\tawait this.table.clear();\r\n\t\t\tif (items.length > 0) {\r\n\t\t\t\tawait this.table.bulkAdd(items);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tclear(): Promise<void> {\r\n\t\tthis.fuzzyIndex = undefined;\r\n\t\treturn this.table.clear();\r\n\t}\r\n\r\n\tcount(): Promise<number> {\r\n\t\treturn this.table.count();\r\n\t}\r\n\r\n\t/**\r\n\t * Estimasi ukuran penyimpanan (byte) untuk seluruh baris di tabel ini.\r\n\t * Dihitung dari panjang serialisasi JSON (UTF-8) tiap record, jadi ini\r\n\t * hanya perkiraan — belum termasuk overhead structured-clone dan index Dexie.\r\n\t * Membaca per baris via `table.each()` agar tidak menahan seluruh tabel di memori.\r\n\t */\r\n\tasync estimateSize(): Promise<number> {\r\n\t\tconst encoder = new TextEncoder();\r\n\t\tlet total = 0;\r\n\t\tawait this.table.each((item) => {\r\n\t\t\ttotal += encoder.encode(JSON.stringify(item)).length;\r\n\t\t});\r\n\t\treturn total;\r\n\t}\r\n}\r\n","import { Inject, Injectable } from '@angular/core';\r\nimport type { VariantByIDHttpResponse } from '@dealpos-npm/ng-dealpos-library/sell';\r\nimport { KeyedTableRepository } from './keyed-table.repository';\r\nimport { POS_DATABASE } from '../di/pos-database.token';\r\nimport type { PosDatabaseBase } from '../db/pos-database.base';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class ProductsRepository extends KeyedTableRepository<VariantByIDHttpResponse, 'ID'> {\r\n\tconstructor(@Inject(POS_DATABASE) db: PosDatabaseBase) {\r\n\t\tsuper(db.products, { codeIndex: 'Code', fuzzyKeys: ['Name', 'Code'] });\r\n\t}\r\n}\r\n","import type { EntityTable } from 'dexie';\r\nimport type { SettingKey, SettingRecord } from '../db/records.model';\r\n\r\nexport class KeyValueRepository<TMap extends object> {\r\n\tconstructor(protected readonly table: EntityTable<SettingRecord, 'key'>) {}\r\n\r\n\tasync get<K extends keyof TMap & string>(key: K): Promise<TMap[K] | undefined> {\r\n\t\tconst record = await this.table.get(key as SettingKey);\r\n\t\treturn record?.value as TMap[K] | undefined;\r\n\t}\r\n\r\n\tput<K extends keyof TMap & string>(key: K, value: TMap[K]): Promise<SettingKey> {\r\n\t\treturn this.table.put({ key: key as SettingKey, value });\r\n\t}\r\n}\r\n","import { Inject, Injectable } from '@angular/core';\r\nimport { KeyValueRepository } from './key-value.repository';\r\nimport { POS_DATABASE } from '../di/pos-database.token';\r\nimport type { PosDatabaseBase } from '../db/pos-database.base';\r\nimport type { SettingKey, SyncTimeValue } from '../db/records.model';\r\n\r\nexport interface CanonicalSettingsMap {\r\n\tsyncTime: SyncTimeValue;\r\n\tLoadPOSAPI: unknown;\r\n\tactiveRegister: unknown;\r\n}\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class SettingsRepository extends KeyValueRepository<CanonicalSettingsMap> {\r\n\tconstructor(@Inject(POS_DATABASE) db: PosDatabaseBase) {\r\n\t\tsuper(db.settings);\r\n\t}\r\n\r\n\tgetSyncTime(): Promise<SyncTimeValue | undefined> {\r\n\t\treturn this.get('syncTime');\r\n\t}\r\n\r\n\t/**\r\n\t * Catat waktu sync terakhir, opsional beserta durasi proses sync (ms).\r\n\t * `durationMs` bersifat opsional agar pemanggil lama tetap kompatibel.\r\n\t * Saat tidak diisi, field tidak disimpan sehingga record tetap `{ time }`.\r\n\t */\r\n\tputSyncTime(time: string, durationMs?: number): Promise<SettingKey> {\r\n\t\tconst value: SyncTimeValue =\r\n\t\t\tdurationMs === undefined ? { time } : { time, durationMs };\r\n\t\treturn this.put('syncTime', value);\r\n\t}\r\n\r\n\tgetLoadPOSAPI<T = unknown>(): Promise<T | undefined> {\r\n\t\treturn this.get('LoadPOSAPI') as Promise<T | undefined>;\r\n\t}\r\n\r\n\tputLoadPOSAPI<T>(value: T): Promise<SettingKey> {\r\n\t\treturn this.put('LoadPOSAPI', value);\r\n\t}\r\n\r\n\tasync getActiveRegister<T = unknown>(): Promise<T | null> {\r\n\t\treturn ((await this.get('activeRegister')) as T | undefined) ?? null;\r\n\t}\r\n\r\n\tputActiveRegister<T>(value: T): Promise<SettingKey> {\r\n\t\treturn this.put('activeRegister', value);\r\n\t}\r\n}\r\n","import { makeEnvironmentProviders } from '@angular/core';\r\nimport type { EnvironmentProviders, Type } from '@angular/core';\r\nimport { POS_DATABASE } from './pos-database.token';\r\nimport type { PosDatabaseBase } from '../db/pos-database.base';\r\nimport { OrdersRepository } from '../repositories/orders.repository';\r\nimport { ProductsRepository } from '../repositories/products.repository';\r\nimport { SettingsRepository } from '../repositories/settings.repository';\r\n\r\nexport function provideDexieDataAccess(database: Type<PosDatabaseBase>): EnvironmentProviders {\r\n\treturn makeEnvironmentProviders([\r\n\t\tdatabase,\r\n\t\t{ provide: POS_DATABASE, useExisting: database },\r\n\t\tOrdersRepository,\r\n\t\tProductsRepository,\r\n\t\tSettingsRepository,\r\n\t]);\r\n}\r\n"],"mappings":";;;;;;AAOA,IAAsB,kBAAtB,cAGU,MAAK;CAKd,YAAsB,MAAY;EACjC,MAAM,IAAI;EACV,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO;GACtB,UAAU;GACV,QAAQ;GACR,UAAU;EACV,CAAA;EAKD,KAAK,QAAQ,CAAC,CAAC,CACb,OAAO,EACP,QAAQ,aACR,CAAA,CAAC,CACD,SAAS,OAAO,GAAG,MAAM,QAAQ,CAAC,CAAC,MAAK,CAAE;CAC7C;AACA;AC7BD,MAAa,e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4"],"sources":["../../../projects/dealpos-npm/ng-dealpos-library/dexie-data-access/src/db/pos-database.base.ts","../../../projects/dealpos-npm/ng-dealpos-library/dexie-data-access/src/di/pos-database.token.ts","../../../projects/dealpos-npm/ng-dealpos-library/dexie-data-access/src/repositories/order-queue.repository.ts","../../../projects/dealpos-npm/ng-dealpos-library/dexie-data-access/src/repositories/orders.repository.ts","../../../projects/dealpos-npm/ng-dealpos-library/dexie-data-access/src/search/fuzzy-search.ts","../../../projects/dealpos-npm/ng-dealpos-library/dexie-data-access/src/repositories/keyed-table.repository.ts","../../../projects/dealpos-npm/ng-dealpos-library/dexie-data-access/src/repositories/products.repository.ts","../../../projects/dealpos-npm/ng-dealpos-library/dexie-data-access/src/repositories/key-value.repository.ts","../../../projects/dealpos-npm/ng-dealpos-library/dexie-data-access/src/repositories/settings.repository.ts","../../../projects/dealpos-npm/ng-dealpos-library/dexie-data-access/src/di/provide-pos-dexie-data-access.ts"],"sourcesContent":["import Dexie, { type EntityTable, type IndexableType } from 'dexie';\r\nimport type {\r\n\tSalesOrderDataModel,\r\n\tVariantByIDHttpResponse,\r\n} from '@dealpos-npm/ng-dealpos-library/sell/models';\r\nimport type { OrderRecord, SettingRecord } from './records.model';\r\n\r\nexport abstract class PosDatabaseBase<\r\n\tTProduct extends { ID: IndexableType } = VariantByIDHttpResponse,\r\n\tTOrder = SalesOrderDataModel,\r\n> extends Dexie {\r\n\tproducts!: EntityTable<TProduct, 'ID'>;\r\n\torders!: EntityTable<OrderRecord<TOrder>, 'id', OrderRecord<TOrder>>;\r\n\tsettings!: EntityTable<SettingRecord, 'key'>;\r\n\r\n\tprotected constructor(name: string) {\r\n\t\tsuper(name);\r\n\t\tthis.version(1).stores({\r\n\t\t\tproducts: 'ID, Code',\r\n\t\t\torders: '++id, status',\r\n\t\t\tsettings: 'key',\r\n\t\t});\r\n\r\n\t\t// v2 replaces the auto-increment `orders` primary key with a UUID string.\r\n\t\t// The schema change already drops the object store, so this explicit clear\r\n\t\t// only states the intent: old numeric-key order rows are not migrated.\r\n\t\tthis.version(2)\r\n\t\t\t.stores({\r\n\t\t\t\torders: 'id, status',\r\n\t\t\t})\r\n\t\t\t.upgrade((tx) => tx.table('orders').clear());\r\n\t}\r\n}\r\n","import { InjectionToken } from '@angular/core';\r\nimport type { PosDatabaseBase } from '../db/pos-database.base';\r\n\r\nexport const POS_DATABASE = new InjectionToken<PosDatabaseBase>('POS_DATABASE');\r\n","import { liveQuery, type EntityTable } from 'dexie';\r\nimport { Observable } from 'rxjs';\r\nimport { v4 as uuidv4 } from 'uuid';\r\nimport type { SalesOrderDataModel } from '@dealpos-npm/ng-dealpos-library/sell/models';\r\nimport type { OrderRecord, OrderStatus } from '../db/records.model';\r\n\r\n/** Orders table keyed by a UUID string primary key (`id`). */\r\nexport type OrderTable<TOrder> = EntityTable<\r\n\tOrderRecord<TOrder>,\r\n\t'id',\r\n\tOrderRecord<TOrder>\r\n>;\r\n\r\nexport type StoredEntity<T> = T & { id?: string };\r\n\r\nexport class OrderQueueRepository<TOrder = SalesOrderDataModel> {\r\n\tconstructor(\r\n\t\tprotected readonly table: OrderTable<TOrder>,\r\n\t\tprotected readonly options: {\r\n\t\t\torderIdExtractor: (order: TOrder) => string | number;\r\n\t\t},\r\n\t) {}\r\n\r\n\tprivate toPayload(order: TOrder): TOrder {\r\n\t\tconst payload = JSON.parse(JSON.stringify(order)) as TOrder & { id?: string };\r\n\t\tdelete payload.id;\r\n\t\treturn payload as TOrder;\r\n\t}\r\n\r\n\tprivate toStored(record: OrderRecord<TOrder>): StoredEntity<TOrder> {\r\n\t\treturn Object.assign(record.order as object, { id: record.id }) as StoredEntity<TOrder>;\r\n\t}\r\n\r\n\t/**\r\n\t * Queues an order. Pass `id` to make the save idempotent — re-saving the same\r\n\t * order overwrites the existing record instead of creating a duplicate.\r\n\t * When omitted, a fresh UUID is generated.\r\n\t */\r\n\tsaveUnsent(order: TOrder, id?: string): Promise<string> {\r\n\t\treturn this.table.add({\r\n\t\t\tid: id ?? uuidv4(),\r\n\t\t\tstatus: 'unsent',\r\n\t\t\torder: this.toPayload(order),\r\n\t\t}) as Promise<string>;\r\n\t}\r\n\r\n\tobserveByStatus(status: OrderStatus): Observable<Array<StoredEntity<TOrder>>> {\r\n\t\treturn new Observable((subscriber) => {\r\n\t\t\tconst live = liveQuery(() => this.table.where('status').equals(status).toArray());\r\n\t\t\tconst subscription = live.subscribe({\r\n\t\t\t\tnext: (records) => subscriber.next(records.map((record) => this.toStored(record))),\r\n\t\t\t\terror: (error) => subscriber.error(error),\r\n\t\t\t});\r\n\t\t\treturn () => subscription.unsubscribe();\r\n\t\t});\r\n\t}\r\n\r\n\tasync listByStatus(status: OrderStatus): Promise<Array<StoredEntity<TOrder>>> {\r\n\t\tconst records = await this.table.where('status').equals(status).toArray();\r\n\t\treturn records.map((record) => this.toStored(record));\r\n\t}\r\n\r\n\tlistUnsent(): Promise<Array<StoredEntity<TOrder>>> {\r\n\t\treturn this.listByStatus('unsent');\r\n\t}\r\n\r\n\tlistFailed(): Promise<Array<StoredEntity<TOrder>>> {\r\n\t\treturn this.listByStatus('failed');\r\n\t}\r\n\r\n\tlistSuccess(): Promise<Array<StoredEntity<TOrder>>> {\r\n\t\treturn this.listByStatus('success');\r\n\t}\r\n\r\n\tasync findUnsentByOrderId(\r\n\t\torderId: string | number,\r\n\t): Promise<StoredEntity<TOrder> | undefined> {\r\n\t\tconst records = await this.table.where('status').equals('unsent').toArray();\r\n\t\tconst match = records.find(\r\n\t\t\t(record) => this.options.orderIdExtractor(record.order) == orderId,\r\n\t\t);\r\n\t\treturn match ? this.toStored(match) : undefined;\r\n\t}\r\n\r\n\tasync remove(id: string): Promise<void> {\r\n\t\tawait this.table.delete(id);\r\n\t}\r\n\r\n\tmarkFailed(id: string, order: TOrder): Promise<string> {\r\n\t\treturn this.table.put({\r\n\t\t\tid,\r\n\t\t\tstatus: 'failed',\r\n\t\t\torder: this.toPayload(order),\r\n\t\t}) as Promise<string>;\r\n\t}\r\n\r\n\tmarkSuccess(id: string, order: TOrder): Promise<string> {\r\n\t\treturn this.table.put({\r\n\t\t\tid,\r\n\t\t\tstatus: 'success',\r\n\t\t\torder: this.toPayload(order),\r\n\t\t}) as Promise<string>;\r\n\t}\r\n\r\n\tclearFailed(): Promise<number> {\r\n\t\treturn this.table.where('status').equals('failed').delete();\r\n\t}\r\n\r\n\tclearSuccess(): Promise<number> {\r\n\t\treturn this.table.where('status').equals('success').delete();\r\n\t}\r\n}\r\n","import { Inject, Injectable } from '@angular/core';\r\nimport type { SalesOrderDataModel } from '@dealpos-npm/ng-dealpos-library/sell/models';\r\nimport { OrderQueueRepository } from './order-queue.repository';\r\nimport { POS_DATABASE } from '../di/pos-database.token';\r\nimport type { PosDatabaseBase } from '../db/pos-database.base';\r\n\r\nexport type StoredOrder = SalesOrderDataModel & { id?: string };\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class OrdersRepository extends OrderQueueRepository<SalesOrderDataModel> {\r\n\tconstructor(@Inject(POS_DATABASE) db: PosDatabaseBase) {\r\n\t\tsuper(db.orders, { orderIdExtractor: (o) => o.Order?.ID });\r\n\t}\r\n}\r\n","import Fuse from 'fuse.js';\r\nimport type {\r\n\tFuseOptionKey,\r\n\tFuseResultMatch,\r\n\tFuseSearchOptions,\r\n\tFuseSortFunction,\r\n\tFuseSortFunctionArg,\r\n\tIFuseOptions,\r\n} from 'fuse.js';\r\n\r\nexport interface FuzzyMatch<T> {\r\n\titem: T;\r\n\tscore: number;\r\n\tmatches: readonly FuseResultMatch[];\r\n}\r\n\r\nconst UNRANKED = Number.MAX_SAFE_INTEGER;\r\n\r\nfunction escapeContainsToken(token: string): string {\r\n\treturn token.replace(/\"/g, '').replace(/\\|/g, '\\\\|');\r\n}\r\n\r\n/**\r\n * Builds an extended-search pattern that matches by **substring** (\"contains\")\r\n * instead of the default fuzzy bitap algorithm. Each word becomes one `include`\r\n * matcher (`'word`) and words are AND-ed because extended search treats\r\n * space-separated tokens as a conjunction.\r\n */\r\nexport function toContainsPattern(query: string): string {\r\n\treturn query\r\n\t\t.trim()\r\n\t\t.split(/\\s+/)\r\n\t\t.map(escapeContainsToken)\r\n\t\t.filter((token) => token.length > 0)\r\n\t\t.map((token) => `'${token}`)\r\n\t\t.join(' ');\r\n}\r\n\r\nfunction firstMatchIndex(arg: FuseSortFunctionArg): number {\r\n\tlet first = UNRANKED;\r\n\tfor (const match of arg.matches ?? []) {\r\n\t\tconst start = match.indices?.[0]?.[0];\r\n\t\tif (typeof start === 'number' && start < first) {\r\n\t\t\tfirst = start;\r\n\t\t}\r\n\t}\r\n\treturn first;\r\n}\r\n\r\nfunction lastMatchIndex(arg: FuseSortFunctionArg): number {\r\n\tlet last = -1;\r\n\tfor (const match of arg.matches ?? []) {\r\n\t\tfor (const range of match.indices ?? []) {\r\n\t\t\tif (range[0] > last) {\r\n\t\t\t\tlast = range[0];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn last;\r\n}\r\n\r\nfunction shortestMatchedValue(arg: FuseSortFunctionArg): number {\r\n\tlet shortest = UNRANKED;\r\n\tfor (const match of arg.matches ?? []) {\r\n\t\tshortest = Math.min(shortest, match.value?.length ?? 0);\r\n\t}\r\n\treturn shortest;\r\n}\r\n\r\n/**\r\n * Substring matches all score 0 in extended search, so relevance is restored\r\n * here: earliest hit first (prefix beats mid-word), then tightest span, then\r\n * shortest matched field, then catalog order as the stable tie-break.\r\n */\r\nexport const matchPositionSortFn: FuseSortFunction = (a, b) => {\r\n\tconst first = firstMatchIndex(a) - firstMatchIndex(b);\r\n\tif (first !== 0) {\r\n\t\treturn first;\r\n\t}\r\n\tconst last = lastMatchIndex(a) - lastMatchIndex(b);\r\n\tif (last !== 0) {\r\n\t\treturn last;\r\n\t}\r\n\tconst length = shortestMatchedValue(a) - shortestMatchedValue(b);\r\n\tif (length !== 0) {\r\n\t\treturn length;\r\n\t}\r\n\treturn a.idx - b.idx;\r\n};\r\n\r\nexport function createFuzzyIndex<T>(\r\n\titems: ReadonlyArray<T>,\r\n\tkeys: ReadonlyArray<FuseOptionKey<T>>,\r\n\toptions?: IFuseOptions<T>,\r\n): Fuse<T> {\r\n\treturn new Fuse([...items], {\r\n\t\tincludeScore: true,\r\n\t\tincludeMatches: true,\r\n\t\tfindAllMatches: true,\r\n\t\tuseExtendedSearch: true,\r\n\t\tsortFn: matchPositionSortFn,\r\n\t\tkeys: [...keys],\r\n\t\t...(options ?? {}),\r\n\t});\r\n}\r\n\r\nexport function fuzzySearch<T>(\r\n\tindex: Fuse<T>,\r\n\tquery: string,\r\n\topts?: FuseSearchOptions,\r\n): Array<FuzzyMatch<T>> {\r\n\tconst pattern =\r\n\t\tindex.options.useExtendedSearch !== false ? toContainsPattern(query) : query.trim();\r\n\tif (!pattern) {\r\n\t\treturn [];\r\n\t}\r\n\treturn index\r\n\t\t.search(pattern, opts)\r\n\t\t.map((r) => ({\r\n\t\t\titem: r.item,\r\n\t\t\tscore: r.score ?? 0,\r\n\t\t\tmatches: r.matches ?? [],\r\n\t\t}));\r\n}\r\n","import type { EntityTable, IDType } from 'dexie';\r\nimport type { default as Fuse, FuseOptionKey, FuseSearchOptions, IFuseOptions } from 'fuse.js';\r\nimport { createFuzzyIndex, fuzzySearch } from '../search/fuzzy-search';\r\nimport type { FuzzyMatch } from '../search/fuzzy-search';\r\n\r\nexport class KeyedTableRepository<T, K extends keyof T & string> {\r\n\tprivate fuzzyIndex: Fuse<T> | undefined;\r\n\r\n\tconstructor(\r\n\t\tprotected readonly table: EntityTable<T, K>,\r\n\t\tprotected readonly options?: {\r\n\t\t\tcodeIndex?: string;\r\n\t\t\tfuzzyKeys?: ReadonlyArray<FuseOptionKey<T>>;\r\n\t\t\tfuzzyOptions?: IFuseOptions<T>;\r\n\t\t},\r\n\t) {}\r\n\r\n\tgetAll(): Promise<T[]> {\r\n\t\treturn this.table.toArray();\r\n\t}\r\n\r\n\tgetById(id: T[K]): Promise<T | undefined> {\r\n\t\treturn this.table.get(id as IDType<T, K>);\r\n\t}\r\n\r\n\tgetByIndex(index: string, value: unknown): Promise<T | undefined> {\r\n\t\treturn this.table.where(index).equals(value as never).first();\r\n\t}\r\n\r\n\tasync searchFuzzy(\r\n\t\tquery: string,\r\n\t\topts?: FuseSearchOptions,\r\n\t): Promise<Array<FuzzyMatch<T>>> {\r\n\t\tconst keys = this.options?.fuzzyKeys;\r\n\t\tif (!keys || keys.length === 0 || !query) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\t\tif (!this.fuzzyIndex) {\r\n\t\t\tthis.fuzzyIndex = createFuzzyIndex(\r\n\t\t\t\tawait this.getAll(),\r\n\t\t\t\tkeys,\r\n\t\t\t\tthis.options?.fuzzyOptions,\r\n\t\t\t);\r\n\t\t}\r\n\t\treturn fuzzySearch(this.fuzzyIndex, query, opts);\r\n\t}\r\n\r\n\treplaceAll(items: T[]): Promise<void> {\r\n\t\tthis.fuzzyIndex = undefined;\r\n\t\treturn this.table.db.transaction('rw', this.table, async () => {\r\n\t\t\tawait this.table.clear();\r\n\t\t\tif (items.length > 0) {\r\n\t\t\t\tawait this.table.bulkAdd(items);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tclear(): Promise<void> {\r\n\t\tthis.fuzzyIndex = undefined;\r\n\t\treturn this.table.clear();\r\n\t}\r\n\r\n\tcount(): Promise<number> {\r\n\t\treturn this.table.count();\r\n\t}\r\n\r\n\t/**\r\n\t * Estimasi ukuran penyimpanan (byte) untuk seluruh baris di tabel ini.\r\n\t * Dihitung dari panjang serialisasi JSON (UTF-8) tiap record, jadi ini\r\n\t * hanya perkiraan — belum termasuk overhead structured-clone dan index Dexie.\r\n\t * Membaca per baris via `table.each()` agar tidak menahan seluruh tabel di memori.\r\n\t */\r\n\tasync estimateSize(): Promise<number> {\r\n\t\tconst encoder = new TextEncoder();\r\n\t\tlet total = 0;\r\n\t\tawait this.table.each((item) => {\r\n\t\t\ttotal += encoder.encode(JSON.stringify(item)).length;\r\n\t\t});\r\n\t\treturn total;\r\n\t}\r\n}\r\n","import { Inject, Injectable } from '@angular/core';\r\nimport type { VariantByIDHttpResponse } from '@dealpos-npm/ng-dealpos-library/sell/models';\r\nimport { KeyedTableRepository } from './keyed-table.repository';\r\nimport { POS_DATABASE } from '../di/pos-database.token';\r\nimport type { PosDatabaseBase } from '../db/pos-database.base';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class ProductsRepository extends KeyedTableRepository<VariantByIDHttpResponse, 'ID'> {\r\n\tconstructor(@Inject(POS_DATABASE) db: PosDatabaseBase) {\r\n\t\tsuper(db.products, { codeIndex: 'Code', fuzzyKeys: ['Name', 'Code'] });\r\n\t}\r\n}\r\n","import type { EntityTable } from 'dexie';\r\nimport type { SettingKey, SettingRecord } from '../db/records.model';\r\n\r\nexport class KeyValueRepository<TMap extends object> {\r\n\tconstructor(protected readonly table: EntityTable<SettingRecord, 'key'>) {}\r\n\r\n\tasync get<K extends keyof TMap & string>(key: K): Promise<TMap[K] | undefined> {\r\n\t\tconst record = await this.table.get(key as SettingKey);\r\n\t\treturn record?.value as TMap[K] | undefined;\r\n\t}\r\n\r\n\tput<K extends keyof TMap & string>(key: K, value: TMap[K]): Promise<SettingKey> {\r\n\t\treturn this.table.put({ key: key as SettingKey, value });\r\n\t}\r\n}\r\n","import { Inject, Injectable } from '@angular/core';\r\nimport { KeyValueRepository } from './key-value.repository';\r\nimport { POS_DATABASE } from '../di/pos-database.token';\r\nimport type { PosDatabaseBase } from '../db/pos-database.base';\r\nimport type { SettingKey, SyncTimeValue } from '../db/records.model';\r\n\r\nexport interface CanonicalSettingsMap {\r\n\tsyncTime: SyncTimeValue;\r\n\tLoadPOSAPI: unknown;\r\n\tactiveRegister: unknown;\r\n}\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class SettingsRepository extends KeyValueRepository<CanonicalSettingsMap> {\r\n\tconstructor(@Inject(POS_DATABASE) db: PosDatabaseBase) {\r\n\t\tsuper(db.settings);\r\n\t}\r\n\r\n\tgetSyncTime(): Promise<SyncTimeValue | undefined> {\r\n\t\treturn this.get('syncTime');\r\n\t}\r\n\r\n\t/**\r\n\t * Catat waktu sync terakhir, opsional beserta durasi proses sync (ms).\r\n\t * `durationMs` bersifat opsional agar pemanggil lama tetap kompatibel.\r\n\t * Saat tidak diisi, field tidak disimpan sehingga record tetap `{ time }`.\r\n\t */\r\n\tputSyncTime(time: string, durationMs?: number): Promise<SettingKey> {\r\n\t\tconst value: SyncTimeValue =\r\n\t\t\tdurationMs === undefined ? { time } : { time, durationMs };\r\n\t\treturn this.put('syncTime', value);\r\n\t}\r\n\r\n\tgetLoadPOSAPI<T = unknown>(): Promise<T | undefined> {\r\n\t\treturn this.get('LoadPOSAPI') as Promise<T | undefined>;\r\n\t}\r\n\r\n\tputLoadPOSAPI<T>(value: T): Promise<SettingKey> {\r\n\t\treturn this.put('LoadPOSAPI', value);\r\n\t}\r\n\r\n\tasync getActiveRegister<T = unknown>(): Promise<T | null> {\r\n\t\treturn ((await this.get('activeRegister')) as T | undefined) ?? null;\r\n\t}\r\n\r\n\tputActiveRegister<T>(value: T): Promise<SettingKey> {\r\n\t\treturn this.put('activeRegister', value);\r\n\t}\r\n}\r\n","import { makeEnvironmentProviders } from '@angular/core';\r\nimport type { EnvironmentProviders, Type } from '@angular/core';\r\nimport { POS_DATABASE } from './pos-database.token';\r\nimport type { PosDatabaseBase } from '../db/pos-database.base';\r\nimport { OrdersRepository } from '../repositories/orders.repository';\r\nimport { ProductsRepository } from '../repositories/products.repository';\r\nimport { SettingsRepository } from '../repositories/settings.repository';\r\n\r\nexport function provideDexieDataAccess(database: Type<PosDatabaseBase>): EnvironmentProviders {\r\n\treturn makeEnvironmentProviders([\r\n\t\tdatabase,\r\n\t\t{ provide: POS_DATABASE, useExisting: database },\r\n\t\tOrdersRepository,\r\n\t\tProductsRepository,\r\n\t\tSettingsRepository,\r\n\t]);\r\n}\r\n"],"mappings":";;;;;;AAOA,IAAsB,kBAAtB,cAGU,MAAK;CAKd,YAAsB,MAAY;EACjC,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