@sdcorejs/angular 20.3.2 → 20.3.4
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/assets/THEME.md +58 -6
- package/assets/scss/core/form.scss +291 -3
- package/assets/scss/themes/_component-tokens.scss +35 -6
- package/components/badge/index.d.ts +19 -1
- package/components/query-bar/index.d.ts +126 -11
- package/components/section/index.d.ts +13 -1
- package/components/splitter/index.d.ts +1 -1
- package/components/tab-router/index.d.ts +47 -5
- package/components/table/index.d.ts +300 -25
- package/components/upload-file/index.d.ts +181 -21
- package/fesm2022/sdcorejs-angular-components-badge.mjs +2 -2
- package/fesm2022/sdcorejs-angular-components-badge.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-form-generic.mjs +3 -3
- package/fesm2022/sdcorejs-angular-components-form-generic.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-query-bar.mjs +460 -42
- package/fesm2022/sdcorejs-angular-components-query-bar.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-section.mjs +15 -3
- package/fesm2022/sdcorejs-angular-components-section.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-side-drawer.mjs +2 -2
- package/fesm2022/sdcorejs-angular-components-side-drawer.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-splitter.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-tab-router.mjs +393 -78
- package/fesm2022/sdcorejs-angular-components-tab-router.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-table.mjs +1669 -126
- package/fesm2022/sdcorejs-angular-components-table.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-upload-file.mjs +887 -174
- package/fesm2022/sdcorejs-angular-components-upload-file.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-autocomplete.mjs +7 -2
- package/fesm2022/sdcorejs-angular-forms-autocomplete.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-chip-calendar.mjs +5 -2
- package/fesm2022/sdcorejs-angular-forms-chip-calendar.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-chip.mjs +422 -122
- package/fesm2022/sdcorejs-angular-forms-chip.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-date-range.mjs +4 -0
- package/fesm2022/sdcorejs-angular-forms-date-range.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-date.mjs +4 -0
- package/fesm2022/sdcorejs-angular-forms-date.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-datetime.mjs +4 -0
- package/fesm2022/sdcorejs-angular-forms-datetime.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-input-number.mjs +17 -2
- package/fesm2022/sdcorejs-angular-forms-input-number.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-input.mjs +4 -0
- package/fesm2022/sdcorejs-angular-forms-input.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-select.mjs +26 -20
- package/fesm2022/sdcorejs-angular-forms-select.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-textarea.mjs +14 -1
- package/fesm2022/sdcorejs-angular-forms-textarea.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-i18n.mjs +350 -5
- package/fesm2022/sdcorejs-angular-i18n.mjs.map +1 -1
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-configuration.page-DnbDCdcz.mjs → sdcorejs-angular-modules-generic-generic-configuration.page-D_1BxDC9.mjs} +3 -3
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-configuration.page-DnbDCdcz.mjs.map → sdcorejs-angular-modules-generic-generic-configuration.page-D_1BxDC9.mjs.map} +1 -1
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-form-host.page-EBHM4kx2.mjs → sdcorejs-angular-modules-generic-generic-form-host.page-CgH8Qi25.mjs} +3 -3
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-form-host.page-EBHM4kx2.mjs.map → sdcorejs-angular-modules-generic-generic-form-host.page-CgH8Qi25.mjs.map} +1 -1
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-list.page-BtHe8YIW.mjs → sdcorejs-angular-modules-generic-generic-list.page-CyCGqW9W.mjs} +3 -3
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-list.page-BtHe8YIW.mjs.map → sdcorejs-angular-modules-generic-generic-list.page-CyCGqW9W.mjs.map} +1 -1
- package/fesm2022/{sdcorejs-angular-modules-generic-sdcorejs-angular-modules-generic-eFshU7ew.mjs → sdcorejs-angular-modules-generic-sdcorejs-angular-modules-generic-DTmU8Te4.mjs} +4 -4
- package/fesm2022/{sdcorejs-angular-modules-generic-sdcorejs-angular-modules-generic-eFshU7ew.mjs.map → sdcorejs-angular-modules-generic-sdcorejs-angular-modules-generic-DTmU8Te4.mjs.map} +1 -1
- package/fesm2022/sdcorejs-angular-modules-generic.mjs +1 -1
- package/fesm2022/sdcorejs-angular-modules-layout.mjs +348 -11
- package/fesm2022/sdcorejs-angular-modules-layout.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-modules-pattern-api-error-BBWwQ6h2.mjs +23 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-api-error-BBWwQ6h2.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-approval-inbox-BMwD6_FC.mjs +16 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-approval-inbox-BMwD6_FC.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-base-api.service-okZVmcd5.mjs +51 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-base-api.service-okZVmcd5.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create-side-drawer.component-CB4F9cBe.mjs +144 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create-side-drawer.component-CB4F9cBe.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create-side-drawer.component-CowdEzyv.mjs +145 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create-side-drawer.component-CowdEzyv.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-2-dyjvCH.mjs +113 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-2-dyjvCH.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-BCoG3bVV.mjs +142 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-BCoG3bVV.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-LPUj7MqG.mjs +460 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-LPUj7MqG.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-customer.model-C3fr4yNw.mjs +18 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-customer.model-C3fr4yNw.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-customer.service-Caua6Xto.mjs +66 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-customer.service-Caua6Xto.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail-side-drawer.component-Bu6E63bN.mjs +148 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail-side-drawer.component-Bu6E63bN.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-B2Y0PbbC.mjs +484 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-B2Y0PbbC.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-_c_4slgf.mjs +172 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-_c_4slgf.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-awjgX7ph.mjs +90 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-awjgX7ph.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-flow.component-C_HziBQN.mjs +514 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-flow.component-C_HziBQN.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-form-api-errors-FwmYVkag.mjs +61 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-form-api-errors-FwmYVkag.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-BRsdOwWy.mjs +87 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-BRsdOwWy.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-BttbZ_yr.mjs +170 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-BttbZ_yr.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-DalxHa8D.mjs +232 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-DalxHa8D.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-view.component-kdEZ9s7K.mjs +70 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-view.component-kdEZ9s7K.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-index.component-B2dNqckm.mjs +100 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-index.component-B2dNqckm.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-lines-table-form.component-Dq8Q8Vfm.mjs +812 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-lines-table-form.component-Dq8Q8Vfm.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-B3-th1z4.mjs +164 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-B3-th1z4.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-Bs9hhMr7.mjs +115 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-Bs9hhMr7.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-CRttQEXa.mjs +118 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-CRttQEXa.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-CeX57FPi.mjs +629 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-CeX57FPi.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-DS8A17mM.mjs +71 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-DS8A17mM.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-mock-backend.factory-Dfil91qL.mjs +1069 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-mock-backend.factory-Dfil91qL.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-pattern-source-viewer-BqHwKfoc.mjs +193 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-pattern-source-viewer-BqHwKfoc.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-pattern-source.generated-CIiLOizq.mjs +99 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-pattern-source.generated-CIiLOizq.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-product.model-BoHLJ8vf.mjs +12 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-product.model-BoHLJ8vf.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-product.service-PaIGZ1ve.mjs +48 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-product.service-PaIGZ1ve.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-profile.component-B8j8cieu.mjs +297 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-profile.component-B8j8cieu.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-0Vh73aXL.mjs +45 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-0Vh73aXL.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-BoB2usST.mjs +43 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-BoB2usST.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-CFLETqYK.mjs +66 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-CFLETqYK.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-CFT9DyKj.mjs +165 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-CFT9DyKj.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-CZusLcS3.mjs +74 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-CZusLcS3.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-Cq4BqjE9.mjs +99 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-Cq4BqjE9.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-Cw9uJySU.mjs +50 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-Cw9uJySU.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-nrxSHE-O.mjs +74 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-nrxSHE-O.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-sdcorejs-angular-modules-pattern-CJ6hUHjk.mjs +406 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-sdcorejs-angular-modules-pattern-CJ6hUHjk.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-shell.component-C_AFK_9X.mjs +317 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-shell.component-C_AFK_9X.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update-side-drawer.component-C74EEboR.mjs +143 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update-side-drawer.component-C74EEboR.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update-side-drawer.component-Dj9lvkCP.mjs +132 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update-side-drawer.component-Dj9lvkCP.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-B7H9pp-R.mjs +100 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-B7H9pp-R.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-Dhfba-qx.mjs +138 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-Dhfba-qx.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-hRTu79uE.mjs +359 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-hRTu79uE.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern.mjs +2 -0
- package/fesm2022/sdcorejs-angular-modules-pattern.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-services-api.mjs +11 -11
- package/fesm2022/sdcorejs-angular-services-api.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-cache.mjs +7 -5
- package/fesm2022/sdcorejs-angular-services-cache.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-storage.mjs +6 -4
- package/fesm2022/sdcorejs-angular-services-storage.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-unsaved-changes.mjs +104 -4
- package/fesm2022/sdcorejs-angular-services-unsaved-changes.mjs.map +1 -1
- package/forms/chip/index.d.ts +136 -26
- package/i18n/index.d.ts +70 -1
- package/modules/layout/index.d.ts +89 -6
- package/modules/pattern/README.md +76 -0
- package/modules/pattern/docs/detail.md +237 -0
- package/modules/pattern/docs/drawer.md +484 -0
- package/modules/pattern/docs/flow.md +631 -0
- package/modules/pattern/docs/form.md +815 -0
- package/modules/pattern/docs/header-actions.md +344 -0
- package/modules/pattern/docs/list.md +247 -0
- package/modules/pattern/docs/relation.md +180 -0
- package/modules/pattern/docs/select.md +214 -0
- package/modules/pattern/docs/split.md +350 -0
- package/modules/pattern/docs/states.md +168 -0
- package/modules/pattern/features/approval/entity.resolver.ts +21 -0
- package/modules/pattern/features/approval/pages/detail/detail.component.ts +139 -0
- package/modules/pattern/features/approval/pages/list/approval-inbox.ts +7 -0
- package/modules/pattern/features/approval/pages/list/list.component.html +20 -0
- package/modules/pattern/features/approval/pages/list/list.component.ts +149 -0
- package/modules/pattern/features/approval/routes.ts +30 -0
- package/modules/pattern/features/approval/services/approval.model.ts +38 -0
- package/modules/pattern/features/approval/services/approval.service.ts +23 -0
- package/modules/pattern/features/category/components/create-side-drawer/create-side-drawer.component.ts +130 -0
- package/modules/pattern/features/category/components/general-information-form/general-information-form.component.ts +61 -0
- package/modules/pattern/features/category/components/update-side-drawer/update-side-drawer.component.ts +134 -0
- package/modules/pattern/features/category/entity.resolver.ts +27 -0
- package/modules/pattern/features/category/pages/list/list.component.html +20 -0
- package/modules/pattern/features/category/pages/list/list.component.ts +105 -0
- package/modules/pattern/features/category/routes.ts +42 -0
- package/modules/pattern/features/category/services/category.model.ts +39 -0
- package/modules/pattern/features/category/services/category.service.ts +36 -0
- package/modules/pattern/features/customer/components/create-side-drawer/create-side-drawer.component.ts +138 -0
- package/modules/pattern/features/customer/components/customer-select/customer-select.component.ts +72 -0
- package/modules/pattern/features/customer/components/customer-type-select/customer-type-select.component.ts +30 -0
- package/modules/pattern/features/customer/components/debts-view/debts-view.component.ts +28 -0
- package/modules/pattern/features/customer/components/detail-side-drawer/detail-side-drawer.component.ts +106 -0
- package/modules/pattern/features/customer/components/documents-view/documents-view.component.ts +50 -0
- package/modules/pattern/features/customer/components/general-information-form/general-information-form.component.ts +140 -0
- package/modules/pattern/features/customer/components/general-information-view/general-information-view.component.ts +39 -0
- package/modules/pattern/features/customer/components/orders-view/orders-view.component.ts +35 -0
- package/modules/pattern/features/customer/components/summary-cards/summary-cards.component.ts +101 -0
- package/modules/pattern/features/customer/components/update-side-drawer/update-side-drawer.component.ts +127 -0
- package/modules/pattern/features/customer/entity.resolver.ts +21 -0
- package/modules/pattern/features/customer/pages/list/list.component.html +22 -0
- package/modules/pattern/features/customer/pages/list/list.component.ts +113 -0
- package/modules/pattern/features/customer/pages/profile/profile.component.ts +120 -0
- package/modules/pattern/features/customer/pipes/customer-detail.pipe.ts +18 -0
- package/modules/pattern/features/customer/routes.ts +59 -0
- package/modules/pattern/features/customer/services/customer.model.ts +87 -0
- package/modules/pattern/features/customer/services/customer.service.ts +79 -0
- package/modules/pattern/features/import/components/mapping-form/mapping-form.component.ts +41 -0
- package/modules/pattern/features/import/components/preview-view/preview-view.component.ts +44 -0
- package/modules/pattern/features/import/pages/flow/flow.component.ts +269 -0
- package/modules/pattern/features/import/routes.ts +19 -0
- package/modules/pattern/features/import/services/import.model.ts +82 -0
- package/modules/pattern/features/import/services/import.service.ts +18 -0
- package/modules/pattern/features/order/components/approval-steps/approval-steps.component.ts +74 -0
- package/modules/pattern/features/order/components/bulk-result/bulk-result.component.ts +46 -0
- package/modules/pattern/features/order/components/general-information-form/general-information-form.component.ts +96 -0
- package/modules/pattern/features/order/components/lines-form/lines-form.component.ts +182 -0
- package/modules/pattern/features/order/components/lines-form/order-lines.ts +101 -0
- package/modules/pattern/features/order/components/lines-table-form/lines-table-form.component.ts +196 -0
- package/modules/pattern/features/order/components/lines-view/lines-view.component.ts +42 -0
- package/modules/pattern/features/order/components/summary-cards/summary-cards.component.ts +128 -0
- package/modules/pattern/features/order/entity.resolver.ts +37 -0
- package/modules/pattern/features/order/pages/create/create.component.ts +113 -0
- package/modules/pattern/features/order/pages/detail/detail.component.ts +224 -0
- package/modules/pattern/features/order/pages/list/list.component.html +38 -0
- package/modules/pattern/features/order/pages/list/list.component.ts +291 -0
- package/modules/pattern/features/order/pages/update/update.component.ts +126 -0
- package/modules/pattern/features/order/routes.ts +54 -0
- package/modules/pattern/features/order/services/order.model.ts +109 -0
- package/modules/pattern/features/order/services/order.service.ts +63 -0
- package/modules/pattern/features/partner/pages/create/create.component.ts +324 -0
- package/modules/pattern/features/partner/routes.ts +20 -0
- package/modules/pattern/features/partner/services/partner.model.ts +30 -0
- package/modules/pattern/features/partner/services/partner.service.ts +17 -0
- package/modules/pattern/features/product/components/general-information-form/general-information-form.component.ts +88 -0
- package/modules/pattern/features/product/components/product-select/product-select.component.ts +73 -0
- package/modules/pattern/features/product/components/product-status-select/product-status-select.component.ts +30 -0
- package/modules/pattern/features/product/entity.resolver.ts +21 -0
- package/modules/pattern/features/product/pages/create/create.component.ts +92 -0
- package/modules/pattern/features/product/pages/detail/detail.component.ts +53 -0
- package/modules/pattern/features/product/pages/list/list.component.html +30 -0
- package/modules/pattern/features/product/pages/list/list.component.ts +71 -0
- package/modules/pattern/features/product/pages/update/update.component.ts +86 -0
- package/modules/pattern/features/product/pipes/product-detail.pipe.ts +18 -0
- package/modules/pattern/features/product/routes.ts +48 -0
- package/modules/pattern/features/product/services/product.model.ts +38 -0
- package/modules/pattern/features/product/services/product.service.ts +48 -0
- package/modules/pattern/features/settings/pages/update/update.component.ts +228 -0
- package/modules/pattern/features/settings/routes.ts +24 -0
- package/modules/pattern/features/settings/services/settings.model.ts +18 -0
- package/modules/pattern/features/settings/services/settings.service.ts +15 -0
- package/modules/pattern/features/settings/settings.resolver.ts +8 -0
- package/modules/pattern/index.d.ts +50 -0
- package/package.json +5 -1
- package/services/api/index.d.ts +5 -5
- package/services/cache/index.d.ts +4 -2
- package/services/storage/index.d.ts +3 -1
- package/services/unsaved-changes/index.d.ts +11 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, Injectable, inject, Pipe, ChangeDetectorRef, viewChild, signal, Input, ChangeDetectionStrategy, Component, DestroyRef,
|
|
2
|
+
import { InjectionToken, Injectable, inject, Pipe, ChangeDetectorRef, input, viewChild, signal, Input, ChangeDetectionStrategy, Component, DestroyRef, output, Injector, NgZone, model, ElementRef, computed, afterNextRender, effect, untracked, booleanAttribute, ErrorHandler, NgModuleFactory, createNgModule } from '@angular/core';
|
|
3
3
|
import { Router, RoutesRecognized, NavigationEnd, NavigationSkipped, NavigationCancel, NavigationError, NavigationSkippedCode, RouterOutlet, ActivatedRoute } from '@angular/router';
|
|
4
4
|
import * as i1$1 from '@angular/common';
|
|
5
5
|
import { CommonModule } from '@angular/common';
|
|
6
|
+
import { Title } from '@angular/platform-browser';
|
|
6
7
|
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
7
8
|
import { BehaviorSubject, Subscription, defer, EMPTY, isObservable, lastValueFrom, ReplaySubject } from 'rxjs';
|
|
8
9
|
import { debounceTime, startWith, filter, map, concatMap, catchError } from 'rxjs/operators';
|
|
@@ -156,6 +157,19 @@ class SdTabRouterService {
|
|
|
156
157
|
});
|
|
157
158
|
}
|
|
158
159
|
};
|
|
160
|
+
/**
|
|
161
|
+
* Đóng mọi tab trừ `tab` (mặc định tab hiện tại). Outlet chạy `beforeClose` của từng tab; tab trả về false thì được
|
|
162
|
+
* giữ lại. Tab hiện tại nằm trong số bị đóng thì `tab` được mở.
|
|
163
|
+
*/
|
|
164
|
+
closeOthers = (tab) => {
|
|
165
|
+
tab = tab || this.#currentTab;
|
|
166
|
+
if (tab) {
|
|
167
|
+
this.actions.next({
|
|
168
|
+
type: 'close-others',
|
|
169
|
+
tab,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
};
|
|
159
173
|
// Gọi hàm này để thực hiện update tab
|
|
160
174
|
updateTab = (tab) => { };
|
|
161
175
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdTabRouterService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -168,22 +182,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImpo
|
|
|
168
182
|
}]
|
|
169
183
|
}] });
|
|
170
184
|
|
|
171
|
-
class SdTabDecoratorService {
|
|
172
|
-
static tabRouterService = new BehaviorSubject(undefined);
|
|
173
|
-
constructor() {
|
|
174
|
-
const tabRouterService = inject(SdTabRouterService);
|
|
175
|
-
SdTabDecoratorService.tabRouterService.next(tabRouterService);
|
|
176
|
-
}
|
|
177
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdTabDecoratorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
178
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdTabDecoratorService, providedIn: 'root' });
|
|
179
|
-
}
|
|
180
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdTabDecoratorService, decorators: [{
|
|
181
|
-
type: Injectable,
|
|
182
|
-
args: [{
|
|
183
|
-
providedIn: 'root',
|
|
184
|
-
}]
|
|
185
|
-
}], ctorParameters: () => [] });
|
|
186
|
-
|
|
187
185
|
class SdTabInfoPipe {
|
|
188
186
|
tabRouterService = inject(SdTabRouterService);
|
|
189
187
|
constructor() { }
|
|
@@ -191,21 +189,7 @@ class SdTabInfoPipe {
|
|
|
191
189
|
if (tabInfo) {
|
|
192
190
|
return tabInfo;
|
|
193
191
|
}
|
|
194
|
-
|
|
195
|
-
const builder = builders.find(e => e.component === tab.component);
|
|
196
|
-
if (builder) {
|
|
197
|
-
const { url, params, queryParams, data } = tab;
|
|
198
|
-
return {
|
|
199
|
-
name: typeof builder.name === 'function' ? builder.name({ url, params, queryParams, data }) : builder.name,
|
|
200
|
-
icon: typeof builder.icon === 'function' ? builder.icon({ url, params, queryParams }) : builder.icon,
|
|
201
|
-
tooltip: typeof builder.tooltip === 'function' ? builder.tooltip({ url, params, queryParams }) : builder.tooltip,
|
|
202
|
-
color: typeof builder.color === 'function' ? builder.color({ url, params, queryParams }) : builder.color,
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
return {
|
|
206
|
-
name: tab.url,
|
|
207
|
-
icon: undefined,
|
|
208
|
-
};
|
|
192
|
+
return sdTabInfoFromBuilders(this.tabRouterService.builders.getValue(), tab);
|
|
209
193
|
}
|
|
210
194
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdTabInfoPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
211
195
|
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.25", ngImport: i0, type: SdTabInfoPipe, isStandalone: true, name: "sdTabInfo" });
|
|
@@ -217,12 +201,51 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImpo
|
|
|
217
201
|
standalone: true,
|
|
218
202
|
}]
|
|
219
203
|
}], ctorParameters: () => [] });
|
|
204
|
+
/**
|
|
205
|
+
* Thông tin tab từ `@SdTabComponent` của component trong tab, khi màn chưa gửi gì qua `tabInfoChanges`; không có builder
|
|
206
|
+
* thì tên là URL. Dùng chung cho tab trên thanh và tiêu đề trình duyệt (`syncBrowserTitle`). Nội bộ, không export ra
|
|
207
|
+
* entry point.
|
|
208
|
+
*/
|
|
209
|
+
function sdTabInfoFromBuilders(builders, tab) {
|
|
210
|
+
const builder = builders.find(e => e.component === tab.component);
|
|
211
|
+
if (builder) {
|
|
212
|
+
const { url, params, queryParams, data } = tab;
|
|
213
|
+
return {
|
|
214
|
+
name: typeof builder.name === 'function' ? builder.name({ url, params, queryParams, data }) : builder.name,
|
|
215
|
+
icon: typeof builder.icon === 'function' ? builder.icon({ url, params, queryParams }) : builder.icon,
|
|
216
|
+
tooltip: typeof builder.tooltip === 'function' ? builder.tooltip({ url, params, queryParams }) : builder.tooltip,
|
|
217
|
+
color: typeof builder.color === 'function' ? builder.color({ url, params, queryParams }) : builder.color,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
name: tab.url,
|
|
222
|
+
icon: undefined,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
class SdTabDecoratorService {
|
|
227
|
+
static tabRouterService = new BehaviorSubject(undefined);
|
|
228
|
+
constructor() {
|
|
229
|
+
const tabRouterService = inject(SdTabRouterService);
|
|
230
|
+
SdTabDecoratorService.tabRouterService.next(tabRouterService);
|
|
231
|
+
}
|
|
232
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdTabDecoratorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
233
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdTabDecoratorService, providedIn: 'root' });
|
|
234
|
+
}
|
|
235
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdTabDecoratorService, decorators: [{
|
|
236
|
+
type: Injectable,
|
|
237
|
+
args: [{
|
|
238
|
+
providedIn: 'root',
|
|
239
|
+
}]
|
|
240
|
+
}], ctorParameters: () => [] });
|
|
220
241
|
|
|
221
242
|
class SdTabRouterItemComponent {
|
|
222
243
|
cdRef = inject(ChangeDetectorRef);
|
|
223
244
|
tabRouterService = inject(SdTabRouterService);
|
|
224
245
|
router = inject(Router);
|
|
225
246
|
tab;
|
|
247
|
+
/** Tab này là điểm dừng Tab duy nhất của thanh (roving tabindex do nav chọn). */
|
|
248
|
+
focusable = input(false, ...(ngDevMode ? [{ debugName: "focusable" }] : []));
|
|
226
249
|
#subscription = new Subscription();
|
|
227
250
|
tabInfo;
|
|
228
251
|
nameRef = viewChild('name', ...(ngDevMode ? [{ debugName: "nameRef" }] : []));
|
|
@@ -256,6 +279,13 @@ class SdTabRouterItemComponent {
|
|
|
256
279
|
state: { switchTab: true },
|
|
257
280
|
});
|
|
258
281
|
};
|
|
282
|
+
// why: Enter/Space mở tab như bấm chuột. Chỉ khi chính tab nhận phím — Enter trên nút đóng (focus được bằng chuột) đã là
|
|
283
|
+
// click của nút đó.
|
|
284
|
+
onTabKeydown = (event) => {
|
|
285
|
+
if (event.target !== event.currentTarget)
|
|
286
|
+
return;
|
|
287
|
+
this.onTabClick(event);
|
|
288
|
+
};
|
|
259
289
|
close = (event) => {
|
|
260
290
|
event.preventDefault();
|
|
261
291
|
event.stopPropagation();
|
|
@@ -273,30 +303,22 @@ class SdTabRouterItemComponent {
|
|
|
273
303
|
this.#closeTab();
|
|
274
304
|
}
|
|
275
305
|
};
|
|
276
|
-
// why: trình duyệt mở link ở tab mới khi xử lý `auxclick` của chuột giữa, nên chỉ huỷ ở đây mới chặn được.
|
|
277
|
-
// Tab đã đóng ở `mouseup`; trước đây không mở tab mới chỉ vì <a> bị gỡ khỏi DOM trước `auxclick`, điều không
|
|
278
|
-
// còn đúng khi app bật `eventCoalescing`, chạy zoneless hay `beforeClose` chạy async.
|
|
279
|
-
onAuxclick = (event) => {
|
|
280
|
-
if (event.button === 1) {
|
|
281
|
-
event.preventDefault();
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
306
|
#closeTab = () => {
|
|
285
307
|
this.tabRouterService.close(this.tab);
|
|
286
308
|
};
|
|
287
309
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdTabRouterItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
288
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: SdTabRouterItemComponent, isStandalone: true, selector: "sd-tab-router-item", inputs: { tab: "tab" }, host: { properties: { "class.sd-tab-router-item--active": "tab.isActive" } }, viewQueries: [{ propertyName: "nameRef", first: true, predicate: ["name"], descendants: true, isSignal: true }], ngImport: i0, template: "<!-- why:
|
|
310
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: SdTabRouterItemComponent, isStandalone: true, selector: "sd-tab-router-item", inputs: { tab: { classPropertyName: "tab", publicName: "tab", isSignal: false, isRequired: true, transformFunction: null }, focusable: { classPropertyName: "focusable", publicName: "focusable", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.sd-tab-router-item--active": "tab.isActive" } }, viewQueries: [{ propertyName: "nameRef", first: true, predicate: ["name"], descendants: true, isSignal: true }], ngImport: i0, template: "@let info = tabInfo | sdTabInfo: tab;\n<!-- why: \u0111\u1EE3t 3 \u00B7 3c (Q\u0110 11) \u2014 ph\u1EA7n t\u1EED role=\"tab\" kh\u00F4ng href. V\u1EDBi <a href>, CDK drag ch\u1EB7n mousedown (th\u1EBB link k\u00E9o \u0111\u01B0\u1EE3c\n theo ki\u1EC3u native) n\u00EAn b\u1EA5m chu\u1ED9t kh\u00F4ng focus \u0111\u01B0\u1EE3c tab, v\u00E0 menu chu\u1ED9t ph\u1EA3i c\u1EE7a tr\u00ECnh duy\u1EC7t chi\u1EBFm ch\u1ED7 menu c\u1EE7a thanh.\n tabindex do nav ch\u1ECDn (roving: c\u1EA3 thanh m\u1ED9t \u0111i\u1EC3m d\u1EEBng Tab); \u2190/\u2192/Home/End/Delete v\u00E0 menu do nav x\u1EED l\u00FD. -->\n<div\n role=\"tab\"\n class=\"tab-router__item\"\n [class.tab-router__item--active]=\"tab.isActive\"\n [class.tab-router__item--dirty]=\"info.dirty\"\n [id]=\"'sd-tab-router-tab-' + tab.key\"\n [attr.aria-selected]=\"tab.isActive\"\n [attr.aria-controls]=\"tab.key\"\n [attr.tabindex]=\"focusable() ? 0 : -1\"\n [sdTooltip]=\"info.tooltip || (truncated() ? info.name : '')\"\n (mouseenter)=\"measureTruncation()\"\n (focusin)=\"measureTruncation()\"\n (click)=\"onTabClick($event)\"\n (keydown.enter)=\"onTabKeydown($event)\"\n (keydown.space)=\"onTabKeydown($event)\"\n (mousedown)=\"onMousedown($event)\"\n (mouseup)=\"onMouseup($event)\">\n <!-- why: \u0111\u1EE3t 3 \u00B7 3a b\u1ECF sd-badge \u2014 badge \u00E9p c\u1EE1 ch\u1EEF v\u00E0 chi\u1EC1u r\u1ED9ng ri\u00EAng, v\u00E0 t\u1EF1 hi\u1EC7n ch\u1EA5m khi tab kh\u00F4ng c\u00F3 icon. -->\n @if (info.icon) {\n <sd-icon class=\"tab-router__icon c-{{ info.color || 'primary' }}\" aria-hidden=\"true\" size=\"16px\" [fontIcon]=\"info.icon\"></sd-icon>\n }\n <span #name class=\"tab-router__name\">{{ info.name }}</span>\n @if (info.dirty) {\n <span class=\"sd-visually-hidden\">{{ 'core.component.tab-router.unsaved' | sdTranslate }}</span>\n }\n <!-- why: n\u00FAt \u0111\u00F3ng l\u00E0 <button> th\u1EADt c\u00F3 nh\u00E3n i18n, nh\u01B0ng tabindex=\"-1\" \u2014 b\u00E0n ph\u00EDm \u0111\u00F3ng tab b\u1EB1ng Delete tr\u00EAn tab, n\u00EAn\n n\u00FAt kh\u00F4ng th\u00EAm \u0111i\u1EC3m d\u1EEBng Tab th\u1EE9 hai cho m\u1ED7i tab. -->\n <button\n type=\"button\"\n class=\"tab-router__close\"\n tabindex=\"-1\"\n [attr.aria-label]=\"'core.common.close' | sdTranslate\"\n (click)=\"close($event)\"\n (mousedown)=\"$event.stopPropagation()\">\n <!-- why: \u0111\u1EE3t 3 \u00B7 3d \u2014 ch\u1EA5m \"ch\u01B0a l\u01B0u\" n\u1EB1m \u1EDF ch\u1ED7 n\u00FAt \u0111\u00F3ng; hover ho\u1EB7c focus b\u00E0n ph\u00EDm th\u00EC ch\u1EA5m \u0111\u1ED5i th\u00E0nh n\u00FAt \u0111\u00F3ng. -->\n @if (info.dirty) {\n <span class=\"tab-router__dirty\" aria-hidden=\"true\"></span>\n }\n <!-- Icon thu\u1EA7n trang tr\u00ED \u2014 n\u00FAt \u0111\u00E3 c\u00F3 aria-label n\u00EAn gi\u1EEF aria-hidden \u1EDF \u0111\u00E2y l\u00E0 \u0111\u00FAng. -->\n <sd-icon aria-hidden=\"true\" size=\"14px\" fontIcon=\"close\"></sd-icon>\n </button>\n</div>\n", styles: [":host{position:relative;display:flex;flex:0 1 200px;min-width:120px}:host:after{content:\"\";position:absolute;right:0;bottom:9px;width:1px;height:16px;background:var(--sd-tab-router-item-divider);pointer-events:none}:host:last-child:after{content:none}.tab-router__item{display:flex;flex:1 1 auto;align-items:center;gap:8px;min-width:0;height:34px;padding:0 6px 0 12px;border-radius:8px 8px 0 0;box-sizing:border-box;color:var(--sd-tab-router-item-text);font-size:var(--sd-font-size-13, 13px);line-height:18px;text-decoration:none;cursor:pointer}.tab-router__item:hover{background:var(--sd-tab-router-item-hover-bg)}.tab-router__item:focus-visible{outline:var(--sd-focus-ring-width, 2px) solid var(--sd-focus-ring-color, var(--sd-primary));outline-offset:-2px}.tab-router__item--active{background:var(--sd-tab-router-item-active-bg);color:var(--sd-text);font-weight:500}.tab-router__item--active:hover{background:var(--sd-tab-router-item-active-bg)}@media(forced-colors:active){.tab-router__item--active{outline:1px solid CanvasText;outline-offset:-1px}}.tab-router__icon.c-primary{color:var(--sd-primary-dark)}.tab-router__icon.c-secondary{color:var(--sd-secondary-dark)}.tab-router__icon.c-info{color:var(--sd-info-dark)}.tab-router__icon.c-success{color:var(--sd-success-dark)}.tab-router__icon.c-warning{color:var(--sd-warning-dark)}.tab-router__icon.c-error{color:var(--sd-error-dark)}.tab-router__name{flex:1 1 auto;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.tab-router__close{display:flex;flex:0 0 auto;align-items:center;justify-content:center;position:relative;width:20px;height:20px;padding:0;border:0;border-radius:6px;background:none;color:var(--sd-tab-router-item-text);cursor:pointer;opacity:0}.tab-router__close:hover{background:color-mix(in srgb,var(--sd-text) 8%,transparent)}.tab-router__close:focus-visible{opacity:1;outline:var(--sd-focus-ring-width, 2px) solid var(--sd-focus-ring-color, var(--sd-primary));outline-offset:-2px}.tab-router__item--active .tab-router__close,.tab-router__item:hover .tab-router__close,.tab-router__item:focus-visible .tab-router__close{opacity:1}@media(pointer:coarse){.tab-router__close{opacity:1}.tab-router__close:before{content:\"\";position:absolute;inset:-6px}}:host(.cdk-drag-preview){overflow:visible}:host(.cdk-drag-preview):after{content:none}:host(.cdk-drag-preview) .tab-router__item{border-radius:8px;background:var(--sd-surface);color:var(--sd-text);box-shadow:var(--sd-shadow-md, none);cursor:grabbing}:host(.cdk-drag-placeholder):after{opacity:0}:host(.cdk-drag-placeholder) .tab-router__item{background:color-mix(in srgb,var(--sd-primary) 12%,transparent);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--sd-primary) 35%,transparent)}:host(.cdk-drag-placeholder) .tab-router__item>*{visibility:hidden}@media(forced-colors:active){:host(.cdk-drag-placeholder) .tab-router__item{outline:1px dashed CanvasText;outline-offset:-1px}}.tab-router__dirty{position:absolute;top:50%;left:50%;width:8px;height:8px;margin:-4px 0 0 -4px;border-radius:50%;background:var(--sd-text-secondary);pointer-events:none}.tab-router__item--dirty .tab-router__close{opacity:1}.tab-router__item--dirty .tab-router__close sd-icon{opacity:0}.tab-router__item--dirty:hover .tab-router__dirty,.tab-router__item--dirty:focus-visible .tab-router__dirty,.tab-router__item--dirty .tab-router__close:focus-visible .tab-router__dirty{opacity:0}.tab-router__item--dirty:hover .tab-router__close sd-icon,.tab-router__item--dirty:focus-visible .tab-router__close sd-icon,.tab-router__item--dirty .tab-router__close:focus-visible sd-icon{opacity:1}@media(forced-colors:active){.tab-router__dirty{background:CanvasText}}\n"], dependencies: [{ kind: "component", type: SdIcon, selector: "sd-icon", inputs: ["name", "fontIcon", "color", "set", "fontSet", "size", "strokeWidth", "absoluteStrokeWidth", "ariaLabel"] }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: SdTooltipDirective, selector: "[sdTooltip]", inputs: ["sdTooltip", "sdTooltipPosition", "sdTooltipDelay", "sdTooltipColor"] }, { kind: "pipe", type: SdTabInfoPipe, name: "sdTabInfo" }, { kind: "pipe", type: SdTranslatePipe, name: "sdTranslate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
289
311
|
}
|
|
290
312
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdTabRouterItemComponent, decorators: [{
|
|
291
313
|
type: Component,
|
|
292
314
|
args: [{ selector: 'sd-tab-router-item', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [SdIcon, CommonModule, SdTabInfoPipe, SdTooltipDirective, SdTranslatePipe], host: {
|
|
293
315
|
// why: nav cần biết tab nào đang mở trên chính phần tử host để ẩn vạch ngăn ở hai bên nó.
|
|
294
316
|
'[class.sd-tab-router-item--active]': 'tab.isActive',
|
|
295
|
-
}, template: "<!-- why:
|
|
317
|
+
}, template: "@let info = tabInfo | sdTabInfo: tab;\n<!-- why: \u0111\u1EE3t 3 \u00B7 3c (Q\u0110 11) \u2014 ph\u1EA7n t\u1EED role=\"tab\" kh\u00F4ng href. V\u1EDBi <a href>, CDK drag ch\u1EB7n mousedown (th\u1EBB link k\u00E9o \u0111\u01B0\u1EE3c\n theo ki\u1EC3u native) n\u00EAn b\u1EA5m chu\u1ED9t kh\u00F4ng focus \u0111\u01B0\u1EE3c tab, v\u00E0 menu chu\u1ED9t ph\u1EA3i c\u1EE7a tr\u00ECnh duy\u1EC7t chi\u1EBFm ch\u1ED7 menu c\u1EE7a thanh.\n tabindex do nav ch\u1ECDn (roving: c\u1EA3 thanh m\u1ED9t \u0111i\u1EC3m d\u1EEBng Tab); \u2190/\u2192/Home/End/Delete v\u00E0 menu do nav x\u1EED l\u00FD. -->\n<div\n role=\"tab\"\n class=\"tab-router__item\"\n [class.tab-router__item--active]=\"tab.isActive\"\n [class.tab-router__item--dirty]=\"info.dirty\"\n [id]=\"'sd-tab-router-tab-' + tab.key\"\n [attr.aria-selected]=\"tab.isActive\"\n [attr.aria-controls]=\"tab.key\"\n [attr.tabindex]=\"focusable() ? 0 : -1\"\n [sdTooltip]=\"info.tooltip || (truncated() ? info.name : '')\"\n (mouseenter)=\"measureTruncation()\"\n (focusin)=\"measureTruncation()\"\n (click)=\"onTabClick($event)\"\n (keydown.enter)=\"onTabKeydown($event)\"\n (keydown.space)=\"onTabKeydown($event)\"\n (mousedown)=\"onMousedown($event)\"\n (mouseup)=\"onMouseup($event)\">\n <!-- why: \u0111\u1EE3t 3 \u00B7 3a b\u1ECF sd-badge \u2014 badge \u00E9p c\u1EE1 ch\u1EEF v\u00E0 chi\u1EC1u r\u1ED9ng ri\u00EAng, v\u00E0 t\u1EF1 hi\u1EC7n ch\u1EA5m khi tab kh\u00F4ng c\u00F3 icon. -->\n @if (info.icon) {\n <sd-icon class=\"tab-router__icon c-{{ info.color || 'primary' }}\" aria-hidden=\"true\" size=\"16px\" [fontIcon]=\"info.icon\"></sd-icon>\n }\n <span #name class=\"tab-router__name\">{{ info.name }}</span>\n @if (info.dirty) {\n <span class=\"sd-visually-hidden\">{{ 'core.component.tab-router.unsaved' | sdTranslate }}</span>\n }\n <!-- why: n\u00FAt \u0111\u00F3ng l\u00E0 <button> th\u1EADt c\u00F3 nh\u00E3n i18n, nh\u01B0ng tabindex=\"-1\" \u2014 b\u00E0n ph\u00EDm \u0111\u00F3ng tab b\u1EB1ng Delete tr\u00EAn tab, n\u00EAn\n n\u00FAt kh\u00F4ng th\u00EAm \u0111i\u1EC3m d\u1EEBng Tab th\u1EE9 hai cho m\u1ED7i tab. -->\n <button\n type=\"button\"\n class=\"tab-router__close\"\n tabindex=\"-1\"\n [attr.aria-label]=\"'core.common.close' | sdTranslate\"\n (click)=\"close($event)\"\n (mousedown)=\"$event.stopPropagation()\">\n <!-- why: \u0111\u1EE3t 3 \u00B7 3d \u2014 ch\u1EA5m \"ch\u01B0a l\u01B0u\" n\u1EB1m \u1EDF ch\u1ED7 n\u00FAt \u0111\u00F3ng; hover ho\u1EB7c focus b\u00E0n ph\u00EDm th\u00EC ch\u1EA5m \u0111\u1ED5i th\u00E0nh n\u00FAt \u0111\u00F3ng. -->\n @if (info.dirty) {\n <span class=\"tab-router__dirty\" aria-hidden=\"true\"></span>\n }\n <!-- Icon thu\u1EA7n trang tr\u00ED \u2014 n\u00FAt \u0111\u00E3 c\u00F3 aria-label n\u00EAn gi\u1EEF aria-hidden \u1EDF \u0111\u00E2y l\u00E0 \u0111\u00FAng. -->\n <sd-icon aria-hidden=\"true\" size=\"14px\" fontIcon=\"close\"></sd-icon>\n </button>\n</div>\n", styles: [":host{position:relative;display:flex;flex:0 1 200px;min-width:120px}:host:after{content:\"\";position:absolute;right:0;bottom:9px;width:1px;height:16px;background:var(--sd-tab-router-item-divider);pointer-events:none}:host:last-child:after{content:none}.tab-router__item{display:flex;flex:1 1 auto;align-items:center;gap:8px;min-width:0;height:34px;padding:0 6px 0 12px;border-radius:8px 8px 0 0;box-sizing:border-box;color:var(--sd-tab-router-item-text);font-size:var(--sd-font-size-13, 13px);line-height:18px;text-decoration:none;cursor:pointer}.tab-router__item:hover{background:var(--sd-tab-router-item-hover-bg)}.tab-router__item:focus-visible{outline:var(--sd-focus-ring-width, 2px) solid var(--sd-focus-ring-color, var(--sd-primary));outline-offset:-2px}.tab-router__item--active{background:var(--sd-tab-router-item-active-bg);color:var(--sd-text);font-weight:500}.tab-router__item--active:hover{background:var(--sd-tab-router-item-active-bg)}@media(forced-colors:active){.tab-router__item--active{outline:1px solid CanvasText;outline-offset:-1px}}.tab-router__icon.c-primary{color:var(--sd-primary-dark)}.tab-router__icon.c-secondary{color:var(--sd-secondary-dark)}.tab-router__icon.c-info{color:var(--sd-info-dark)}.tab-router__icon.c-success{color:var(--sd-success-dark)}.tab-router__icon.c-warning{color:var(--sd-warning-dark)}.tab-router__icon.c-error{color:var(--sd-error-dark)}.tab-router__name{flex:1 1 auto;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.tab-router__close{display:flex;flex:0 0 auto;align-items:center;justify-content:center;position:relative;width:20px;height:20px;padding:0;border:0;border-radius:6px;background:none;color:var(--sd-tab-router-item-text);cursor:pointer;opacity:0}.tab-router__close:hover{background:color-mix(in srgb,var(--sd-text) 8%,transparent)}.tab-router__close:focus-visible{opacity:1;outline:var(--sd-focus-ring-width, 2px) solid var(--sd-focus-ring-color, var(--sd-primary));outline-offset:-2px}.tab-router__item--active .tab-router__close,.tab-router__item:hover .tab-router__close,.tab-router__item:focus-visible .tab-router__close{opacity:1}@media(pointer:coarse){.tab-router__close{opacity:1}.tab-router__close:before{content:\"\";position:absolute;inset:-6px}}:host(.cdk-drag-preview){overflow:visible}:host(.cdk-drag-preview):after{content:none}:host(.cdk-drag-preview) .tab-router__item{border-radius:8px;background:var(--sd-surface);color:var(--sd-text);box-shadow:var(--sd-shadow-md, none);cursor:grabbing}:host(.cdk-drag-placeholder):after{opacity:0}:host(.cdk-drag-placeholder) .tab-router__item{background:color-mix(in srgb,var(--sd-primary) 12%,transparent);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--sd-primary) 35%,transparent)}:host(.cdk-drag-placeholder) .tab-router__item>*{visibility:hidden}@media(forced-colors:active){:host(.cdk-drag-placeholder) .tab-router__item{outline:1px dashed CanvasText;outline-offset:-1px}}.tab-router__dirty{position:absolute;top:50%;left:50%;width:8px;height:8px;margin:-4px 0 0 -4px;border-radius:50%;background:var(--sd-text-secondary);pointer-events:none}.tab-router__item--dirty .tab-router__close{opacity:1}.tab-router__item--dirty .tab-router__close sd-icon{opacity:0}.tab-router__item--dirty:hover .tab-router__dirty,.tab-router__item--dirty:focus-visible .tab-router__dirty,.tab-router__item--dirty .tab-router__close:focus-visible .tab-router__dirty{opacity:0}.tab-router__item--dirty:hover .tab-router__close sd-icon,.tab-router__item--dirty:focus-visible .tab-router__close sd-icon,.tab-router__item--dirty .tab-router__close:focus-visible sd-icon{opacity:1}@media(forced-colors:active){.tab-router__dirty{background:CanvasText}}\n"] }]
|
|
296
318
|
}], ctorParameters: () => [], propDecorators: { tab: [{
|
|
297
319
|
type: Input,
|
|
298
320
|
args: [{ required: true }]
|
|
299
|
-
}], nameRef: [{ type: i0.ViewChild, args: ['name', { isSignal: true }] }] } });
|
|
321
|
+
}], focusable: [{ type: i0.Input, args: [{ isSignal: true, alias: "focusable", required: false }] }], nameRef: [{ type: i0.ViewChild, args: ['name', { isSignal: true }] }] } });
|
|
300
322
|
|
|
301
323
|
let nextId = 0;
|
|
302
324
|
/** Một hàng của menu danh sách tab (đợt 3 · 3b): icon, tên và nút đóng hiện khi hover. Nội bộ, không export. */
|
|
@@ -333,22 +355,56 @@ class SdTabRouterNavComponent {
|
|
|
333
355
|
#tabRouterService = inject(SdTabRouterService);
|
|
334
356
|
#injector = inject(Injector);
|
|
335
357
|
#zone = inject(NgZone);
|
|
336
|
-
|
|
358
|
+
// why: model, không phải input — kéo thả phát một mảng mới qua `tabsChange` (outlet bind `[(tabs)]`) thay vì sửa thẳng
|
|
359
|
+
// mảng outlet đang giữ.
|
|
360
|
+
tabs = model([], ...(ngDevMode ? [{ debugName: "tabs" }] : []));
|
|
337
361
|
elementRef = inject(ElementRef);
|
|
338
362
|
scroller = viewChild.required('scroller');
|
|
339
363
|
listButton = viewChild('listButton', ...(ngDevMode ? [{ debugName: "listButton" }] : []));
|
|
364
|
+
contextMenu = viewChild('contextMenu', ...(ngDevMode ? [{ debugName: "contextMenu" }] : []));
|
|
340
365
|
/** Tổng `min-width` của các tab vượt bề rộng thanh: thanh cuộn ngang và có nút danh sách tab. */
|
|
341
366
|
overflowing = signal(false, ...(ngDevMode ? [{ debugName: "overflowing" }] : []));
|
|
342
367
|
/** Còn tab khuất ở cạnh đầu / cạnh cuối: hiện lớp mờ ở cạnh đó. */
|
|
343
368
|
fadeStart = signal(false, ...(ngDevMode ? [{ debugName: "fadeStart" }] : []));
|
|
344
369
|
fadeEnd = signal(false, ...(ngDevMode ? [{ debugName: "fadeEnd" }] : []));
|
|
345
370
|
listOpen = signal(false, ...(ngDevMode ? [{ debugName: "listOpen" }] : []));
|
|
371
|
+
menu = signal(null, ...(ngDevMode ? [{ debugName: "menu" }] : []));
|
|
372
|
+
/** Tab vừa nhận focus bằng phím mũi tên; `null` khi focus đã rời thanh. */
|
|
373
|
+
#focusKey = signal(null, ...(ngDevMode ? [{ debugName: "#focusKey" }] : []));
|
|
374
|
+
/**
|
|
375
|
+
* Roving tabindex: điểm dừng Tab duy nhất của thanh. Là tab đang có focus khi người dùng di chuyển bằng phím, nếu
|
|
376
|
+
* không thì tab đang mở (focus vào lại thanh luôn rơi vào tab đang mở).
|
|
377
|
+
*/
|
|
378
|
+
tabStopKey = computed(() => {
|
|
379
|
+
const tabs = this.tabs();
|
|
380
|
+
const key = this.#focusKey();
|
|
381
|
+
if (key && tabs.some(tab => tab.key === key))
|
|
382
|
+
return key;
|
|
383
|
+
return (tabs.find(tab => tab.isActive) ?? tabs[0])?.key ?? null;
|
|
384
|
+
}, ...(ngDevMode ? [{ debugName: "tabStopKey" }] : []));
|
|
346
385
|
// why: menu treo dưới cả khối nút (cao bằng thanh 40px) cách 4px, mép phải thẳng mép phải nút (khối có đệm phải 6px).
|
|
347
386
|
listPositions = [
|
|
348
387
|
{ originX: 'end', originY: 'bottom', overlayX: 'end', overlayY: 'top', offsetX: -6, offsetY: 4 },
|
|
349
388
|
{ originX: 'end', originY: 'top', overlayX: 'end', overlayY: 'bottom', offsetX: -6, offsetY: -4 },
|
|
350
389
|
];
|
|
390
|
+
/** Menu chuột phải mở bằng bàn phím: dưới tab, thẳng mép trái. */
|
|
391
|
+
menuAtTab = [
|
|
392
|
+
{ originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top', offsetY: 4 },
|
|
393
|
+
{ originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom', offsetY: -4 },
|
|
394
|
+
];
|
|
395
|
+
/** Menu chuột phải mở bằng chuột: góc trên trái tại con trỏ, lật khi chạm mép màn hình. */
|
|
396
|
+
#menuAtPointer = [
|
|
397
|
+
{ originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'top' },
|
|
398
|
+
{ originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom' },
|
|
399
|
+
{ originX: 'start', originY: 'top', overlayX: 'end', overlayY: 'top' },
|
|
400
|
+
{ originX: 'start', originY: 'top', overlayX: 'end', overlayY: 'bottom' },
|
|
401
|
+
];
|
|
351
402
|
#activeKey;
|
|
403
|
+
// Focus trong thanh: tab cuối cùng có focus, và focus còn ở trong thanh hay không. Khi tab đó bị gỡ khỏi DOM (đóng
|
|
404
|
+
// bằng Delete, menu, nút đóng) trình duyệt đưa focus về body — thanh đưa focus sang tab kế bên.
|
|
405
|
+
#lastFocusedKey;
|
|
406
|
+
#focusWithin = false;
|
|
407
|
+
#previousTabs = [];
|
|
352
408
|
constructor() {
|
|
353
409
|
const destroyRef = inject(DestroyRef);
|
|
354
410
|
afterNextRender(() => {
|
|
@@ -373,13 +429,19 @@ class SdTabRouterNavComponent {
|
|
|
373
429
|
resize?.disconnect();
|
|
374
430
|
});
|
|
375
431
|
});
|
|
376
|
-
// Danh sách tab đổi: đo lại sau khi DOM đã có tab mới, rồi cuộn tới tab đang mở nếu nó vừa đổi.
|
|
432
|
+
// Danh sách tab đổi: đo lại sau khi DOM đã có tab mới, rồi cuộn tới tab đang mở nếu nó vừa đổi. Tab đang có focus
|
|
433
|
+
// vừa bị đóng thì focus sang tab bên phải nó, không có thì bên trái.
|
|
377
434
|
effect(() => {
|
|
378
435
|
const tabs = this.tabs();
|
|
379
|
-
untracked(() =>
|
|
380
|
-
this.#
|
|
381
|
-
|
|
382
|
-
|
|
436
|
+
untracked(() => {
|
|
437
|
+
const refocus = this.#neighbourOfClosedFocus(tabs);
|
|
438
|
+
afterNextRender(() => {
|
|
439
|
+
this.#measure();
|
|
440
|
+
this.#revealActive(tabs);
|
|
441
|
+
if (refocus)
|
|
442
|
+
this.#refocus(refocus);
|
|
443
|
+
}, { injector: this.#injector });
|
|
444
|
+
});
|
|
383
445
|
});
|
|
384
446
|
}
|
|
385
447
|
toggleList = () => {
|
|
@@ -410,7 +472,185 @@ class SdTabRouterNavComponent {
|
|
|
410
472
|
this.#tabRouterService.close(tab);
|
|
411
473
|
};
|
|
412
474
|
onDrop = (event) => {
|
|
413
|
-
|
|
475
|
+
if (event.previousIndex === event.currentIndex)
|
|
476
|
+
return;
|
|
477
|
+
const tabs = [...this.tabs()];
|
|
478
|
+
moveItemInArray(tabs, event.previousIndex, event.currentIndex);
|
|
479
|
+
this.tabs.set(tabs);
|
|
480
|
+
};
|
|
481
|
+
// Bàn phím của tablist (WAI-ARIA tabs, kích hoạt thủ công): ←/→ chuyển focus (quay vòng ở hai đầu), Home/End về
|
|
482
|
+
// đầu/cuối, Delete đóng, Shift+F10 / phím Menu mở menu chuột phải. Enter/Space mở tab nằm trên chính tab.
|
|
483
|
+
onKeydown = (event) => {
|
|
484
|
+
const index = this.#indexOf(event.target);
|
|
485
|
+
const tabs = this.tabs();
|
|
486
|
+
if (index < 0 || !tabs[index])
|
|
487
|
+
return;
|
|
488
|
+
const last = tabs.length - 1;
|
|
489
|
+
let next;
|
|
490
|
+
switch (event.key) {
|
|
491
|
+
case 'ArrowRight':
|
|
492
|
+
next = index === last ? 0 : index + 1;
|
|
493
|
+
break;
|
|
494
|
+
case 'ArrowLeft':
|
|
495
|
+
next = index === 0 ? last : index - 1;
|
|
496
|
+
break;
|
|
497
|
+
case 'Home':
|
|
498
|
+
next = 0;
|
|
499
|
+
break;
|
|
500
|
+
case 'End':
|
|
501
|
+
next = last;
|
|
502
|
+
break;
|
|
503
|
+
case 'Delete':
|
|
504
|
+
event.preventDefault();
|
|
505
|
+
this.#tabRouterService.close(tabs[index]);
|
|
506
|
+
return;
|
|
507
|
+
case 'ContextMenu':
|
|
508
|
+
case 'F10':
|
|
509
|
+
if (event.key === 'F10' && !event.shiftKey)
|
|
510
|
+
return;
|
|
511
|
+
event.preventDefault();
|
|
512
|
+
this.#openMenuAtTab(index);
|
|
513
|
+
return;
|
|
514
|
+
default:
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
event.preventDefault();
|
|
518
|
+
this.#focusTab(next);
|
|
519
|
+
};
|
|
520
|
+
onFocusin = (event) => {
|
|
521
|
+
const tab = this.tabs()[this.#indexOf(event.target)];
|
|
522
|
+
if (!tab)
|
|
523
|
+
return;
|
|
524
|
+
this.#focusKey.set(tab.key);
|
|
525
|
+
this.#lastFocusedKey = tab.key;
|
|
526
|
+
this.#focusWithin = true;
|
|
527
|
+
};
|
|
528
|
+
// why: focus rời thanh (sang phần tử khác) thì điểm dừng Tab trở về tab đang mở. `relatedTarget` null là focus về
|
|
529
|
+
// body — có thể vì chính tab đang focus vừa bị gỡ khỏi DOM, nên vẫn nhớ tab đó để đưa focus sang tab kế bên.
|
|
530
|
+
onFocusout = (event) => {
|
|
531
|
+
const next = event.relatedTarget;
|
|
532
|
+
if (next && this.scroller().nativeElement.contains(next))
|
|
533
|
+
return;
|
|
534
|
+
this.#focusKey.set(null);
|
|
535
|
+
if (next)
|
|
536
|
+
this.#focusWithin = false;
|
|
537
|
+
};
|
|
538
|
+
onContextmenu = (event) => {
|
|
539
|
+
const index = this.#indexOf(event.target);
|
|
540
|
+
const tab = this.tabs()[index];
|
|
541
|
+
if (!tab)
|
|
542
|
+
return;
|
|
543
|
+
event.preventDefault();
|
|
544
|
+
// why: Shift+F10 / phím Menu đã mở menu ở `keydown`; `contextmenu` trình duyệt phát tiếp theo không mở lại.
|
|
545
|
+
const open = this.menu();
|
|
546
|
+
if (open?.byKeyboard && open.tab.key === tab.key && event.button !== 2)
|
|
547
|
+
return;
|
|
548
|
+
if (event.button !== 2) {
|
|
549
|
+
this.#openMenuAtTab(index);
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
this.menu.set({ tab, origin: { x: event.clientX, y: event.clientY }, positions: this.#menuAtPointer, byKeyboard: false });
|
|
553
|
+
};
|
|
554
|
+
/** Menu vừa gắn vào overlay: focus mục đầu. */
|
|
555
|
+
focusMenu = () => {
|
|
556
|
+
afterNextRender(() => this.#menuItems()[0]?.focus(), { injector: this.#injector });
|
|
557
|
+
};
|
|
558
|
+
closeMenu = (restoreFocus = true) => {
|
|
559
|
+
const open = this.menu();
|
|
560
|
+
if (!open)
|
|
561
|
+
return;
|
|
562
|
+
this.menu.set(null);
|
|
563
|
+
if (restoreFocus)
|
|
564
|
+
this.#focusTab(this.tabs().findIndex(tab => tab.key === open.tab.key));
|
|
565
|
+
};
|
|
566
|
+
// ↑/↓ (quay vòng), Home/End giữa các mục; Esc hoặc Tab đóng menu và trả focus về tab.
|
|
567
|
+
onMenuKeydown = (event) => {
|
|
568
|
+
const items = this.#menuItems();
|
|
569
|
+
const index = items.indexOf(document.activeElement);
|
|
570
|
+
let next;
|
|
571
|
+
switch (event.key) {
|
|
572
|
+
case 'ArrowDown':
|
|
573
|
+
next = index + 1 >= items.length ? 0 : index + 1;
|
|
574
|
+
break;
|
|
575
|
+
case 'ArrowUp':
|
|
576
|
+
next = index <= 0 ? items.length - 1 : index - 1;
|
|
577
|
+
break;
|
|
578
|
+
case 'Home':
|
|
579
|
+
next = 0;
|
|
580
|
+
break;
|
|
581
|
+
case 'End':
|
|
582
|
+
next = items.length - 1;
|
|
583
|
+
break;
|
|
584
|
+
case 'Escape':
|
|
585
|
+
case 'Esc':
|
|
586
|
+
case 'Tab':
|
|
587
|
+
event.preventDefault();
|
|
588
|
+
this.closeMenu();
|
|
589
|
+
return;
|
|
590
|
+
default:
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
event.preventDefault();
|
|
594
|
+
items[next]?.focus();
|
|
595
|
+
};
|
|
596
|
+
closeFromMenu = () => {
|
|
597
|
+
const tab = this.menu()?.tab;
|
|
598
|
+
this.closeMenu();
|
|
599
|
+
if (tab)
|
|
600
|
+
this.#tabRouterService.close(tab);
|
|
601
|
+
};
|
|
602
|
+
closeOthersFromMenu = () => {
|
|
603
|
+
const tab = this.menu()?.tab;
|
|
604
|
+
this.closeMenu();
|
|
605
|
+
if (tab)
|
|
606
|
+
this.#tabRouterService.closeOthers(tab);
|
|
607
|
+
};
|
|
608
|
+
#tabElements = () => Array.from(this.scroller().nativeElement.querySelectorAll('[role="tab"]'));
|
|
609
|
+
// why: chỉ số của tab chứa `target` (chính tab hoặc nút đóng bên trong). Thứ tự DOM trùng thứ tự `tabs` — CDK chỉ dời
|
|
610
|
+
// tab bằng transform trong lúc kéo.
|
|
611
|
+
#indexOf = (target) => {
|
|
612
|
+
const tab = target instanceof Element ? target.closest('[role="tab"]') : null;
|
|
613
|
+
return tab ? this.#tabElements().indexOf(tab) : -1;
|
|
614
|
+
};
|
|
615
|
+
#menuItems = () => Array.from(this.contextMenu()?.nativeElement.querySelectorAll('[role="menuitem"]') ?? []);
|
|
616
|
+
#openMenuAtTab = (index) => {
|
|
617
|
+
const tab = this.tabs()[index];
|
|
618
|
+
const element = this.#tabElements()[index];
|
|
619
|
+
if (!tab || !element)
|
|
620
|
+
return;
|
|
621
|
+
this.menu.set({ tab, origin: element, positions: this.menuAtTab, byKeyboard: true });
|
|
622
|
+
};
|
|
623
|
+
#focusTab = (index) => {
|
|
624
|
+
const tab = this.tabs()[index];
|
|
625
|
+
const element = this.#tabElements()[index];
|
|
626
|
+
if (!tab || !element)
|
|
627
|
+
return;
|
|
628
|
+
this.#focusKey.set(tab.key);
|
|
629
|
+
element.focus({ preventScroll: true });
|
|
630
|
+
this.#reveal(element.closest('sd-tab-router-item'));
|
|
631
|
+
};
|
|
632
|
+
/** Tab đang có focus vừa bị đóng: key của tab bên phải nó còn lại, không có thì bên trái. */
|
|
633
|
+
#neighbourOfClosedFocus = (tabs) => {
|
|
634
|
+
const previous = this.#previousTabs;
|
|
635
|
+
this.#previousTabs = tabs;
|
|
636
|
+
const lost = this.#lastFocusedKey;
|
|
637
|
+
if (!lost || !this.#focusWithin || tabs.some(tab => tab.key === lost))
|
|
638
|
+
return null;
|
|
639
|
+
const index = previous.findIndex(tab => tab.key === lost);
|
|
640
|
+
if (index < 0)
|
|
641
|
+
return null;
|
|
642
|
+
const remains = (tab) => tabs.some(({ key }) => key === tab.key);
|
|
643
|
+
const neighbour = previous.slice(index + 1).find(remains) ?? previous.slice(0, index).reverse().find(remains);
|
|
644
|
+
if (!neighbour)
|
|
645
|
+
this.#focusWithin = false;
|
|
646
|
+
return neighbour?.key ?? null;
|
|
647
|
+
};
|
|
648
|
+
// why: chỉ lấy lại focus khi nó đã rơi về body (tab đang focus bị gỡ) — người dùng đã chuyển focus đi chỗ khác thì thôi.
|
|
649
|
+
#refocus = (key) => {
|
|
650
|
+
const active = document.activeElement;
|
|
651
|
+
if (active && active !== document.body && !this.scroller().nativeElement.contains(active))
|
|
652
|
+
return;
|
|
653
|
+
this.#focusTab(this.tabs().findIndex(tab => tab.key === key));
|
|
414
654
|
};
|
|
415
655
|
#measure = () => {
|
|
416
656
|
const scroller = this.scroller().nativeElement;
|
|
@@ -442,8 +682,11 @@ class SdTabRouterNavComponent {
|
|
|
442
682
|
if (!active || (!force && active.key === this.#activeKey))
|
|
443
683
|
return;
|
|
444
684
|
this.#activeKey = active.key;
|
|
685
|
+
this.#reveal(this.scroller().nativeElement.querySelector('sd-tab-router-item.sd-tab-router-item--active'));
|
|
686
|
+
};
|
|
687
|
+
/** Cuộn thanh để `item` hiện trọn, ngoài vùng lớp mờ. */
|
|
688
|
+
#reveal = (item) => {
|
|
445
689
|
const scroller = this.scroller().nativeElement;
|
|
446
|
-
const item = scroller.querySelector('sd-tab-router-item.sd-tab-router-item--active');
|
|
447
690
|
if (!item || scroller.scrollWidth - scroller.clientWidth <= 1)
|
|
448
691
|
return;
|
|
449
692
|
const left = item.getBoundingClientRect().left - scroller.getBoundingClientRect().left + scroller.scrollLeft;
|
|
@@ -457,15 +700,20 @@ class SdTabRouterNavComponent {
|
|
|
457
700
|
this.#measure();
|
|
458
701
|
};
|
|
459
702
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdTabRouterNavComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
460
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: SdTabRouterNavComponent, isStandalone: true, selector: "sd-tab-router-nav", inputs: { tabs: { classPropertyName: "tabs", publicName: "tabs", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "scroller", first: true, predicate: ["scroller"], descendants: true, isSignal: true }, { propertyName: "listButton", first: true, predicate: ["listButton"], descendants: true, isSignal: true }], ngImport: i0, template: "@let _tabs = tabs();\n@let _open = listOpen();\n<div class=\"tab-router__nav\" [class.tab-router__nav--hidden]=\"_tabs.length <= 1\">\n <div class=\"tab-router__tabs\">\n <div\n #scroller\n class=\"tab-router__scroller\"\n cdkDropList\n cdkDropListLockAxis=\"x\"\n cdkDropListOrientation=\"horizontal\"\n (cdkDropListDropped)=\"onDrop($event)\">\n @for (tab of _tabs; track tab.injector ?? tab.key) {\n <sd-tab-router-item [tab]=\"tab\" cdkDrag [cdkDragBoundary]=\"elementRef.nativeElement\"></sd-tab-router-item>\n }\n </div>\n @if (fadeStart()) {\n <span class=\"tab-router__fade tab-router__fade--start\" aria-hidden=\"true\"></span>\n }\n @if (fadeEnd()) {\n <span class=\"tab-router__fade tab-router__fade--end\" aria-hidden=\"true\"></span>\n }\n </div>\n\n @if (overflowing()) {\n <div class=\"tab-router__more\" cdkOverlayOrigin #listOrigin=\"cdkOverlayOrigin\">\n <button\n #listButton\n type=\"button\"\n class=\"tab-router__list-button\"\n [attr.aria-label]=\"'core.component.tab-router.tab-list' | sdTranslate\"\n aria-haspopup=\"dialog\"\n [attr.aria-expanded]=\"_open\"\n (click)=\"toggleList()\">\n <span class=\"tab-router__list-count\">{{ _tabs.length }}</span>\n <sd-icon aria-hidden=\"true\" size=\"18px\" fontIcon=\"expand_more\"></sd-icon>\n </button>\n </div>\n\n <ng-template\n cdkConnectedOverlay\n [cdkConnectedOverlayOrigin]=\"listOrigin\"\n [cdkConnectedOverlayOpen]=\"_open\"\n [cdkConnectedOverlayPositions]=\"listPositions\"\n [cdkConnectedOverlayViewportMargin]=\"8\"\n [cdkConnectedOverlayPush]=\"true\"\n [cdkConnectedOverlayHasBackdrop]=\"true\"\n [cdkConnectedOverlayDisableClose]=\"true\"\n cdkConnectedOverlayBackdropClass=\"cdk-overlay-transparent-backdrop\"\n (backdropClick)=\"closeList(false)\"\n (overlayKeydown)=\"onListKeydown($event)\">\n @let _title = 'core.component.tab-router.open-tabs' | sdTranslate: { count: _tabs.length };\n <!-- why: trap focus v\u00E0 t\u1EF1 \u0111\u01B0a focus v\u00E0o h\u00E0ng \u0111\u1EA7u khi m\u1EDF (m\u1EABu sd-avatar-group); Esc tr\u1EA3 focus v\u1EC1 n\u00FAt. -->\n <div class=\"tab-router__menu\" role=\"dialog\" [attr.aria-label]=\"_title\" cdkTrapFocus [cdkTrapFocusAutoCapture]=\"true\">\n <div class=\"tab-router__menu-title\" aria-hidden=\"true\">{{ _title }}</div>\n <div class=\"tab-router__menu-list\" role=\"list\">\n @for (tab of _tabs; track tab.injector ?? tab.key) {\n <sd-tab-router-list-item [tab]=\"tab\" (pick)=\"pickTab(tab)\" (closeTab)=\"closeTab(tab)\"></sd-tab-router-list-item>\n }\n </div>\n </div>\n </ng-template>\n }\n</div>\n", styles: [":host{display:block}.tab-router__nav{display:flex;flex-wrap:nowrap;align-items:stretch;height:40px;box-sizing:border-box;overflow:hidden;background:var(--sd-tab-router-nav-bg);transition:height .15s ease-out}.tab-router__nav--hidden{height:0;visibility:hidden;transition:height .15s ease-out,visibility 0s .15s}@media(prefers-reduced-motion:reduce){.tab-router__nav,.tab-router__nav--hidden{transition:none}}.tab-router__tabs{position:relative;display:flex;flex:1 1 auto;min-width:0}.tab-router__scroller{display:flex;flex:1 1 auto;flex-wrap:nowrap;align-items:flex-end;min-width:0;padding:0 8px;box-sizing:border-box;overflow-x:auto;overflow-y:hidden;scrollbar-width:none}.tab-router__scroller::-webkit-scrollbar{display:none}.tab-router__fade{position:absolute;top:0;bottom:0;width:32px;pointer-events:none}.tab-router__fade--start{left:0;background:linear-gradient(90deg,var(--sd-tab-router-nav-bg),transparent)}.tab-router__fade--end{right:0;background:linear-gradient(270deg,var(--sd-tab-router-nav-bg),transparent)}.tab-router__more{display:flex;flex:0 0 auto;align-items:center;padding:0 6px 0 4px;border-left:1px solid var(--sd-tab-router-item-divider);box-sizing:border-box}.tab-router__list-button{display:flex;align-items:center;gap:2px;height:30px;padding:0 6px 0 8px;border:0;border-radius:8px;box-sizing:border-box;background:none;color:var(--sd-text);font:inherit;font-size:var(--sd-font-size-12, 12px);font-weight:500;cursor:pointer}.tab-router__list-button:hover,.tab-router__list-button[aria-expanded=true]{background:var(--sd-tab-router-item-hover-bg)}.tab-router__list-button:focus-visible{outline:var(--sd-focus-ring-width, 2px) solid var(--sd-focus-ring-color, var(--sd-primary));outline-offset:-2px}.tab-router__list-count{font-variant-numeric:tabular-nums}.tab-router__menu{display:flex;flex-direction:column;box-sizing:border-box;width:320px;max-width:calc(100vw - 16px);padding:6px;color:var(--sd-text);background-color:var(--sd-select-panel-bg, var(--sd-surface));border:1px solid color-mix(in srgb,var(--sd-border) 60%,var(--sd-surface));border-radius:var(--sd-panel-radius, 10px);box-shadow:var(--sd-shadow-md, none)}.tab-router__menu-title{padding:6px 10px;color:var(--sd-text-secondary);font-size:var(--sd-font-size-12, 12px);font-weight:500;line-height:16px}.tab-router__menu-list{display:flex;flex-direction:column;max-height:300px;overflow-y:auto}sd-tab-router-item.sd-tab-router-item--active:after,sd-tab-router-item:has(+sd-tab-router-item.sd-tab-router-item--active):after,sd-tab-router-item:hover:after,sd-tab-router-item:has(+sd-tab-router-item:hover):after{opacity:0}\n"], dependencies: [{ kind: "ngmodule", type: A11yModule }, { kind: "directive", type: i1.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }, { kind: "ngmodule", type: DragDropModule }, { kind: "directive", type: i2.CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep", "cdkDropListElementContainer", "cdkDropListHasAnchor"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: i2.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer", "cdkDragScale"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "ngmodule", type: OverlayModule }, { kind: "directive", type: i3.CdkConnectedOverlay, selector: "[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]", inputs: ["cdkConnectedOverlayOrigin", "cdkConnectedOverlayPositions", "cdkConnectedOverlayPositionStrategy", "cdkConnectedOverlayOffsetX", "cdkConnectedOverlayOffsetY", "cdkConnectedOverlayWidth", "cdkConnectedOverlayHeight", "cdkConnectedOverlayMinWidth", "cdkConnectedOverlayMinHeight", "cdkConnectedOverlayBackdropClass", "cdkConnectedOverlayPanelClass", "cdkConnectedOverlayViewportMargin", "cdkConnectedOverlayScrollStrategy", "cdkConnectedOverlayOpen", "cdkConnectedOverlayDisableClose", "cdkConnectedOverlayTransformOriginOn", "cdkConnectedOverlayHasBackdrop", "cdkConnectedOverlayLockPosition", "cdkConnectedOverlayFlexibleDimensions", "cdkConnectedOverlayGrowAfterOpen", "cdkConnectedOverlayPush", "cdkConnectedOverlayDisposeOnNavigation"], outputs: ["backdropClick", "positionChange", "attach", "detach", "overlayKeydown", "overlayOutsideClick"], exportAs: ["cdkConnectedOverlay"] }, { kind: "directive", type: i3.CdkOverlayOrigin, selector: "[cdk-overlay-origin], [overlay-origin], [cdkOverlayOrigin]", exportAs: ["cdkOverlayOrigin"] }, { kind: "component", type: SdIcon, selector: "sd-icon", inputs: ["name", "fontIcon", "color", "set", "fontSet", "size", "strokeWidth", "absoluteStrokeWidth", "ariaLabel"] }, { kind: "component", type: SdTabRouterItemComponent, selector: "sd-tab-router-item", inputs: ["tab"] }, { kind: "component", type: SdTabRouterListItemComponent, selector: "sd-tab-router-list-item", inputs: ["tab"], outputs: ["pick", "closeTab"] }, { kind: "pipe", type: SdTranslatePipe, name: "sdTranslate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
703
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: SdTabRouterNavComponent, isStandalone: true, selector: "sd-tab-router-nav", inputs: { tabs: { classPropertyName: "tabs", publicName: "tabs", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { tabs: "tabsChange" }, viewQueries: [{ propertyName: "scroller", first: true, predicate: ["scroller"], descendants: true, isSignal: true }, { propertyName: "listButton", first: true, predicate: ["listButton"], descendants: true, isSignal: true }, { propertyName: "contextMenu", first: true, predicate: ["contextMenu"], descendants: true, isSignal: true }], ngImport: i0, template: "@let _tabs = tabs();\n@let _open = listOpen();\n@let _tabStop = tabStopKey();\n@let _menu = menu();\n<div class=\"tab-router__nav\" [class.tab-router__nav--hidden]=\"_tabs.length <= 1\">\n <div class=\"tab-router__tabs\">\n <!-- why: \u0111\u1EE3t 3 \u00B7 3c \u2014 \u2190/\u2192/Home/End, Delete v\u00E0 menu chu\u1ED9t ph\u1EA3i (c\u1EA3 Shift+F10 / ph\u00EDm Menu) x\u1EED l\u00FD t\u1EA1i \u0111\u00E2y cho m\u1ECDi tab,\n n\u00EAn ch\u1EC9 nav c\u1EA7n bi\u1EBFt th\u1EE9 t\u1EF1 tab. Enter/Space m\u1EDF tab n\u1EB1m tr\u00EAn ch\u00EDnh tab. B\u1EA3n th\u00E2n tablist kh\u00F4ng nh\u1EADn focus: s\u1EF1\n ki\u1EC7n \u0111\u1EBFn t\u1EEB c\u00E1c tab (role=\"tab\", roving tabindex) b\u00EAn trong. -->\n <!-- eslint-disable-next-line @angular-eslint/template/interactive-supports-focus -->\n <div\n #scroller\n class=\"tab-router__scroller\"\n role=\"tablist\"\n cdkDropList\n cdkDropListLockAxis=\"x\"\n cdkDropListOrientation=\"horizontal\"\n (cdkDropListDropped)=\"onDrop($event)\"\n (keydown)=\"onKeydown($event)\"\n (focusin)=\"onFocusin($event)\"\n (focusout)=\"onFocusout($event)\"\n (contextmenu)=\"onContextmenu($event)\">\n @for (tab of _tabs; track tab.injector ?? tab.key) {\n <sd-tab-router-item\n [tab]=\"tab\"\n [focusable]=\"tab.key === _tabStop\"\n cdkDrag\n [cdkDragBoundary]=\"elementRef.nativeElement\"></sd-tab-router-item>\n }\n </div>\n @if (fadeStart()) {\n <span class=\"tab-router__fade tab-router__fade--start\" aria-hidden=\"true\"></span>\n }\n @if (fadeEnd()) {\n <span class=\"tab-router__fade tab-router__fade--end\" aria-hidden=\"true\"></span>\n }\n </div>\n\n @if (overflowing()) {\n <div class=\"tab-router__more\" cdkOverlayOrigin #listOrigin=\"cdkOverlayOrigin\">\n <button\n #listButton\n type=\"button\"\n class=\"tab-router__list-button\"\n [attr.aria-label]=\"'core.component.tab-router.tab-list' | sdTranslate\"\n aria-haspopup=\"dialog\"\n [attr.aria-expanded]=\"_open\"\n (click)=\"toggleList()\">\n <span class=\"tab-router__list-count\">{{ _tabs.length }}</span>\n <sd-icon aria-hidden=\"true\" size=\"18px\" fontIcon=\"expand_more\"></sd-icon>\n </button>\n </div>\n\n <ng-template\n cdkConnectedOverlay\n [cdkConnectedOverlayOrigin]=\"listOrigin\"\n [cdkConnectedOverlayOpen]=\"_open\"\n [cdkConnectedOverlayPositions]=\"listPositions\"\n [cdkConnectedOverlayViewportMargin]=\"8\"\n [cdkConnectedOverlayPush]=\"true\"\n [cdkConnectedOverlayHasBackdrop]=\"true\"\n [cdkConnectedOverlayDisableClose]=\"true\"\n cdkConnectedOverlayBackdropClass=\"cdk-overlay-transparent-backdrop\"\n (backdropClick)=\"closeList(false)\"\n (overlayKeydown)=\"onListKeydown($event)\">\n @let _title = 'core.component.tab-router.open-tabs' | sdTranslate: { count: _tabs.length };\n <!-- why: trap focus v\u00E0 t\u1EF1 \u0111\u01B0a focus v\u00E0o h\u00E0ng \u0111\u1EA7u khi m\u1EDF (m\u1EABu sd-avatar-group); Esc tr\u1EA3 focus v\u1EC1 n\u00FAt. -->\n <div class=\"tab-router__menu\" role=\"dialog\" [attr.aria-label]=\"_title\" cdkTrapFocus [cdkTrapFocusAutoCapture]=\"true\">\n <div class=\"tab-router__menu-title\" aria-hidden=\"true\">{{ _title }}</div>\n <div class=\"tab-router__menu-list\" role=\"list\">\n @for (tab of _tabs; track tab.injector ?? tab.key) {\n <sd-tab-router-list-item [tab]=\"tab\" (pick)=\"pickTab(tab)\" (closeTab)=\"closeTab(tab)\"></sd-tab-router-list-item>\n }\n </div>\n </div>\n </ng-template>\n }\n\n <!-- Menu chu\u1ED9t ph\u1EA3i (\u0111\u1EE3t 3 \u00B7 3c): treo t\u1EA1i con tr\u1ECF, ho\u1EB7c d\u01B0\u1EDBi tab khi m\u1EDF b\u1EB1ng b\u00E0n ph\u00EDm. Kh\u00F4ng trap focus \u2014 Tab, Esc hay\n b\u1EA5m ra ngo\u00E0i \u0111\u1EC1u \u0111\u00F3ng menu. -->\n <ng-template\n cdkConnectedOverlay\n [cdkConnectedOverlayOrigin]=\"_menu?.origin ?? elementRef\"\n [cdkConnectedOverlayOpen]=\"!!_menu\"\n [cdkConnectedOverlayPositions]=\"_menu?.positions ?? menuAtTab\"\n [cdkConnectedOverlayViewportMargin]=\"8\"\n [cdkConnectedOverlayPush]=\"true\"\n [cdkConnectedOverlayDisableClose]=\"true\"\n (attach)=\"focusMenu()\"\n (detach)=\"menu.set(null)\"\n (overlayOutsideClick)=\"closeMenu(false)\"\n (overlayKeydown)=\"onMenuKeydown($event)\">\n <div #contextMenu class=\"tab-router__context-menu\" role=\"menu\" (contextmenu)=\"$event.preventDefault()\">\n <button type=\"button\" role=\"menuitem\" class=\"tab-router__context-item\" (click)=\"closeFromMenu()\">\n <sd-icon aria-hidden=\"true\" size=\"18px\" fontIcon=\"close\"></sd-icon>\n <span>{{ 'core.component.tab-router.close-tab' | sdTranslate }}</span>\n </button>\n <button type=\"button\" role=\"menuitem\" class=\"tab-router__context-item tab-router__context-item--plain\" (click)=\"closeOthersFromMenu()\">\n {{ 'core.component.tab-router.close-others' | sdTranslate }}\n </button>\n </div>\n </ng-template>\n</div>\n", styles: [":host{display:block}.tab-router__nav{display:flex;flex-wrap:nowrap;align-items:stretch;height:40px;box-sizing:border-box;overflow:hidden;background:var(--sd-tab-router-nav-bg);transition:height .15s ease-out}.tab-router__nav--hidden{height:0;visibility:hidden;transition:height .15s ease-out,visibility 0s .15s}@media(prefers-reduced-motion:reduce){.tab-router__nav,.tab-router__nav--hidden{transition:none}}.tab-router__tabs{position:relative;display:flex;flex:1 1 auto;min-width:0}.tab-router__scroller{display:flex;flex:1 1 auto;flex-wrap:nowrap;align-items:flex-end;min-width:0;padding:0 8px;box-sizing:border-box;overflow-x:auto;overflow-y:hidden;scrollbar-width:none}.tab-router__scroller::-webkit-scrollbar{display:none}.tab-router__fade{position:absolute;top:0;bottom:0;width:32px;pointer-events:none}.tab-router__fade--start{left:0;background:linear-gradient(90deg,var(--sd-tab-router-nav-bg),transparent)}.tab-router__fade--end{right:0;background:linear-gradient(270deg,var(--sd-tab-router-nav-bg),transparent)}.tab-router__more{display:flex;flex:0 0 auto;align-items:center;padding:0 6px 0 4px;border-left:1px solid var(--sd-tab-router-item-divider);box-sizing:border-box}.tab-router__list-button{display:flex;align-items:center;gap:2px;height:30px;padding:0 6px 0 8px;border:0;border-radius:8px;box-sizing:border-box;background:none;color:var(--sd-text);font:inherit;font-size:var(--sd-font-size-12, 12px);font-weight:500;cursor:pointer}.tab-router__list-button:hover,.tab-router__list-button[aria-expanded=true]{background:var(--sd-tab-router-item-hover-bg)}.tab-router__list-button:focus-visible{outline:var(--sd-focus-ring-width, 2px) solid var(--sd-focus-ring-color, var(--sd-primary));outline-offset:-2px}.tab-router__list-count{font-variant-numeric:tabular-nums}.tab-router__menu{display:flex;flex-direction:column;box-sizing:border-box;width:320px;max-width:calc(100vw - 16px);padding:6px;color:var(--sd-text);background-color:var(--sd-select-panel-bg, var(--sd-surface));border:1px solid color-mix(in srgb,var(--sd-border) 60%,var(--sd-surface));border-radius:var(--sd-panel-radius, 10px);box-shadow:var(--sd-shadow-md, none)}.tab-router__menu-title{padding:6px 10px;color:var(--sd-text-secondary);font-size:var(--sd-font-size-12, 12px);font-weight:500;line-height:16px}.tab-router__menu-list{display:flex;flex-direction:column;max-height:300px;overflow-y:auto}sd-tab-router-item.sd-tab-router-item--active:after,sd-tab-router-item:has(+sd-tab-router-item.sd-tab-router-item--active):after,sd-tab-router-item:hover:after,sd-tab-router-item:has(+sd-tab-router-item:hover):after{opacity:0}.cdk-drop-list-dragging sd-tab-router-item:not(.cdk-drag-placeholder),sd-tab-router-item.cdk-drag-animating{transition:transform .25s cubic-bezier(0,0,.2,1)}@media(prefers-reduced-motion:reduce){.cdk-drop-list-dragging sd-tab-router-item:not(.cdk-drag-placeholder),sd-tab-router-item.cdk-drag-animating{transition:none}}.tab-router__context-menu{display:flex;flex-direction:column;box-sizing:border-box;width:224px;padding:6px;color:var(--sd-text);background-color:var(--sd-select-panel-bg, var(--sd-surface));border:1px solid color-mix(in srgb,var(--sd-border) 60%,var(--sd-surface));border-radius:var(--sd-panel-radius, 10px);box-shadow:var(--sd-shadow-md, none)}.tab-router__context-item{display:flex;flex:0 0 34px;align-items:center;gap:10px;height:34px;padding:0 10px;border:0;border-radius:6px;box-sizing:border-box;background:none;color:inherit;font:inherit;font-size:var(--sd-font-size-13, 13px);line-height:18px;text-align:start;cursor:pointer}.tab-router__context-item sd-icon{color:var(--sd-text-secondary)}.tab-router__context-item:hover{background:var(--sd-tab-router-nav-bg)}.tab-router__context-item:focus-visible{outline:var(--sd-focus-ring-width, 2px) solid var(--sd-focus-ring-color, var(--sd-primary));outline-offset:-2px}.tab-router__context-item--plain{padding-left:38px}\n"], dependencies: [{ kind: "ngmodule", type: A11yModule }, { kind: "directive", type: i1.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }, { kind: "ngmodule", type: DragDropModule }, { kind: "directive", type: i2.CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep", "cdkDropListElementContainer", "cdkDropListHasAnchor"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: i2.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer", "cdkDragScale"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "ngmodule", type: OverlayModule }, { kind: "directive", type: i3.CdkConnectedOverlay, selector: "[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]", inputs: ["cdkConnectedOverlayOrigin", "cdkConnectedOverlayPositions", "cdkConnectedOverlayPositionStrategy", "cdkConnectedOverlayOffsetX", "cdkConnectedOverlayOffsetY", "cdkConnectedOverlayWidth", "cdkConnectedOverlayHeight", "cdkConnectedOverlayMinWidth", "cdkConnectedOverlayMinHeight", "cdkConnectedOverlayBackdropClass", "cdkConnectedOverlayPanelClass", "cdkConnectedOverlayViewportMargin", "cdkConnectedOverlayScrollStrategy", "cdkConnectedOverlayOpen", "cdkConnectedOverlayDisableClose", "cdkConnectedOverlayTransformOriginOn", "cdkConnectedOverlayHasBackdrop", "cdkConnectedOverlayLockPosition", "cdkConnectedOverlayFlexibleDimensions", "cdkConnectedOverlayGrowAfterOpen", "cdkConnectedOverlayPush", "cdkConnectedOverlayDisposeOnNavigation"], outputs: ["backdropClick", "positionChange", "attach", "detach", "overlayKeydown", "overlayOutsideClick"], exportAs: ["cdkConnectedOverlay"] }, { kind: "directive", type: i3.CdkOverlayOrigin, selector: "[cdk-overlay-origin], [overlay-origin], [cdkOverlayOrigin]", exportAs: ["cdkOverlayOrigin"] }, { kind: "component", type: SdIcon, selector: "sd-icon", inputs: ["name", "fontIcon", "color", "set", "fontSet", "size", "strokeWidth", "absoluteStrokeWidth", "ariaLabel"] }, { kind: "component", type: SdTabRouterItemComponent, selector: "sd-tab-router-item", inputs: ["tab", "focusable"] }, { kind: "component", type: SdTabRouterListItemComponent, selector: "sd-tab-router-list-item", inputs: ["tab"], outputs: ["pick", "closeTab"] }, { kind: "pipe", type: SdTranslatePipe, name: "sdTranslate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
461
704
|
}
|
|
462
705
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdTabRouterNavComponent, decorators: [{
|
|
463
706
|
type: Component,
|
|
464
|
-
args: [{ selector: 'sd-tab-router-nav', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [A11yModule, DragDropModule, OverlayModule, SdIcon, SdTabRouterItemComponent, SdTabRouterListItemComponent, SdTranslatePipe], template: "@let _tabs = tabs();\n@let _open = listOpen();\n<div class=\"tab-router__nav\" [class.tab-router__nav--hidden]=\"_tabs.length <= 1\">\n <div class=\"tab-router__tabs\">\n <div\n #scroller\n class=\"tab-router__scroller\"\n cdkDropList\n cdkDropListLockAxis=\"x\"\n cdkDropListOrientation=\"horizontal\"\n (cdkDropListDropped)=\"onDrop($event)\">\n @for (tab of _tabs; track tab.injector ?? tab.key) {\n <sd-tab-router-item
|
|
465
|
-
}], ctorParameters: () => [], propDecorators: { tabs: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabs", required: false }] }], scroller: [{ type: i0.ViewChild, args: ['scroller', { isSignal: true }] }], listButton: [{ type: i0.ViewChild, args: ['listButton', { isSignal: true }] }] } });
|
|
707
|
+
args: [{ selector: 'sd-tab-router-nav', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [A11yModule, DragDropModule, OverlayModule, SdIcon, SdTabRouterItemComponent, SdTabRouterListItemComponent, SdTranslatePipe], template: "@let _tabs = tabs();\n@let _open = listOpen();\n@let _tabStop = tabStopKey();\n@let _menu = menu();\n<div class=\"tab-router__nav\" [class.tab-router__nav--hidden]=\"_tabs.length <= 1\">\n <div class=\"tab-router__tabs\">\n <!-- why: \u0111\u1EE3t 3 \u00B7 3c \u2014 \u2190/\u2192/Home/End, Delete v\u00E0 menu chu\u1ED9t ph\u1EA3i (c\u1EA3 Shift+F10 / ph\u00EDm Menu) x\u1EED l\u00FD t\u1EA1i \u0111\u00E2y cho m\u1ECDi tab,\n n\u00EAn ch\u1EC9 nav c\u1EA7n bi\u1EBFt th\u1EE9 t\u1EF1 tab. Enter/Space m\u1EDF tab n\u1EB1m tr\u00EAn ch\u00EDnh tab. B\u1EA3n th\u00E2n tablist kh\u00F4ng nh\u1EADn focus: s\u1EF1\n ki\u1EC7n \u0111\u1EBFn t\u1EEB c\u00E1c tab (role=\"tab\", roving tabindex) b\u00EAn trong. -->\n <!-- eslint-disable-next-line @angular-eslint/template/interactive-supports-focus -->\n <div\n #scroller\n class=\"tab-router__scroller\"\n role=\"tablist\"\n cdkDropList\n cdkDropListLockAxis=\"x\"\n cdkDropListOrientation=\"horizontal\"\n (cdkDropListDropped)=\"onDrop($event)\"\n (keydown)=\"onKeydown($event)\"\n (focusin)=\"onFocusin($event)\"\n (focusout)=\"onFocusout($event)\"\n (contextmenu)=\"onContextmenu($event)\">\n @for (tab of _tabs; track tab.injector ?? tab.key) {\n <sd-tab-router-item\n [tab]=\"tab\"\n [focusable]=\"tab.key === _tabStop\"\n cdkDrag\n [cdkDragBoundary]=\"elementRef.nativeElement\"></sd-tab-router-item>\n }\n </div>\n @if (fadeStart()) {\n <span class=\"tab-router__fade tab-router__fade--start\" aria-hidden=\"true\"></span>\n }\n @if (fadeEnd()) {\n <span class=\"tab-router__fade tab-router__fade--end\" aria-hidden=\"true\"></span>\n }\n </div>\n\n @if (overflowing()) {\n <div class=\"tab-router__more\" cdkOverlayOrigin #listOrigin=\"cdkOverlayOrigin\">\n <button\n #listButton\n type=\"button\"\n class=\"tab-router__list-button\"\n [attr.aria-label]=\"'core.component.tab-router.tab-list' | sdTranslate\"\n aria-haspopup=\"dialog\"\n [attr.aria-expanded]=\"_open\"\n (click)=\"toggleList()\">\n <span class=\"tab-router__list-count\">{{ _tabs.length }}</span>\n <sd-icon aria-hidden=\"true\" size=\"18px\" fontIcon=\"expand_more\"></sd-icon>\n </button>\n </div>\n\n <ng-template\n cdkConnectedOverlay\n [cdkConnectedOverlayOrigin]=\"listOrigin\"\n [cdkConnectedOverlayOpen]=\"_open\"\n [cdkConnectedOverlayPositions]=\"listPositions\"\n [cdkConnectedOverlayViewportMargin]=\"8\"\n [cdkConnectedOverlayPush]=\"true\"\n [cdkConnectedOverlayHasBackdrop]=\"true\"\n [cdkConnectedOverlayDisableClose]=\"true\"\n cdkConnectedOverlayBackdropClass=\"cdk-overlay-transparent-backdrop\"\n (backdropClick)=\"closeList(false)\"\n (overlayKeydown)=\"onListKeydown($event)\">\n @let _title = 'core.component.tab-router.open-tabs' | sdTranslate: { count: _tabs.length };\n <!-- why: trap focus v\u00E0 t\u1EF1 \u0111\u01B0a focus v\u00E0o h\u00E0ng \u0111\u1EA7u khi m\u1EDF (m\u1EABu sd-avatar-group); Esc tr\u1EA3 focus v\u1EC1 n\u00FAt. -->\n <div class=\"tab-router__menu\" role=\"dialog\" [attr.aria-label]=\"_title\" cdkTrapFocus [cdkTrapFocusAutoCapture]=\"true\">\n <div class=\"tab-router__menu-title\" aria-hidden=\"true\">{{ _title }}</div>\n <div class=\"tab-router__menu-list\" role=\"list\">\n @for (tab of _tabs; track tab.injector ?? tab.key) {\n <sd-tab-router-list-item [tab]=\"tab\" (pick)=\"pickTab(tab)\" (closeTab)=\"closeTab(tab)\"></sd-tab-router-list-item>\n }\n </div>\n </div>\n </ng-template>\n }\n\n <!-- Menu chu\u1ED9t ph\u1EA3i (\u0111\u1EE3t 3 \u00B7 3c): treo t\u1EA1i con tr\u1ECF, ho\u1EB7c d\u01B0\u1EDBi tab khi m\u1EDF b\u1EB1ng b\u00E0n ph\u00EDm. Kh\u00F4ng trap focus \u2014 Tab, Esc hay\n b\u1EA5m ra ngo\u00E0i \u0111\u1EC1u \u0111\u00F3ng menu. -->\n <ng-template\n cdkConnectedOverlay\n [cdkConnectedOverlayOrigin]=\"_menu?.origin ?? elementRef\"\n [cdkConnectedOverlayOpen]=\"!!_menu\"\n [cdkConnectedOverlayPositions]=\"_menu?.positions ?? menuAtTab\"\n [cdkConnectedOverlayViewportMargin]=\"8\"\n [cdkConnectedOverlayPush]=\"true\"\n [cdkConnectedOverlayDisableClose]=\"true\"\n (attach)=\"focusMenu()\"\n (detach)=\"menu.set(null)\"\n (overlayOutsideClick)=\"closeMenu(false)\"\n (overlayKeydown)=\"onMenuKeydown($event)\">\n <div #contextMenu class=\"tab-router__context-menu\" role=\"menu\" (contextmenu)=\"$event.preventDefault()\">\n <button type=\"button\" role=\"menuitem\" class=\"tab-router__context-item\" (click)=\"closeFromMenu()\">\n <sd-icon aria-hidden=\"true\" size=\"18px\" fontIcon=\"close\"></sd-icon>\n <span>{{ 'core.component.tab-router.close-tab' | sdTranslate }}</span>\n </button>\n <button type=\"button\" role=\"menuitem\" class=\"tab-router__context-item tab-router__context-item--plain\" (click)=\"closeOthersFromMenu()\">\n {{ 'core.component.tab-router.close-others' | sdTranslate }}\n </button>\n </div>\n </ng-template>\n</div>\n", styles: [":host{display:block}.tab-router__nav{display:flex;flex-wrap:nowrap;align-items:stretch;height:40px;box-sizing:border-box;overflow:hidden;background:var(--sd-tab-router-nav-bg);transition:height .15s ease-out}.tab-router__nav--hidden{height:0;visibility:hidden;transition:height .15s ease-out,visibility 0s .15s}@media(prefers-reduced-motion:reduce){.tab-router__nav,.tab-router__nav--hidden{transition:none}}.tab-router__tabs{position:relative;display:flex;flex:1 1 auto;min-width:0}.tab-router__scroller{display:flex;flex:1 1 auto;flex-wrap:nowrap;align-items:flex-end;min-width:0;padding:0 8px;box-sizing:border-box;overflow-x:auto;overflow-y:hidden;scrollbar-width:none}.tab-router__scroller::-webkit-scrollbar{display:none}.tab-router__fade{position:absolute;top:0;bottom:0;width:32px;pointer-events:none}.tab-router__fade--start{left:0;background:linear-gradient(90deg,var(--sd-tab-router-nav-bg),transparent)}.tab-router__fade--end{right:0;background:linear-gradient(270deg,var(--sd-tab-router-nav-bg),transparent)}.tab-router__more{display:flex;flex:0 0 auto;align-items:center;padding:0 6px 0 4px;border-left:1px solid var(--sd-tab-router-item-divider);box-sizing:border-box}.tab-router__list-button{display:flex;align-items:center;gap:2px;height:30px;padding:0 6px 0 8px;border:0;border-radius:8px;box-sizing:border-box;background:none;color:var(--sd-text);font:inherit;font-size:var(--sd-font-size-12, 12px);font-weight:500;cursor:pointer}.tab-router__list-button:hover,.tab-router__list-button[aria-expanded=true]{background:var(--sd-tab-router-item-hover-bg)}.tab-router__list-button:focus-visible{outline:var(--sd-focus-ring-width, 2px) solid var(--sd-focus-ring-color, var(--sd-primary));outline-offset:-2px}.tab-router__list-count{font-variant-numeric:tabular-nums}.tab-router__menu{display:flex;flex-direction:column;box-sizing:border-box;width:320px;max-width:calc(100vw - 16px);padding:6px;color:var(--sd-text);background-color:var(--sd-select-panel-bg, var(--sd-surface));border:1px solid color-mix(in srgb,var(--sd-border) 60%,var(--sd-surface));border-radius:var(--sd-panel-radius, 10px);box-shadow:var(--sd-shadow-md, none)}.tab-router__menu-title{padding:6px 10px;color:var(--sd-text-secondary);font-size:var(--sd-font-size-12, 12px);font-weight:500;line-height:16px}.tab-router__menu-list{display:flex;flex-direction:column;max-height:300px;overflow-y:auto}sd-tab-router-item.sd-tab-router-item--active:after,sd-tab-router-item:has(+sd-tab-router-item.sd-tab-router-item--active):after,sd-tab-router-item:hover:after,sd-tab-router-item:has(+sd-tab-router-item:hover):after{opacity:0}.cdk-drop-list-dragging sd-tab-router-item:not(.cdk-drag-placeholder),sd-tab-router-item.cdk-drag-animating{transition:transform .25s cubic-bezier(0,0,.2,1)}@media(prefers-reduced-motion:reduce){.cdk-drop-list-dragging sd-tab-router-item:not(.cdk-drag-placeholder),sd-tab-router-item.cdk-drag-animating{transition:none}}.tab-router__context-menu{display:flex;flex-direction:column;box-sizing:border-box;width:224px;padding:6px;color:var(--sd-text);background-color:var(--sd-select-panel-bg, var(--sd-surface));border:1px solid color-mix(in srgb,var(--sd-border) 60%,var(--sd-surface));border-radius:var(--sd-panel-radius, 10px);box-shadow:var(--sd-shadow-md, none)}.tab-router__context-item{display:flex;flex:0 0 34px;align-items:center;gap:10px;height:34px;padding:0 10px;border:0;border-radius:6px;box-sizing:border-box;background:none;color:inherit;font:inherit;font-size:var(--sd-font-size-13, 13px);line-height:18px;text-align:start;cursor:pointer}.tab-router__context-item sd-icon{color:var(--sd-text-secondary)}.tab-router__context-item:hover{background:var(--sd-tab-router-nav-bg)}.tab-router__context-item:focus-visible{outline:var(--sd-focus-ring-width, 2px) solid var(--sd-focus-ring-color, var(--sd-primary));outline-offset:-2px}.tab-router__context-item--plain{padding-left:38px}\n"] }]
|
|
708
|
+
}], ctorParameters: () => [], propDecorators: { tabs: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabs", required: false }] }, { type: i0.Output, args: ["tabsChange"] }], scroller: [{ type: i0.ViewChild, args: ['scroller', { isSignal: true }] }], listButton: [{ type: i0.ViewChild, args: ['listButton', { isSignal: true }] }], contextMenu: [{ type: i0.ViewChild, args: ['contextMenu', { isSignal: true }] }] } });
|
|
466
709
|
|
|
467
710
|
class SdTabRouterOutletComponent {
|
|
468
711
|
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
712
|
+
/**
|
|
713
|
+
* Đặt tiêu đề trình duyệt theo tab đang mở: `{tên tab} – {tên app}`, thêm "● " ở đầu khi tab `dirty`. Tên app là
|
|
714
|
+
* tiêu đề lúc outlet khởi tạo; tắt, `disabled` hay huỷ outlet thì trả lại tiêu đề đó. Mặc định tắt.
|
|
715
|
+
*/
|
|
716
|
+
syncBrowserTitle = input(false, ...(ngDevMode ? [{ debugName: "syncBrowserTitle", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
469
717
|
tabRouterNav = viewChild('tabRouterNav', ...(ngDevMode ? [{ debugName: "tabRouterNav" }] : []));
|
|
470
718
|
tabs = signal([], ...(ngDevMode ? [{ debugName: "tabs" }] : []));
|
|
471
719
|
#router = inject(Router);
|
|
@@ -474,6 +722,9 @@ class SdTabRouterOutletComponent {
|
|
|
474
722
|
#tabRouterService = inject(SdTabRouterService);
|
|
475
723
|
#sdNotifyService = inject(SdNotifyService);
|
|
476
724
|
#i18n = inject(I18nService);
|
|
725
|
+
#title = inject(Title);
|
|
726
|
+
#appTitle = this.#title.getTitle();
|
|
727
|
+
#titleChanged = false;
|
|
477
728
|
// why: @SdTabComponent KHÔNG còn đọc BehaviorSubject tĩnh này nữa (đã chuyển sang collection
|
|
478
729
|
// tĩnh + drain ở constructor bên dưới). Vẫn inject để `SdTabDecoratorService.tabRouterService`
|
|
479
730
|
// tiếp tục phát instance service ra cho consumer cũ. Không dùng trực tiếp ở đây.
|
|
@@ -501,10 +752,21 @@ class SdTabRouterOutletComponent {
|
|
|
501
752
|
event instanceof NavigationCancel ||
|
|
502
753
|
event instanceof NavigationError),
|
|
503
754
|
// Chụp getCurrentNavigation đồng bộ vì concatMap có thể chạy sau khi Angular đã xoá navigation hiện tại.
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
755
|
+
// why: route của tab cũng phải chụp ở đây. Khi hàng đợi kích hoạt còn bận (tab trước chờ nạp module lazy),
|
|
756
|
+
// router đã sang URL sau trước khi tác vụ của URL này chạy; đọc routerState lúc đó làm tab nhận component,
|
|
757
|
+
// route và tên của URL sau.
|
|
758
|
+
map((event) => {
|
|
759
|
+
const context = {
|
|
760
|
+
event,
|
|
761
|
+
navigationState: this.#router.getCurrentNavigation()?.extras?.state ?? {},
|
|
762
|
+
};
|
|
763
|
+
if (event instanceof NavigationEnd || event instanceof NavigationSkipped) {
|
|
764
|
+
const route = this.#getActivatedRouteSnapshot(this.#router.routerState.snapshot.root);
|
|
765
|
+
context.route = route;
|
|
766
|
+
context.activatedRoute = route ? this.#findActivatedRouteForSnapshot(this.#router.routerState.root, route) : null;
|
|
767
|
+
}
|
|
768
|
+
return context;
|
|
769
|
+
}),
|
|
508
770
|
// Serialize: #handleEvent async (await getBestInjector). 2 nav liên tiếp
|
|
509
771
|
// không await xen kẽ → tránh race đọc this.tabs() = [] khi tab đầu chưa kịp set.
|
|
510
772
|
concatMap(context => defer(() => this.#handleEvent(context)).pipe(
|
|
@@ -520,11 +782,26 @@ class SdTabRouterOutletComponent {
|
|
|
520
782
|
if (event?.type === 'close') {
|
|
521
783
|
this.#closeTab(event.tab);
|
|
522
784
|
}
|
|
785
|
+
else if (event?.type === 'close-others') {
|
|
786
|
+
void this.#closeOthers(event.tab);
|
|
787
|
+
}
|
|
523
788
|
}));
|
|
524
789
|
// why: @SdTabComponent chỉ ghi builder vào một collection tĩnh (không subscribe gì cả,
|
|
525
790
|
// xem tab.decorator.ts). Outlet là nơi duy nhất chắc chắn có SdTabRouterService nên nó
|
|
526
791
|
// drain collection đó vào service khi khởi tạo, và ngắt kết nối khi destroy.
|
|
527
792
|
this.#disconnectTabBuilders = ɵsdConnectTabComponentBuilders(builder => this.#tabRouterService.addBuilder(builder));
|
|
793
|
+
// Đợt 3 · 3d: tiêu đề trình duyệt theo tab đang mở (tên từ `tabInfoChanges`, trước đó từ `@SdTabComponent`).
|
|
794
|
+
effect(onCleanup => {
|
|
795
|
+
const active = this.syncBrowserTitle() && !this.disabled() ? this.tabs().find(tab => tab.isActive) : undefined;
|
|
796
|
+
if (!active) {
|
|
797
|
+
untracked(() => this.#restoreTitle());
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
const subscription = untracked(() => active.tabInfoChanges
|
|
801
|
+
.pipe(startWith(null))
|
|
802
|
+
.subscribe(info => this.#showTitle(info ?? sdTabInfoFromBuilders(this.#tabRouterService.builders.getValue(), active), active)));
|
|
803
|
+
onCleanup(() => subscription.unsubscribe());
|
|
804
|
+
});
|
|
528
805
|
// Initial navigation có thể hoàn tất trước khi outlet subscribe router.events
|
|
529
806
|
// (blocking init hoặc outlet mount muộn). Catch-up sau first render.
|
|
530
807
|
afterNextRender(() => {
|
|
@@ -532,6 +809,7 @@ class SdTabRouterOutletComponent {
|
|
|
532
809
|
});
|
|
533
810
|
}
|
|
534
811
|
ngOnDestroy() {
|
|
812
|
+
this.#restoreTitle();
|
|
535
813
|
this.#subscription.unsubscribe();
|
|
536
814
|
this.#pendingNavigationStates.clear();
|
|
537
815
|
this.#disconnectTabBuilders?.();
|
|
@@ -542,7 +820,7 @@ class SdTabRouterOutletComponent {
|
|
|
542
820
|
this.#activationQueue = run.catch(() => undefined);
|
|
543
821
|
return run;
|
|
544
822
|
};
|
|
545
|
-
#handleEvent = async ({ event, navigationState }) => {
|
|
823
|
+
#handleEvent = async ({ event, navigationState, route, activatedRoute }) => {
|
|
546
824
|
if (this.disabled()) {
|
|
547
825
|
this.#pendingNavigationStates.clear();
|
|
548
826
|
return;
|
|
@@ -571,9 +849,8 @@ class SdTabRouterOutletComponent {
|
|
|
571
849
|
fullUrl = event.urlAfterRedirects || event.url;
|
|
572
850
|
}
|
|
573
851
|
await this.#scheduleActivation(async () => {
|
|
574
|
-
const route = this.#getActivatedRouteSnapshot(this.#router.routerState.snapshot.root);
|
|
575
852
|
this.#rootRoute = this.#router.routerState.root;
|
|
576
|
-
await this.#activeRoute(fullUrl, route, state);
|
|
853
|
+
await this.#activeRoute(fullUrl, route ?? null, state, activatedRoute ?? null);
|
|
577
854
|
});
|
|
578
855
|
};
|
|
579
856
|
// Bù initial navigation nếu NavigationEnd đã fire trước khi outlet subscribe.
|
|
@@ -602,21 +879,33 @@ class SdTabRouterOutletComponent {
|
|
|
602
879
|
});
|
|
603
880
|
};
|
|
604
881
|
tabTrackBy = (index, tab) => tab.key;
|
|
882
|
+
#showTitle = (info, tab) => {
|
|
883
|
+
const name = info.name || sdTabInfoFromBuilders(this.#tabRouterService.builders.getValue(), tab).name;
|
|
884
|
+
this.#title.setTitle(`${info.dirty ? '● ' : ''}${name} – ${this.#appTitle}`);
|
|
885
|
+
this.#titleChanged = true;
|
|
886
|
+
};
|
|
887
|
+
#restoreTitle = () => {
|
|
888
|
+
if (!this.#titleChanged)
|
|
889
|
+
return;
|
|
890
|
+
this.#title.setTitle(this.#appTitle);
|
|
891
|
+
this.#titleChanged = false;
|
|
892
|
+
};
|
|
893
|
+
// `beforeClose` chỉ cho đóng khi trả về true; false, throw hay reject đều giữ tab lại.
|
|
894
|
+
#canClose = async (tab) => {
|
|
895
|
+
try {
|
|
896
|
+
const result = tab.beforeClose ? tab.beforeClose() : true;
|
|
897
|
+
return typeof result === 'boolean' ? result : await result;
|
|
898
|
+
}
|
|
899
|
+
catch {
|
|
900
|
+
return false;
|
|
901
|
+
}
|
|
902
|
+
};
|
|
605
903
|
#closeTab = async (tab) => {
|
|
606
904
|
if (this.disabled())
|
|
607
905
|
return;
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
const result = tab.beforeClose();
|
|
612
|
-
canClose = typeof result === 'boolean' ? result : await result;
|
|
613
|
-
}
|
|
614
|
-
catch {
|
|
615
|
-
canClose = false;
|
|
616
|
-
}
|
|
617
|
-
if (!canClose)
|
|
618
|
-
return;
|
|
619
|
-
}
|
|
906
|
+
// why: không có `beforeClose` thì đóng ngay trong cùng lượt (không await), như trước.
|
|
907
|
+
if (tab.beforeClose && !(await this.#canClose(tab)))
|
|
908
|
+
return;
|
|
620
909
|
const currentTabs = this.tabs();
|
|
621
910
|
const { isActive, key: activeKey } = tab;
|
|
622
911
|
if (isActive) {
|
|
@@ -637,7 +926,31 @@ class SdTabRouterOutletComponent {
|
|
|
637
926
|
this.tabs.set(currentTabs.filter(({ key }) => key !== tab.key));
|
|
638
927
|
}
|
|
639
928
|
};
|
|
640
|
-
|
|
929
|
+
// Menu chuột phải "Đóng các tab khác" (đợt 3 · 3c). Hỏi `beforeClose` lần lượt từng tab (mỗi tab có thể mở hộp xác
|
|
930
|
+
// nhận riêng), rồi gỡ một lần những tab cho đóng. Tab đang mở nằm trong số đó thì mở `keep`.
|
|
931
|
+
#closeOthers = async (keep) => {
|
|
932
|
+
if (this.disabled())
|
|
933
|
+
return;
|
|
934
|
+
const closing = new Set();
|
|
935
|
+
for (const tab of this.tabs()) {
|
|
936
|
+
if (tab.key !== keep.key && (!tab.beforeClose || (await this.#canClose(tab))))
|
|
937
|
+
closing.add(tab.key);
|
|
938
|
+
}
|
|
939
|
+
if (!closing.size || this.disabled())
|
|
940
|
+
return;
|
|
941
|
+
// why: đọc lại sau các lần await — tab có thể đã đổi trong lúc chờ hộp xác nhận.
|
|
942
|
+
const currentTabs = this.tabs();
|
|
943
|
+
const kept = currentTabs.find(({ key }) => key === keep.key);
|
|
944
|
+
const closesActive = currentTabs.some(({ key, isActive }) => isActive && closing.has(key));
|
|
945
|
+
this.tabs.set(currentTabs.filter(({ key }) => !closing.has(key)));
|
|
946
|
+
if (closesActive && kept) {
|
|
947
|
+
this.#router.navigate([kept.url], {
|
|
948
|
+
queryParams: { ...(kept.queryParams || {}) },
|
|
949
|
+
state: { switchTab: true },
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
#activeRoute = async (fullUrl, route, state = {}, capturedActivatedRoute = null) => {
|
|
641
954
|
if (this.disabled())
|
|
642
955
|
return;
|
|
643
956
|
if (!route?.component)
|
|
@@ -713,8 +1026,10 @@ class SdTabRouterOutletComponent {
|
|
|
713
1026
|
};
|
|
714
1027
|
const finalInjector = await getBestInjector(route);
|
|
715
1028
|
// Refresh root sau await: lazy route tree có thể hoàn tất trong lúc resolve injector.
|
|
1029
|
+
// why: router có thể đã sang URL khác trong lúc await — snapshot của route này không còn trong cây mới, nên dùng
|
|
1030
|
+
// ActivatedRoute đã chụp lúc NavigationEnd.
|
|
716
1031
|
this.#rootRoute = this.#router.routerState.root;
|
|
717
|
-
const activatedRoute = this.#findActivatedRouteForSnapshot(this.#rootRoute, route);
|
|
1032
|
+
const activatedRoute = this.#findActivatedRouteForSnapshot(this.#rootRoute, route) ?? capturedActivatedRoute;
|
|
718
1033
|
const sdInjector = new SdOutletInjector(activatedRoute, finalInjector);
|
|
719
1034
|
const newTab = {
|
|
720
1035
|
key,
|
|
@@ -793,12 +1108,12 @@ class SdTabRouterOutletComponent {
|
|
|
793
1108
|
return null;
|
|
794
1109
|
};
|
|
795
1110
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdTabRouterOutletComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
796
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: SdTabRouterOutletComponent, isStandalone: true, selector: "sd-tab-router-outlet", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "tabRouterNav", first: true, predicate: ["tabRouterNav"], descendants: true, isSignal: true }], ngImport: i0, template: "@if (disabled()) {\n <div class=\"tab-router__disabled-outlet\">\n <router-outlet></router-outlet>\n </div>\n} @else {\n <sd-tab-router-nav [tabs]=\"tabs
|
|
1111
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: SdTabRouterOutletComponent, isStandalone: true, selector: "sd-tab-router-outlet", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, syncBrowserTitle: { classPropertyName: "syncBrowserTitle", publicName: "syncBrowserTitle", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "tabRouterNav", first: true, predicate: ["tabRouterNav"], descendants: true, isSignal: true }], ngImport: i0, template: "@if (disabled()) {\n <div class=\"tab-router__disabled-outlet\">\n <router-outlet></router-outlet>\n </div>\n} @else {\n <sd-tab-router-nav [(tabs)]=\"tabs\" #tabRouterNav></sd-tab-router-nav>\n <div class=\"tab-router__list\">\n @for (tab of tabs(); track tab.injector ?? tab.key) {\n <div\n class=\"tab-router__pane\"\n role=\"tabpanel\"\n [class.active]=\"tab.isActive\"\n [id]=\"tab.key\"\n [attr.aria-labelledby]=\"'sd-tab-router-tab-' + tab.key\">\n <div class=\"tab-router__content\">\n <ng-container *ngComponentOutlet=\"tab.component; injector: tab.injector\"></ng-container>\n </div>\n </div>\n }\n </div>\n}\n", styles: [":host{display:flex;flex-direction:column;width:100%;min-height:0;height:100vh;height:100dvh}:host ::ng-deep .sd-loading{max-width:100%;max-height:100%}.tab-router__list{flex:1;min-height:0}.tab-router__disabled-outlet{flex:1;width:100%;min-height:0;overflow:auto}.tab-router__pane{display:none;position:relative;height:100%;width:100%}.tab-router__pane.active{display:block}.tab-router__content{position:absolute;inset:0;overflow:auto;height:100%;width:100%}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$1.NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule", "ngComponentOutletNgModuleFactory"], exportAs: ["ngComponentOutlet"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name", "routerOutletData"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }, { kind: "component", type: SdTabRouterNavComponent, selector: "sd-tab-router-nav", inputs: ["tabs"], outputs: ["tabsChange"] }] });
|
|
797
1112
|
}
|
|
798
1113
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdTabRouterOutletComponent, decorators: [{
|
|
799
1114
|
type: Component,
|
|
800
|
-
args: [{ selector: 'sd-tab-router-outlet', standalone: true, imports: [CommonModule, MatTooltipModule, RouterOutlet, SdTabRouterNavComponent], template: "@if (disabled()) {\n <div class=\"tab-router__disabled-outlet\">\n <router-outlet></router-outlet>\n </div>\n} @else {\n <sd-tab-router-nav [tabs]=\"tabs
|
|
801
|
-
}], ctorParameters: () => [], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], tabRouterNav: [{ type: i0.ViewChild, args: ['tabRouterNav', { isSignal: true }] }] } });
|
|
1115
|
+
args: [{ selector: 'sd-tab-router-outlet', standalone: true, imports: [CommonModule, MatTooltipModule, RouterOutlet, SdTabRouterNavComponent], template: "@if (disabled()) {\n <div class=\"tab-router__disabled-outlet\">\n <router-outlet></router-outlet>\n </div>\n} @else {\n <sd-tab-router-nav [(tabs)]=\"tabs\" #tabRouterNav></sd-tab-router-nav>\n <div class=\"tab-router__list\">\n @for (tab of tabs(); track tab.injector ?? tab.key) {\n <div\n class=\"tab-router__pane\"\n role=\"tabpanel\"\n [class.active]=\"tab.isActive\"\n [id]=\"tab.key\"\n [attr.aria-labelledby]=\"'sd-tab-router-tab-' + tab.key\">\n <div class=\"tab-router__content\">\n <ng-container *ngComponentOutlet=\"tab.component; injector: tab.injector\"></ng-container>\n </div>\n </div>\n }\n </div>\n}\n", styles: [":host{display:flex;flex-direction:column;width:100%;min-height:0;height:100vh;height:100dvh}:host ::ng-deep .sd-loading{max-width:100%;max-height:100%}.tab-router__list{flex:1;min-height:0}.tab-router__disabled-outlet{flex:1;width:100%;min-height:0;overflow:auto}.tab-router__pane{display:none;position:relative;height:100%;width:100%}.tab-router__pane.active{display:block}.tab-router__content{position:absolute;inset:0;overflow:auto;height:100%;width:100%}\n"] }]
|
|
1116
|
+
}], ctorParameters: () => [], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], syncBrowserTitle: [{ type: i0.Input, args: [{ isSignal: true, alias: "syncBrowserTitle", required: false }] }], tabRouterNav: [{ type: i0.ViewChild, args: ['tabRouterNav', { isSignal: true }] }] } });
|
|
802
1117
|
// Custom Injector cho từng tab: override ActivatedRoute thành route của TAB ĐÓ
|
|
803
1118
|
// (không phải route hiện tại của router). Nếu không override, mọi tab sẽ inject ActivatedRoute
|
|
804
1119
|
// của route đang active → component cũ trong tab inactive nhận data sai khi user navigate.
|