cmat 0.0.13 → 0.0.15
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/components/cascade/cascade-bottom-sheet/cascade-bottom-sheet.component.d.ts +0 -1
- package/components/cascade/cascade-list/cascade-list.component.d.ts +3 -3
- package/components/cascade/cascade-menu/cascade-menu.component.d.ts +0 -1
- package/components/cascade/options.interface.d.ts +1 -1
- package/components/chip-input/chip-input.component.d.ts +0 -1
- package/components/custom-formly/public-api.d.ts +1 -0
- package/components/custom-formly/types/multicheckbox/multicheckbox.component.d.ts +0 -1
- package/components/custom-formly/types/quill/quill.component.d.ts +42 -0
- package/components/custom-formly/types/radio/radio.component.d.ts +0 -1
- package/components/custom-formly/types/repeat/repeat.component.d.ts +0 -1
- package/components/custom-formly/types/select/select.component.d.ts +0 -1
- package/components/custom-formly/types/stepper/horizontal/stepper.component.d.ts +0 -1
- package/components/custom-formly/types/stepper/vertical/stepper.component.d.ts +0 -1
- package/components/custom-formly/types/table/table.component.d.ts +2 -3
- package/components/custom-formly/types/tabs/tab.component.d.ts +0 -1
- package/components/custom-formly/types/tags/tags.component.d.ts +0 -1
- package/components/material-color-picker/material-color-picker.component.d.ts +0 -1
- package/components/material-datetimepicker/calendar-body.d.ts +0 -1
- package/components/material-datetimepicker/calendar.d.ts +3 -4
- package/components/material-datetimepicker/clock.d.ts +2 -3
- package/components/material-datetimepicker/datetimepicker.d.ts +3 -4
- package/components/material-datetimepicker/month-view.d.ts +0 -1
- package/components/navigation/navigation.types.d.ts +1 -1
- package/components/pagination/pagination.component.d.ts +0 -1
- package/components/password-strength/mat-password-strength-validator.d.ts +1 -1
- package/components/popover/popover.component.d.ts +4 -7
- package/components/popover/popover.interfaces.d.ts +1 -2
- package/components/select-tree/select-tree.component.d.ts +0 -1
- package/components/timeline/timeline.component.d.ts +4 -6
- package/components/transfer-picker/filter/filter.component.d.ts +1 -2
- package/components/transfer-picker/interface.d.ts +4 -4
- package/components/transfer-picker/transfer-picker-source/transfer-picker-source.component.d.ts +2 -2
- package/components/transfer-picker/transfer-picker-target/transfer-picker-target.component.d.ts +1 -2
- package/components/transfer-picker/transfer-picker.component.d.ts +5 -5
- package/components/transfer-picker/transfer-picker.service.d.ts +6 -6
- package/components/upload/upload-queue/upload-queue.component.d.ts +1 -1
- package/directives/digit-only/mask.directive.d.ts +2 -0
- package/directives/equal-validator/equal-validator.directive.d.ts +1 -3
- package/esm2022/components/adapter/datetime-adapter.mjs +1 -1
- package/esm2022/components/adapter/dayjs-date-adapter.mjs +5 -5
- package/esm2022/components/adapter/dayjs-datetime-adapter.mjs +4 -4
- package/esm2022/components/adapter/native-datetime-adapter.mjs +4 -4
- package/esm2022/components/breadcrumb/breadcrumb-item.directive.mjs +3 -3
- package/esm2022/components/breadcrumb/breadcrumb.component.mjs +6 -6
- package/esm2022/components/breadcrumb/breadcrumb.service.mjs +9 -12
- package/esm2022/components/card/card.component.mjs +4 -4
- package/esm2022/components/cascade/cascade-bottom-sheet/cascade-bottom-sheet.component.mjs +5 -8
- package/esm2022/components/cascade/cascade-list/cascade-list.component.mjs +12 -10
- package/esm2022/components/cascade/cascade-menu/cascade-menu.component.mjs +5 -8
- package/esm2022/components/cascade/options.interface.mjs +1 -1
- package/esm2022/components/chip-input/chip-input.component.mjs +10 -11
- package/esm2022/components/custom-formly/extension/addons.extension.mjs +2 -2
- package/esm2022/components/custom-formly/public-api.mjs +2 -1
- package/esm2022/components/custom-formly/types/button/button.component.mjs +4 -4
- package/esm2022/components/custom-formly/types/cascade/cascade.component.mjs +4 -4
- package/esm2022/components/custom-formly/types/checklist/checklist.component.mjs +5 -5
- package/esm2022/components/custom-formly/types/chips/chips.component.mjs +5 -5
- package/esm2022/components/custom-formly/types/color-picker/color-picker.component.mjs +3 -3
- package/esm2022/components/custom-formly/types/date-range/date-range.component.mjs +3 -3
- package/esm2022/components/custom-formly/types/datepicker/datepicker.component.mjs +5 -5
- package/esm2022/components/custom-formly/types/multicheckbox/multicheckbox.component.mjs +4 -5
- package/esm2022/components/custom-formly/types/number/number.component.mjs +5 -5
- package/esm2022/components/custom-formly/types/quill/quill.component.mjs +171 -0
- package/esm2022/components/custom-formly/types/radio/radio.component.mjs +5 -6
- package/esm2022/components/custom-formly/types/rating/rating.component.mjs +3 -3
- package/esm2022/components/custom-formly/types/repeat/repeat.component.mjs +5 -8
- package/esm2022/components/custom-formly/types/select/select.component.mjs +5 -8
- package/esm2022/components/custom-formly/types/select-tree/select-tree.component.mjs +4 -4
- package/esm2022/components/custom-formly/types/stepper/horizontal/stepper.component.mjs +5 -8
- package/esm2022/components/custom-formly/types/stepper/vertical/stepper.component.mjs +5 -8
- package/esm2022/components/custom-formly/types/table/table.component.mjs +5 -8
- package/esm2022/components/custom-formly/types/tabs/tab.component.mjs +5 -8
- package/esm2022/components/custom-formly/types/tags/tags.component.mjs +7 -10
- package/esm2022/components/custom-formly/types/textarea/textarea.component.mjs +3 -3
- package/esm2022/components/custom-formly/types/upload/upload.component.mjs +4 -4
- package/esm2022/components/custom-formly/wrappers/addons/addons.component.mjs +4 -4
- package/esm2022/components/custom-formly/wrappers/card/card.component.mjs +3 -3
- package/esm2022/components/custom-formly/wrappers/expansion/expansion.component.mjs +5 -5
- package/esm2022/components/custom-formly/wrappers/panel/panel.component.mjs +3 -3
- package/esm2022/components/date-range/date-range.component.mjs +20 -15
- package/esm2022/components/drawer/drawer.component.mjs +4 -4
- package/esm2022/components/drawer/drawer.service.mjs +3 -3
- package/esm2022/components/fullscreen/fullscreen.component.mjs +5 -5
- package/esm2022/components/highlight/highlight.component.mjs +4 -4
- package/esm2022/components/highlight/highlight.service.mjs +4 -4
- package/esm2022/components/json-editor/json-editor.component.mjs +10 -10
- package/esm2022/components/masonry/masonry.component.mjs +4 -4
- package/esm2022/components/material-color-picker/material-color-picker.component.mjs +7 -8
- package/esm2022/components/material-datetimepicker/calendar-body.mjs +6 -9
- package/esm2022/components/material-datetimepicker/calendar.mjs +9 -15
- package/esm2022/components/material-datetimepicker/clock.mjs +5 -8
- package/esm2022/components/material-datetimepicker/datetimepicker-input.mjs +7 -5
- package/esm2022/components/material-datetimepicker/datetimepicker-intl.mjs +3 -3
- package/esm2022/components/material-datetimepicker/datetimepicker-toggle.mjs +9 -9
- package/esm2022/components/material-datetimepicker/datetimepicker.mjs +14 -15
- package/esm2022/components/material-datetimepicker/month-view.mjs +5 -8
- package/esm2022/components/material-datetimepicker/multi-year-view.mjs +5 -5
- package/esm2022/components/material-datetimepicker/time.mjs +10 -10
- package/esm2022/components/material-datetimepicker/year-view.mjs +5 -5
- package/esm2022/components/navigation/horizontal/components/basic/basic.component.mjs +5 -5
- package/esm2022/components/navigation/horizontal/components/branch/branch.component.mjs +5 -5
- package/esm2022/components/navigation/horizontal/components/divider/divider.component.mjs +3 -3
- package/esm2022/components/navigation/horizontal/components/spacer/spacer.component.mjs +3 -3
- package/esm2022/components/navigation/horizontal/horizontal.component.mjs +5 -5
- package/esm2022/components/navigation/navigation.service.mjs +4 -4
- package/esm2022/components/navigation/navigation.types.mjs +1 -1
- package/esm2022/components/navigation/vertical/components/aside/aside.component.mjs +5 -5
- package/esm2022/components/navigation/vertical/components/basic/basic.component.mjs +3 -3
- package/esm2022/components/navigation/vertical/components/collapsable/collapsable.component.mjs +5 -5
- package/esm2022/components/navigation/vertical/components/divider/divider.component.mjs +3 -3
- package/esm2022/components/navigation/vertical/components/group/group.component.mjs +5 -5
- package/esm2022/components/navigation/vertical/components/spacer/spacer.component.mjs +5 -5
- package/esm2022/components/navigation/vertical/vertical.component.mjs +5 -5
- package/esm2022/components/pagination/pagination.component.mjs +5 -8
- package/esm2022/components/pagination/pagination.directive.mjs +4 -4
- package/esm2022/components/pagination/pagination.pipe.mjs +5 -5
- package/esm2022/components/pagination/pagination.service.mjs +4 -4
- package/esm2022/components/password-strength/mat-pass-toggle-visibility/mat-pass-toggle-visibility.component.mjs +5 -5
- package/esm2022/components/password-strength/mat-password-strength/mat-password-strength.component.mjs +6 -6
- package/esm2022/components/password-strength/mat-password-strength-info/mat-password-strength-info.component.mjs +5 -5
- package/esm2022/components/password-strength/mat-password-strength-validator.mjs +2 -2
- package/esm2022/components/popover/popover-trigger.mjs +6 -8
- package/esm2022/components/popover/popover.component.mjs +8 -9
- package/esm2022/components/popover/popover.interfaces.mjs +1 -1
- package/esm2022/components/popover/popover.target.mjs +3 -3
- package/esm2022/components/progress-bar/progress-bar.component.mjs +4 -4
- package/esm2022/components/rating/rating.component.mjs +11 -7
- package/esm2022/components/select-search/select-no-entries-found.directive.mjs +3 -3
- package/esm2022/components/select-search/select-search-clear.directive.mjs +3 -3
- package/esm2022/components/select-search/select-search.component.mjs +9 -9
- package/esm2022/components/select-tree/select-tree.component.mjs +10 -11
- package/esm2022/components/timeline/timeline-item/timeline-item.component.mjs +11 -11
- package/esm2022/components/timeline/timeline.component.mjs +8 -15
- package/esm2022/components/toast/toast-modal.component.mjs +5 -5
- package/esm2022/components/toast/toast.component.mjs +6 -6
- package/esm2022/components/toast/toast.service.mjs +10 -10
- package/esm2022/components/transfer-picker/filter/filter.component.mjs +6 -9
- package/esm2022/components/transfer-picker/interface.mjs +1 -1
- package/esm2022/components/transfer-picker/search/search.component.mjs +3 -3
- package/esm2022/components/transfer-picker/transfer-picker-source/transfer-picker-source.component.mjs +4 -4
- package/esm2022/components/transfer-picker/transfer-picker-target/transfer-picker-target.component.mjs +5 -8
- package/esm2022/components/transfer-picker/transfer-picker.component.mjs +4 -4
- package/esm2022/components/transfer-picker/transfer-picker.service.mjs +8 -8
- package/esm2022/components/upload/files.util.service.mjs +4 -4
- package/esm2022/components/upload/upload-queue/upload-queue.component.mjs +8 -8
- package/esm2022/components/upload/upload.component.mjs +5 -5
- package/esm2022/directives/animate-on-scroll/animate-on-scroll.directive.mjs +4 -4
- package/esm2022/directives/animate-on-scroll/scroll.service.mjs +3 -3
- package/esm2022/directives/autofocus/autofocus.directive.mjs +3 -3
- package/esm2022/directives/debounce/abstract-debounce.directive.mjs +3 -3
- package/esm2022/directives/debounce/debounce-click.directive.mjs +3 -3
- package/esm2022/directives/debounce/debounce-keyup.directive.mjs +3 -3
- package/esm2022/directives/digit-only/digit-only.directive.mjs +6 -6
- package/esm2022/directives/digit-only/mask.directive.mjs +20 -5
- package/esm2022/directives/equal-validator/equal-validator.directive.mjs +4 -4
- package/esm2022/lib/mock-api/mock-api.interceptor.mjs +4 -4
- package/esm2022/lib/mock-api/mock-api.request-handler.mjs +1 -1
- package/esm2022/lib/mock-api/mock-api.service.mjs +4 -4
- package/esm2022/lib/mock-api/mock-api.types.mjs +1 -1
- package/esm2022/lib/mock-api/mock-api.utils.mjs +1 -2
- package/esm2022/pipes/bytes/bytes.pipe.mjs +4 -4
- package/esm2022/pipes/date-format/date-format.pipe.mjs +3 -3
- package/esm2022/pipes/find-by-key/find-by-key.pipe.mjs +4 -4
- package/esm2022/pipes/group-by/group-by.pipe.mjs +4 -4
- package/esm2022/pipes/keys/keys.pipe.mjs +4 -4
- package/esm2022/pipes/secure/secure-pipe.mjs +3 -3
- package/esm2022/pipes/uppercase/uppercase.pipe.mjs +3 -3
- package/esm2022/public-api.mjs +1 -1
- package/esm2022/services/alert/alert.service.mjs +11 -10
- package/esm2022/services/config/config.service.mjs +3 -3
- package/esm2022/services/config/urlStateConfig.service.mjs +5 -5
- package/esm2022/services/confirmation/confirmation.service.mjs +3 -3
- package/esm2022/services/confirmation/dialog/dialog.component.mjs +3 -3
- package/esm2022/services/data/data.service.mjs +4 -4
- package/esm2022/services/loading/loading.interceptor.mjs +4 -4
- package/esm2022/services/loading/loading.service.mjs +4 -4
- package/esm2022/services/local-storage/local-storage.service.mjs +3 -3
- package/esm2022/services/media-watcher/media-watcher.service.mjs +4 -4
- package/esm2022/services/platform/platform.service.mjs +4 -4
- package/esm2022/services/splash-screen/splash-screen.service.mjs +3 -3
- package/esm2022/services/title/title.service.mjs +4 -4
- package/esm2022/services/translation/translation.service.mjs +4 -4
- package/esm2022/services/utils/utils.service.mjs +9 -11
- package/esm2022/validators/validators.mjs +1 -1
- package/fesm2022/cmat-animations.mjs +1 -1
- package/fesm2022/cmat-components-adapter.mjs +10 -10
- package/fesm2022/cmat-components-adapter.mjs.map +1 -1
- package/fesm2022/cmat-components-breadcrumb.mjs +16 -19
- package/fesm2022/cmat-components-breadcrumb.mjs.map +1 -1
- package/fesm2022/cmat-components-card.mjs +3 -3
- package/fesm2022/cmat-components-card.mjs.map +1 -1
- package/fesm2022/cmat-components-cascade.mjs +19 -23
- package/fesm2022/cmat-components-cascade.mjs.map +1 -1
- package/fesm2022/cmat-components-chip-input.mjs +9 -10
- package/fesm2022/cmat-components-chip-input.mjs.map +1 -1
- package/fesm2022/cmat-components-custom-formly.mjs +257 -115
- package/fesm2022/cmat-components-custom-formly.mjs.map +1 -1
- package/fesm2022/cmat-components-date-range.mjs +20 -15
- package/fesm2022/cmat-components-date-range.mjs.map +1 -1
- package/fesm2022/cmat-components-drawer.mjs +7 -7
- package/fesm2022/cmat-components-drawer.mjs.map +1 -1
- package/fesm2022/cmat-components-fullscreen.mjs +4 -4
- package/fesm2022/cmat-components-fullscreen.mjs.map +1 -1
- package/fesm2022/cmat-components-highlight.mjs +6 -6
- package/fesm2022/cmat-components-highlight.mjs.map +1 -1
- package/fesm2022/cmat-components-json-editor.mjs +9 -9
- package/fesm2022/cmat-components-json-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-masonry.mjs +3 -3
- package/fesm2022/cmat-components-masonry.mjs.map +1 -1
- package/fesm2022/cmat-components-material-color-picker.mjs +6 -7
- package/fesm2022/cmat-components-material-color-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-material-datetimepicker.mjs +70 -83
- package/fesm2022/cmat-components-material-datetimepicker.mjs.map +1 -1
- package/fesm2022/cmat-components-navigation.mjs +48 -48
- package/fesm2022/cmat-components-navigation.mjs.map +1 -1
- package/fesm2022/cmat-components-pagination.mjs +14 -17
- package/fesm2022/cmat-components-pagination.mjs.map +1 -1
- package/fesm2022/cmat-components-password-strength.mjs +15 -15
- package/fesm2022/cmat-components-password-strength.mjs.map +1 -1
- package/fesm2022/cmat-components-popover.mjs +15 -18
- package/fesm2022/cmat-components-popover.mjs.map +1 -1
- package/fesm2022/cmat-components-progress-bar.mjs +3 -3
- package/fesm2022/cmat-components-progress-bar.mjs.map +1 -1
- package/fesm2022/cmat-components-rating.mjs +9 -5
- package/fesm2022/cmat-components-rating.mjs.map +1 -1
- package/fesm2022/cmat-components-select-search.mjs +15 -15
- package/fesm2022/cmat-components-select-search.mjs.map +1 -1
- package/fesm2022/cmat-components-select-tree.mjs +9 -10
- package/fesm2022/cmat-components-select-tree.mjs.map +1 -1
- package/fesm2022/cmat-components-timeline.mjs +17 -24
- package/fesm2022/cmat-components-timeline.mjs.map +1 -1
- package/fesm2022/cmat-components-toast.mjs +18 -18
- package/fesm2022/cmat-components-toast.mjs.map +1 -1
- package/fesm2022/cmat-components-transfer-picker.mjs +25 -31
- package/fesm2022/cmat-components-transfer-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-upload.mjs +14 -14
- package/fesm2022/cmat-components-upload.mjs.map +1 -1
- package/fesm2022/cmat-directives-animate-on-scroll.mjs +6 -6
- package/fesm2022/cmat-directives-animate-on-scroll.mjs.map +1 -1
- package/fesm2022/cmat-directives-autofocus.mjs +3 -3
- package/fesm2022/cmat-directives-debounce.mjs +9 -9
- package/fesm2022/cmat-directives-digit-only.mjs +24 -9
- package/fesm2022/cmat-directives-digit-only.mjs.map +1 -1
- package/fesm2022/cmat-directives-equal-validator.mjs +3 -3
- package/fesm2022/cmat-directives-equal-validator.mjs.map +1 -1
- package/fesm2022/cmat-lib-mock-api.mjs +7 -8
- package/fesm2022/cmat-lib-mock-api.mjs.map +1 -1
- package/fesm2022/cmat-pipes-bytes.mjs +3 -3
- package/fesm2022/cmat-pipes-bytes.mjs.map +1 -1
- package/fesm2022/cmat-pipes-date-format.mjs +3 -3
- package/fesm2022/cmat-pipes-find-by-key.mjs +3 -3
- package/fesm2022/cmat-pipes-find-by-key.mjs.map +1 -1
- package/fesm2022/cmat-pipes-group-by.mjs +3 -3
- package/fesm2022/cmat-pipes-group-by.mjs.map +1 -1
- package/fesm2022/cmat-pipes-keys.mjs +3 -3
- package/fesm2022/cmat-pipes-keys.mjs.map +1 -1
- package/fesm2022/cmat-pipes-secure.mjs +3 -3
- package/fesm2022/cmat-pipes-uppercase.mjs +3 -3
- package/fesm2022/cmat-services-alert.mjs +10 -9
- package/fesm2022/cmat-services-alert.mjs.map +1 -1
- package/fesm2022/cmat-services-config.mjs +7 -7
- package/fesm2022/cmat-services-config.mjs.map +1 -1
- package/fesm2022/cmat-services-confirmation.mjs +6 -6
- package/fesm2022/cmat-services-data.mjs +3 -3
- package/fesm2022/cmat-services-data.mjs.map +1 -1
- package/fesm2022/cmat-services-loading.mjs +6 -6
- package/fesm2022/cmat-services-loading.mjs.map +1 -1
- package/fesm2022/cmat-services-local-storage.mjs +3 -3
- package/fesm2022/cmat-services-media-watcher.mjs +3 -3
- package/fesm2022/cmat-services-media-watcher.mjs.map +1 -1
- package/fesm2022/cmat-services-platform.mjs +3 -3
- package/fesm2022/cmat-services-platform.mjs.map +1 -1
- package/fesm2022/cmat-services-splash-screen.mjs +3 -3
- package/fesm2022/cmat-services-title.mjs +3 -3
- package/fesm2022/cmat-services-title.mjs.map +1 -1
- package/fesm2022/cmat-services-translation.mjs +3 -3
- package/fesm2022/cmat-services-translation.mjs.map +1 -1
- package/fesm2022/cmat-services-utils.mjs +8 -10
- package/fesm2022/cmat-services-utils.mjs.map +1 -1
- package/fesm2022/cmat-validators.mjs.map +1 -1
- package/lib/mock-api/mock-api.request-handler.d.ts +1 -3
- package/lib/mock-api/mock-api.service.d.ts +1 -3
- package/lib/mock-api/mock-api.types.d.ts +2 -4
- package/package.json +76 -67
- package/pipes/group-by/group-by.pipe.d.ts +1 -1
- package/services/config/urlStateConfig.service.d.ts +0 -1
- package/services/translation/translation.service.d.ts +2 -2
- package/services/utils/utils.service.d.ts +5 -7
- package/styles/overrides/angular-material.scss +0 -1
- package/styles/overrides/quill.scss +102 -0
- package/styles/themes.scss +19 -19
|
@@ -19,7 +19,7 @@ class CmatFullscreenComponent {
|
|
|
19
19
|
}
|
|
20
20
|
const fullScreen = this._document.fullscreenElement;
|
|
21
21
|
if (fullScreen) {
|
|
22
|
-
this._document.exitFullscreen();
|
|
22
|
+
void this._document.exitFullscreen();
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
25
|
this._document.documentElement.requestFullscreen()
|
|
@@ -28,10 +28,10 @@ class CmatFullscreenComponent {
|
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
32
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
31
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: CmatFullscreenComponent, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
32
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.0.1", type: CmatFullscreenComponent, isStandalone: true, selector: "cmat-fullscreen", inputs: { iconTpl: "iconTpl", tooltip: "tooltip" }, exportAs: ["cmatFullscreen"], ngImport: i0, template: "<!-- Button -->\r\n<button type=\"button\" mat-icon-button [matTooltip]=\"tooltip || '\u5207\u6362\u5168\u5C4F'\" (click)=\"toggleFullscreen()\">\r\n <ng-container [ngTemplateOutlet]=\"iconTpl || defaultIconTpl\"></ng-container>\r\n</button>\r\n\r\n<!-- Default icon -->\r\n<ng-template #defaultIconTpl>\r\n <mat-icon [svgIcon]=\"'heroicons_outline:arrows-pointing-out'\"></mat-icon>\r\n</ng-template>", dependencies: [{ kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i1.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i2.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
33
33
|
}
|
|
34
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
34
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: CmatFullscreenComponent, decorators: [{
|
|
35
35
|
type: Component,
|
|
36
36
|
args: [{ selector: 'cmat-fullscreen', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, exportAs: 'cmatFullscreen', standalone: true, imports: [MatButtonModule, MatTooltipModule, NgTemplateOutlet, MatIconModule], template: "<!-- Button -->\r\n<button type=\"button\" mat-icon-button [matTooltip]=\"tooltip || '\u5207\u6362\u5168\u5C4F'\" (click)=\"toggleFullscreen()\">\r\n <ng-container [ngTemplateOutlet]=\"iconTpl || defaultIconTpl\"></ng-container>\r\n</button>\r\n\r\n<!-- Default icon -->\r\n<ng-template #defaultIconTpl>\r\n <mat-icon [svgIcon]=\"'heroicons_outline:arrows-pointing-out'\"></mat-icon>\r\n</ng-template>" }]
|
|
37
37
|
}], ctorParameters: () => [{ type: Document, decorators: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cmat-components-fullscreen.mjs","sources":["../../../projects/cmat/components/fullscreen/fullscreen.component.ts","../../../projects/cmat/components/fullscreen/fullscreen.component.html","../../../projects/cmat/components/fullscreen/cmat-components-fullscreen.ts"],"sourcesContent":["import { DOCUMENT, NgTemplateOutlet } from '@angular/common';\r\nimport { ChangeDetectionStrategy, Component, Inject, Input, TemplateRef, ViewEncapsulation } from '@angular/core';\r\nimport { MatButtonModule } from '@angular/material/button';\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { MatTooltipModule } from '@angular/material/tooltip';\r\n\r\n@Component({\r\n selector: 'cmat-fullscreen',\r\n templateUrl: './fullscreen.component.html',\r\n encapsulation: ViewEncapsulation.None,\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n exportAs: 'cmatFullscreen',\r\n standalone: true,\r\n imports: [MatButtonModule, MatTooltipModule, NgTemplateOutlet, MatIconModule]\r\n})\r\nexport class CmatFullscreenComponent {\r\n @Input() iconTpl: TemplateRef<any>;\r\n @Input() tooltip: string;\r\n\r\n constructor(@Inject(DOCUMENT) private _document: Document) { }\r\n\r\n toggleFullscreen(): void\r\n {\r\n if (!this._document.fullscreenEnabled)\r\n {\r\n console.log('Fullscreen is not available in this browser.');\r\n return;\r\n }\r\n\r\n const fullScreen = this._document.fullscreenElement;\r\n\r\n if (fullScreen)\r\n {\r\n this._document.exitFullscreen();\r\n }\r\n else\r\n {\r\n this._document.documentElement.requestFullscreen()\r\n .catch(() =>\r\n {\r\n console.error('Entering fullscreen mode failed.');\r\n });\r\n }\r\n }\r\n}\r\n","<!-- Button -->\r\n<button type=\"button\" mat-icon-button [matTooltip]=\"tooltip || '切换全屏'\" (click)=\"toggleFullscreen()\">\r\n <ng-container [ngTemplateOutlet]=\"iconTpl || defaultIconTpl\"></ng-container>\r\n</button>\r\n\r\n<!-- Default icon -->\r\n<ng-template #defaultIconTpl>\r\n <mat-icon [svgIcon]=\"'heroicons_outline:arrows-pointing-out'\"></mat-icon>\r\n</ng-template>","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;MAea,uBAAuB,CAAA;AAIhC,IAAA,WAAA,CAAsC,SAAmB,EAAA;QAAnB,IAAS,CAAA,SAAA,GAAT,SAAS,CAAU;KAAK;IAE9D,gBAAgB,GAAA;AAEZ,QAAA,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,iBAAiB,EACrC;AACI,YAAA,OAAO,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;YAC5D,OAAO;
|
|
1
|
+
{"version":3,"file":"cmat-components-fullscreen.mjs","sources":["../../../projects/cmat/components/fullscreen/fullscreen.component.ts","../../../projects/cmat/components/fullscreen/fullscreen.component.html","../../../projects/cmat/components/fullscreen/cmat-components-fullscreen.ts"],"sourcesContent":["import { DOCUMENT, NgTemplateOutlet } from '@angular/common';\r\nimport { ChangeDetectionStrategy, Component, Inject, Input, TemplateRef, ViewEncapsulation } from '@angular/core';\r\nimport { MatButtonModule } from '@angular/material/button';\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { MatTooltipModule } from '@angular/material/tooltip';\r\n\r\n@Component({\r\n selector: 'cmat-fullscreen',\r\n templateUrl: './fullscreen.component.html',\r\n encapsulation: ViewEncapsulation.None,\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n exportAs: 'cmatFullscreen',\r\n standalone: true,\r\n imports: [MatButtonModule, MatTooltipModule, NgTemplateOutlet, MatIconModule]\r\n})\r\nexport class CmatFullscreenComponent {\r\n @Input() iconTpl: TemplateRef<any>;\r\n @Input() tooltip: string;\r\n\r\n constructor(@Inject(DOCUMENT) private _document: Document) { }\r\n\r\n toggleFullscreen(): void\r\n {\r\n if (!this._document.fullscreenEnabled)\r\n {\r\n console.log('Fullscreen is not available in this browser.');\r\n return;\r\n }\r\n\r\n const fullScreen = this._document.fullscreenElement;\r\n\r\n if (fullScreen)\r\n {\r\n void this._document.exitFullscreen();\r\n }\r\n else\r\n {\r\n this._document.documentElement.requestFullscreen()\r\n .catch(() =>\r\n {\r\n console.error('Entering fullscreen mode failed.');\r\n });\r\n }\r\n }\r\n}\r\n","<!-- Button -->\r\n<button type=\"button\" mat-icon-button [matTooltip]=\"tooltip || '切换全屏'\" (click)=\"toggleFullscreen()\">\r\n <ng-container [ngTemplateOutlet]=\"iconTpl || defaultIconTpl\"></ng-container>\r\n</button>\r\n\r\n<!-- Default icon -->\r\n<ng-template #defaultIconTpl>\r\n <mat-icon [svgIcon]=\"'heroicons_outline:arrows-pointing-out'\"></mat-icon>\r\n</ng-template>","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;MAea,uBAAuB,CAAA;AAIhC,IAAA,WAAA,CAAsC,SAAmB,EAAA;QAAnB,IAAS,CAAA,SAAA,GAAT,SAAS,CAAU;KAAK;IAE9D,gBAAgB,GAAA;AAEZ,QAAA,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,iBAAiB,EACrC;AACI,YAAA,OAAO,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;YAC5D,OAAO;SACV;AAED,QAAA,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC;QAEpD,IAAI,UAAU,EACd;AACI,YAAA,KAAK,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC;SACxC;aAED;AACI,YAAA,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,iBAAiB,EAAE;iBAC7C,KAAK,CAAC,MAAK;AAER,gBAAA,OAAO,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;AACtD,aAAC,CAAC,CAAC;SACV;KACJ;AA5BQ,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,kBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,uBAAuB,kBAIZ,QAAQ,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAA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B,EAAA,aAAA,EAEZ,iBAAiB,CAAC,IAAI,mBACpB,uBAAuB,CAAC,MAAM,EACrC,QAAA,EAAA,gBAAgB,cACd,IAAI,EAAA,OAAA,EACP,CAAC,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,CAAC,EAAA,QAAA,EAAA,yZAAA,EAAA,CAAA;;0BAMhE,MAAM;2BAAC,QAAQ,CAAA;yCAHnB,OAAO,EAAA,CAAA;sBAAf,KAAK;gBACG,OAAO,EAAA,CAAA;sBAAf,KAAK;;;AEjBV;;AAEG;;;;"}
|
|
@@ -38,10 +38,10 @@ class CmatHighlightService {
|
|
|
38
38
|
// indentation, join them together and return it
|
|
39
39
|
return lines.map(line => line.substring(indentation)).join('\n');
|
|
40
40
|
}
|
|
41
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
42
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
41
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: CmatHighlightService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
42
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: CmatHighlightService, providedIn: 'root' }); }
|
|
43
43
|
}
|
|
44
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
44
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: CmatHighlightService, decorators: [{
|
|
45
45
|
type: Injectable,
|
|
46
46
|
args: [{
|
|
47
47
|
providedIn: 'root'
|
|
@@ -108,10 +108,10 @@ class CmatHighlightComponent {
|
|
|
108
108
|
// Detect the changes
|
|
109
109
|
this._viewRef.detectChanges();
|
|
110
110
|
}
|
|
111
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
112
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
111
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: CmatHighlightComponent, deps: [{ token: i1.DomSanitizer }, { token: i0.ElementRef }, { token: CmatHighlightService }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
112
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.0.1", type: CmatHighlightComponent, isStandalone: true, selector: "textarea[cmat-highlight]", inputs: { code: "code", lang: "lang" }, viewQueries: [{ propertyName: "templateRef", first: true, predicate: TemplateRef, descendants: true }], exportAs: ["cmatHighlight"], usesOnChanges: true, ngImport: i0, template: "<ng-content></ng-content>\r\n\r\n<ng-template let-highlightedCode=\"highlightedCode\" let-lang=\"lang\">\r\n <div class=\"cmat-highlight cmat-highlight-code-container\">\r\n <pre [ngClass]=\"'language-' + lang\"><code [ngClass]=\"'language-' + lang\" [innerHTML]=\"highlightedCode\"></code>\r\n </pre>\r\n </div>\r\n</ng-template>", styles: ["textarea[cmat-highlight]{display:none}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
113
113
|
}
|
|
114
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
114
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: CmatHighlightComponent, decorators: [{
|
|
115
115
|
type: Component,
|
|
116
116
|
args: [{ selector: 'textarea[cmat-highlight]', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, exportAs: 'cmatHighlight', standalone: true, imports: [NgClass], template: "<ng-content></ng-content>\r\n\r\n<ng-template let-highlightedCode=\"highlightedCode\" let-lang=\"lang\">\r\n <div class=\"cmat-highlight cmat-highlight-code-container\">\r\n <pre [ngClass]=\"'language-' + lang\"><code [ngClass]=\"'language-' + lang\" [innerHTML]=\"highlightedCode\"></code>\r\n </pre>\r\n </div>\r\n</ng-template>", styles: ["textarea[cmat-highlight]{display:none}\n"] }]
|
|
117
117
|
}], ctorParameters: () => [{ type: i1.DomSanitizer }, { type: i0.ElementRef }, { type: CmatHighlightService }, { type: i0.ViewContainerRef }], propDecorators: { code: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cmat-components-highlight.mjs","sources":["../../../projects/cmat/components/highlight/highlight.service.ts","../../../projects/cmat/components/highlight/highlight.component.ts","../../../projects/cmat/components/highlight/highlight.component.html","../../../projects/cmat/components/highlight/cmat-components-highlight.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\r\nimport hljs from 'highlight.js';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class CmatHighlightService {\r\n highlight(code: string, language: string): string {\r\n // Format the code\r\n code = this._format(code);\r\n\r\n // Highlight and return the code\r\n return hljs.highlight(code, { language }).value;\r\n }\r\n\r\n private _format(code: string): string {\r\n let indentation = 0;\r\n\r\n // Split the code into lines and store the lines\r\n const lines = code.split('\\n');\r\n\r\n // Trim the empty lines around the code block\r\n while (lines.length && lines[0].trim() === '') {\r\n lines.shift();\r\n }\r\n\r\n while (lines.length && lines[lines.length - 1].trim() === '') {\r\n lines.pop();\r\n }\r\n\r\n // Iterate through the lines\r\n lines.filter(line => line.length)\r\n .forEach((line, index) => {\r\n\r\n // Always get the indentation of the first line so we can\r\n // have something to compare with\r\n if (index === 0) {\r\n indentation = line.search(/\\S|$/);\r\n return;\r\n }\r\n\r\n // Look at all the remaining lines to figure out the smallest indentation.\r\n indentation = Math.min(line.search(/\\S|$/), indentation);\r\n });\r\n\r\n // Iterate through the lines one more time, remove the extra\r\n // indentation, join them together and return it\r\n return lines.map(line => line.substring(indentation)).join('\\n');\r\n }\r\n}\r\n","import { NgClass } from '@angular/common';\r\nimport {\r\n AfterViewInit,\r\n ChangeDetectionStrategy,\r\n Component,\r\n ElementRef,\r\n EmbeddedViewRef,\r\n Input,\r\n OnChanges,\r\n SecurityContext,\r\n SimpleChanges,\r\n TemplateRef,\r\n ViewChild,\r\n ViewContainerRef,\r\n ViewEncapsulation\r\n} from '@angular/core';\r\nimport { DomSanitizer } from '@angular/platform-browser';\r\nimport { CmatHighlightService } from './highlight.service';\r\n\r\n@Component({\r\n selector: 'textarea[cmat-highlight]',\r\n templateUrl: './highlight.component.html',\r\n styleUrls: ['./highlight.component.scss'],\r\n encapsulation: ViewEncapsulation.None,\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n exportAs: 'cmatHighlight',\r\n standalone: true,\r\n imports: [NgClass]\r\n})\r\nexport class CmatHighlightComponent implements OnChanges, AfterViewInit {\r\n @Input() code: string;\r\n @Input() lang: string;\r\n @ViewChild(TemplateRef) templateRef: TemplateRef<any>;\r\n\r\n highlightedCode: string | null;\r\n private _viewRef: EmbeddedViewRef<any> | null;\r\n\r\n constructor(\r\n private _domSanitizer: DomSanitizer,\r\n private _elementRef: ElementRef,\r\n private _cmatHighlightService: CmatHighlightService,\r\n private _viewContainerRef: ViewContainerRef\r\n ) {\r\n }\r\n\r\n ngOnChanges(changes: SimpleChanges): void {\r\n // Code & Lang\r\n if ('code' in changes || 'lang' in changes) {\r\n // Return if the viewContainerRef is not available\r\n if (!this._viewContainerRef.length) {\r\n return;\r\n }\r\n\r\n // Highlight and insert the code\r\n this._highlightAndInsert();\r\n }\r\n }\r\n\r\n ngAfterViewInit(): void {\r\n // Return if there is no language set\r\n if (!this.lang) {\r\n return;\r\n }\r\n\r\n // If there is no code input, get the code from\r\n // the textarea\r\n if (!this.code) {\r\n // Get the code\r\n this.code = this._elementRef.nativeElement.value;\r\n }\r\n\r\n // Highlight and insert\r\n this._highlightAndInsert();\r\n }\r\n\r\n private _highlightAndInsert(): void {\r\n // Return if the template reference is not available\r\n if (!this.templateRef) {\r\n return;\r\n }\r\n\r\n // Return if the code or language is not defined\r\n if (!this.code || !this.lang) {\r\n return;\r\n }\r\n\r\n // Destroy the component if there is already one\r\n if (this._viewRef) {\r\n this._viewRef.destroy();\r\n this._viewRef = null;\r\n }\r\n\r\n // Highlight and sanitize the code just in case\r\n this.highlightedCode = this._domSanitizer.sanitize(SecurityContext.HTML, this._cmatHighlightService.highlight(this.code, this.lang));\r\n\r\n // Return if the highlighted code is null\r\n if (this.highlightedCode === null) {\r\n return;\r\n }\r\n\r\n // Render and insert the template\r\n this._viewRef = this._viewContainerRef.createEmbeddedView(this.templateRef, {\r\n highlightedCode: this.highlightedCode,\r\n lang: this.lang\r\n });\r\n\r\n // Detect the changes\r\n this._viewRef.detectChanges();\r\n }\r\n}\r\n","<ng-content></ng-content>\r\n\r\n<ng-template let-highlightedCode=\"highlightedCode\" let-lang=\"lang\">\r\n <div class=\"cmat-highlight cmat-highlight-code-container\">\r\n <pre [ngClass]=\"'language-' + lang\"><code [ngClass]=\"'language-' + lang\" [innerHTML]=\"highlightedCode\"></code>\r\n </pre>\r\n </div>\r\n</ng-template>","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i2.CmatHighlightService"],"mappings":";;;;;;MAMa,oBAAoB,CAAA;IAC7B,SAAS,CAAC,IAAY,EAAE,QAAgB,EAAA;;AAEpC,QAAA,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;;AAG1B,QAAA,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC;KACnD;AAEO,IAAA,OAAO,CAAC,IAAY,EAAA;QACxB,IAAI,WAAW,GAAG,CAAC,CAAC;;QAGpB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;;AAG/B,QAAA,OAAO,KAAK,CAAC,MAA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AAA,eAAA,CAAA,EAAA,aAAA,EAAA,IAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,EAAA,gWAOc,kGDoBA,OAAO,EAAA,QAAA,EAAA,WAAA,EAAA,MAAA,EAAA,CAAA,OAAA,EAAA,SAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,aAAA,EAAA,EAAA,CAAA,iBAAA,CAAA,IAAA,EAAA,CAAA,CAAA,EAAA;;2FAER,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBAVlC,SAAS;AACI,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,0BAA0B,EAGrB,aAAA,EAAA,iBAAiB,CAAC,IAAI,mBACpB,uBAAuB,CAAC,MAAM,EAAA,QAAA,EACrC,eAAe,EACb,UAAA,EAAA,IAAI,EACP,OAAA,EAAA,CAAC,OAAO,CAAC,EAAA,QAAA,EAAA,gWAAA,EAAA,MAAA,EAAA,CAAA,0CAAA,CAAA,EAAA,CAAA;yKAGT,IAAI,EAAA,CAAA;sBAAZ,KAAK;gBACG,IAAI,EAAA,CAAA;sBAAZ,KAAK;gBACkB,WAAW,EAAA,CAAA;sBAAlC,SAAS;uBAAC,WAAW,CAAA;;;AEhC1B;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"cmat-components-highlight.mjs","sources":["../../../projects/cmat/components/highlight/highlight.service.ts","../../../projects/cmat/components/highlight/highlight.component.ts","../../../projects/cmat/components/highlight/highlight.component.html","../../../projects/cmat/components/highlight/cmat-components-highlight.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\r\nimport hljs from 'highlight.js';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class CmatHighlightService {\r\n highlight(code: string, language: string): string {\r\n // Format the code\r\n code = this._format(code);\r\n\r\n // Highlight and return the code\r\n return hljs.highlight(code, { language }).value;\r\n }\r\n\r\n private _format(code: string): string {\r\n let indentation = 0;\r\n\r\n // Split the code into lines and store the lines\r\n const lines = code.split('\\n');\r\n\r\n // Trim the empty lines around the code block\r\n while (lines.length && lines[0].trim() === '') {\r\n lines.shift();\r\n }\r\n\r\n while (lines.length && lines[lines.length - 1].trim() === '') {\r\n lines.pop();\r\n }\r\n\r\n // Iterate through the lines\r\n lines.filter(line => line.length)\r\n .forEach((line, index) => {\r\n\r\n // Always get the indentation of the first line so we can\r\n // have something to compare with\r\n if (index === 0) {\r\n indentation = line.search(/\\S|$/);\r\n return;\r\n }\r\n\r\n // Look at all the remaining lines to figure out the smallest indentation.\r\n indentation = Math.min(line.search(/\\S|$/), indentation);\r\n });\r\n\r\n // Iterate through the lines one more time, remove the extra\r\n // indentation, join them together and return it\r\n return lines.map(line => line.substring(indentation)).join('\\n');\r\n }\r\n}\r\n","import { NgClass } from '@angular/common';\r\nimport {\r\n AfterViewInit,\r\n ChangeDetectionStrategy,\r\n Component,\r\n ElementRef,\r\n EmbeddedViewRef,\r\n Input,\r\n OnChanges,\r\n SecurityContext,\r\n SimpleChanges,\r\n TemplateRef,\r\n ViewChild,\r\n ViewContainerRef,\r\n ViewEncapsulation\r\n} from '@angular/core';\r\nimport { DomSanitizer } from '@angular/platform-browser';\r\nimport { CmatHighlightService } from './highlight.service';\r\n\r\n@Component({\r\n selector: 'textarea[cmat-highlight]',\r\n templateUrl: './highlight.component.html',\r\n styleUrls: ['./highlight.component.scss'],\r\n encapsulation: ViewEncapsulation.None,\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n exportAs: 'cmatHighlight',\r\n standalone: true,\r\n imports: [NgClass]\r\n})\r\nexport class CmatHighlightComponent implements OnChanges, AfterViewInit {\r\n @Input() code: string;\r\n @Input() lang: string;\r\n @ViewChild(TemplateRef) templateRef: TemplateRef<any>;\r\n\r\n highlightedCode: string | null;\r\n private _viewRef: EmbeddedViewRef<any> | null;\r\n\r\n constructor(\r\n private _domSanitizer: DomSanitizer,\r\n private _elementRef: ElementRef,\r\n private _cmatHighlightService: CmatHighlightService,\r\n private _viewContainerRef: ViewContainerRef\r\n ) {\r\n }\r\n\r\n ngOnChanges(changes: SimpleChanges): void {\r\n // Code & Lang\r\n if ('code' in changes || 'lang' in changes) {\r\n // Return if the viewContainerRef is not available\r\n if (!this._viewContainerRef.length) {\r\n return;\r\n }\r\n\r\n // Highlight and insert the code\r\n this._highlightAndInsert();\r\n }\r\n }\r\n\r\n ngAfterViewInit(): void {\r\n // Return if there is no language set\r\n if (!this.lang) {\r\n return;\r\n }\r\n\r\n // If there is no code input, get the code from\r\n // the textarea\r\n if (!this.code) {\r\n // Get the code\r\n this.code = this._elementRef.nativeElement.value;\r\n }\r\n\r\n // Highlight and insert\r\n this._highlightAndInsert();\r\n }\r\n\r\n private _highlightAndInsert(): void {\r\n // Return if the template reference is not available\r\n if (!this.templateRef) {\r\n return;\r\n }\r\n\r\n // Return if the code or language is not defined\r\n if (!this.code || !this.lang) {\r\n return;\r\n }\r\n\r\n // Destroy the component if there is already one\r\n if (this._viewRef) {\r\n this._viewRef.destroy();\r\n this._viewRef = null;\r\n }\r\n\r\n // Highlight and sanitize the code just in case\r\n this.highlightedCode = this._domSanitizer.sanitize(SecurityContext.HTML, this._cmatHighlightService.highlight(this.code, this.lang));\r\n\r\n // Return if the highlighted code is null\r\n if (this.highlightedCode === null) {\r\n return;\r\n }\r\n\r\n // Render and insert the template\r\n this._viewRef = this._viewContainerRef.createEmbeddedView(this.templateRef, {\r\n highlightedCode: this.highlightedCode,\r\n lang: this.lang\r\n });\r\n\r\n // Detect the changes\r\n this._viewRef.detectChanges();\r\n }\r\n}\r\n","<ng-content></ng-content>\r\n\r\n<ng-template let-highlightedCode=\"highlightedCode\" let-lang=\"lang\">\r\n <div class=\"cmat-highlight cmat-highlight-code-container\">\r\n <pre [ngClass]=\"'language-' + lang\"><code [ngClass]=\"'language-' + lang\" [innerHTML]=\"highlightedCode\"></code>\r\n </pre>\r\n </div>\r\n</ng-template>","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-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atJsonEditorComponent {
|
|
|
97
97
|
json: this.data
|
|
98
98
|
};
|
|
99
99
|
if (this._editor) {
|
|
100
|
-
this._editor.update(this.content);
|
|
100
|
+
void this._editor.update(this.content);
|
|
101
101
|
}
|
|
102
102
|
this._changeDetectorRef.markForCheck();
|
|
103
103
|
}
|
|
104
104
|
if (changes.options) {
|
|
105
105
|
if (this._editor) {
|
|
106
|
-
this._editor?.updateProps(this.options);
|
|
106
|
+
void this._editor?.updateProps(this.options);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
ngOnDestroy() {
|
|
111
|
-
this._editor?.destroy();
|
|
111
|
+
void this._editor?.destroy();
|
|
112
112
|
}
|
|
113
113
|
setSchema(schema) {
|
|
114
114
|
const validator = createAjvValidator({ schema });
|
|
115
|
-
this._editor?.updateProps({ validator: validator });
|
|
115
|
+
void this._editor?.updateProps({ validator: validator });
|
|
116
116
|
}
|
|
117
117
|
setSelectionToPath(pathString) {
|
|
118
118
|
const path = parseJSONPath(pathString);
|
|
119
119
|
const selection = createMultiSelection(path, path);
|
|
120
120
|
try {
|
|
121
|
-
this._editor?.select(selection);
|
|
121
|
+
void this._editor?.select(selection);
|
|
122
122
|
}
|
|
123
123
|
catch (error) {
|
|
124
124
|
console.warn('Set selection to path not possible:', pathString, error);
|
|
@@ -144,7 +144,7 @@ class CmatJsonEditorComponent {
|
|
|
144
144
|
const value = {
|
|
145
145
|
json: json,
|
|
146
146
|
};
|
|
147
|
-
this._editor?.set(value);
|
|
147
|
+
void this._editor?.set(value);
|
|
148
148
|
}
|
|
149
149
|
_onSelect(selection) {
|
|
150
150
|
if (isKeySelection(selection)) {
|
|
@@ -156,10 +156,10 @@ class CmatJsonEditorComponent {
|
|
|
156
156
|
this.pathChanged.emit(st);
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
160
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
159
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: CmatJsonEditorComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
160
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.0.1", type: CmatJsonEditorComponent, isStandalone: true, selector: "cmat-json-editor", inputs: { options: "options", data: "data" }, outputs: { contentChanged: "contentChanged", pathChanged: "pathChanged" }, viewQueries: [{ propertyName: "jsonEditorContainer", first: true, predicate: ["jsonEditorContainer"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: '<div class="cmat-jsoneditor" [id]="id" #jsonEditorContainer></div>', isInline: true, styles: [".cmat-jsoneditor .jse-main.svelte-sxaskb{min-height:24rem}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
161
161
|
}
|
|
162
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
162
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: CmatJsonEditorComponent, decorators: [{
|
|
163
163
|
type: Component,
|
|
164
164
|
args: [{ selector: 'cmat-json-editor', template: '<div class="cmat-jsoneditor" [id]="id" #jsonEditorContainer></div>', preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, standalone: true, imports: [], styles: [".cmat-jsoneditor .jse-main.svelte-sxaskb{min-height:24rem}\n"] }]
|
|
165
165
|
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { jsonEditorContainer: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cmat-components-json-editor.mjs","sources":["../../../projects/cmat/components/json-editor/json-editor.component.ts","../../../projects/cmat/components/json-editor/cmat-components-json-editor.ts"],"sourcesContent":["import {\r\n Component,\r\n ElementRef,\r\n Input,\r\n OnInit,\r\n OnDestroy,\r\n ViewChild,\r\n Output,\r\n EventEmitter,\r\n ChangeDetectionStrategy,\r\n ViewEncapsulation,\r\n OnChanges,\r\n SimpleChanges,\r\n ChangeDetectorRef,\r\n} from '@angular/core';\r\nimport {\r\n JSONEditor,\r\n stringifyJSONPath,\r\n Content,\r\n MenuItem,\r\n createAjvValidator,\r\n parseJSONPath,\r\n JSONEditorSelection,\r\n isKeySelection,\r\n isJSONContent,\r\n JSONContent,\r\n isMultiSelection,\r\n createMultiSelection,\r\n MenuButton,\r\n TextContent,\r\n} from 'vanilla-jsoneditor';\r\n\r\n@Component({\r\n selector: 'cmat-json-editor',\r\n template: '<div class=\"cmat-jsoneditor\" [id]=\"id\" #jsonEditorContainer></div>',\r\n preserveWhitespaces: false,\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n styleUrls: ['./json-editor.component.scss'],\r\n encapsulation: ViewEncapsulation.None,\r\n standalone: true,\r\n imports: []\r\n})\r\nexport class CmatJsonEditorComponent implements OnInit, OnChanges, OnDestroy {\r\n @ViewChild('jsonEditorContainer', { static: true }) jsonEditorContainer!: ElementRef;\r\n @Input() options: any;\r\n @Input() data: any;\r\n\r\n @Output() contentChanged: EventEmitter<any> = new EventEmitter<any>();\r\n @Output() pathChanged: EventEmitter<string> = new EventEmitter<string>();\r\n\r\n public id = 'cmatjsoneditor' + Math.floor(Math.random() * 1000000);\r\n content: Content = {\r\n text: undefined,\r\n json: {}\r\n };\r\n\r\n private _editor: JSONEditor | undefined;\r\n\r\n constructor(private _changeDetectorRef: ChangeDetectorRef) { }\r\n\r\n ngOnInit(): void {\r\n if (!this.jsonEditorContainer.nativeElement) {\r\n console.error('Can\\'t find the ElementRef reference for jsoneditor)');\r\n }\r\n this._editor = new JSONEditor({\r\n target: this.jsonEditorContainer.nativeElement,\r\n props: {\r\n ...this.options,\r\n content: this.content,\r\n onChange: (\r\n updatedContent,\r\n previousContent,\r\n { contentErrors, patchResult }\r\n ): void => {\r\n console.log('onChange', {\r\n updatedContent,\r\n previousContent,\r\n contentErrors,\r\n patchResult,\r\n });\r\n this.content = updatedContent;\r\n this.contentChanged.emit(updatedContent);\r\n },\r\n onSelect: this._onSelect.bind(this),\r\n onRenderMenu(\r\n items: MenuItem[],\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n context: { mode: 'tree' | 'text' | 'table'; modal: boolean }\r\n ): MenuItem[] | undefined {\r\n // remove buttons for table-mode, transform, sort\r\n items.splice(\r\n items.findIndex(i => (i as MenuButton)['text'] === 'table'),\r\n 1\r\n );\r\n items.splice(\r\n items.findIndex(i => (i as MenuButton)['className'] === 'jse-sort'),\r\n 1\r\n );\r\n items.splice(\r\n items.findIndex(i => (i as MenuButton)['className'] === 'jse-transform'),\r\n 1\r\n );\r\n\r\n items.forEach((item) => {\r\n const button = item as MenuButton;\r\n switch (button['title']) {\r\n case 'Switch to text mode (current mode: text)':\r\n button.text = '文本';\r\n button.title = '切换到文本模式(当前模式:文本)';\r\n break;\r\n case 'Switch to tree mode (current mode: text)':\r\n button.text = '树';\r\n button.title = '切换到树模式(当前模式:文本)';\r\n break;\r\n case 'Switch to text mode (current mode: tree)':\r\n button.text = '文本';\r\n button.title = '切换到文本模式(当前模式:树)';\r\n break;\r\n case 'Switch to tree mode (current mode: tree)':\r\n button.text = '树';\r\n button.title = '切换到树模式(当前模式:树)';\r\n break;\r\n case 'Format JSON: add proper indentation and new lines (Ctrl+I)':\r\n button.title = 'JSON格式化: 添加适当的缩进和新行 (Ctrl+I)';\r\n break;\r\n case 'Compact JSON: remove all white spacing and new lines (Ctrl+Shift+I)':\r\n button.title = '压缩JSON: 删除所有白色间距和新行 (Ctrl+Shift+I)';\r\n break;\r\n case 'Search (Ctrl+F)':\r\n button.title = '搜索 (Ctrl+F)';\r\n break;\r\n case 'Undo (Ctrl+Z)':\r\n button.title = '撤回 (Ctrl+Z)';\r\n break;\r\n case 'Redo (Ctrl+Shift+Z)':\r\n button.title = '重试 (Ctrl+Shift+Z)';\r\n break;\r\n case 'Expand all':\r\n button.title = '全部展开';\r\n break;\r\n case 'Collapse all':\r\n button.title = '全部折叠';\r\n break;\r\n case 'Open context menu (Click here, right click on the selection, or use the context menu button or Ctrl+Q)':\r\n button.title = '打开内容菜单 (单击此处,右键单击所选内容,或使用内容菜单按钮或 Ctrl+Q)';\r\n break;\r\n }\r\n });\r\n return items;\r\n },\r\n },\r\n });\r\n }\r\n\r\n ngOnChanges(changes: SimpleChanges): void {\r\n if (changes.data) {\r\n this.content = {\r\n text: undefined,\r\n json: <any>this.data\r\n };\r\n\r\n if (this._editor) {\r\n this._editor.update(this.content);\r\n }\r\n\r\n this._changeDetectorRef.markForCheck();\r\n }\r\n\r\n if(changes.options){\r\n if(this._editor){\r\n this._editor?.updateProps(this.options);\r\n }\r\n }\r\n }\r\n\r\n ngOnDestroy(): void {\r\n this._editor?.destroy();\r\n }\r\n\r\n setSchema(schema: any): void {\r\n const validator = createAjvValidator({ schema });\r\n this._editor?.updateProps({ validator: validator });\r\n }\r\n\r\n setSelectionToPath(pathString: string): void {\r\n const path = parseJSONPath(pathString);\r\n const selection = createMultiSelection(path, path);\r\n\r\n try {\r\n this._editor?.select(selection);\r\n } catch (error) {\r\n console.warn('Set selection to path not possible:', pathString, error);\r\n }\r\n this.pathChanged.emit(pathString);\r\n }\r\n\r\n get(): JSON | undefined {\r\n if (this._editor) {\r\n const content: Content = this._editor.get();\r\n if (isJSONContent(content)) {\r\n const j: any = (this._editor.get() as JSONContent).json;\r\n return j;\r\n } else {\r\n const t: any = (this._editor.get() as TextContent).text;\r\n const j: JSON = JSON.parse(t);\r\n return j;\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n set(json: any): void {\r\n const value: JSONContent = {\r\n json: json,\r\n };\r\n\r\n this._editor?.set(value);\r\n }\r\n\r\n private _onSelect(selection: JSONEditorSelection | null): void {\r\n if (isKeySelection(selection)) {\r\n const st = stringifyJSONPath((selection as any).path);\r\n this.pathChanged.emit(st);\r\n } else if (isMultiSelection(selection)) {\r\n const st = stringifyJSONPath((selection as any).anchorPath);\r\n this.pathChanged.emit(st);\r\n }\r\n }\r\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MA0Ca,uBAAuB,CAAA;AAgBhC,IAAA,WAAA,CAAoB,kBAAqC,EAAA;QAArC,IAAkB,CAAA,kBAAA,GAAlB,kBAAkB,CAAmB;AAX/C,QAAA,IAAA,CAAA,cAAc,GAAsB,IAAI,YAAY,EAAO,CAAC;AAC5D,QAAA,IAAA,CAAA,WAAW,GAAyB,IAAI,YAAY,EAAU,CAAC;AAElE,QAAA,IAAA,CAAA,EAAE,GAAG,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;AACnE,QAAA,IAAA,CAAA,OAAO,GAAY;AACf,YAAA,IAAI,EAAE,SAAS;AACf,YAAA,IAAI,EAAE,EAAE;SACX,CAAC;KAI4D;IAE9D,QAAQ,GAAA;AACJ,QAAA,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,aAAa,EAAE;AACzC,YAAA,OAAO,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC;AACzE,SAAA;AACD,QAAA,IAAI,CAAC,OAAO,GAAG,IAAI,UAAU,CAAC;AAC1B,YAAA,MAAM,EAAE,IAAI,CAAC,mBAAmB,CAAC,aAAa;AAC9C,YAAA,KAAK,EAAE;gBACH,GAAG,IAAI,CAAC,OAAO;gBACf,OAAO,EAAE,IAAI,CAAC,OAAO;AACrB,gBAAA,QAAQ,EAAE,CACN,cAAc,EACd,eAAe,EACf,EAAE,aAAa,EAAE,WAAW,EAAE,KACxB;AACN,oBAAA,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE;wBACpB,cAAc;wBACd,eAAe;wBACf,aAAa;wBACb,WAAW;AACd,qBAAA,CA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,oWARtB,oEAAoE,EAAA,QAAA,EAAA,IAAA,EAAA,MAAA,EAAA,CAAA,8DAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,aAAA,EAAA,EAAA,CAAA,iBAAA,CAAA,IAAA,EAAA,CAAA,CAAA,EAAA;;2FAQrE,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBAVnC,SAAS;AACI,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,kBAAkB,EAClB,QAAA,EAAA,oEAAoE,EACzD,mBAAA,EAAA,KAAK,mBACT,uBAAuB,CAAC,MAAM,EAAA,aAAA,EAEhC,iBAAiB,CAAC,IAAI,EACzB,UAAA,EAAA,IAAI,WACP,EAAE,EAAA,MAAA,EAAA,CAAA,8DAAA,CAAA,EAAA,CAAA;sFAGyC,mBAAmB,EAAA,CAAA;sBAAtE,SAAS;AAAC,gBAAA,IAAA,EAAA,CAAA,qBAAqB,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;gBACzC,OAAO,EAAA,CAAA;sBAAf,KAAK;gBACG,IAAI,EAAA,CAAA;sBAAZ,KAAK;gBAEI,cAAc,EAAA,CAAA;sBAAvB,MAAM;gBACG,WAAW,EAAA,CAAA;sBAApB,MAAM;;;AChDX;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"cmat-components-json-editor.mjs","sources":["../../../projects/cmat/components/json-editor/json-editor.component.ts","../../../projects/cmat/components/json-editor/cmat-components-json-editor.ts"],"sourcesContent":["import {\r\n Component,\r\n ElementRef,\r\n Input,\r\n OnInit,\r\n OnDestroy,\r\n ViewChild,\r\n Output,\r\n EventEmitter,\r\n ChangeDetectionStrategy,\r\n ViewEncapsulation,\r\n OnChanges,\r\n SimpleChanges,\r\n ChangeDetectorRef,\r\n} from '@angular/core';\r\nimport {\r\n JSONEditor,\r\n stringifyJSONPath,\r\n Content,\r\n MenuItem,\r\n createAjvValidator,\r\n parseJSONPath,\r\n JSONEditorSelection,\r\n isKeySelection,\r\n isJSONContent,\r\n JSONContent,\r\n isMultiSelection,\r\n createMultiSelection,\r\n MenuButton,\r\n TextContent,\r\n} from 'vanilla-jsoneditor';\r\n\r\n@Component({\r\n selector: 'cmat-json-editor',\r\n template: '<div class=\"cmat-jsoneditor\" [id]=\"id\" #jsonEditorContainer></div>',\r\n preserveWhitespaces: false,\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n styleUrls: ['./json-editor.component.scss'],\r\n encapsulation: ViewEncapsulation.None,\r\n standalone: true,\r\n imports: []\r\n})\r\nexport class CmatJsonEditorComponent implements OnInit, OnChanges, OnDestroy {\r\n @ViewChild('jsonEditorContainer', { static: true }) jsonEditorContainer!: ElementRef;\r\n @Input() options: any;\r\n @Input() data: any;\r\n\r\n @Output() contentChanged: EventEmitter<any> = new EventEmitter<any>();\r\n @Output() pathChanged: EventEmitter<string> = new EventEmitter<string>();\r\n\r\n public id = 'cmatjsoneditor' + Math.floor(Math.random() * 1000000);\r\n content: Content = {\r\n text: undefined,\r\n json: {}\r\n };\r\n\r\n private _editor: JSONEditor | undefined;\r\n\r\n constructor(private _changeDetectorRef: ChangeDetectorRef) { }\r\n\r\n ngOnInit(): void {\r\n if (!this.jsonEditorContainer.nativeElement) {\r\n console.error('Can\\'t find the ElementRef reference for jsoneditor)');\r\n }\r\n this._editor = new JSONEditor({\r\n target: this.jsonEditorContainer.nativeElement,\r\n props: {\r\n ...this.options,\r\n content: this.content,\r\n onChange: (\r\n updatedContent,\r\n previousContent,\r\n { contentErrors, patchResult }\r\n ): void => {\r\n console.log('onChange', {\r\n updatedContent,\r\n previousContent,\r\n contentErrors,\r\n patchResult,\r\n });\r\n this.content = updatedContent;\r\n this.contentChanged.emit(updatedContent);\r\n },\r\n onSelect: this._onSelect.bind(this),\r\n onRenderMenu(\r\n items: MenuItem[],\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n context: { mode: 'tree' | 'text' | 'table'; modal: boolean }\r\n ): MenuItem[] | undefined {\r\n // remove buttons for table-mode, transform, sort\r\n items.splice(\r\n items.findIndex(i => (i as MenuButton)['text'] === 'table'),\r\n 1\r\n );\r\n items.splice(\r\n items.findIndex(i => (i as MenuButton)['className'] === 'jse-sort'),\r\n 1\r\n );\r\n items.splice(\r\n items.findIndex(i => (i as MenuButton)['className'] === 'jse-transform'),\r\n 1\r\n );\r\n\r\n items.forEach((item) => {\r\n const button = item as MenuButton;\r\n switch (button['title']) {\r\n case 'Switch to text mode (current mode: text)':\r\n button.text = '文本';\r\n button.title = '切换到文本模式(当前模式:文本)';\r\n break;\r\n case 'Switch to tree mode (current mode: text)':\r\n button.text = '树';\r\n button.title = '切换到树模式(当前模式:文本)';\r\n break;\r\n case 'Switch to text mode (current mode: tree)':\r\n button.text = '文本';\r\n button.title = '切换到文本模式(当前模式:树)';\r\n break;\r\n case 'Switch to tree mode (current mode: tree)':\r\n button.text = '树';\r\n button.title = '切换到树模式(当前模式:树)';\r\n break;\r\n case 'Format JSON: add proper indentation and new lines (Ctrl+I)':\r\n button.title = 'JSON格式化: 添加适当的缩进和新行 (Ctrl+I)';\r\n break;\r\n case 'Compact JSON: remove all white spacing and new lines (Ctrl+Shift+I)':\r\n button.title = '压缩JSON: 删除所有白色间距和新行 (Ctrl+Shift+I)';\r\n break;\r\n case 'Search (Ctrl+F)':\r\n button.title = '搜索 (Ctrl+F)';\r\n break;\r\n case 'Undo (Ctrl+Z)':\r\n button.title = '撤回 (Ctrl+Z)';\r\n break;\r\n case 'Redo (Ctrl+Shift+Z)':\r\n button.title = '重试 (Ctrl+Shift+Z)';\r\n break;\r\n case 'Expand all':\r\n button.title = '全部展开';\r\n break;\r\n case 'Collapse all':\r\n button.title = '全部折叠';\r\n break;\r\n case 'Open context menu (Click here, right click on the selection, or use the context menu button or Ctrl+Q)':\r\n button.title = '打开内容菜单 (单击此处,右键单击所选内容,或使用内容菜单按钮或 Ctrl+Q)';\r\n break;\r\n }\r\n });\r\n return items;\r\n },\r\n },\r\n });\r\n }\r\n\r\n ngOnChanges(changes: SimpleChanges): void {\r\n if (changes.data) {\r\n this.content = {\r\n text: undefined,\r\n json: this.data\r\n };\r\n\r\n if (this._editor) {\r\n void this._editor.update(this.content);\r\n }\r\n\r\n this._changeDetectorRef.markForCheck();\r\n }\r\n\r\n if(changes.options){\r\n if(this._editor){\r\n void this._editor?.updateProps(this.options);\r\n }\r\n }\r\n }\r\n\r\n ngOnDestroy(): void {\r\n void this._editor?.destroy();\r\n }\r\n\r\n setSchema(schema: any): void {\r\n const validator = createAjvValidator({ schema });\r\n void this._editor?.updateProps({ validator: validator });\r\n }\r\n\r\n setSelectionToPath(pathString: string): void {\r\n const path = parseJSONPath(pathString);\r\n const selection = createMultiSelection(path, path);\r\n\r\n try {\r\n void this._editor?.select(selection);\r\n } catch (error) {\r\n console.warn('Set selection to path not possible:', pathString, error);\r\n }\r\n this.pathChanged.emit(pathString);\r\n }\r\n\r\n get(): JSON | undefined {\r\n if (this._editor) {\r\n const content: Content = this._editor.get();\r\n if (isJSONContent(content)) {\r\n const j: any = (this._editor.get() as JSONContent).json;\r\n return j;\r\n } else {\r\n const t: any = (this._editor.get() as TextContent).text;\r\n const j: JSON = JSON.parse(t);\r\n return j;\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n set(json: any): void {\r\n const value: JSONContent = {\r\n json: json,\r\n };\r\n\r\n void this._editor?.set(value);\r\n }\r\n\r\n private _onSelect(selection: JSONEditorSelection | null): void {\r\n if (isKeySelection(selection)) {\r\n const st = stringifyJSONPath((selection as any).path);\r\n this.pathChanged.emit(st);\r\n } else if (isMultiSelection(selection)) {\r\n const st = stringifyJSONPath((selection as any).anchorPath);\r\n this.pathChanged.emit(st);\r\n }\r\n }\r\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MA0Ca,uBAAuB,CAAA;AAgBhC,IAAA,WAAA,CAAoB,kBAAqC,EAAA;QAArC,IAAkB,CAAA,kBAAA,GA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A,EAAA,oEAAoE,EACzD,mBAAA,EAAA,KAAK,mBACT,uBAAuB,CAAC,MAAM,EAAA,aAAA,EAEhC,iBAAiB,CAAC,IAAI,EACzB,UAAA,EAAA,IAAI,WACP,EAAE,EAAA,MAAA,EAAA,CAAA,8DAAA,CAAA,EAAA,CAAA;sFAGyC,mBAAmB,EAAA,CAAA;sBAAtE,SAAS;AAAC,gBAAA,IAAA,EAAA,CAAA,qBAAqB,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;gBACzC,OAAO,EAAA,CAAA;sBAAf,KAAK;gBACG,IAAI,EAAA,CAAA;sBAAZ,KAAK;gBAEI,cAAc,EAAA,CAAA;sBAAvB,MAAM;gBACG,WAAW,EAAA,CAAA;sBAApB,MAAM;;;AChDX;;AAEG;;;;"}
|
|
@@ -37,10 +37,10 @@ class CmatMasonryComponent {
|
|
|
37
37
|
this.distributedColumns[i % this.columns].items.push(this.items[i]);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
41
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
40
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: CmatMasonryComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
41
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.0.1", type: CmatMasonryComponent, isStandalone: true, selector: "cmat-masonry", inputs: { columnsTemplate: "columnsTemplate", columns: "columns", items: "items" }, exportAs: ["cmatMasonry"], usesOnChanges: true, ngImport: i0, template: "<div class=\"flex p-2\">\r\n <ng-container *ngTemplateOutlet=\"columnsTemplate; context: { $implicit: distributedColumns }\"></ng-container>\r\n</div>", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], animations: cmatAnimations, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
42
42
|
}
|
|
43
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
43
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: CmatMasonryComponent, decorators: [{
|
|
44
44
|
type: Component,
|
|
45
45
|
args: [{ selector: 'cmat-masonry', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, animations: cmatAnimations, exportAs: 'cmatMasonry', standalone: true, imports: [NgTemplateOutlet], template: "<div class=\"flex p-2\">\r\n <ng-container *ngTemplateOutlet=\"columnsTemplate; context: { $implicit: distributedColumns }\"></ng-container>\r\n</div>" }]
|
|
46
46
|
}], propDecorators: { columnsTemplate: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cmat-components-masonry.mjs","sources":["../../../projects/cmat/components/masonry/masonry.component.ts","../../../projects/cmat/components/masonry/masonry.component.html","../../../projects/cmat/components/masonry/cmat-components-masonry.ts"],"sourcesContent":["import { NgTemplateOutlet } from '@angular/common';\r\nimport {AfterViewInit, ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges, TemplateRef, ViewEncapsulation} from '@angular/core';\r\nimport {cmatAnimations} from 'cmat/animations';\r\n\r\n@Component({\r\n selector: 'cmat-masonry',\r\n templateUrl: './masonry.component.html',\r\n encapsulation: ViewEncapsulation.None,\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n animations: cmatAnimations,\r\n exportAs: 'cmatMasonry',\r\n standalone: true,\r\n imports: [NgTemplateOutlet]\r\n})\r\nexport class CmatMasonryComponent implements OnChanges, AfterViewInit {\r\n @Input({ required: true }) columnsTemplate: TemplateRef<any>;\r\n @Input({ required: true }) columns: number;\r\n @Input() items: any[] = [];\r\n distributedColumns: any[] = [];\r\n\r\n ngOnChanges(changes: SimpleChanges): void {\r\n // Columns\r\n if ('columns' in changes) {\r\n // Distribute the items\r\n this._distributeItems();\r\n }\r\n\r\n // Items\r\n if ('items' in changes) {\r\n // Distribute the items\r\n this._distributeItems();\r\n }\r\n }\r\n\r\n ngAfterViewInit(): void {\r\n // Distribute the items for the first time\r\n this._distributeItems();\r\n }\r\n\r\n private _distributeItems(): void {\r\n // Return an empty array if there are no items\r\n if (this.items.length === 0) {\r\n this.distributedColumns = [];\r\n return;\r\n }\r\n\r\n // Prepare the distributed columns array\r\n this.distributedColumns = Array.from(Array(this.columns), () => ({items: []}));\r\n\r\n // Distribute the items to columns\r\n for (let i = 0; i < this.items.length; i++) {\r\n this.distributedColumns[i % this.columns].items.push(this.items[i]);\r\n }\r\n }\r\n}\r\n","<div class=\"flex p-2\">\r\n <ng-container *ngTemplateOutlet=\"columnsTemplate; context: { $implicit: distributedColumns }\"></ng-container>\r\n</div>","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAca,oBAAoB,CAAA;AAVjC,IAAA,WAAA,GAAA;QAaa,IAAK,CAAA,KAAA,GAAU,EAAE,CAAC;QAC3B,IAAkB,CAAA,kBAAA,GAAU,EAAE,CAAC;AAoClC,KAAA;AAlCG,IAAA,WAAW,CAAC,OAAsB,EAAA;;
|
|
1
|
+
{"version":3,"file":"cmat-components-masonry.mjs","sources":["../../../projects/cmat/components/masonry/masonry.component.ts","../../../projects/cmat/components/masonry/masonry.component.html","../../../projects/cmat/components/masonry/cmat-components-masonry.ts"],"sourcesContent":["import { NgTemplateOutlet } from '@angular/common';\r\nimport {AfterViewInit, ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges, TemplateRef, ViewEncapsulation} from '@angular/core';\r\nimport {cmatAnimations} from 'cmat/animations';\r\n\r\n@Component({\r\n selector: 'cmat-masonry',\r\n templateUrl: './masonry.component.html',\r\n encapsulation: ViewEncapsulation.None,\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n animations: cmatAnimations,\r\n exportAs: 'cmatMasonry',\r\n standalone: true,\r\n imports: [NgTemplateOutlet]\r\n})\r\nexport class CmatMasonryComponent implements OnChanges, AfterViewInit {\r\n @Input({ required: true }) columnsTemplate: TemplateRef<any>;\r\n @Input({ required: true }) columns: number;\r\n @Input() items: any[] = [];\r\n distributedColumns: any[] = [];\r\n\r\n ngOnChanges(changes: SimpleChanges): void {\r\n // Columns\r\n if ('columns' in changes) {\r\n // Distribute the items\r\n this._distributeItems();\r\n }\r\n\r\n // Items\r\n if ('items' in changes) {\r\n // Distribute the items\r\n this._distributeItems();\r\n }\r\n }\r\n\r\n ngAfterViewInit(): void {\r\n // Distribute the items for the first time\r\n this._distributeItems();\r\n }\r\n\r\n private _distributeItems(): void {\r\n // Return an empty array if there are no items\r\n if (this.items.length === 0) {\r\n this.distributedColumns = [];\r\n return;\r\n }\r\n\r\n // Prepare the distributed columns array\r\n this.distributedColumns = Array.from(Array(this.columns), () => ({items: []}));\r\n\r\n // Distribute the items to columns\r\n for (let i = 0; i < this.items.length; i++) {\r\n this.distributedColumns[i % this.columns].items.push(this.items[i]);\r\n }\r\n }\r\n}\r\n","<div class=\"flex p-2\">\r\n <ng-container *ngTemplateOutlet=\"columnsTemplate; context: { $implicit: distributedColumns }\"></ng-container>\r\n</div>","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAca,oBAAoB,CAAA;AAVjC,IAAA,WAAA,GAAA;QAaa,IAAK,CAAA,KAAA,GAAU,EAAE,CAAC;QAC3B,IAAkB,CAAA,kBAAA,GAAU,EAAE,CAAC;AAoClC,KAAA;AAlCG,IAAA,WAAW,CAAC,OAAsB,EAAA;;AAE9B,QAAA,IAAI,SAAS,IAAI,OAAO,EAAE;;YAEtB,IAAI,CAAC,gBAAgB,EAAE,CAAC;SAC3B;;AAGD,QAAA,IAAI,OAAO,IAAI,OAAO,EAAE;;YAEpB,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A,IAAA,EAAA,WAAA,EAAA,IAAA,EAAA,gBAAgB,sIAHd,cAAc,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,aAAA,EAAA,EAAA,CAAA,iBAAA,CAAA,IAAA,EAAA,CAAA,CAAA,EAAA;;2FAKjB,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBAVhC,SAAS;AACI,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,cAAc,iBAET,iBAAiB,CAAC,IAAI,EAAA,eAAA,EACpB,uBAAuB,CAAC,MAAM,EACnC,UAAA,EAAA,cAAc,YAChB,aAAa,EAAA,UAAA,EACX,IAAI,EACP,OAAA,EAAA,CAAC,gBAAgB,CAAC,EAAA,QAAA,EAAA,2JAAA,EAAA,CAAA;8BAGA,eAAe,EAAA,CAAA;sBAAzC,KAAK;uBAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;gBACE,OAAO,EAAA,CAAA;sBAAjC,KAAK;uBAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;gBAChB,KAAK,EAAA,CAAA;sBAAb,KAAK;;;AEjBV;;AAEG;;;;"}
|
|
@@ -41,7 +41,9 @@ class CmatMaterialColorPickerComponent {
|
|
|
41
41
|
this.selectedHue = '500';
|
|
42
42
|
this.selectedPalette = 'bg-indigo';
|
|
43
43
|
this.view = 'palettes';
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
44
45
|
this._modelChange = () => { };
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
45
47
|
this._modelTouched = () => { };
|
|
46
48
|
this.updateSelectedColor();
|
|
47
49
|
}
|
|
@@ -140,15 +142,12 @@ class CmatMaterialColorPickerComponent {
|
|
|
140
142
|
this.view = 'hues';
|
|
141
143
|
}
|
|
142
144
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.9", ngImport: i0, type: CmatMaterialColorPickerComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
147
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.9", type: CmatMaterialColorPickerComponent, isStandalone: true, selector: "cmat-material-color-picker", inputs: { color: "color", title: "title", readonly: "readonly" }, outputs: { colorChanged: "colorChanged" }, providers: [CMAT_MATERIAL_COLOR_PICKER_VALUE_ACCESSOR], exportAs: ["cmatMaterialColorPicker"], ngImport: i0, template: "<div class=\"rounded\" [ngClass]=\"selectedColor.color\">\n <mat-select value=\"init\" [disableOptionCentering]=\"true\" [hideSingleSelectionIndicator]=\"true\" [disabled]=\"readonly\"\n (openedChange)=\"onMenuOpen($event)\" panelClass=\"min-w-64\">\n <mat-select-trigger class=\"flex p-1\">\n <mat-icon [svgIcon]=\"'heroicons_outline:paint-brush'\"></mat-icon>\n </mat-select-trigger>\n\n <header [ngClass]=\"'accent'\" class=\"shadow flex flex-row content-between justify-between p-2\">\n <button type=\"button\" mat-icon-button class=\"secondary-text\" [class.invisible]=\"view === 'palettes'\"\n (click)=\"goToPalettesView()\" aria-label=\"\u8C03\u8272\u677F\">\n <mat-icon svgIcon=\"mat_outline:arrow_back\"></mat-icon>\n </button>\n <span class=\"align-middle leading-loose text-xl font-bold\">{{title}}</span>\n <button type=\"button\" mat-icon-button class=\"remove-color-button secondary-text\" (click)=\"removeColor()\"\n aria-label=\"\u79FB\u9664\u989C\u8272\" matTooltip=\"\u79FB\u9664\u989C\u8272\">\n <mat-icon color=\"warn\" [svgIcon]=\"'mat_outline:cleaning_services'\"></mat-icon>\n </button>\n </header>\n\n <div class=\"flex flex-wrap w-60 m-2\">\n <mat-option value=\"init\" class=\"hidden\">\u521D\u59CB\u5316</mat-option>\n <div>\n @switch (view) {\n @case ('palettes') {\n <div>\n <div class=\"flex flex-row flex-wrap justify-start content-start colors\">\n @for (palette of palettes; track trackByFn($index, palette)) {\n <div role=\"presentation\"\n class=\"cursor-pointer\" (click)=\"selectPalette(palette)\">\n <mat-option\n class=\"relative flex w-12 h-12 p-0 pointer-events-none rounded-full bg-transparent hover:opacity-50\"\n [value]=\"selectedPalette\">\n @if (selectedColor.color===palette + '-' + selectedHue) {\n <mat-icon class=\"absolute m-3 text-white\"\n [svgIcon]=\"'heroicons_outline:check'\"></mat-icon>\n }\n <span class=\"flex w-10 h-10 m-1 rounded-full\"\n [ngClass]=\"palette + '-' + selectedHue\"></span>\n </mat-option>\n </div>\n }\n </div>\n </div>\n }\n @case ('hues') {\n <div>\n <div class=\"flex flex-row flex-wrap justify-start content-start colors\">\n @for (hue of hues; track trackByFn($index, hue)) {\n <div role=\"presentation\" class=\"cursor-pointer\"\n (click)=\"selectHue(hue)\">\n <mat-option\n class=\"relative flex w-12 h-12 p-0 pointer-events-none rounded-full bg-transparent hover:opacity-50\"\n [value]=\"selectedHue\">\n @if (selectedColor.color===selectedPalette + '-' + hue) {\n <mat-icon class=\"absolute m-3 text-white\"\n [svgIcon]=\"'heroicons_outline:check'\"></mat-icon>\n }\n <span class=\"flex w-10 h-10 m-1 rounded-full\"\n [ngClass]=\"selectedPalette + '-' + hue\"></span>\n </mat-option>\n </div>\n }\n </div>\n </div>\n }\n }\n </div>\n </div>\n </mat-select>\n</div>", styles: ["cmat-material-color-picker .mat-mdc-select-arrow-wrapper{display:none!important}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i1.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "directive", type: i1.MatSelectTrigger, selector: "mat-select-trigger" }, { kind: "component", type: i2.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i4.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i5.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }], animations: cmatAnimations, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
145
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: CmatMaterialColorPickerComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
146
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.0.1", type: CmatMaterialColorPickerComponent, isStandalone: true, selector: "cmat-material-color-picker", inputs: { color: "color", title: "title", readonly: "readonly" }, outputs: { colorChanged: "colorChanged" }, providers: [CMAT_MATERIAL_COLOR_PICKER_VALUE_ACCESSOR], exportAs: ["cmatMaterialColorPicker"], ngImport: i0, template: "<div class=\"rounded\" [ngClass]=\"selectedColor.color\">\n <mat-select value=\"init\" panelClass=\"min-w-64\" [disableOptionCentering]=\"true\" [hideSingleSelectionIndicator]=\"true\"\n [disabled]=\"readonly\" (openedChange)=\"onMenuOpen($event)\">\n <mat-select-trigger class=\"flex p-1\">\n <mat-icon [svgIcon]=\"'heroicons_outline:paint-brush'\"></mat-icon>\n </mat-select-trigger>\n\n <header class=\"shadow flex flex-row content-between justify-between p-2\" [ngClass]=\"'accent'\">\n <button type=\"button\" mat-icon-button class=\"secondary-text\" aria-label=\"\u8C03\u8272\u677F\"\n [class.invisible]=\"view === 'palettes'\" (click)=\"goToPalettesView()\">\n <mat-icon svgIcon=\"mat_outline:arrow_back\"></mat-icon>\n </button>\n <span class=\"align-middle leading-loose text-xl font-bold\">{{title}}</span>\n <button type=\"button\" mat-icon-button class=\"remove-color-button secondary-text\" aria-label=\"\u79FB\u9664\u989C\u8272\"\n matTooltip=\"\u79FB\u9664\u989C\u8272\" (click)=\"removeColor()\">\n <mat-icon color=\"warn\" [svgIcon]=\"'mat_outline:cleaning_services'\"></mat-icon>\n </button>\n </header>\n\n <div class=\"flex flex-wrap w-60 m-2\">\n <mat-option value=\"init\" class=\"hidden\">\u521D\u59CB\u5316</mat-option>\n <div>\n @switch (view) {\n @case ('palettes') {\n <div>\n <div class=\"flex flex-row flex-wrap justify-start content-start colors\">\n @for (palette of palettes; track $index) {\n <div role=\"presentation\"\n class=\"cursor-pointer\" (click)=\"selectPalette(palette)\">\n <mat-option\n class=\"relative flex w-12 h-12 p-0 pointer-events-none rounded-full bg-transparent hover:opacity-50\"\n [value]=\"selectedPalette\">\n @if (selectedColor.color===palette + '-' + selectedHue) {\n <mat-icon class=\"absolute m-3 text-white\"\n [svgIcon]=\"'heroicons_outline:check'\"></mat-icon>\n }\n <span class=\"flex w-10 h-10 m-1 rounded-full\"\n [ngClass]=\"palette + '-' + selectedHue\"></span>\n </mat-option>\n </div>\n }\n </div>\n </div>\n }\n @case ('hues') {\n <div>\n <div class=\"flex flex-row flex-wrap justify-start content-start colors\">\n @for (hue of hues; track $index) {\n <div role=\"presentation\" class=\"cursor-pointer\"\n (click)=\"selectHue(hue)\">\n <mat-option\n class=\"relative flex w-12 h-12 p-0 pointer-events-none rounded-full bg-transparent hover:opacity-50\"\n [value]=\"selectedHue\">\n @if (selectedColor.color===selectedPalette + '-' + hue) {\n <mat-icon class=\"absolute m-3 text-white\"\n [svgIcon]=\"'heroicons_outline:check'\"></mat-icon>\n }\n <span class=\"flex w-10 h-10 m-1 rounded-full\"\n [ngClass]=\"selectedPalette + '-' + hue\"></span>\n </mat-option>\n </div>\n }\n </div>\n </div>\n }\n }\n </div>\n </div>\n </mat-select>\n</div>", styles: ["cmat-material-color-picker .mat-mdc-select-arrow-wrapper{display:none!important}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i1.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "directive", type: i1.MatSelectTrigger, selector: "mat-select-trigger" }, { kind: "component", type: i2.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i4.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i5.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }], animations: cmatAnimations, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
148
147
|
}
|
|
149
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
148
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: CmatMaterialColorPickerComponent, decorators: [{
|
|
150
149
|
type: Component,
|
|
151
|
-
args: [{ selector: 'cmat-material-color-picker', animations: cmatAnimations, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, exportAs: 'cmatMaterialColorPicker', providers: [CMAT_MATERIAL_COLOR_PICKER_VALUE_ACCESSOR], standalone: true, imports: [NgClass, MatSelectModule, MatIconModule, MatButtonModule, MatTooltipModule], template: "<div class=\"rounded\" [ngClass]=\"selectedColor.color\">\n <mat-select value=\"init\" [disableOptionCentering]=\"true\" [hideSingleSelectionIndicator]=\"true\"
|
|
150
|
+
args: [{ selector: 'cmat-material-color-picker', animations: cmatAnimations, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, exportAs: 'cmatMaterialColorPicker', providers: [CMAT_MATERIAL_COLOR_PICKER_VALUE_ACCESSOR], standalone: true, imports: [NgClass, MatSelectModule, MatIconModule, MatButtonModule, MatTooltipModule], template: "<div class=\"rounded\" [ngClass]=\"selectedColor.color\">\n <mat-select value=\"init\" panelClass=\"min-w-64\" [disableOptionCentering]=\"true\" [hideSingleSelectionIndicator]=\"true\"\n [disabled]=\"readonly\" (openedChange)=\"onMenuOpen($event)\">\n <mat-select-trigger class=\"flex p-1\">\n <mat-icon [svgIcon]=\"'heroicons_outline:paint-brush'\"></mat-icon>\n </mat-select-trigger>\n\n <header class=\"shadow flex flex-row content-between justify-between p-2\" [ngClass]=\"'accent'\">\n <button type=\"button\" mat-icon-button class=\"secondary-text\" aria-label=\"\u8C03\u8272\u677F\"\n [class.invisible]=\"view === 'palettes'\" (click)=\"goToPalettesView()\">\n <mat-icon svgIcon=\"mat_outline:arrow_back\"></mat-icon>\n </button>\n <span class=\"align-middle leading-loose text-xl font-bold\">{{title}}</span>\n <button type=\"button\" mat-icon-button class=\"remove-color-button secondary-text\" aria-label=\"\u79FB\u9664\u989C\u8272\"\n matTooltip=\"\u79FB\u9664\u989C\u8272\" (click)=\"removeColor()\">\n <mat-icon color=\"warn\" [svgIcon]=\"'mat_outline:cleaning_services'\"></mat-icon>\n </button>\n </header>\n\n <div class=\"flex flex-wrap w-60 m-2\">\n <mat-option value=\"init\" class=\"hidden\">\u521D\u59CB\u5316</mat-option>\n <div>\n @switch (view) {\n @case ('palettes') {\n <div>\n <div class=\"flex flex-row flex-wrap justify-start content-start colors\">\n @for (palette of palettes; track $index) {\n <div role=\"presentation\"\n class=\"cursor-pointer\" (click)=\"selectPalette(palette)\">\n <mat-option\n class=\"relative flex w-12 h-12 p-0 pointer-events-none rounded-full bg-transparent hover:opacity-50\"\n [value]=\"selectedPalette\">\n @if (selectedColor.color===palette + '-' + selectedHue) {\n <mat-icon class=\"absolute m-3 text-white\"\n [svgIcon]=\"'heroicons_outline:check'\"></mat-icon>\n }\n <span class=\"flex w-10 h-10 m-1 rounded-full\"\n [ngClass]=\"palette + '-' + selectedHue\"></span>\n </mat-option>\n </div>\n }\n </div>\n </div>\n }\n @case ('hues') {\n <div>\n <div class=\"flex flex-row flex-wrap justify-start content-start colors\">\n @for (hue of hues; track $index) {\n <div role=\"presentation\" class=\"cursor-pointer\"\n (click)=\"selectHue(hue)\">\n <mat-option\n class=\"relative flex w-12 h-12 p-0 pointer-events-none rounded-full bg-transparent hover:opacity-50\"\n [value]=\"selectedHue\">\n @if (selectedColor.color===selectedPalette + '-' + hue) {\n <mat-icon class=\"absolute m-3 text-white\"\n [svgIcon]=\"'heroicons_outline:check'\"></mat-icon>\n }\n <span class=\"flex w-10 h-10 m-1 rounded-full\"\n [ngClass]=\"selectedPalette + '-' + hue\"></span>\n </mat-option>\n </div>\n }\n </div>\n </div>\n }\n }\n </div>\n </div>\n </mat-select>\n</div>", styles: ["cmat-material-color-picker .mat-mdc-select-arrow-wrapper{display:none!important}\n"] }]
|
|
152
151
|
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { colorChanged: [{
|
|
153
152
|
type: Output
|
|
154
153
|
}], color: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cmat-components-material-color-picker.mjs","sources":["../../../projects/cmat/components/material-color-picker/base-color.ts","../../../projects/cmat/components/material-color-picker/material-color-picker.component.ts","../../../projects/cmat/components/material-color-picker/material-color-picker.component.html","../../../projects/cmat/components/material-color-picker/selected-color.ts","../../../projects/cmat/components/material-color-picker/cmat-components-material-color-picker.ts"],"sourcesContent":["export const baseColors = [\r\n 'bg-slate',\r\n 'bg-red',\r\n 'bg-amber',\r\n 'bg-orange',\r\n 'bg-emerald',\r\n 'bg-teal',\r\n 'bg-blue',\r\n 'bg-indigo',\r\n 'bg-violet',\r\n 'bg-pink'\r\n];\r\n","import { NgClass } from '@angular/common';\r\nimport { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, forwardRef, Input, Output, ViewEncapsulation } from '@angular/core';\r\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\r\nimport { MatButtonModule } from '@angular/material/button';\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { MatSelectModule } from '@angular/material/select';\r\nimport { MatTooltipModule } from '@angular/material/tooltip';\r\nimport { cmatAnimations } from 'cmat/animations';\r\nimport { baseColors } from './base-color';\r\nimport { CmatSelectedColor } from './selected-color';\r\n\r\nexport const CMAT_MATERIAL_COLOR_PICKER_VALUE_ACCESSOR: any = {\r\n provide: NG_VALUE_ACCESSOR,\r\n useExisting: forwardRef(() => CmatMaterialColorPickerComponent),\r\n multi: true\r\n};\r\n\r\n\r\n@Component({\r\n selector: 'cmat-material-color-picker',\r\n templateUrl: './material-color-picker.component.html',\r\n styleUrls: ['./material-color-picker.component.scss'],\r\n animations: cmatAnimations,\r\n encapsulation: ViewEncapsulation.None,\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n exportAs: 'cmatMaterialColorPicker',\r\n providers: [CMAT_MATERIAL_COLOR_PICKER_VALUE_ACCESSOR],\r\n standalone: true,\r\n imports: [NgClass, MatSelectModule, MatIconModule, MatButtonModule, MatTooltipModule]\r\n})\r\nexport class CmatMaterialColorPickerComponent implements ControlValueAccessor {\r\n // Color changed\r\n @Output()\r\n colorChanged: EventEmitter<any>;\r\n\r\n palettes: string[];\r\n hues: string[];\r\n view: string;\r\n selectedColor: CmatSelectedColor;\r\n selectedPalette: string;\r\n selectedHue: string;\r\n\r\n // Private\r\n private _color: string;\r\n private _title: string;\r\n private _readonly:boolean;\r\n private _modelChange: (value: any) => void;\r\n private _modelTouched: (value: any) => void;\r\n\r\n constructor(private _changeDetectorRef: ChangeDetectorRef) {\r\n // Set the defaults\r\n this.colorChanged = new EventEmitter();\r\n this.palettes = baseColors;\r\n this.hues = ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900'];\r\n this.selectedHue = '500';\r\n this.selectedPalette = 'bg-indigo';\r\n this.view = 'palettes';\r\n\r\n this._modelChange = (): any => { };\r\n this._modelTouched = (): any => { };\r\n\r\n this.updateSelectedColor();\r\n }\r\n\r\n get color(): string {\r\n return this._color;\r\n }\r\n\r\n @Input()\r\n set color(value) {\r\n if (!value || value === '' || this._color === value) {\r\n return;\r\n }\r\n\r\n // Split the color value (bg-red-400, bg-blue-500 etc.)\r\n const colorParts = value.split('-');\r\n\r\n // Take the very last part as the selected hue value\r\n this.selectedHue = colorParts[colorParts.length - 1];\r\n\r\n // Remove the last part\r\n colorParts.pop();\r\n\r\n // Rejoin the remaining parts as the selected palette name\r\n this.selectedPalette = colorParts.join('-');\r\n\r\n // Update the selected color\r\n this.updateSelectedColor();\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/member-ordering\r\n get title(): string {\r\n return this._title;\r\n }\r\n\r\n @Input()\r\n set title(value) {\r\n this._title = value;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/member-ordering\r\n get readonly(): boolean {\r\n return this._readonly;\r\n }\r\n\r\n @Input()\r\n set readonly(value) {\r\n this._readonly = value;\r\n }\r\n \r\n\r\n registerOnChange(fn: any): void {\r\n this._modelChange = fn;\r\n }\r\n\r\n registerOnTouched(fn: any): void {\r\n this._modelTouched = fn;\r\n }\r\n\r\n writeValue(color: any): void {\r\n // Return if null\r\n if (!color) {\r\n return;\r\n }\r\n\r\n // Set the color\r\n this.color = color;\r\n }\r\n\r\n selectPalette(palette: string): void {\r\n // Go to 'hues' view\r\n this.view = 'hues';\r\n\r\n // Update the selected palette\r\n this.selectedPalette = palette;\r\n\r\n // Update the selected color\r\n this.updateSelectedColor();\r\n }\r\n\r\n selectHue(hue: string): void {\r\n // Update the selected hue\r\n this.selectedHue = hue;\r\n\r\n // Update the selected color\r\n this.updateSelectedColor();\r\n }\r\n\r\n removeColor(): void {\r\n // Return to the 'palettes' view\r\n this.view = 'palettes';\r\n\r\n // Clear the selected palette and hue\r\n this.selectedPalette = 'bg-indigo';\r\n this.selectedHue = '500';\r\n\r\n // Update the selected color\r\n this.updateSelectedColor();\r\n }\r\n\r\n updateSelectedColor(): void {\r\n if (this.selectedColor && this.selectedColor.palette === this.selectedPalette && this.selectedColor.hue === this.selectedHue) {\r\n return;\r\n }\r\n\r\n // Set the selected color object\r\n this.selectedColor = {\r\n palette: this.selectedPalette,\r\n hue: this.selectedHue,\r\n color: this.selectedPalette + '-' + this.selectedHue\r\n };\r\n\r\n this._color = this.selectedColor.color;\r\n\r\n this.colorChanged.emit(this.selectedColor);\r\n\r\n // Mark the model as touched\r\n this._modelTouched(this.selectedColor.color);\r\n\r\n // Update the model\r\n this._modelChange(this.selectedColor.color);\r\n\r\n this._changeDetectorRef.markForCheck();\r\n }\r\n\r\n goToPalettesView(): void {\r\n this.view = 'palettes';\r\n }\r\n\r\n onMenuOpen(opened: boolean): void {\r\n if (opened) {\r\n this.view = 'hues';\r\n }\r\n }\r\n\r\n trackByFn(index: number, item: any): any {\r\n return index || item;\r\n }\r\n}\r\n","<div class=\"rounded\" [ngClass]=\"selectedColor.color\">\n <mat-select value=\"init\" [disableOptionCentering]=\"true\" [hideSingleSelectionIndicator]=\"true\" [disabled]=\"readonly\"\n (openedChange)=\"onMenuOpen($event)\" panelClass=\"min-w-64\">\n <mat-select-trigger class=\"flex p-1\">\n <mat-icon [svgIcon]=\"'heroicons_outline:paint-brush'\"></mat-icon>\n </mat-select-trigger>\n\n <header [ngClass]=\"'accent'\" class=\"shadow flex flex-row content-between justify-between p-2\">\n <button type=\"button\" mat-icon-button class=\"secondary-text\" [class.invisible]=\"view === 'palettes'\"\n (click)=\"goToPalettesView()\" aria-label=\"调色板\">\n <mat-icon svgIcon=\"mat_outline:arrow_back\"></mat-icon>\n </button>\n <span class=\"align-middle leading-loose text-xl font-bold\">{{title}}</span>\n <button type=\"button\" mat-icon-button class=\"remove-color-button secondary-text\" (click)=\"removeColor()\"\n aria-label=\"移除颜色\" matTooltip=\"移除颜色\">\n <mat-icon color=\"warn\" [svgIcon]=\"'mat_outline:cleaning_services'\"></mat-icon>\n </button>\n </header>\n\n <div class=\"flex flex-wrap w-60 m-2\">\n <mat-option value=\"init\" class=\"hidden\">初始化</mat-option>\n <div>\n @switch (view) {\n @case ('palettes') {\n <div>\n <div class=\"flex flex-row flex-wrap justify-start content-start colors\">\n @for (palette of palettes; track trackByFn($index, palette)) {\n <div role=\"presentation\"\n class=\"cursor-pointer\" (click)=\"selectPalette(palette)\">\n <mat-option\n class=\"relative flex w-12 h-12 p-0 pointer-events-none rounded-full bg-transparent hover:opacity-50\"\n [value]=\"selectedPalette\">\n @if (selectedColor.color===palette + '-' + selectedHue) {\n <mat-icon class=\"absolute m-3 text-white\"\n [svgIcon]=\"'heroicons_outline:check'\"></mat-icon>\n }\n <span class=\"flex w-10 h-10 m-1 rounded-full\"\n [ngClass]=\"palette + '-' + selectedHue\"></span>\n </mat-option>\n </div>\n }\n </div>\n </div>\n }\n @case ('hues') {\n <div>\n <div class=\"flex flex-row flex-wrap justify-start content-start colors\">\n @for (hue of hues; track trackByFn($index, hue)) {\n <div role=\"presentation\" class=\"cursor-pointer\"\n (click)=\"selectHue(hue)\">\n <mat-option\n class=\"relative flex w-12 h-12 p-0 pointer-events-none rounded-full bg-transparent hover:opacity-50\"\n [value]=\"selectedHue\">\n @if (selectedColor.color===selectedPalette + '-' + hue) {\n <mat-icon class=\"absolute m-3 text-white\"\n [svgIcon]=\"'heroicons_outline:check'\"></mat-icon>\n }\n <span class=\"flex w-10 h-10 m-1 rounded-full\"\n [ngClass]=\"selectedPalette + '-' + hue\"></span>\n </mat-option>\n </div>\n }\n </div>\n </div>\n }\n }\n </div>\n </div>\n </mat-select>\n</div>","export class CmatSelectedColor {\r\n palette: string;\r\n hue: string;\r\n color: string;\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAO,MAAM,UAAU,GAAG;IACtB,UAAU;IACV,QAAQ;IACR,UAAU;IACV,WAAW;IACX,YAAY;IACZ,SAAS;IACT,SAAS;IACT,WAAW;IACX,WAAW;IACX,SAAS;CACZ;;ACAY,MAAA,yCAAyC,GAAQ;AAC1D,IAAA,OAAO,EAAE,iBAAiB;AAC1B,IAAA,WAAW,EAAE,UAAU,CAAC,MAAM,gCAAgC,CAAC;AAC/D,IAAA,KAAK,EAAE,IAAI;EACb;MAeW,gCAAgC,CAAA;AAmBzC,IAAA,WAAA,CAAoB,kBAAqC,EAAA;QAArC,IAAkB,CAAA,kBAAA,GAAlB,kBAAkB,CAAmB;;AAErD,QAAA,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;AACvC,QAAA,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,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A;sBADR,KAAK;gBA4BF,KAAK,EAAA,CAAA;sBADR,KAAK;gBAWF,QAAQ,EAAA,CAAA;sBADX,KAAK;;;MEzGG,iBAAiB,CAAA;AAI7B;;ACJD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"cmat-components-material-color-picker.mjs","sources":["../../../projects/cmat/components/material-color-picker/base-color.ts","../../../projects/cmat/components/material-color-picker/material-color-picker.component.ts","../../../projects/cmat/components/material-color-picker/material-color-picker.component.html","../../../projects/cmat/components/material-color-picker/selected-color.ts","../../../projects/cmat/components/material-color-picker/cmat-components-material-color-picker.ts"],"sourcesContent":["export const baseColors = [\r\n 'bg-slate',\r\n 'bg-red',\r\n 'bg-amber',\r\n 'bg-orange',\r\n 'bg-emerald',\r\n 'bg-teal',\r\n 'bg-blue',\r\n 'bg-indigo',\r\n 'bg-violet',\r\n 'bg-pink'\r\n];\r\n","import { NgClass } from '@angular/common';\r\nimport { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, forwardRef, Input, Output, ViewEncapsulation } from '@angular/core';\r\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\r\nimport { MatButtonModule } from '@angular/material/button';\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { MatSelectModule } from '@angular/material/select';\r\nimport { MatTooltipModule } from '@angular/material/tooltip';\r\nimport { cmatAnimations } from 'cmat/animations';\r\nimport { baseColors } from './base-color';\r\nimport { CmatSelectedColor } from './selected-color';\r\n\r\nexport const CMAT_MATERIAL_COLOR_PICKER_VALUE_ACCESSOR: any = {\r\n provide: NG_VALUE_ACCESSOR,\r\n useExisting: forwardRef(() => CmatMaterialColorPickerComponent),\r\n multi: true\r\n};\r\n\r\n\r\n@Component({\r\n selector: 'cmat-material-color-picker',\r\n templateUrl: './material-color-picker.component.html',\r\n styleUrls: ['./material-color-picker.component.scss'],\r\n animations: cmatAnimations,\r\n encapsulation: ViewEncapsulation.None,\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n exportAs: 'cmatMaterialColorPicker',\r\n providers: [CMAT_MATERIAL_COLOR_PICKER_VALUE_ACCESSOR],\r\n standalone: true,\r\n imports: [NgClass, MatSelectModule, MatIconModule, MatButtonModule, MatTooltipModule]\r\n})\r\nexport class CmatMaterialColorPickerComponent implements ControlValueAccessor {\r\n // Color changed\r\n @Output()\r\n colorChanged: EventEmitter<any>;\r\n\r\n palettes: string[];\r\n hues: string[];\r\n view: string;\r\n selectedColor: CmatSelectedColor;\r\n selectedPalette: string;\r\n selectedHue: string;\r\n\r\n // Private\r\n private _color: string;\r\n private _title: string;\r\n private _readonly:boolean;\r\n private _modelChange: (value: any) => void;\r\n private _modelTouched: (value: any) => void;\r\n\r\n constructor(private _changeDetectorRef: ChangeDetectorRef) {\r\n // Set the defaults\r\n this.colorChanged = new EventEmitter();\r\n this.palettes = baseColors;\r\n this.hues = ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900'];\r\n this.selectedHue = '500';\r\n this.selectedPalette = 'bg-indigo';\r\n this.view = 'palettes';\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n this._modelChange = (): any => { };\r\n // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n this._modelTouched = (): any => { };\r\n\r\n this.updateSelectedColor();\r\n }\r\n\r\n get color(): string {\r\n return this._color;\r\n }\r\n\r\n @Input()\r\n set color(value) {\r\n if (!value || value === '' || this._color === value) {\r\n return;\r\n }\r\n\r\n // Split the color value (bg-red-400, bg-blue-500 etc.)\r\n const colorParts = value.split('-');\r\n\r\n // Take the very last part as the selected hue value\r\n this.selectedHue = colorParts[colorParts.length - 1];\r\n\r\n // Remove the last part\r\n colorParts.pop();\r\n\r\n // Rejoin the remaining parts as the selected palette name\r\n this.selectedPalette = colorParts.join('-');\r\n\r\n // Update the selected color\r\n this.updateSelectedColor();\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/member-ordering\r\n get title(): string {\r\n return this._title;\r\n }\r\n\r\n @Input()\r\n set title(value) {\r\n this._title = value;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/member-ordering\r\n get readonly(): boolean {\r\n return this._readonly;\r\n }\r\n\r\n @Input()\r\n set readonly(value) {\r\n this._readonly = value;\r\n }\r\n \r\n\r\n registerOnChange(fn: any): void {\r\n this._modelChange = fn;\r\n }\r\n\r\n registerOnTouched(fn: any): void {\r\n this._modelTouched = fn;\r\n }\r\n\r\n writeValue(color: any): void {\r\n // Return if null\r\n if (!color) {\r\n return;\r\n }\r\n\r\n // Set the color\r\n this.color = color;\r\n }\r\n\r\n selectPalette(palette: string): void {\r\n // Go to 'hues' view\r\n this.view = 'hues';\r\n\r\n // Update the selected palette\r\n this.selectedPalette = palette;\r\n\r\n // Update the selected color\r\n this.updateSelectedColor();\r\n }\r\n\r\n selectHue(hue: string): void {\r\n // Update the selected hue\r\n this.selectedHue = hue;\r\n\r\n // Update the selected color\r\n this.updateSelectedColor();\r\n }\r\n\r\n removeColor(): void {\r\n // Return to the 'palettes' view\r\n this.view = 'palettes';\r\n\r\n // Clear the selected palette and hue\r\n this.selectedPalette = 'bg-indigo';\r\n this.selectedHue = '500';\r\n\r\n // Update the selected color\r\n this.updateSelectedColor();\r\n }\r\n\r\n updateSelectedColor(): void {\r\n if (this.selectedColor && this.selectedColor.palette === this.selectedPalette && this.selectedColor.hue === this.selectedHue) {\r\n return;\r\n }\r\n\r\n // Set the selected color object\r\n this.selectedColor = {\r\n palette: this.selectedPalette,\r\n hue: this.selectedHue,\r\n color: this.selectedPalette + '-' + this.selectedHue\r\n };\r\n\r\n this._color = this.selectedColor.color;\r\n\r\n this.colorChanged.emit(this.selectedColor);\r\n\r\n // Mark the model as touched\r\n this._modelTouched(this.selectedColor.color);\r\n\r\n // Update the model\r\n this._modelChange(this.selectedColor.color);\r\n\r\n this._changeDetectorRef.markForCheck();\r\n }\r\n\r\n goToPalettesView(): void {\r\n this.view = 'palettes';\r\n }\r\n\r\n onMenuOpen(opened: boolean): void {\r\n if (opened) {\r\n this.view = 'hues';\r\n }\r\n }\r\n}\r\n","<div class=\"rounded\" [ngClass]=\"selectedColor.color\">\n <mat-select value=\"init\" panelClass=\"min-w-64\" [disableOptionCentering]=\"true\" [hideSingleSelectionIndicator]=\"true\"\n [disabled]=\"readonly\" (openedChange)=\"onMenuOpen($event)\">\n <mat-select-trigger class=\"flex p-1\">\n <mat-icon [svgIcon]=\"'heroicons_outline:paint-brush'\"></mat-icon>\n </mat-select-trigger>\n\n <header class=\"shadow flex flex-row content-between justify-between p-2\" [ngClass]=\"'accent'\">\n <button type=\"button\" mat-icon-button class=\"secondary-text\" aria-label=\"调色板\"\n [class.invisible]=\"view === 'palettes'\" (click)=\"goToPalettesView()\">\n <mat-icon svgIcon=\"mat_outline:arrow_back\"></mat-icon>\n </button>\n <span class=\"align-middle leading-loose text-xl font-bold\">{{title}}</span>\n <button type=\"button\" mat-icon-button class=\"remove-color-button secondary-text\" aria-label=\"移除颜色\"\n matTooltip=\"移除颜色\" (click)=\"removeColor()\">\n <mat-icon color=\"warn\" [svgIcon]=\"'mat_outline:cleaning_services'\"></mat-icon>\n </button>\n </header>\n\n <div class=\"flex flex-wrap w-60 m-2\">\n <mat-option value=\"init\" class=\"hidden\">初始化</mat-option>\n <div>\n @switch (view) {\n @case ('palettes') {\n <div>\n <div class=\"flex flex-row flex-wrap justify-start content-start colors\">\n @for (palette of palettes; track $index) {\n <div role=\"presentation\"\n class=\"cursor-pointer\" (click)=\"selectPalette(palette)\">\n <mat-option\n class=\"relative flex w-12 h-12 p-0 pointer-events-none rounded-full bg-transparent hover:opacity-50\"\n [value]=\"selectedPalette\">\n @if (selectedColor.color===palette + '-' + selectedHue) {\n <mat-icon class=\"absolute m-3 text-white\"\n [svgIcon]=\"'heroicons_outline:check'\"></mat-icon>\n }\n <span class=\"flex w-10 h-10 m-1 rounded-full\"\n [ngClass]=\"palette + '-' + selectedHue\"></span>\n </mat-option>\n </div>\n }\n </div>\n </div>\n }\n @case ('hues') {\n <div>\n <div class=\"flex flex-row flex-wrap justify-start content-start colors\">\n @for (hue of hues; track $index) {\n <div role=\"presentation\" class=\"cursor-pointer\"\n (click)=\"selectHue(hue)\">\n <mat-option\n class=\"relative flex w-12 h-12 p-0 pointer-events-none rounded-full bg-transparent hover:opacity-50\"\n [value]=\"selectedHue\">\n @if (selectedColor.color===selectedPalette + '-' + hue) {\n <mat-icon class=\"absolute m-3 text-white\"\n [svgIcon]=\"'heroicons_outline:check'\"></mat-icon>\n }\n <span class=\"flex w-10 h-10 m-1 rounded-full\"\n [ngClass]=\"selectedPalette + '-' + hue\"></span>\n </mat-option>\n </div>\n }\n </div>\n </div>\n }\n }\n </div>\n </div>\n </mat-select>\n</div>","export class CmatSelectedColor {\r\n palette: string;\r\n hue: string;\r\n color: string;\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAO,MAAM,UAAU,GAAG;IACtB,UAAU;IACV,QAAQ;IACR,UAAU;IACV,WAAW;IACX,YAAY;IACZ,SAAS;IACT,SAAS;IACT,WAAW;IACX,WAAW;IACX,SAAS;CACZ;;ACAY,MAAA,yCAAyC,GAAQ;AAC1D,IAAA,OAAO,EAAE,iBAAiB;AAC1B,IAAA,WAAW,EAAE,UAAU,CAAC,MAAM,gCAAgC,CAAC;AAC/D,IAAA,KAAK,EAAE,IAAI;EACb;MAeW,gCAAgC,CAAA;AAmBzC,IAAA,WAAA,CAAoB,kBAAqC,EAAA;QAArC,IAAkB,CAAA,kBAAA,GAAlB,kBAAkB,CAAmB;;AAErD,QAAA,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;AACvC,QAAA,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAA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