@sd-angular/core 19.0.0-beta.8 → 19.0.0-beta.81
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/README.md +686 -33
- package/assets/scss/ckeditor5.scss +61 -4
- package/assets/scss/core/bootstrap.scss +17 -0
- package/assets/scss/core/form.scss +32 -6
- package/assets/scss/core/grid.scss +40 -0
- package/assets/scss/sd-core.scss +5 -0
- package/assets/scss/themes/material-theme.scss +82 -40
- package/components/anchor-v2/src/components/anchor-item-v2/anchor-item-v2.component.d.ts +5 -5
- package/components/anchor-v2/src/components/anchor-v2/anchor-v2.component.d.ts +12 -18
- package/components/anchor-v2/src/components/anchor-vertical-v2/anchor-vertical-list-v2.component.d.ts +9 -10
- package/components/anchor-v2/src/models/sd-anchor-v2.model.d.ts +3 -3
- package/components/avatar/index.d.ts +1 -0
- package/components/avatar/src/avatar.component.d.ts +19 -0
- package/components/badge/src/badge.component.d.ts +77 -19
- package/components/button/src/button.component.d.ts +30 -28
- package/components/chart/index.d.ts +4 -0
- package/components/chart/src/bar-chart.component.d.ts +18 -0
- package/components/chart/src/doughnut-chart.component.d.ts +16 -0
- package/components/chart/src/line-chart.component.d.ts +18 -0
- package/components/chart/src/pie-chart.component.d.ts +16 -0
- package/components/code-editor/index.d.ts +1 -0
- package/components/code-editor/src/code-editor.component.d.ts +25 -0
- package/components/document-builder/index.d.ts +1 -0
- package/components/document-builder/src/document-builder.component.d.ts +13 -42
- package/components/document-builder/src/document-builder.model.d.ts +15 -12
- package/components/document-builder/src/plugins/block-space/block-space.plugin.d.ts +9 -0
- package/components/document-builder/src/plugins/ck-comment/ck-comment.plugin.d.ts +44 -0
- package/components/document-builder/src/plugins/ck-comment/ck-comment.plugin.model.d.ts +57 -0
- package/components/document-builder/src/plugins/heading/heading.plugin.d.ts +1 -0
- package/components/document-builder/src/plugins/highlight-range/highlight-range.plugin.d.ts +4 -0
- package/components/document-builder/src/plugins/image-custom/image-custom.plugin.d.ts +31 -0
- package/components/document-builder/src/plugins/index.d.ts +7 -2
- package/components/document-builder/src/plugins/page-orientation/page-orientation.plugin.d.ts +2 -2
- package/components/document-builder/src/plugins/paste-handler/filters/bookmark.d.ts +14 -0
- package/components/document-builder/src/plugins/paste-handler/filters/br.d.ts +15 -0
- package/components/document-builder/src/plugins/paste-handler/filters/image.d.ts +25 -0
- package/components/document-builder/src/plugins/paste-handler/filters/list.d.ts +29 -0
- package/components/document-builder/src/plugins/paste-handler/filters/parse.d.ts +35 -0
- package/components/document-builder/src/plugins/paste-handler/filters/removeboldwrapper.d.ts +15 -0
- package/components/document-builder/src/plugins/paste-handler/filters/removegooglesheetstag.d.ts +15 -0
- package/components/document-builder/src/plugins/paste-handler/filters/removeinvalidtablewidth.d.ts +15 -0
- package/components/document-builder/src/plugins/paste-handler/filters/removemsattributes.d.ts +15 -0
- package/components/document-builder/src/plugins/paste-handler/filters/removestyleblock.d.ts +15 -0
- package/components/document-builder/src/plugins/paste-handler/filters/removexmlns.d.ts +15 -0
- package/components/document-builder/src/plugins/paste-handler/filters/replacemsfootnotes.d.ts +54 -0
- package/components/document-builder/src/plugins/paste-handler/filters/replacetabswithinprewithspaces.d.ts +24 -0
- package/components/document-builder/src/plugins/paste-handler/filters/space.d.ts +27 -0
- package/components/document-builder/src/plugins/paste-handler/filters/table.d.ts +16 -0
- package/components/document-builder/src/plugins/paste-handler/filters/utils.d.ts +25 -0
- package/components/document-builder/src/plugins/paste-handler/index.d.ts +35 -0
- package/components/document-builder/src/plugins/paste-handler/normalizers/googledocsnormalizer.d.ts +31 -0
- package/components/document-builder/src/plugins/paste-handler/normalizers/googlesheetsnormalizer.d.ts +31 -0
- package/components/document-builder/src/plugins/paste-handler/normalizers/mswordnormalizer.d.ts +29 -0
- package/components/document-builder/src/plugins/paste-handler/types.d.ts +30 -0
- package/components/document-builder/src/plugins/table-custom/index.d.ts +34 -0
- package/components/document-builder/src/plugins/variable/variable.plugin.d.ts +39 -0
- package/components/editor/index.d.ts +3 -0
- package/components/editor/src/configurations/editor.configuration.d.ts +12 -0
- package/components/editor/src/configurations/index.d.ts +1 -0
- package/components/editor/src/editor.component.d.ts +42 -0
- package/components/editor/src/models/editor.model.d.ts +8 -0
- package/components/editor/src/models/image-upload.plugin.model.d.ts +20 -0
- package/components/editor/src/models/index.d.ts +2 -0
- package/components/editor/src/plugins/image-upload/image-upload.plugin.d.ts +22 -0
- package/components/editor/src/plugins/image-upload/utils/batch.utils.d.ts +14 -0
- package/components/editor/src/plugins/image-upload/utils/index.d.ts +3 -0
- package/components/editor/src/plugins/image-upload/utils/style.utils.d.ts +2 -0
- package/components/editor/src/plugins/image-upload/utils/validate.utils.d.ts +3 -0
- package/components/index.d.ts +6 -0
- package/components/mini-editor/index.d.ts +2 -0
- package/components/mini-editor/src/mini-editor.component.d.ts +91 -0
- package/components/mini-editor/src/mini-editor.model.d.ts +44 -0
- package/components/modal/index.d.ts +1 -1
- package/components/modal/src/modal.component.d.ts +26 -0
- package/components/section/index.d.ts +1 -0
- package/components/section/src/section-item/section-item.component.d.ts +7 -0
- package/components/section/src/section.component.d.ts +11 -11
- package/components/side-drawer/src/side-drawer.component.d.ts +11 -24
- package/components/tab-router/src/components/tab-router-item/tab-router-item.component.d.ts +4 -1
- package/components/tab-router/src/components/tab-router-outlet/tab-router-outlet.component.d.ts +3 -15
- package/components/table/index.d.ts +2 -0
- package/components/table/src/components/column-filter/column-filter.component.d.ts +3 -3
- package/components/table/src/components/column-title/column-title.component.d.ts +10 -0
- package/components/table/src/components/desktop-cell/desktop-cell.component.d.ts +18 -11
- package/components/table/src/components/desktop-cell/view/view.component.d.ts +24 -0
- package/components/table/src/components/external-filter/external-filter.component.d.ts +1 -1
- package/components/table/src/components/index.d.ts +1 -0
- package/components/table/src/components/selector-action/action-filter.pipe.d.ts +11 -10
- package/components/table/src/components/selector-action/selector-action.component.d.ts +5 -3
- package/components/table/src/directives/index.d.ts +4 -0
- package/components/table/src/directives/sd-table-cell-def.directive.d.ts +2 -3
- package/components/table/src/directives/sd-table-column-filter-def.directive.d.ts +8 -0
- package/components/table/src/directives/sd-table-expand-def.directive.d.ts +0 -1
- package/components/table/src/directives/sd-table-filter-def.directive.d.ts +4 -6
- package/components/table/src/directives/sd-table-footer-def.directive.d.ts +2 -3
- package/components/table/src/directives/sd-table-title-def.directive.d.ts +8 -0
- package/components/table/src/directives/sticky-shadow.directive.d.ts +17 -0
- package/components/table/src/models/table-column.model.d.ts +49 -40
- package/components/table/src/models/table-command.model.d.ts +7 -3
- package/components/table/src/models/table-item.model.d.ts +5 -4
- package/components/table/src/models/table-option-config.model.d.ts +3 -0
- package/components/table/src/models/table-option-export.model.d.ts +3 -2
- package/components/table/src/models/table-option-selector.model.d.ts +17 -10
- package/components/table/src/models/table-option.model.d.ts +15 -8
- package/components/table/src/services/index.d.ts +3 -0
- package/components/table/src/services/table-export/table-export.service.d.ts +26 -0
- package/components/table/src/services/table-filter/table-filter.model.d.ts +6 -5
- package/components/table/src/services/table-format/table-format.service.d.ts +16 -0
- package/components/table/src/table.component.d.ts +46 -53
- package/components/upload-file/src/configurations/upload-file.configuration.d.ts +34 -1
- package/components/upload-file/src/services/upload-file.service.d.ts +0 -1
- package/components/upload-file/src/upload-file.component.d.ts +52 -54
- package/components/view/index.d.ts +1 -0
- package/components/view/src/view.component.d.ts +16 -0
- package/components/workflow/src/models/form-generic-component.model.d.ts +5 -4
- package/components/workflow/src/models/form-generic-expression.model.d.ts +1 -0
- package/components/workflow/src/models/index.d.ts +1 -0
- package/components/workflow/src/pipes/html.pipe.d.ts +4 -4
- package/directives/index.d.ts +2 -0
- package/directives/src/sd-href.directive.d.ts +9 -0
- package/directives/src/sd-tooltip.directive.d.ts +26 -0
- package/fesm2022/sd-angular-core-components-anchor-v2.mjs +79 -154
- package/fesm2022/sd-angular-core-components-anchor-v2.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-avatar.mjs +103 -0
- package/fesm2022/sd-angular-core-components-avatar.mjs.map +1 -0
- package/fesm2022/sd-angular-core-components-badge.mjs +101 -91
- package/fesm2022/sd-angular-core-components-badge.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-button.mjs +70 -96
- package/fesm2022/sd-angular-core-components-button.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-chart.mjs +290 -0
- package/fesm2022/sd-angular-core-components-chart.mjs.map +1 -0
- package/fesm2022/sd-angular-core-components-code-editor.mjs +127 -0
- package/fesm2022/sd-angular-core-components-code-editor.mjs.map +1 -0
- package/fesm2022/sd-angular-core-components-document-builder.mjs +4005 -611
- package/fesm2022/sd-angular-core-components-document-builder.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-editor.mjs +933 -0
- package/fesm2022/sd-angular-core-components-editor.mjs.map +1 -0
- package/fesm2022/sd-angular-core-components-history.mjs +1 -1
- package/fesm2022/sd-angular-core-components-history.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-import-excel.mjs +1 -1
- package/fesm2022/sd-angular-core-components-import-excel.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-mini-editor.mjs +332 -0
- package/fesm2022/sd-angular-core-components-mini-editor.mjs.map +1 -0
- package/fesm2022/sd-angular-core-components-modal.mjs +63 -92
- package/fesm2022/sd-angular-core-components-modal.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-preview.mjs +1 -1
- package/fesm2022/sd-angular-core-components-preview.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-quick-action.mjs +2 -2
- package/fesm2022/sd-angular-core-components-quick-action.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-section.mjs +41 -43
- package/fesm2022/sd-angular-core-components-section.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-side-drawer.mjs +78 -84
- package/fesm2022/sd-angular-core-components-side-drawer.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-tab-router.mjs +151 -241
- package/fesm2022/sd-angular-core-components-tab-router.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-table.mjs +1394 -1254
- package/fesm2022/sd-angular-core-components-table.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-upload-file.mjs +390 -443
- package/fesm2022/sd-angular-core-components-upload-file.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components-view.mjs +45 -0
- package/fesm2022/sd-angular-core-components-view.mjs.map +1 -0
- package/fesm2022/sd-angular-core-components-workflow.mjs +165 -168
- package/fesm2022/sd-angular-core-components-workflow.mjs.map +1 -1
- package/fesm2022/sd-angular-core-components.mjs +6 -0
- package/fesm2022/sd-angular-core-components.mjs.map +1 -1
- package/fesm2022/sd-angular-core-directives.mjs +286 -27
- package/fesm2022/sd-angular-core-directives.mjs.map +1 -1
- package/fesm2022/sd-angular-core-forms-autocomplete.mjs +289 -363
- package/fesm2022/sd-angular-core-forms-autocomplete.mjs.map +1 -1
- package/fesm2022/sd-angular-core-forms-chip-calendar.mjs +170 -189
- package/fesm2022/sd-angular-core-forms-chip-calendar.mjs.map +1 -1
- package/fesm2022/sd-angular-core-forms-chip.mjs +184 -194
- package/fesm2022/sd-angular-core-forms-chip.mjs.map +1 -1
- package/fesm2022/sd-angular-core-forms-date-range.mjs +180 -242
- package/fesm2022/sd-angular-core-forms-date-range.mjs.map +1 -1
- package/fesm2022/sd-angular-core-forms-date.mjs +178 -270
- package/fesm2022/sd-angular-core-forms-date.mjs.map +1 -1
- package/fesm2022/sd-angular-core-forms-datetime.mjs +177 -285
- package/fesm2022/sd-angular-core-forms-datetime.mjs.map +1 -1
- package/fesm2022/sd-angular-core-forms-input-number.mjs +210 -337
- package/fesm2022/sd-angular-core-forms-input-number.mjs.map +1 -1
- package/fesm2022/sd-angular-core-forms-input.mjs +169 -286
- package/fesm2022/sd-angular-core-forms-input.mjs.map +1 -1
- package/fesm2022/sd-angular-core-forms-radio.mjs +3 -2
- package/fesm2022/sd-angular-core-forms-radio.mjs.map +1 -1
- package/fesm2022/sd-angular-core-forms-select.mjs +390 -447
- package/fesm2022/sd-angular-core-forms-select.mjs.map +1 -1
- package/fesm2022/sd-angular-core-forms-textarea.mjs +167 -226
- package/fesm2022/sd-angular-core-forms-textarea.mjs.map +1 -1
- package/fesm2022/sd-angular-core-modules-authom.mjs +359 -0
- package/fesm2022/sd-angular-core-modules-authom.mjs.map +1 -0
- package/fesm2022/sd-angular-core-modules-keycloak.mjs +126 -0
- package/fesm2022/sd-angular-core-modules-keycloak.mjs.map +1 -0
- package/fesm2022/sd-angular-core-modules-layout.mjs +709 -456
- package/fesm2022/sd-angular-core-modules-layout.mjs.map +1 -1
- package/fesm2022/sd-angular-core-modules-permission.mjs +160 -74
- package/fesm2022/sd-angular-core-modules-permission.mjs.map +1 -1
- package/fesm2022/sd-angular-core-modules.mjs +2 -1
- package/fesm2022/sd-angular-core-modules.mjs.map +1 -1
- package/fesm2022/sd-angular-core-services-api.mjs +5 -10
- package/fesm2022/sd-angular-core-services-api.mjs.map +1 -1
- package/fesm2022/sd-angular-core-services-confirm.mjs +9 -7
- package/fesm2022/sd-angular-core-services-confirm.mjs.map +1 -1
- package/fesm2022/sd-angular-core-services-docx.mjs +173 -0
- package/fesm2022/sd-angular-core-services-docx.mjs.map +1 -0
- package/fesm2022/sd-angular-core-services-notify.mjs +2 -2
- package/fesm2022/sd-angular-core-services-notify.mjs.map +1 -1
- package/fesm2022/sd-angular-core-services.mjs +1 -0
- package/fesm2022/sd-angular-core-services.mjs.map +1 -1
- package/fesm2022/sd-angular-core-utilities-extensions.mjs +58 -80
- package/fesm2022/sd-angular-core-utilities-extensions.mjs.map +1 -1
- package/fesm2022/sd-angular-core-utilities-models.mjs +15 -1
- package/fesm2022/sd-angular-core-utilities-models.mjs.map +1 -1
- package/fesm2022/sd-angular-core.mjs +0 -1
- package/fesm2022/sd-angular-core.mjs.map +1 -1
- package/forms/autocomplete/src/autocomplete.component.d.ts +55 -55
- package/forms/chip/src/chip.component.d.ts +37 -40
- package/forms/chip-calendar/src/chip-calendar.component.d.ts +37 -38
- package/forms/date/src/date.component.d.ts +48 -46
- package/forms/date-range/src/date-range.component.d.ts +35 -34
- package/forms/datetime/src/datetime.component.d.ts +48 -49
- package/forms/input/src/input.component.d.ts +54 -57
- package/forms/input-number/src/input-number.component.d.ts +53 -54
- package/forms/select/src/select.component.d.ts +67 -64
- package/forms/textarea/src/textarea.component.d.ts +40 -43
- package/modules/authom/authom.configuration.d.ts +17 -0
- package/modules/authom/authom.interceptor.d.ts +3 -0
- package/modules/authom/authom.module.d.ts +16 -0
- package/modules/authom/authom.service.d.ts +32 -0
- package/modules/authom/index.d.ts +35 -0
- package/modules/index.d.ts +2 -1
- package/modules/keycloak/index.d.ts +4 -0
- package/modules/keycloak/keycloak.configuration.d.ts +11 -0
- package/modules/keycloak/keycloak.interceptor.d.ts +2 -0
- package/modules/keycloak/keycloak.module.d.ts +18 -0
- package/modules/keycloak/keycloak.service.d.ts +14 -0
- package/modules/layout/components/index.d.ts +2 -0
- package/modules/layout/components/layout-main/layout-main.component.d.ts +8 -12
- package/modules/layout/components/page/page.component.d.ts +5 -7
- package/modules/layout/components/sidebar-mobile-v1/components/sidebar/sidebar.component.d.ts +35 -0
- package/modules/layout/components/sidebar-mobile-v1/components/user/user.component.d.ts +24 -0
- package/modules/layout/components/sidebar-mobile-v1/main.component.d.ts +21 -0
- package/modules/layout/components/sidebar-v1/components/sidebar/sidebar.component.d.ts +22 -29
- package/modules/layout/components/sidebar-v1/components/user/user.component.d.ts +11 -17
- package/modules/layout/components/sidebar-v1/main.component.d.ts +14 -14
- package/modules/layout/configurations/layout.configuration.d.ts +46 -3
- package/modules/layout/modules/forbidden/pages/root/root.component.d.ts +3 -8
- package/modules/layout/modules/home/components/home-page/home-page.component.d.ts +2 -5
- package/modules/layout/modules/not-found/pages/root/root.component.d.ts +3 -8
- package/modules/layout/pipes/high-light-search.pipe.d.ts +1 -1
- package/modules/layout/services/index.d.ts +1 -0
- package/modules/layout/services/layout.service.d.ts +10 -0
- package/modules/layout/services/menu/menu.model.d.ts +4 -1
- package/modules/layout/services/storage/storage.service.d.ts +0 -3
- package/modules/permission/src/configurations/permission.configuration.d.ts +56 -2
- package/modules/permission/src/directives/permission.directive.d.ts +5 -8
- package/modules/permission/src/guards/permission.guard.d.ts +2 -1
- package/modules/permission/src/services/permission.service.d.ts +6 -9
- package/package.json +107 -79
- package/public-api.d.ts +0 -1
- package/sd-angular-core-19.0.0-beta.81.tgz +0 -0
- package/services/api/src/api.model.d.ts +6 -1
- package/services/confirm/src/lib/confirm.service.d.ts +5 -0
- package/services/docx/index.d.ts +1 -0
- package/services/docx/src/lib/docx.model.d.ts +9 -0
- package/services/docx/src/lib/docx.service.d.ts +13 -0
- package/services/docx/src/public-api.d.ts +2 -0
- package/services/index.d.ts +1 -0
- package/services/notify/index.d.ts +1 -0
- package/services/notify/src/notify.model.d.ts +1 -1
- package/services/notify/src/notify.service.d.ts +5 -5
- package/utilities/extensions/src/string.extension.d.ts +3 -0
- package/utilities/extensions/src/utility.extension.d.ts +1 -0
- package/utilities/models/index.d.ts +3 -0
- package/utilities/models/src/filter.model.d.ts +17 -4
- package/utilities/models/src/icon.model.d.ts +2 -0
- package/utilities/models/src/nested-key-of.model.d.ts +5 -0
- package/utilities/models/src/order.model.d.ts +2 -1
- package/utilities/models/src/paging.model.d.ts +2 -1
- package/utilities/models/src/pattern.model.d.ts +1 -1
- package/utilities/models/src/unwrap-signal.model.d.ts +6 -0
- package/components/document-builder/src/plugins/comment/comment.plugin.d.ts +0 -4
- package/components/document-builder/src/plugins/table-fit/table-fit.plugin.d.ts +0 -4
- package/components/modal/src/modal/modal.component.d.ts +0 -31
- package/components/table/src/components/desktop-cell-view/desktop-cell-view.component.d.ts +0 -14
- package/fesm2022/sd-angular-core-guards-permission.mjs +0 -155
- package/fesm2022/sd-angular-core-guards-permission.mjs.map +0 -1
- package/fesm2022/sd-angular-core-guards.mjs +0 -6
- package/fesm2022/sd-angular-core-guards.mjs.map +0 -1
- package/fesm2022/sd-angular-core-modules-oidc.mjs +0 -127
- package/fesm2022/sd-angular-core-modules-oidc.mjs.map +0 -1
- package/guards/index.d.ts +0 -1
- package/guards/permission/index.d.ts +0 -4
- package/guards/permission/src/configurations/index.d.ts +0 -1
- package/guards/permission/src/configurations/permission.configuration.d.ts +0 -8
- package/guards/permission/src/directives/index.d.ts +0 -1
- package/guards/permission/src/directives/permission.directive.d.ts +0 -12
- package/guards/permission/src/guards/index.d.ts +0 -1
- package/guards/permission/src/guards/permission.guard.d.ts +0 -13
- package/guards/permission/src/services/index.d.ts +0 -1
- package/guards/permission/src/services/permission.service.d.ts +0 -15
- package/modules/oidc/dynamic-sts.loader.d.ts +0 -11
- package/modules/oidc/index.d.ts +0 -2
- package/modules/oidc/oidc.configuration.d.ts +0 -11
- package/modules/oidc/oidc.module.d.ts +0 -14
- package/sd-angular-core-19.0.0-beta.8.tgz +0 -0
|
@@ -1,222 +1,147 @@
|
|
|
1
|
-
import * as i1 from '@angular/common';
|
|
1
|
+
import * as i1$1 from '@angular/common';
|
|
2
2
|
import { CommonModule } from '@angular/common';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import {
|
|
4
|
+
import { input, inject, ElementRef, effect, Component, output, ChangeDetectionStrategy, viewChild, contentChildren, booleanAttribute, signal, afterNextRender } from '@angular/core';
|
|
5
5
|
import { v4 } from 'uuid';
|
|
6
|
-
import * as i2 from '@angular/material/icon';
|
|
7
|
-
import { MatIconModule } from '@angular/material/icon';
|
|
8
6
|
import { Subject, Subscription, debounceTime, fromEvent, auditTime, map, filter, take } from 'rxjs';
|
|
7
|
+
import * as i1 from '@angular/material/icon';
|
|
8
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
9
9
|
|
|
10
10
|
class SdAnchorItemV2 {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
icon;
|
|
11
|
+
title = input.required();
|
|
12
|
+
icon = input();
|
|
14
13
|
id = v4();
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
elementRef = inject(ElementRef);
|
|
15
|
+
constructor() {
|
|
16
|
+
effect(() => {
|
|
17
|
+
if (this.title()) {
|
|
18
|
+
this.elementRef.nativeElement.removeAttribute('title');
|
|
19
|
+
}
|
|
20
|
+
});
|
|
17
21
|
}
|
|
18
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdAnchorItemV2, deps: [
|
|
19
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
22
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdAnchorItemV2, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
23
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.17", type: SdAnchorItemV2, isStandalone: true, selector: "sd-anchor-item-v2", inputs: { title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: true, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<section>\r\n <ng-content></ng-content>\r\n</section>\r\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }] });
|
|
20
24
|
}
|
|
21
25
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdAnchorItemV2, decorators: [{
|
|
22
26
|
type: Component,
|
|
23
27
|
args: [{ selector: 'sd-anchor-item-v2', imports: [CommonModule], standalone: true, template: "<section>\r\n <ng-content></ng-content>\r\n</section>\r\n" }]
|
|
24
|
-
}], ctorParameters: () => [
|
|
25
|
-
type: Input
|
|
26
|
-
}], icon: [{
|
|
27
|
-
type: Input
|
|
28
|
-
}] } });
|
|
28
|
+
}], ctorParameters: () => [] });
|
|
29
29
|
|
|
30
30
|
class SdAnchorVerticalListV2 {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
sdClickSection = new EventEmitter();
|
|
31
|
+
sections = input.required();
|
|
32
|
+
activeSectionId = input('');
|
|
33
|
+
ellipsis = input(false);
|
|
34
|
+
sidebarWidth = input('');
|
|
35
|
+
sdClickSection = output();
|
|
37
36
|
#delay = 200;
|
|
38
37
|
#clickSectionSubject = new Subject();
|
|
39
38
|
#subscription = new Subscription();
|
|
40
|
-
|
|
41
|
-
this.#subscription.add(this.#clickSectionSubject
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
constructor() {
|
|
40
|
+
this.#subscription.add(this.#clickSectionSubject
|
|
41
|
+
.pipe(debounceTime(this.#delay))
|
|
42
|
+
.subscribe((id) => this.sdClickSection.emit(id)));
|
|
44
43
|
}
|
|
45
|
-
onClickSection = (
|
|
46
|
-
this.#clickSectionSubject.next(
|
|
44
|
+
onClickSection = (id) => {
|
|
45
|
+
this.#clickSectionSubject.next(id);
|
|
47
46
|
};
|
|
48
47
|
ngOnDestroy() {
|
|
49
|
-
this.#subscription
|
|
48
|
+
this.#subscription.unsubscribe();
|
|
50
49
|
}
|
|
51
50
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdAnchorVerticalListV2, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
52
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.17", type: SdAnchorVerticalListV2, isStandalone: true, selector: "sd-anchor-vertical-list-v2", inputs: { sections: "sections", activeSectionId: "activeSectionId", ellipsis: "ellipsis", sidebarWidth: "sidebarWidth" }, outputs: { sdClickSection: "sdClickSection" }, ngImport: i0, template: "<div class=\"c-anchor-list\" [style.width]=\"sidebarWidth\">\
|
|
51
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.17", type: SdAnchorVerticalListV2, isStandalone: true, selector: "sd-anchor-vertical-list-v2", inputs: { sections: { classPropertyName: "sections", publicName: "sections", isSignal: true, isRequired: true, transformFunction: null }, activeSectionId: { classPropertyName: "activeSectionId", publicName: "activeSectionId", isSignal: true, isRequired: false, transformFunction: null }, ellipsis: { classPropertyName: "ellipsis", publicName: "ellipsis", isSignal: true, isRequired: false, transformFunction: null }, sidebarWidth: { classPropertyName: "sidebarWidth", publicName: "sidebarWidth", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { sdClickSection: "sdClickSection" }, ngImport: i0, template: "<div class=\"c-anchor-list\" [style.width]=\"sidebarWidth()\">\n @for (section of sections(); track section.id) {\n <div\n class=\"c-anchor-list-item\"\n [class.active]=\"section.id === activeSectionId()\"\n (click)=\"onClickSection(section.id)\"\n (keydown.enter)=\"onClickSection(section.id)\"\n tabindex=\"0\">\n @if (section.icon()) {\n <mat-icon class=\"c-anchor-list-item-icon\">{{ section.icon() }}</mat-icon>\n }\n <div class=\"c-anchor-list-item-text\" [class.ellipsis]=\"ellipsis()\">\n {{ section.title() }}\n </div>\n </div>\n }\n</div>\n", styles: [".text-primary{color:var(--sd-primary)!important}.bg-primary{background:var(--sd-primary)!important}.border-primary{border-color:var(--sd-primary)!important}.text-primary-light{color:var(--sd-primary-light)!important}.bg-primary-light{background:var(--sd-primary-light)!important}.border-primary-light{border-color:var(--sd-primary-light)!important}.text-primary-dark{color:var(--sd-primary-dark)!important}.bg-primary-dark{background:var(--sd-primary-dark)!important}.border-primary-dark{border-color:var(--sd-primary-dark)!important}.text-info{color:var(--sd-info)!important}.bg-info{background:var(--sd-info)!important}.border-info{border-color:var(--sd-info)!important}.text-info-light{color:var(--sd-info-light)!important}.bg-info-light{background:var(--sd-info-light)!important}.border-info-light{border-color:var(--sd-info-light)!important}.text-info-dark{color:var(--sd-info-dark)!important}.bg-info-dark{background:var(--sd-info-dark)!important}.border-info-dark{border-color:var(--sd-info-dark)!important}.text-success{color:var(--sd-success)!important}.bg-success{background:var(--sd-success)!important}.border-success{border-color:var(--sd-success)!important}.text-success-light{color:var(--sd-success-light)!important}.bg-success-light{background:var(--sd-success-light)!important}.border-success-light{border-color:var(--sd-success-light)!important}.text-success-dark{color:var(--sd-success-dark)!important}.bg-success-dark{background:var(--sd-success-dark)!important}.border-success-dark{border-color:var(--sd-success-dark)!important}.text-warning{color:var(--sd-warning)!important}.bg-warning{background:var(--sd-warning)!important}.border-warning{border-color:var(--sd-warning)!important}.text-warning-light{color:var(--sd-warning-light)!important}.bg-warning-light{background:var(--sd-warning-light)!important}.border-warning-light{border-color:var(--sd-warning-light)!important}.text-warning-dark{color:var(--sd-warning-dark)!important}.bg-warning-dark{background:var(--sd-warning-dark)!important}.border-warning-dark{border-color:var(--sd-warning-dark)!important}.text-error{color:var(--sd-error)!important}.bg-error{background:var(--sd-error)!important}.border-error{border-color:var(--sd-error)!important}.text-error-light{color:var(--sd-error-light)!important}.bg-error-light{background:var(--sd-error-light)!important}.border-error-light{border-color:var(--sd-error-light)!important}.text-error-dark{color:var(--sd-error-dark)!important}.bg-error-dark{background:var(--sd-error-dark)!important}.border-error-dark{border-color:var(--sd-error-dark)!important}.text-secondary{color:var(--sd-secondary)!important}.bg-secondary{background:var(--sd-secondary)!important}.border-secondary{border-color:var(--sd-secondary)!important}.text-secondary-light{color:var(--sd-secondary-light)!important}.bg-secondary-light{background:var(--sd-secondary-light)!important}.border-secondary-light{border-color:var(--sd-secondary-light)!important}.text-secondary-dark{color:var(--sd-secondary-dark)!important}.bg-secondary-dark{background:var(--sd-secondary-dark)!important}.border-secondary-dark{border-color:var(--sd-secondary-dark)!important}.text-light{color:var(--sd-light)!important}.bg-light{background:var(--sd-light)!important}.border-light{border-color:var(--sd-light)!important}.text-dark{color:var(--sd-dark)!important}.bg-dark{background:var(--sd-dark)!important}.border-dark{border-color:var(--sd-dark)!important}.text-black500{color:var(--sd-black500)!important}.bg-black500{background:var(--sd-black500)!important}.border-black500{border-color:var(--sd-black500)!important}.text-black400{color:var(--sd-black400)!important}.bg-black400{background:var(--sd-black400)!important}.border-black400{border-color:var(--sd-black400)!important}.text-black300{color:var(--sd-black300)!important}.bg-black300{background:var(--sd-black300)!important}.border-black300{border-color:var(--sd-black300)!important}.text-black200{color:var(--sd-black200)!important}.bg-black200{background:var(--sd-black200)!important}.border-black200{border-color:var(--sd-black200)!important}.text-black100{color:var(--sd-black100)!important}.bg-black100{background:var(--sd-black100)!important}.border-black100{border-color:var(--sd-black100)!important}.text-white{color:#fff!important}.bg-white{background:#fff!important}.border-white{border-color:#fff!important}.text-black{color:#000!important}.bg-black{background:#000!important}.border-black{border-color:#000!important}.c-anchor-list{height:100%;display:flex;flex-direction:column}.c-anchor-list .c-anchor-list-item{border-left:2px solid var(--sd-secondary-light);color:var(--sd-black500);padding:.5rem 1.5rem;cursor:pointer;display:flex;align-items:center;gap:.5rem}.c-anchor-list .c-anchor-list-item .c-anchor-list-item-text{user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.c-anchor-list .c-anchor-list-item .c-anchor-list-item-text.ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.c-anchor-list .c-anchor-list-item.active{border-left:2px solid var(--sd-primary);font-weight:700}.c-anchor-list .c-anchor-list-item:not(.active){border-left:2px solid var(--sd-secondary-light);font-weight:400}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
53
52
|
}
|
|
54
53
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdAnchorVerticalListV2, decorators: [{
|
|
55
54
|
type: Component,
|
|
56
|
-
args: [{ selector: 'sd-anchor-vertical-list-v2', imports: [CommonModule, MatIconModule], standalone: true, template: "<div class=\"c-anchor-list\" [style.width]=\"sidebarWidth\">\
|
|
57
|
-
}], ctorParameters: () => []
|
|
58
|
-
type: Input
|
|
59
|
-
}], activeSectionId: [{
|
|
60
|
-
type: Input
|
|
61
|
-
}], ellipsis: [{
|
|
62
|
-
type: Input
|
|
63
|
-
}], sidebarWidth: [{
|
|
64
|
-
type: Input
|
|
65
|
-
}], sdClickSection: [{
|
|
66
|
-
type: Output
|
|
67
|
-
}] } });
|
|
55
|
+
args: [{ selector: 'sd-anchor-vertical-list-v2', changeDetection: ChangeDetectionStrategy.OnPush, imports: [CommonModule, MatIconModule], standalone: true, template: "<div class=\"c-anchor-list\" [style.width]=\"sidebarWidth()\">\n @for (section of sections(); track section.id) {\n <div\n class=\"c-anchor-list-item\"\n [class.active]=\"section.id === activeSectionId()\"\n (click)=\"onClickSection(section.id)\"\n (keydown.enter)=\"onClickSection(section.id)\"\n tabindex=\"0\">\n @if (section.icon()) {\n <mat-icon class=\"c-anchor-list-item-icon\">{{ section.icon() }}</mat-icon>\n }\n <div class=\"c-anchor-list-item-text\" [class.ellipsis]=\"ellipsis()\">\n {{ section.title() }}\n </div>\n </div>\n }\n</div>\n", styles: [".text-primary{color:var(--sd-primary)!important}.bg-primary{background:var(--sd-primary)!important}.border-primary{border-color:var(--sd-primary)!important}.text-primary-light{color:var(--sd-primary-light)!important}.bg-primary-light{background:var(--sd-primary-light)!important}.border-primary-light{border-color:var(--sd-primary-light)!important}.text-primary-dark{color:var(--sd-primary-dark)!important}.bg-primary-dark{background:var(--sd-primary-dark)!important}.border-primary-dark{border-color:var(--sd-primary-dark)!important}.text-info{color:var(--sd-info)!important}.bg-info{background:var(--sd-info)!important}.border-info{border-color:var(--sd-info)!important}.text-info-light{color:var(--sd-info-light)!important}.bg-info-light{background:var(--sd-info-light)!important}.border-info-light{border-color:var(--sd-info-light)!important}.text-info-dark{color:var(--sd-info-dark)!important}.bg-info-dark{background:var(--sd-info-dark)!important}.border-info-dark{border-color:var(--sd-info-dark)!important}.text-success{color:var(--sd-success)!important}.bg-success{background:var(--sd-success)!important}.border-success{border-color:var(--sd-success)!important}.text-success-light{color:var(--sd-success-light)!important}.bg-success-light{background:var(--sd-success-light)!important}.border-success-light{border-color:var(--sd-success-light)!important}.text-success-dark{color:var(--sd-success-dark)!important}.bg-success-dark{background:var(--sd-success-dark)!important}.border-success-dark{border-color:var(--sd-success-dark)!important}.text-warning{color:var(--sd-warning)!important}.bg-warning{background:var(--sd-warning)!important}.border-warning{border-color:var(--sd-warning)!important}.text-warning-light{color:var(--sd-warning-light)!important}.bg-warning-light{background:var(--sd-warning-light)!important}.border-warning-light{border-color:var(--sd-warning-light)!important}.text-warning-dark{color:var(--sd-warning-dark)!important}.bg-warning-dark{background:var(--sd-warning-dark)!important}.border-warning-dark{border-color:var(--sd-warning-dark)!important}.text-error{color:var(--sd-error)!important}.bg-error{background:var(--sd-error)!important}.border-error{border-color:var(--sd-error)!important}.text-error-light{color:var(--sd-error-light)!important}.bg-error-light{background:var(--sd-error-light)!important}.border-error-light{border-color:var(--sd-error-light)!important}.text-error-dark{color:var(--sd-error-dark)!important}.bg-error-dark{background:var(--sd-error-dark)!important}.border-error-dark{border-color:var(--sd-error-dark)!important}.text-secondary{color:var(--sd-secondary)!important}.bg-secondary{background:var(--sd-secondary)!important}.border-secondary{border-color:var(--sd-secondary)!important}.text-secondary-light{color:var(--sd-secondary-light)!important}.bg-secondary-light{background:var(--sd-secondary-light)!important}.border-secondary-light{border-color:var(--sd-secondary-light)!important}.text-secondary-dark{color:var(--sd-secondary-dark)!important}.bg-secondary-dark{background:var(--sd-secondary-dark)!important}.border-secondary-dark{border-color:var(--sd-secondary-dark)!important}.text-light{color:var(--sd-light)!important}.bg-light{background:var(--sd-light)!important}.border-light{border-color:var(--sd-light)!important}.text-dark{color:var(--sd-dark)!important}.bg-dark{background:var(--sd-dark)!important}.border-dark{border-color:var(--sd-dark)!important}.text-black500{color:var(--sd-black500)!important}.bg-black500{background:var(--sd-black500)!important}.border-black500{border-color:var(--sd-black500)!important}.text-black400{color:var(--sd-black400)!important}.bg-black400{background:var(--sd-black400)!important}.border-black400{border-color:var(--sd-black400)!important}.text-black300{color:var(--sd-black300)!important}.bg-black300{background:var(--sd-black300)!important}.border-black300{border-color:var(--sd-black300)!important}.text-black200{color:var(--sd-black200)!important}.bg-black200{background:var(--sd-black200)!important}.border-black200{border-color:var(--sd-black200)!important}.text-black100{color:var(--sd-black100)!important}.bg-black100{background:var(--sd-black100)!important}.border-black100{border-color:var(--sd-black100)!important}.text-white{color:#fff!important}.bg-white{background:#fff!important}.border-white{border-color:#fff!important}.text-black{color:#000!important}.bg-black{background:#000!important}.border-black{border-color:#000!important}.c-anchor-list{height:100%;display:flex;flex-direction:column}.c-anchor-list .c-anchor-list-item{border-left:2px solid var(--sd-secondary-light);color:var(--sd-black500);padding:.5rem 1.5rem;cursor:pointer;display:flex;align-items:center;gap:.5rem}.c-anchor-list .c-anchor-list-item .c-anchor-list-item-text{user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.c-anchor-list .c-anchor-list-item .c-anchor-list-item-text.ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.c-anchor-list .c-anchor-list-item.active{border-left:2px solid var(--sd-primary);font-weight:700}.c-anchor-list .c-anchor-list-item:not(.active){border-left:2px solid var(--sd-secondary-light);font-weight:400}\n"] }]
|
|
56
|
+
}], ctorParameters: () => [] });
|
|
68
57
|
|
|
69
58
|
class SdAnchorV2 {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
set _ellipsis(value) {
|
|
81
|
-
this.ellipsis = value === '' || !!value;
|
|
82
|
-
}
|
|
83
|
-
isOverscroll = false; // Có cho phép scroll vượt qua sd-anchor và scroll tiếp đến phần tử bên ngoài?
|
|
84
|
-
set _isOverscroll(value) {
|
|
85
|
-
this.isOverscroll = value === '' || !!value;
|
|
86
|
-
}
|
|
87
|
-
isHiddenAnchorList = false; // Có ẩn danh sách tiêu đề section hay không?
|
|
88
|
-
set _isHiddenAnchorList(value) {
|
|
89
|
-
this.isHiddenAnchorList = value === '' || !!value;
|
|
90
|
-
}
|
|
91
|
-
// RxJS
|
|
92
|
-
// Note : Scroll bằng con lăn chuột hay scroll bằng click thì tại 1 thời điểm chỉ được lắng nghe 1 Rxjs
|
|
93
|
-
#scrollSubscription = new Subscription(); // Scroll bằng con lăn chuột
|
|
94
|
-
#clickScrollSubscription = new Subscription(); // Scroll bằng click
|
|
95
|
-
// End
|
|
96
|
-
// Variables Private
|
|
59
|
+
wrapper = viewChild.required('wrapper');
|
|
60
|
+
sections = contentChildren(SdAnchorItemV2);
|
|
61
|
+
type = input('vertical');
|
|
62
|
+
sidebarWidth = input('200px');
|
|
63
|
+
ellipsis = input(false, { transform: booleanAttribute });
|
|
64
|
+
isOverscroll = input(false, { transform: booleanAttribute });
|
|
65
|
+
isHiddenAnchorList = input(false, { transform: booleanAttribute });
|
|
66
|
+
activeSectionId = signal('');
|
|
67
|
+
#scrollSubscription = new Subscription();
|
|
68
|
+
#clickScrollSubscription = new Subscription();
|
|
97
69
|
#delay = 100;
|
|
98
70
|
#currentScrollTop = 0;
|
|
99
71
|
#timeoutId = null;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
this.#registerScrollSubscription(); // Đăng ký Rxjs Scroll bằng con lăn chuột
|
|
108
|
-
this.#setWidthAnchorContent();
|
|
109
|
-
}
|
|
72
|
+
constructor() {
|
|
73
|
+
afterNextRender(() => {
|
|
74
|
+
if (!this.isHiddenAnchorList()) {
|
|
75
|
+
this.activeSectionId.set(this.sections()[0]?.id ?? '');
|
|
76
|
+
this.#registerScrollSubscription();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
110
79
|
}
|
|
111
80
|
#registerScrollSubscription = () => {
|
|
112
|
-
this.#disposeResources();
|
|
113
|
-
const wrapperEl = this.wrapper.nativeElement;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const rect = section
|
|
81
|
+
this.#disposeResources();
|
|
82
|
+
const wrapperEl = this.wrapper().nativeElement;
|
|
83
|
+
this.#scrollSubscription = fromEvent(wrapperEl, 'scroll')
|
|
84
|
+
.pipe(auditTime(50))
|
|
85
|
+
.subscribe((event) => {
|
|
86
|
+
const el = event.target;
|
|
87
|
+
this.#currentScrollTop = this.#updateCurrentScroll(el);
|
|
88
|
+
for (const section of this.sections()) {
|
|
89
|
+
const rect = section.elementRef.nativeElement;
|
|
121
90
|
const rectTop = rect.offsetTop;
|
|
122
91
|
const rectBottom = rectTop + rect.offsetHeight;
|
|
123
|
-
// End
|
|
124
92
|
if (this.#currentScrollTop >= rectTop && this.#currentScrollTop < rectBottom) {
|
|
125
|
-
this.activeSectionId
|
|
93
|
+
this.activeSectionId.set(section.id);
|
|
126
94
|
break;
|
|
127
95
|
}
|
|
128
96
|
}
|
|
129
97
|
});
|
|
130
98
|
};
|
|
131
99
|
scrollSectionByClick(idSectionTarget) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
this.activeSectionId = idSectionTarget;
|
|
136
|
-
const targetSection = this.sections.find(s => s?.id === this.activeSectionId)?.elementRef;
|
|
137
|
-
if (!targetSection) {
|
|
100
|
+
this.activeSectionId.set(idSectionTarget);
|
|
101
|
+
const targetSection = this.sections().find(s => s.id === idSectionTarget)?.elementRef;
|
|
102
|
+
if (!targetSection)
|
|
138
103
|
return;
|
|
139
|
-
|
|
140
|
-
this
|
|
141
|
-
const wrapperEl = this.wrapper.nativeElement;
|
|
104
|
+
this.#disposeResources();
|
|
105
|
+
const wrapperEl = this.wrapper().nativeElement;
|
|
142
106
|
const targetElement = targetSection.nativeElement;
|
|
143
|
-
const prevScrollTop = this.#currentScrollTop;
|
|
144
|
-
|
|
145
|
-
const clickScrollEnd$ = fromEvent(wrapperEl, 'scroll');
|
|
146
|
-
this.#clickScrollSubscription = clickScrollEnd$
|
|
107
|
+
const prevScrollTop = this.#currentScrollTop;
|
|
108
|
+
this.#clickScrollSubscription = fromEvent(wrapperEl, 'scroll')
|
|
147
109
|
.pipe(auditTime(this.#delay), map((event) => {
|
|
148
|
-
const
|
|
149
|
-
this.#currentScrollTop = this.#updateCurrentScroll(
|
|
110
|
+
const el = event.target;
|
|
111
|
+
this.#currentScrollTop = this.#updateCurrentScroll(el);
|
|
150
112
|
const wrapperTop = wrapperEl.getBoundingClientRect().top;
|
|
151
113
|
const targetRect = targetElement.getBoundingClientRect();
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
return Math.abs(targetTop - wrapperTop) < 1 || isVisible; // Đã được scroll tới hoặc element đã nằm trong vùng viewPort
|
|
114
|
+
const isVisible = targetRect.top >= 0 && targetRect.bottom <= window.innerHeight;
|
|
115
|
+
return Math.abs(targetRect.top - wrapperTop) < 1 || isVisible;
|
|
155
116
|
}), filter(Boolean), debounceTime(this.#delay + 100), take(1))
|
|
156
|
-
.subscribe(() =>
|
|
157
|
-
this.#registerScrollSubscription(); // Đã xác nhận scroll xong thì mới đăng ký lại Rxjs Scroll bằng con lăn chuột
|
|
158
|
-
});
|
|
159
|
-
// // End
|
|
160
|
-
// Case 2: Nếu không được scroll thì sau (#delay + 100) đăng ký lại Rxjs Scroll bằng con lăn chuột
|
|
117
|
+
.subscribe(() => this.#registerScrollSubscription());
|
|
161
118
|
this.#timeoutId = setTimeout(() => {
|
|
162
119
|
if (prevScrollTop === this.#currentScrollTop) {
|
|
163
120
|
this.#registerScrollSubscription();
|
|
164
121
|
}
|
|
165
122
|
}, this.#delay + 100);
|
|
166
|
-
wrapperEl.scrollTo({ top: targetElement.offsetTop, behavior: 'smooth' });
|
|
167
|
-
// End
|
|
123
|
+
wrapperEl.scrollTo({ top: targetElement.offsetTop, behavior: 'smooth' });
|
|
168
124
|
}
|
|
169
|
-
#updateCurrentScroll(
|
|
170
|
-
const style = getComputedStyle(
|
|
171
|
-
|
|
172
|
-
const borderTop = parseFloat(style.borderTopWidth);
|
|
173
|
-
return elementTarget.scrollTop + paddingTop + borderTop; // Vị trí scroll thực tế nếu có padding, border
|
|
125
|
+
#updateCurrentScroll(el) {
|
|
126
|
+
const style = getComputedStyle(el);
|
|
127
|
+
return el.scrollTop + parseFloat(style.paddingTop) + parseFloat(style.borderTopWidth);
|
|
174
128
|
}
|
|
175
|
-
// Giải phóng tất cả subscription và timer đang hoạt động
|
|
176
129
|
#disposeResources = () => {
|
|
177
|
-
if (this.#timeoutId)
|
|
130
|
+
if (this.#timeoutId)
|
|
178
131
|
clearTimeout(this.#timeoutId);
|
|
179
|
-
}
|
|
180
132
|
this.#scrollSubscription?.unsubscribe();
|
|
181
133
|
this.#clickScrollSubscription?.unsubscribe();
|
|
182
134
|
};
|
|
183
|
-
// Thiết lập chiều rộng nội dung phụ thuộc vào chiều rộng danh sách tiêu đề section
|
|
184
|
-
#setWidthAnchorContent = () => {
|
|
185
|
-
const gap = '16px'; // Khoảng cách giữa nội dung và danh sách tiêu đề section
|
|
186
|
-
this.renderer.setStyle(this.anchorContent.nativeElement, 'width', `calc(100% - ${this.sidebarWidth} - ${gap})`);
|
|
187
|
-
};
|
|
188
135
|
ngOnDestroy() {
|
|
189
136
|
this.#disposeResources();
|
|
190
137
|
}
|
|
191
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdAnchorV2, deps: [
|
|
192
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.17", type: SdAnchorV2, isStandalone: true, selector: "sd-anchor-v2", inputs: { type: "type",
|
|
138
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdAnchorV2, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
139
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.17", type: SdAnchorV2, isStandalone: true, selector: "sd-anchor-v2", inputs: { type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, sidebarWidth: { classPropertyName: "sidebarWidth", publicName: "sidebarWidth", isSignal: true, isRequired: false, transformFunction: null }, ellipsis: { classPropertyName: "ellipsis", publicName: "ellipsis", isSignal: true, isRequired: false, transformFunction: null }, isOverscroll: { classPropertyName: "isOverscroll", publicName: "isOverscroll", isSignal: true, isRequired: false, transformFunction: null }, isHiddenAnchorList: { classPropertyName: "isHiddenAnchorList", publicName: "isHiddenAnchorList", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "sections", predicate: SdAnchorItemV2, isSignal: true }], viewQueries: [{ propertyName: "wrapper", first: true, predicate: ["wrapper"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"c-anchor-vertical\" [ngClass]=\"{ 'c-stop-scroll-propagation': !isOverscroll() }\" #wrapper>\n <div class=\"c-anchor-content\" [style.width]=\"'calc(100% - ' + sidebarWidth() + ' - 16px)'\">\n <ng-content></ng-content>\n </div>\n\n @if (!isHiddenAnchorList()) {\n <div class=\"c-anchor-list\" [style.width]=\"sidebarWidth()\">\n <sd-anchor-vertical-list-v2\n [sections]=\"sections()\"\n [ellipsis]=\"ellipsis()\"\n [sidebarWidth]=\"sidebarWidth()\"\n [activeSectionId]=\"activeSectionId()\"\n (sdClickSection)=\"scrollSectionByClick($event)\">\n </sd-anchor-vertical-list-v2>\n </div>\n }\n</div>\n", styles: ["@charset \"UTF-8\";.c-anchor-vertical{position:relative;display:flex;height:100%;width:100%;gap:16px;overflow-y:auto}.c-anchor-vertical.c-stop-scroll-propagation{overscroll-behavior:contain}.c-anchor-vertical .c-anchor-content{width:100%}.c-anchor-vertical .c-anchor-list{position:sticky;top:0;right:6px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: SdAnchorVerticalListV2, selector: "sd-anchor-vertical-list-v2", inputs: ["sections", "activeSectionId", "ellipsis", "sidebarWidth"], outputs: ["sdClickSection"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
193
140
|
}
|
|
194
141
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdAnchorV2, decorators: [{
|
|
195
142
|
type: Component,
|
|
196
|
-
args: [{ selector: 'sd-anchor-v2', imports: [CommonModule, SdAnchorVerticalListV2], standalone: true, template: "<div class=\"c-anchor-vertical\" [ngClass]=\"{ 'c-stop-scroll-propagation': !isOverscroll }\" #wrapper>\
|
|
197
|
-
}], ctorParameters: () => [
|
|
198
|
-
type: ViewChild,
|
|
199
|
-
args: ['wrapper', { static: false }]
|
|
200
|
-
}], anchorContent: [{
|
|
201
|
-
type: ViewChild,
|
|
202
|
-
args: ['anchorContent', { static: false }]
|
|
203
|
-
}], sections: [{
|
|
204
|
-
type: ContentChildren,
|
|
205
|
-
args: [SdAnchorItemV2]
|
|
206
|
-
}], type: [{
|
|
207
|
-
type: Input
|
|
208
|
-
}], sidebarWidth: [{
|
|
209
|
-
type: Input
|
|
210
|
-
}], _ellipsis: [{
|
|
211
|
-
type: Input,
|
|
212
|
-
args: ['ellipsis']
|
|
213
|
-
}], _isOverscroll: [{
|
|
214
|
-
type: Input,
|
|
215
|
-
args: ['isOverscroll']
|
|
216
|
-
}], _isHiddenAnchorList: [{
|
|
217
|
-
type: Input,
|
|
218
|
-
args: ['isHiddenAnchorList']
|
|
219
|
-
}] } });
|
|
143
|
+
args: [{ selector: 'sd-anchor-v2', changeDetection: ChangeDetectionStrategy.OnPush, imports: [CommonModule, SdAnchorVerticalListV2], standalone: true, template: "<div class=\"c-anchor-vertical\" [ngClass]=\"{ 'c-stop-scroll-propagation': !isOverscroll() }\" #wrapper>\n <div class=\"c-anchor-content\" [style.width]=\"'calc(100% - ' + sidebarWidth() + ' - 16px)'\">\n <ng-content></ng-content>\n </div>\n\n @if (!isHiddenAnchorList()) {\n <div class=\"c-anchor-list\" [style.width]=\"sidebarWidth()\">\n <sd-anchor-vertical-list-v2\n [sections]=\"sections()\"\n [ellipsis]=\"ellipsis()\"\n [sidebarWidth]=\"sidebarWidth()\"\n [activeSectionId]=\"activeSectionId()\"\n (sdClickSection)=\"scrollSectionByClick($event)\">\n </sd-anchor-vertical-list-v2>\n </div>\n }\n</div>\n", styles: ["@charset \"UTF-8\";.c-anchor-vertical{position:relative;display:flex;height:100%;width:100%;gap:16px;overflow-y:auto}.c-anchor-vertical.c-stop-scroll-propagation{overscroll-behavior:contain}.c-anchor-vertical .c-anchor-content{width:100%}.c-anchor-vertical .c-anchor-list{position:sticky;top:0;right:6px}\n"] }]
|
|
144
|
+
}], ctorParameters: () => [] });
|
|
220
145
|
|
|
221
146
|
/**
|
|
222
147
|
* Generated bundle index. Do not edit.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sd-angular-core-components-anchor-v2.mjs","sources":["../../../projects/sd-angular/components/anchor-v2/src/components/anchor-item-v2/anchor-item-v2.component.ts","../../../projects/sd-angular/components/anchor-v2/src/components/anchor-item-v2/anchor-item-v2.component.html","../../../projects/sd-angular/components/anchor-v2/src/components/anchor-vertical-v2/anchor-vertical-list-v2.component.ts","../../../projects/sd-angular/components/anchor-v2/src/components/anchor-vertical-v2/anchor-vertical-list-v2.component.html","../../../projects/sd-angular/components/anchor-v2/src/components/anchor-v2/anchor-v2.component.ts","../../../projects/sd-angular/components/anchor-v2/src/components/anchor-v2/anchor-v2.component.html","../../../projects/sd-angular/components/anchor-v2/sd-angular-core-components-anchor-v2.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\r\nimport { Component, ElementRef, Input } from '@angular/core';\r\nimport { v4 as uuidv4 } from 'uuid';\r\nimport { IAnchorItemV2 } from '../../models';\r\n\r\n@Component({\r\n selector: 'sd-anchor-item-v2',\r\n templateUrl: './anchor-item-v2.component.html',\r\n styleUrls: ['./anchor-item-v2.component.scss'],\r\n imports: [CommonModule],\r\n standalone: true,\r\n})\r\nexport class SdAnchorItemV2 implements IAnchorItemV2 {\r\n @Input() title!: string;\r\n @Input() icon?: string;\r\n id: string = uuidv4();\r\n constructor(public elementRef: ElementRef) {}\r\n}\r\n","<section>\r\n <ng-content></ng-content>\r\n</section>\r\n","import { CommonModule } from '@angular/common';\r\nimport { Component, ContentChildren, EventEmitter, Input, OnInit, Output, QueryList } from '@angular/core';\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { debounceTime, Subject, Subscription } from 'rxjs';\r\nimport { SdAnchorItemV2 } from '../anchor-item-v2/anchor-item-v2.component';\r\n\r\n@Component({\r\n selector: 'sd-anchor-vertical-list-v2',\r\n templateUrl: './anchor-vertical-list-v2.component.html',\r\n styleUrl: './anchor-vertical-list-v2.component.scss',\r\n imports: [CommonModule, MatIconModule],\r\n standalone: true,\r\n})\r\nexport class SdAnchorVerticalListV2 implements OnInit {\r\n constructor() {}\r\n @Input() sections!: QueryList<SdAnchorItemV2>;\r\n @Input() activeSectionId: string = '';\r\n @Input() ellipsis!: boolean;\r\n @Input() sidebarWidth!: string;\r\n\r\n @Output() sdClickSection = new EventEmitter<string>();\r\n\r\n #delay: number = 200;\r\n #clickSectionSubject = new Subject<string>();\r\n #subscription = new Subscription();\r\n\r\n ngOnInit() {\r\n this.#subscription.add(\r\n this.#clickSectionSubject.pipe(debounceTime(this.#delay)).subscribe((idSectionTarget: string) => {\r\n this.sdClickSection.emit(idSectionTarget);\r\n })\r\n );\r\n }\r\n\r\n onClickSection = (idSectionTarget: string): void => {\r\n this.#clickSectionSubject.next(idSectionTarget);\r\n };\r\n \r\n ngOnDestroy() {\r\n this.#subscription?.unsubscribe();\r\n }\r\n}\r\n","<div class=\"c-anchor-list\" [style.width]=\"sidebarWidth\">\r\n @for (section of sections; track section.id) {\r\n <div\r\n class=\"c-anchor-list-item\"\r\n [class.active]=\"section.id === activeSectionId\"\r\n (click)=\"onClickSection(section.id)\"\r\n (keydown.enter)=\"onClickSection(section.id)\"\r\n tabindex=\"0\">\r\n @if (section?.icon) {\r\n <mat-icon class=\"c-anchor-list-item-icon\">{{ section?.icon }}</mat-icon>\r\n }\r\n <div\r\n class=\"c-anchor-list-item-text\"\r\n [ngClass]=\"{\r\n ellipsis\r\n }\">\r\n {{ section.title }}\r\n </div>\r\n </div>\r\n }\r\n</div>\r\n","import { AfterViewInit, Component, ContentChildren, ElementRef, Input, QueryList, Renderer2, ViewChild } from '@angular/core';\r\nimport { SdAnchorVerticalListV2 } from '../anchor-vertical-v2/anchor-vertical-list-v2.component';\r\nimport { SdAnchorItemV2 } from '../anchor-item-v2/anchor-item-v2.component';\r\nimport { auditTime, debounceTime, filter, fromEvent, map, Subscription, take } from 'rxjs';\r\nimport { CommonModule } from '@angular/common';\r\n\r\n@Component({\r\n selector: 'sd-anchor-v2',\r\n templateUrl: './anchor-v2.component.html',\r\n styleUrls: ['./anchor-v2.component.scss'],\r\n imports: [CommonModule, SdAnchorVerticalListV2],\r\n standalone: true,\r\n})\r\nexport class SdAnchorV2 implements AfterViewInit {\r\n constructor(private renderer: Renderer2) {}\r\n @ViewChild('wrapper', { static: false }) wrapper!: ElementRef;\r\n @ViewChild('anchorContent', { static: false }) anchorContent!: ElementRef;\r\n\r\n @ContentChildren(SdAnchorItemV2) sections!: QueryList<SdAnchorItemV2>; // Danh sách sd-anchor-v2 được khai báo\r\n\r\n @Input() type: 'vertical' | 'horizontal' = 'vertical';\r\n @Input() sidebarWidth: string = '200px'; // Độ rộng của danh sách tiêu đề\r\n\r\n ellipsis = false; // Có thu gọn tiêu đề bằng dấu 3 chấm?\r\n @Input('ellipsis') set _ellipsis(value: '' | boolean | undefined | null) {\r\n this.ellipsis = value === '' || !!value;\r\n }\r\n\r\n isOverscroll = false; // Có cho phép scroll vượt qua sd-anchor và scroll tiếp đến phần tử bên ngoài?\r\n @Input('isOverscroll') set _isOverscroll(value: '' | boolean | undefined | null) {\r\n this.isOverscroll = value === '' || !!value;\r\n }\r\n\r\n isHiddenAnchorList = false; // Có ẩn danh sách tiêu đề section hay không?\r\n @Input('isHiddenAnchorList') set _isHiddenAnchorList(value: '' | boolean | undefined | null) {\r\n this.isHiddenAnchorList = value === '' || !!value;\r\n }\r\n\r\n // RxJS\r\n // Note : Scroll bằng con lăn chuột hay scroll bằng click thì tại 1 thời điểm chỉ được lắng nghe 1 Rxjs\r\n #scrollSubscription = new Subscription(); // Scroll bằng con lăn chuột\r\n #clickScrollSubscription = new Subscription(); // Scroll bằng click\r\n // End\r\n\r\n // Variables Private\r\n #delay: number = 100;\r\n #currentScrollTop: number = 0;\r\n #timeoutId: ReturnType<typeof setTimeout> | null = null;\r\n // End\r\n\r\n // Variables Public\r\n activeSectionId: string = '';\r\n // End\r\n\r\n ngAfterViewInit(): void {\r\n if (!this.isHiddenAnchorList) {\r\n this.activeSectionId = this.sections?.first?.id ?? ''; // Active section đầu tiên\r\n this.#registerScrollSubscription(); // Đăng ký Rxjs Scroll bằng con lăn chuột\r\n this.#setWidthAnchorContent()\r\n }\r\n }\r\n\r\n #registerScrollSubscription = (): void => {\r\n this.#disposeResources(); // Giải phóng tất cả subscription và timer cũ\r\n const wrapperEl = this.wrapper.nativeElement;\r\n const scroll$ = fromEvent<UIEvent>(wrapperEl, 'scroll').pipe(debounceTime(this.#delay));\r\n this.#scrollSubscription = scroll$.subscribe((event: UIEvent) => {\r\n const elementTarget = event.target as HTMLElement;\r\n this.#currentScrollTop = this.#updateCurrentScroll(elementTarget); // Ví trí scroll hiện tại\r\n for (const section of this.sections) {\r\n // Vùng section chiếm diện tích\r\n const rect = section?.elementRef?.nativeElement;\r\n const rectTop = rect.offsetTop;\r\n const rectBottom = rectTop + rect.offsetHeight;\r\n // End\r\n if (this.#currentScrollTop >= rectTop && this.#currentScrollTop < rectBottom) {\r\n this.activeSectionId = section?.id;\r\n break;\r\n }\r\n }\r\n });\r\n };\r\n\r\n scrollSectionByClick(idSectionTarget: string): void {\r\n // Khi scrollByClick sẽ có 2 case xảy ra:\r\n // Case 1 : Được scroll (ElementTarget không nằm trong vùng viewport và được scroll đến vị trí)\r\n // Case 2 : Không được scroll (ElementTarget đã được scroll trước đó hoặc đã nằm trong vùng viewport luôn)\r\n\r\n this.activeSectionId = idSectionTarget;\r\n const targetSection = this.sections.find(s => s?.id === this.activeSectionId)?.elementRef;\r\n if (!targetSection) {\r\n return;\r\n }\r\n\r\n this.#disposeResources(); // Giải phóng tất cả subscription và timer cũ\r\n const wrapperEl = this.wrapper.nativeElement;\r\n const targetElement = targetSection.nativeElement;\r\n const prevScrollTop = this.#currentScrollTop; // Lưu lại ví trí trước khi scroll bởi event click\r\n\r\n // Case 1: Nếu được Scroll check điều kiện để đăng ký lại Rxjs Scroll bằng con lăn chuột\r\n const clickScrollEnd$ = fromEvent<UIEvent>(wrapperEl, 'scroll');\r\n this.#clickScrollSubscription = clickScrollEnd$\r\n .pipe(\r\n auditTime(this.#delay),\r\n map((event: UIEvent) => {\r\n const elementTarget = event.target as HTMLElement;\r\n this.#currentScrollTop = this.#updateCurrentScroll(elementTarget); // Cập nhật vị trí sau mỗi lần #delay\r\n const wrapperTop = wrapperEl.getBoundingClientRect().top;\r\n const targetRect = targetElement.getBoundingClientRect();\r\n const targetTop = targetRect.top;\r\n const isVisible = targetRect.top >= 0 && targetRect.bottom <= window.innerHeight; // Nằm trong viewPort\r\n return Math.abs(targetTop - wrapperTop) < 1 || isVisible; // Đã được scroll tới hoặc element đã nằm trong vùng viewPort\r\n }),\r\n filter(Boolean),\r\n debounceTime(this.#delay + 100),\r\n take(1)\r\n )\r\n .subscribe(() => {\r\n this.#registerScrollSubscription(); // Đã xác nhận scroll xong thì mới đăng ký lại Rxjs Scroll bằng con lăn chuột\r\n });\r\n // // End\r\n\r\n // Case 2: Nếu không được scroll thì sau (#delay + 100) đăng ký lại Rxjs Scroll bằng con lăn chuột\r\n this.#timeoutId = setTimeout(() => {\r\n if (prevScrollTop === this.#currentScrollTop) {\r\n this.#registerScrollSubscription();\r\n }\r\n }, this.#delay + 100);\r\n\r\n wrapperEl.scrollTo({ top: targetElement.offsetTop, behavior: 'smooth' }); // Action scroll\r\n // End\r\n }\r\n\r\n #updateCurrentScroll(elementTarget: HTMLElement): number {\r\n const style = getComputedStyle(elementTarget);\r\n const paddingTop = parseFloat(style.paddingTop);\r\n const borderTop = parseFloat(style.borderTopWidth);\r\n return elementTarget.scrollTop + paddingTop + borderTop; // Vị trí scroll thực tế nếu có padding, border\r\n }\r\n\r\n // Giải phóng tất cả subscription và timer đang hoạt động\r\n #disposeResources = (): void => {\r\n if (this.#timeoutId) {\r\n clearTimeout(this.#timeoutId);\r\n }\r\n this.#scrollSubscription?.unsubscribe();\r\n this.#clickScrollSubscription?.unsubscribe();\r\n };\r\n\r\n // Thiết lập chiều rộng nội dung phụ thuộc vào chiều rộng danh sách tiêu đề section\r\n #setWidthAnchorContent = (): void => {\r\n const gap = '16px'; // Khoảng cách giữa nội dung và danh sách tiêu đề section\r\n this.renderer.setStyle(this.anchorContent.nativeElement, 'width', `calc(100% - ${this.sidebarWidth} - ${gap})`);\r\n };\r\n\r\n ngOnDestroy(): void {\r\n this.#disposeResources();\r\n }\r\n}\r\n","<div class=\"c-anchor-vertical\" [ngClass]=\"{ 'c-stop-scroll-propagation': !isOverscroll }\" #wrapper>\r\n <!-- Nội dung -->\r\n <div class=\"c-anchor-content\" #anchorContent>\r\n <ng-content></ng-content>\r\n </div>\r\n\r\n <!-- Danh sách tiêu đề các sections-->\r\n @if(!isHiddenAnchorList){\r\n <div class=\"c-anchor-list\" [style.width]=\"sidebarWidth\">\r\n <sd-anchor-vertical-list-v2\r\n [sections]=\"sections\"\r\n [ellipsis]=\"ellipsis\"\r\n [sidebarWidth]=\"sidebarWidth\"\r\n [activeSectionId]=\"activeSectionId\"\r\n (sdClickSection)=\"scrollSectionByClick($event)\">\r\n </sd-anchor-vertical-list-v2>\r\n </div>\r\n }\r\n</div>\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["uuidv4"],"mappings":";;;;;;;;;MAYa,cAAc,CAAA;AAIN,IAAA,UAAA;AAHV,IAAA,KAAK;AACL,I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AAA,EAAA,CAAA,oTAAA,CAAA,EAAA;8EAIyB,OAAO,EAAA,CAAA;sBAA/C,SAAS;AAAC,gBAAA,IAAA,EAAA,CAAA,SAAS,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;gBACQ,aAAa,EAAA,CAAA;sBAA3D,SAAS;AAAC,gBAAA,IAAA,EAAA,CAAA,eAAe,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;gBAEZ,QAAQ,EAAA,CAAA;sBAAxC,eAAe;uBAAC,cAAc;gBAEtB,IAAI,EAAA,CAAA;sBAAZ;gBACQ,YAAY,EAAA,CAAA;sBAApB;gBAGsB,SAAS,EAAA,CAAA;sBAA/B,KAAK;uBAAC,UAAU;gBAKU,aAAa,EAAA,CAAA;sBAAvC,KAAK;uBAAC,cAAc;gBAKY,mBAAmB,EAAA,CAAA;sBAAnD,KAAK;uBAAC,oBAAoB;;;AElC7B;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"sd-angular-core-components-anchor-v2.mjs","sources":["../../../projects/sd-angular/components/anchor-v2/src/components/anchor-item-v2/anchor-item-v2.component.ts","../../../projects/sd-angular/components/anchor-v2/src/components/anchor-item-v2/anchor-item-v2.component.html","../../../projects/sd-angular/components/anchor-v2/src/components/anchor-vertical-v2/anchor-vertical-list-v2.component.ts","../../../projects/sd-angular/components/anchor-v2/src/components/anchor-vertical-v2/anchor-vertical-list-v2.component.html","../../../projects/sd-angular/components/anchor-v2/src/components/anchor-v2/anchor-v2.component.ts","../../../projects/sd-angular/components/anchor-v2/src/components/anchor-v2/anchor-v2.component.html","../../../projects/sd-angular/components/anchor-v2/sd-angular-core-components-anchor-v2.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\r\nimport { Component, ElementRef, effect, inject, input } from '@angular/core';\r\nimport { v4 as uuidv4 } from 'uuid';\r\nimport { IAnchorItemV2 } from '../../models';\r\n\r\n@Component({\r\n selector: 'sd-anchor-item-v2',\r\n templateUrl: './anchor-item-v2.component.html',\r\n styleUrls: ['./anchor-item-v2.component.scss'],\r\n imports: [CommonModule],\r\n standalone: true,\r\n})\r\nexport class SdAnchorItemV2 implements IAnchorItemV2 {\r\n title = input.required<string>();\r\n icon = input<string | undefined>();\r\n id: string = uuidv4();\r\n elementRef = inject(ElementRef);\r\n\r\n constructor() {\r\n effect(() => {\r\n if (this.title()) {\r\n this.elementRef.nativeElement.removeAttribute('title');\r\n }\r\n });\r\n }\r\n}\r\n","<section>\r\n <ng-content></ng-content>\r\n</section>\r\n","import { ChangeDetectionStrategy, Component, OnDestroy, input, output } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { MatIconModule } from '@angular/material/icon';\nimport { Subject, Subscription, debounceTime } from 'rxjs';\n\nimport { SdAnchorItemV2 } from '../anchor-item-v2/anchor-item-v2.component';\n\n@Component({\n selector: 'sd-anchor-vertical-list-v2',\n templateUrl: './anchor-vertical-list-v2.component.html',\n styleUrl: './anchor-vertical-list-v2.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [CommonModule, MatIconModule],\n standalone: true,\n})\nexport class SdAnchorVerticalListV2 implements OnDestroy {\n sections = input.required<readonly SdAnchorItemV2[]>();\n activeSectionId = input<string>('');\n ellipsis = input<boolean>(false);\n sidebarWidth = input<string>('');\n\n sdClickSection = output<string>();\n\n #delay = 200;\n #clickSectionSubject = new Subject<string>();\n #subscription = new Subscription();\n\n constructor() {\n this.#subscription.add(\n this.#clickSectionSubject\n .pipe(debounceTime(this.#delay))\n .subscribe((id: string) => this.sdClickSection.emit(id))\n );\n }\n\n onClickSection = (id: string): void => {\n this.#clickSectionSubject.next(id);\n };\n\n ngOnDestroy(): void {\n this.#subscription.unsubscribe();\n }\n}\n","<div class=\"c-anchor-list\" [style.width]=\"sidebarWidth()\">\n @for (section of sections(); track section.id) {\n <div\n class=\"c-anchor-list-item\"\n [class.active]=\"section.id === activeSectionId()\"\n (click)=\"onClickSection(section.id)\"\n (keydown.enter)=\"onClickSection(section.id)\"\n tabindex=\"0\">\n @if (section.icon()) {\n <mat-icon class=\"c-anchor-list-item-icon\">{{ section.icon() }}</mat-icon>\n }\n <div class=\"c-anchor-list-item-text\" [class.ellipsis]=\"ellipsis()\">\n {{ section.title() }}\n </div>\n </div>\n }\n</div>\n","import {\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n OnDestroy,\n afterNextRender,\n booleanAttribute,\n contentChildren,\n input,\n signal,\n viewChild,\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { Subscription, auditTime, debounceTime, filter, fromEvent, map, take } from 'rxjs';\n\nimport { SdAnchorVerticalListV2 } from '../anchor-vertical-v2/anchor-vertical-list-v2.component';\nimport { SdAnchorItemV2 } from '../anchor-item-v2/anchor-item-v2.component';\n\n@Component({\n selector: 'sd-anchor-v2',\n templateUrl: './anchor-v2.component.html',\n styleUrls: ['./anchor-v2.component.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [CommonModule, SdAnchorVerticalListV2],\n standalone: true,\n})\nexport class SdAnchorV2 implements OnDestroy {\n wrapper = viewChild.required<ElementRef>('wrapper');\n sections = contentChildren(SdAnchorItemV2);\n\n type = input<'vertical' | 'horizontal'>('vertical');\n sidebarWidth = input<string>('200px');\n ellipsis = input(false, { transform: booleanAttribute });\n isOverscroll = input(false, { transform: booleanAttribute });\n isHiddenAnchorList = input(false, { transform: booleanAttribute });\n\n activeSectionId = signal<string>('');\n\n #scrollSubscription = new Subscription();\n #clickScrollSubscription = new Subscription();\n #delay = 100;\n #currentScrollTop = 0;\n #timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n constructor() {\n afterNextRender(() => {\n if (!this.isHiddenAnchorList()) {\n this.activeSectionId.set(this.sections()[0]?.id ?? '');\n this.#registerScrollSubscription();\n }\n });\n }\n\n #registerScrollSubscription = (): void => {\n this.#disposeResources();\n const wrapperEl = this.wrapper().nativeElement;\n this.#scrollSubscription = fromEvent<UIEvent>(wrapperEl, 'scroll')\n .pipe(auditTime(50))\n .subscribe((event: UIEvent) => {\n const el = event.target as HTMLElement;\n this.#currentScrollTop = this.#updateCurrentScroll(el);\n for (const section of this.sections()) {\n const rect = section.elementRef.nativeElement;\n const rectTop = rect.offsetTop;\n const rectBottom = rectTop + rect.offsetHeight;\n if (this.#currentScrollTop >= rectTop && this.#currentScrollTop < rectBottom) {\n this.activeSectionId.set(section.id);\n break;\n }\n }\n });\n };\n\n scrollSectionByClick(idSectionTarget: string): void {\n this.activeSectionId.set(idSectionTarget);\n const targetSection = this.sections().find(s => s.id === idSectionTarget)?.elementRef;\n if (!targetSection) return;\n\n this.#disposeResources();\n const wrapperEl = this.wrapper().nativeElement;\n const targetElement = targetSection.nativeElement;\n const prevScrollTop = this.#currentScrollTop;\n\n this.#clickScrollSubscription = fromEvent<UIEvent>(wrapperEl, 'scroll')\n .pipe(\n auditTime(this.#delay),\n map((event: UIEvent) => {\n const el = event.target as HTMLElement;\n this.#currentScrollTop = this.#updateCurrentScroll(el);\n const wrapperTop = wrapperEl.getBoundingClientRect().top;\n const targetRect = targetElement.getBoundingClientRect();\n const isVisible = targetRect.top >= 0 && targetRect.bottom <= window.innerHeight;\n return Math.abs(targetRect.top - wrapperTop) < 1 || isVisible;\n }),\n filter(Boolean),\n debounceTime(this.#delay + 100),\n take(1)\n )\n .subscribe(() => this.#registerScrollSubscription());\n\n this.#timeoutId = setTimeout(() => {\n if (prevScrollTop === this.#currentScrollTop) {\n this.#registerScrollSubscription();\n }\n }, this.#delay + 100);\n\n wrapperEl.scrollTo({ top: targetElement.offsetTop, behavior: 'smooth' });\n }\n\n #updateCurrentScroll(el: HTMLElement): number {\n const style = getComputedStyle(el);\n return el.scrollTop + parseFloat(style.paddingTop) + parseFloat(style.borderTopWidth);\n }\n\n #disposeResources = (): void => {\n if (this.#timeoutId) clearTimeout(this.#timeoutId);\n this.#scrollSubscription?.unsubscribe();\n this.#clickScrollSubscription?.unsubscribe();\n };\n\n ngOnDestroy(): void {\n this.#disposeResources();\n }\n}\n","<div class=\"c-anchor-vertical\" [ngClass]=\"{ 'c-stop-scroll-propagation': !isOverscroll() }\" #wrapper>\n <div class=\"c-anchor-content\" [style.width]=\"'calc(100% - ' + sidebarWidth() + ' - 16px)'\">\n <ng-content></ng-content>\n </div>\n\n @if (!isHiddenAnchorList()) {\n <div class=\"c-anchor-list\" [style.width]=\"sidebarWidth()\">\n <sd-anchor-vertical-list-v2\n [sections]=\"sections()\"\n [ellipsis]=\"ellipsis()\"\n [sidebarWidth]=\"sidebarWidth()\"\n [activeSectionId]=\"activeSectionId()\"\n (sdClickSection)=\"scrollSectionByClick($event)\">\n </sd-anchor-vertical-list-v2>\n </div>\n }\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["uuidv4"],"mappings":";;;;;;;;;MAYa,cAAc,CAAA;AACzB,IAAA,KAAK,GAAG,KAAK,CAAC,QAAQ,EAAU;IAChC,IAAI,GAAG,KAAK,EAAsB;IAClC,EAAE,GAAWA,EAAM,EAAE;AACrB,IAAA,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;AAE/B,IAAA,WAAA,GAAA;QACE,MAAM,CAAC,MAAK;AACV,YAAA,IAAI,IAAI,CAAC,KAAK,EAAE,EAAE;gBAChB,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,eAAe,CAAC,OAAO,CAAC;YACxD;AACF,QAAA,CAAC,CAAC;IACJ;wGAZW,cAAc,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;4FAAd,cAAc,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,mBAAA,EAAA,MAAA,EAAA,EAAA,KAAA,EAAA,EAAA,iBAAA,EAAA,OAAA,EAAA,UAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,IAAA,EAAA,EAAA,iBAAA,EAAA,MAAA,EAAA,UAAA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AA,CAAA,oTAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EDMY,YAAY,+HAAE,sBAAsB,EAAA,QAAA,EAAA,4BAAA,EAAA,MAAA,EAAA,CAAA,UAAA,EAAA,iBAAA,EAAA,UAAA,EAAA,cAAA,CAAA,EAAA,OAAA,EAAA,CAAA,gBAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;4FAGnC,UAAU,EAAA,UAAA,EAAA,CAAA;kBARtB,SAAS;+BACE,cAAc,EAAA,eAAA,EAGP,uBAAuB,CAAC,MAAM,EAAA,OAAA,EACtC,CAAC,YAAY,EAAE,sBAAsB,CAAC,EAAA,UAAA,EACnC,IAAI,EAAA,QAAA,EAAA,+pBAAA,EAAA,MAAA,EAAA,CAAA,oTAAA,CAAA,EAAA;;;AExBlB;;AAEG;;;;"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { input, signal, effect, computed, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
4
|
+
|
|
5
|
+
class SdAvatar {
|
|
6
|
+
/**
|
|
7
|
+
* The source string to be used for the avatar.
|
|
8
|
+
* - If it matches a URL pattern, an image is displayed.
|
|
9
|
+
* - If it is a string representing a name, initials and a colored background are generated.
|
|
10
|
+
* - If undefined, it falls back to a neutral ? initial.
|
|
11
|
+
*/
|
|
12
|
+
src = input.required();
|
|
13
|
+
size = input(32);
|
|
14
|
+
#imageError = signal(false);
|
|
15
|
+
constructor() {
|
|
16
|
+
// Reset image error state whenever src changes
|
|
17
|
+
effect(() => {
|
|
18
|
+
this.src();
|
|
19
|
+
this.#imageError.set(false);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
isUrl = computed(() => {
|
|
23
|
+
// If image has failed to load, treat it as a non-url to fallback to initials using the literal URL text
|
|
24
|
+
if (this.#imageError()) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
const val = this.src() || '';
|
|
28
|
+
const urlPattern = /^(http|https|data:image|\/)/;
|
|
29
|
+
return urlPattern.test(val);
|
|
30
|
+
});
|
|
31
|
+
bgColor = computed(() => {
|
|
32
|
+
if (this.isUrl()) {
|
|
33
|
+
return 'transparent';
|
|
34
|
+
}
|
|
35
|
+
const val = this.src() || '';
|
|
36
|
+
if (!val) {
|
|
37
|
+
return '#bdc3c7';
|
|
38
|
+
}
|
|
39
|
+
return this.#generateColor(val);
|
|
40
|
+
});
|
|
41
|
+
initials = computed(() => {
|
|
42
|
+
if (this.isUrl()) {
|
|
43
|
+
return '';
|
|
44
|
+
}
|
|
45
|
+
const val = this.src() || '';
|
|
46
|
+
if (!val) {
|
|
47
|
+
return '?';
|
|
48
|
+
}
|
|
49
|
+
return this.#getInitials(val);
|
|
50
|
+
});
|
|
51
|
+
handleError() {
|
|
52
|
+
this.#imageError.set(true);
|
|
53
|
+
}
|
|
54
|
+
#getInitials = (name) => {
|
|
55
|
+
const words = name.trim().split(' ').filter(Boolean);
|
|
56
|
+
if (!words.length)
|
|
57
|
+
return '';
|
|
58
|
+
if (words.length === 1)
|
|
59
|
+
return words[0][0].toUpperCase();
|
|
60
|
+
return (words[0][0] + words[words.length - 1][0]).toUpperCase();
|
|
61
|
+
};
|
|
62
|
+
#generateColor = (name) => {
|
|
63
|
+
const colors = [
|
|
64
|
+
'#1abc9c',
|
|
65
|
+
'#2ecc71',
|
|
66
|
+
'#3498db',
|
|
67
|
+
'#9b59b6',
|
|
68
|
+
'#34495e',
|
|
69
|
+
'#16a085',
|
|
70
|
+
'#27ae60',
|
|
71
|
+
'#2980b9',
|
|
72
|
+
'#8e44ad',
|
|
73
|
+
'#2c3e50',
|
|
74
|
+
'#f1c40f',
|
|
75
|
+
'#e67e22',
|
|
76
|
+
'#e74c3c',
|
|
77
|
+
'#95a5a6',
|
|
78
|
+
'#f39c12',
|
|
79
|
+
'#d35400',
|
|
80
|
+
'#c0392b',
|
|
81
|
+
'#bdc3c7',
|
|
82
|
+
'#7f8c8d',
|
|
83
|
+
];
|
|
84
|
+
let hash = 0;
|
|
85
|
+
for (let i = 0; i < name.length; i++) {
|
|
86
|
+
hash = name.charCodeAt(i) + ((hash << 5) - hash);
|
|
87
|
+
}
|
|
88
|
+
return colors[Math.abs(hash) % colors.length];
|
|
89
|
+
};
|
|
90
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdAvatar, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
91
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.17", type: SdAvatar, isStandalone: true, selector: "sd-avatar", inputs: { src: { classPropertyName: "src", publicName: "src", isSignal: true, isRequired: true, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<div class=\"sd-avatar\" [style.width.px]=\"size()\" [style.height.px]=\"size()\" [style.line-height.px]=\"size()\" [style.backgroundColor]=\"bgColor()\">\n @if (isUrl()) {\n <img [src]=\"src()\" (error)=\"handleError()\" alt=\"avatar\" />\n } @else {\n <span class=\"sd-avatar-text\" [style.fontSize.px]=\"size() / 2.5\">\n {{ initials() }}\n </span>\n }\n</div>\n", styles: [".sd-avatar{display:inline-flex;align-items:center;justify-content:center;border-radius:50%;overflow:hidden;color:#fff;font-weight:500;-webkit-user-select:none;user-select:none;background-size:cover}.sd-avatar img{width:100%;height:100%;object-fit:cover}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
92
|
+
}
|
|
93
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdAvatar, decorators: [{
|
|
94
|
+
type: Component,
|
|
95
|
+
args: [{ selector: 'sd-avatar', standalone: true, imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"sd-avatar\" [style.width.px]=\"size()\" [style.height.px]=\"size()\" [style.line-height.px]=\"size()\" [style.backgroundColor]=\"bgColor()\">\n @if (isUrl()) {\n <img [src]=\"src()\" (error)=\"handleError()\" alt=\"avatar\" />\n } @else {\n <span class=\"sd-avatar-text\" [style.fontSize.px]=\"size() / 2.5\">\n {{ initials() }}\n </span>\n }\n</div>\n", styles: [".sd-avatar{display:inline-flex;align-items:center;justify-content:center;border-radius:50%;overflow:hidden;color:#fff;font-weight:500;-webkit-user-select:none;user-select:none;background-size:cover}.sd-avatar img{width:100%;height:100%;object-fit:cover}\n"] }]
|
|
96
|
+
}], ctorParameters: () => [] });
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Generated bundle index. Do not edit.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
export { SdAvatar };
|
|
103
|
+
//# sourceMappingURL=sd-angular-core-components-avatar.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sd-angular-core-components-avatar.mjs","sources":["../../../projects/sd-angular/components/avatar/src/avatar.component.ts","../../../projects/sd-angular/components/avatar/src/avatar.component.html","../../../projects/sd-angular/components/avatar/sd-angular-core-components-avatar.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { ChangeDetectionStrategy, Component, computed, effect, input, signal } from '@angular/core';\n\n@Component({\n selector: 'sd-avatar',\n standalone: true,\n imports: [CommonModule],\n templateUrl: './avatar.component.html',\n styleUrls: ['./avatar.component.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class SdAvatar {\n /**\n * The source string to be used for the avatar.\n * - If it matches a URL pattern, an image is displayed.\n * - If it is a string representing a name, initials and a colored background are generated.\n * - If undefined, it falls back to a neutral ? initial.\n */\n readonly src = input.required<string | undefined | null>();\n readonly size = input<number>(32);\n\n readonly #imageError = signal<boolean>(false);\n\n constructor() {\n // Reset image error state whenever src changes\n effect(() => {\n this.src();\n this.#imageError.set(false);\n });\n }\n\n readonly isUrl = computed(() => {\n // If image has failed to load, treat it as a non-url to fallback to initials using the literal URL text\n if (this.#imageError()) {\n return false;\n }\n const val = this.src() || '';\n const urlPattern = /^(http|https|data:image|\\/)/;\n return urlPattern.test(val);\n });\n\n readonly bgColor = computed(() => {\n if (this.isUrl()) {\n return 'transparent';\n }\n const val = this.src() || '';\n if (!val) {\n return '#bdc3c7';\n }\n return this.#generateColor(val);\n });\n\n readonly initials = computed(() => {\n if (this.isUrl()) {\n return '';\n }\n const val = this.src() || '';\n if (!val) {\n return '?';\n }\n return this.#getInitials(val);\n });\n\n handleError() {\n this.#imageError.set(true);\n }\n\n #getInitials = (name: string): string => {\n const words = name.trim().split(' ').filter(Boolean);\n if (!words.length) return '';\n if (words.length === 1) return words[0][0].toUpperCase();\n return (words[0][0] + words[words.length - 1][0]).toUpperCase();\n };\n\n #generateColor = (name: string): string => {\n const colors = [\n '#1abc9c',\n '#2ecc71',\n '#3498db',\n '#9b59b6',\n '#34495e',\n '#16a085',\n '#27ae60',\n '#2980b9',\n '#8e44ad',\n '#2c3e50',\n '#f1c40f',\n '#e67e22',\n '#e74c3c',\n '#95a5a6',\n '#f39c12',\n '#d35400',\n '#c0392b',\n '#bdc3c7',\n '#7f8c8d',\n ];\n let hash = 0;\n for (let i = 0; i < name.length; i++) {\n hash = name.charCodeAt(i) + ((hash << 5) - hash);\n }\n return colors[Math.abs(hash) % colors.length];\n };\n}\n","<div class=\"sd-avatar\" [style.width.px]=\"size()\" [style.height.px]=\"size()\" [style.line-height.px]=\"size()\" [style.backgroundColor]=\"bgColor()\">\n @if (isUrl()) {\n <img [src]=\"src()\" (error)=\"handleError()\" alt=\"avatar\" />\n } @else {\n <span class=\"sd-avatar-text\" [style.fontSize.px]=\"size() / 2.5\">\n {{ initials() }}\n </span>\n }\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":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