cmat 0.0.86 → 0.0.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/cmat-components-adapter.mjs +9 -9
- package/fesm2022/cmat-components-adapter.mjs.map +1 -1
- package/fesm2022/cmat-components-breadcrumb.mjs +98 -80
- package/fesm2022/cmat-components-breadcrumb.mjs.map +1 -1
- package/fesm2022/cmat-components-card.mjs +26 -34
- package/fesm2022/cmat-components-card.mjs.map +1 -1
- package/fesm2022/cmat-components-carousel.mjs +467 -556
- package/fesm2022/cmat-components-carousel.mjs.map +1 -1
- package/fesm2022/cmat-components-cascade.mjs +270 -259
- package/fesm2022/cmat-components-cascade.mjs.map +1 -1
- package/fesm2022/cmat-components-chip-input.mjs +200 -116
- package/fesm2022/cmat-components-chip-input.mjs.map +1 -1
- package/fesm2022/cmat-components-code-editor.mjs +85 -38
- package/fesm2022/cmat-components-code-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-color-picker.mjs +841 -0
- package/fesm2022/cmat-components-color-picker.mjs.map +1 -0
- package/fesm2022/cmat-components-custom-formly.mjs +1395 -838
- package/fesm2022/cmat-components-custom-formly.mjs.map +1 -1
- package/fesm2022/cmat-components-data-picker.mjs +996 -0
- package/fesm2022/cmat-components-data-picker.mjs.map +1 -0
- package/fesm2022/cmat-components-date-range.mjs +310 -264
- package/fesm2022/cmat-components-date-range.mjs.map +1 -1
- package/fesm2022/cmat-components-date-time-display.mjs +16 -20
- package/fesm2022/cmat-components-date-time-display.mjs.map +1 -1
- package/fesm2022/cmat-components-drawer.mjs +120 -137
- package/fesm2022/cmat-components-drawer.mjs.map +1 -1
- package/fesm2022/cmat-components-empty-state.mjs +17 -24
- package/fesm2022/cmat-components-empty-state.mjs.map +1 -1
- package/fesm2022/cmat-components-file-preview.mjs +18 -24
- package/fesm2022/cmat-components-file-preview.mjs.map +1 -1
- package/fesm2022/cmat-components-filter-toolbar.mjs +30 -39
- package/fesm2022/cmat-components-filter-toolbar.mjs.map +1 -1
- package/fesm2022/cmat-components-form-actions.mjs +12 -12
- package/fesm2022/cmat-components-form-actions.mjs.map +1 -1
- package/fesm2022/cmat-components-fullscreen.mjs +10 -10
- package/fesm2022/cmat-components-fullscreen.mjs.map +1 -1
- package/fesm2022/cmat-components-highlight.mjs +48 -41
- package/fesm2022/cmat-components-highlight.mjs.map +1 -1
- package/fesm2022/cmat-components-image-viewer.mjs +104 -107
- package/fesm2022/cmat-components-image-viewer.mjs.map +1 -1
- package/fesm2022/cmat-components-inline-loading.mjs +12 -15
- package/fesm2022/cmat-components-inline-loading.mjs.map +1 -1
- package/fesm2022/cmat-components-json-editor.mjs +118 -75
- package/fesm2022/cmat-components-json-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-knob-input.mjs +196 -178
- package/fesm2022/cmat-components-knob-input.mjs.map +1 -1
- package/fesm2022/cmat-components-masonry.mjs +26 -41
- package/fesm2022/cmat-components-masonry.mjs.map +1 -1
- package/fesm2022/cmat-components-material-color-picker.mjs +81 -80
- package/fesm2022/cmat-components-material-color-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-material-datetimepicker.mjs +1212 -1287
- package/fesm2022/cmat-components-material-datetimepicker.mjs.map +1 -1
- package/fesm2022/cmat-components-navigation.mjs +467 -450
- package/fesm2022/cmat-components-navigation.mjs.map +1 -1
- package/fesm2022/cmat-components-opt-input.mjs +143 -132
- package/fesm2022/cmat-components-opt-input.mjs.map +1 -1
- package/fesm2022/cmat-components-org-chart.mjs +68 -83
- package/fesm2022/cmat-components-org-chart.mjs.map +1 -1
- package/fesm2022/cmat-components-page-header.mjs +18 -24
- package/fesm2022/cmat-components-page-header.mjs.map +1 -1
- package/fesm2022/cmat-components-pagination.mjs +220 -136
- package/fesm2022/cmat-components-pagination.mjs.map +1 -1
- package/fesm2022/cmat-components-password-strength.mjs +262 -215
- package/fesm2022/cmat-components-password-strength.mjs.map +1 -1
- package/fesm2022/cmat-components-popover.mjs +227 -195
- package/fesm2022/cmat-components-popover.mjs.map +1 -1
- package/fesm2022/cmat-components-progress-bar.mjs +15 -34
- package/fesm2022/cmat-components-progress-bar.mjs.map +1 -1
- package/fesm2022/cmat-components-qrcode.mjs +95 -88
- package/fesm2022/cmat-components-qrcode.mjs.map +1 -1
- package/fesm2022/cmat-components-rating.mjs +70 -67
- package/fesm2022/cmat-components-rating.mjs.map +1 -1
- package/fesm2022/cmat-components-rich-text-editor.mjs +23 -26
- package/fesm2022/cmat-components-rich-text-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-select-search.mjs +190 -159
- package/fesm2022/cmat-components-select-search.mjs.map +1 -1
- package/fesm2022/cmat-components-select-table.mjs +276 -213
- package/fesm2022/cmat-components-select-table.mjs.map +1 -1
- package/fesm2022/cmat-components-select-tree.mjs +178 -128
- package/fesm2022/cmat-components-select-tree.mjs.map +1 -1
- package/fesm2022/cmat-components-skeleton.mjs +44 -28
- package/fesm2022/cmat-components-skeleton.mjs.map +1 -1
- package/fesm2022/cmat-components-speed-dial.mjs +107 -163
- package/fesm2022/cmat-components-speed-dial.mjs.map +1 -1
- package/fesm2022/cmat-components-status-tag.mjs +29 -36
- package/fesm2022/cmat-components-status-tag.mjs.map +1 -1
- package/fesm2022/cmat-components-table-toolbar.mjs +14 -18
- package/fesm2022/cmat-components-table-toolbar.mjs.map +1 -1
- package/fesm2022/cmat-components-timeline.mjs +111 -118
- package/fesm2022/cmat-components-timeline.mjs.map +1 -1
- package/fesm2022/cmat-components-toast.mjs +65 -66
- package/fesm2022/cmat-components-toast.mjs.map +1 -1
- package/fesm2022/cmat-components-transfer-picker.mjs +130 -160
- package/fesm2022/cmat-components-transfer-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-treetable.mjs +32 -39
- package/fesm2022/cmat-components-treetable.mjs.map +1 -1
- package/fesm2022/cmat-components-upload.mjs +186 -176
- package/fesm2022/cmat-components-upload.mjs.map +1 -1
- package/fesm2022/cmat-directives-animate-on-scroll.mjs +25 -28
- package/fesm2022/cmat-directives-animate-on-scroll.mjs.map +1 -1
- package/fesm2022/cmat-directives-arrow-cursor.mjs +85 -92
- package/fesm2022/cmat-directives-arrow-cursor.mjs.map +1 -1
- package/fesm2022/cmat-directives-autofocus.mjs +3 -3
- package/fesm2022/cmat-directives-autofocus.mjs.map +1 -1
- package/fesm2022/cmat-directives-data-exporter.mjs +49 -50
- package/fesm2022/cmat-directives-data-exporter.mjs.map +1 -1
- package/fesm2022/cmat-directives-debounce.mjs +16 -19
- package/fesm2022/cmat-directives-debounce.mjs.map +1 -1
- package/fesm2022/cmat-directives-digit-only.mjs +60 -69
- 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-directives-seamless-auto-scroll.mjs +31 -30
- package/fesm2022/cmat-directives-seamless-auto-scroll.mjs.map +1 -1
- package/fesm2022/cmat-lib-mock-api.mjs +6 -6
- 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-date-format.mjs.map +1 -1
- 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 +7 -13
- package/fesm2022/cmat-pipes-secure.mjs.map +1 -1
- package/fesm2022/cmat-pipes-uppercase.mjs +3 -3
- package/fesm2022/cmat-pipes-uppercase.mjs.map +1 -1
- package/fesm2022/cmat-services-alert.mjs +26 -27
- package/fesm2022/cmat-services-alert.mjs.map +1 -1
- package/fesm2022/cmat-services-config.mjs +14 -23
- package/fesm2022/cmat-services-config.mjs.map +1 -1
- package/fesm2022/cmat-services-confirmation.mjs +8 -8
- package/fesm2022/cmat-services-confirmation.mjs.map +1 -1
- package/fesm2022/cmat-services-data.mjs +6 -10
- package/fesm2022/cmat-services-data.mjs.map +1 -1
- package/fesm2022/cmat-services-export-as.mjs +3 -3
- package/fesm2022/cmat-services-export-as.mjs.map +1 -1
- package/fesm2022/cmat-services-loading.mjs +30 -47
- package/fesm2022/cmat-services-loading.mjs.map +1 -1
- package/fesm2022/cmat-services-local-storage.mjs +3 -3
- package/fesm2022/cmat-services-local-storage.mjs.map +1 -1
- package/fesm2022/cmat-services-media-watcher.mjs +43 -34
- 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-splash-screen.mjs.map +1 -1
- package/fesm2022/cmat-services-title.mjs +3 -3
- package/fesm2022/cmat-services-title.mjs.map +1 -1
- package/fesm2022/cmat-services-translation.mjs +11 -11
- package/fesm2022/cmat-services-translation.mjs.map +1 -1
- package/fesm2022/cmat-services-utils.mjs +4 -4
- package/fesm2022/cmat-services-utils.mjs.map +1 -1
- package/fesm2022/cmat.mjs +9229 -7508
- package/fesm2022/cmat.mjs.map +1 -1
- package/icons/material-icons/heroicons-outline.svg +3 -0
- package/icons/material-icons/heroicons-solid.svg +3 -0
- package/package.json +10 -1
- package/styles/components/bundle.scss +21 -0
- package/styles/overrides/angular-material.scss +22 -1
- package/tailwind/plugins/theming.js +183 -183
- package/types/cmat-components-breadcrumb.d.ts +40 -37
- package/types/cmat-components-card.d.ts +11 -13
- package/types/cmat-components-carousel.d.ts +87 -113
- package/types/cmat-components-cascade.d.ts +84 -65
- package/types/cmat-components-chip-input.d.ts +29 -24
- package/types/cmat-components-code-editor.d.ts +28 -12
- package/types/cmat-components-color-picker.d.ts +236 -0
- package/types/cmat-components-custom-formly.d.ts +316 -184
- package/types/cmat-components-data-picker.d.ts +372 -0
- package/types/cmat-components-date-range.d.ts +31 -36
- package/types/cmat-components-date-time-display.d.ts +8 -8
- package/types/cmat-components-drawer.d.ts +30 -32
- package/types/cmat-components-empty-state.d.ts +9 -10
- package/types/cmat-components-file-preview.d.ts +9 -9
- package/types/cmat-components-filter-toolbar.d.ts +15 -15
- package/types/cmat-components-form-actions.d.ts +5 -5
- package/types/cmat-components-fullscreen.d.ts +5 -5
- package/types/cmat-components-highlight.d.ts +13 -14
- package/types/cmat-components-image-viewer.d.ts +29 -33
- package/types/cmat-components-inline-loading.d.ts +6 -6
- package/types/cmat-components-json-editor.d.ts +15 -17
- package/types/cmat-components-knob-input.d.ts +58 -55
- package/types/cmat-components-masonry.d.ts +9 -12
- package/types/cmat-components-material-color-picker.d.ts +16 -21
- package/types/cmat-components-material-datetimepicker.d.ts +174 -216
- package/types/cmat-components-navigation.d.ts +34 -39
- package/types/cmat-components-opt-input.d.ts +35 -33
- package/types/cmat-components-org-chart.d.ts +8 -9
- package/types/cmat-components-page-header.d.ts +9 -9
- package/types/cmat-components-pagination.d.ts +36 -40
- package/types/cmat-components-password-strength.d.ts +58 -64
- package/types/cmat-components-popover.d.ts +22 -32
- package/types/cmat-components-progress-bar.d.ts +7 -10
- package/types/cmat-components-qrcode.d.ts +22 -22
- package/types/cmat-components-rating.d.ts +17 -19
- package/types/cmat-components-rich-text-editor.d.ts +11 -12
- package/types/cmat-components-select-search.d.ts +48 -36
- package/types/cmat-components-select-table.d.ts +38 -34
- package/types/cmat-components-select-tree.d.ts +17 -15
- package/types/cmat-components-skeleton.d.ts +27 -10
- package/types/cmat-components-speed-dial.d.ts +24 -33
- package/types/cmat-components-status-tag.d.ts +19 -9
- package/types/cmat-components-table-toolbar.d.ts +7 -7
- package/types/cmat-components-timeline.d.ts +33 -34
- package/types/cmat-components-toast.d.ts +26 -30
- package/types/cmat-components-transfer-picker.d.ts +51 -56
- package/types/cmat-components-treetable.d.ts +12 -13
- package/types/cmat-components-upload.d.ts +33 -38
- package/types/cmat-components-x6-angular-shape.d.ts +1 -1
- package/types/cmat-directives-animate-on-scroll.d.ts +7 -7
- package/types/cmat-directives-arrow-cursor.d.ts +18 -20
- package/types/cmat-directives-data-exporter.d.ts +10 -10
- package/types/cmat-directives-debounce.d.ts +5 -5
- package/types/cmat-directives-digit-only.d.ts +13 -13
- package/types/cmat-directives-seamless-auto-scroll.d.ts +7 -7
- package/types/cmat-pipes-secure.d.ts +1 -3
- package/types/cmat-services-alert.d.ts +11 -12
- package/types/cmat-services-config.d.ts +2 -7
- package/types/cmat-services-confirmation.d.ts +2 -2
- package/types/cmat-services-data.d.ts +0 -1
- package/types/cmat-services-loading.d.ts +14 -22
- package/types/cmat-services-media-watcher.d.ts +5 -5
- package/types/cmat-services-translation.d.ts +4 -5
- package/types/cmat.d.ts +2167 -1746
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
|
2
2
|
import { NgStyle, NgClass } from '@angular/common';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import {
|
|
4
|
+
import { viewChild, input, output, signal, inject, effect, Input, ChangeDetectionStrategy, ViewEncapsulation, Component } from '@angular/core';
|
|
5
5
|
import { NgControl } from '@angular/forms';
|
|
6
6
|
import { MatFormFieldControl } from '@angular/material/form-field';
|
|
7
7
|
import * as i1 from '@angular/material/icon';
|
|
@@ -14,60 +14,69 @@ let NEXT_ID = 0;
|
|
|
14
14
|
class CmatRatingComponent {
|
|
15
15
|
constructor() {
|
|
16
16
|
this.id = `cmat-chip-input-${NEXT_ID++}`;
|
|
17
|
-
this.
|
|
18
|
-
|
|
19
|
-
this.
|
|
20
|
-
|
|
21
|
-
this.
|
|
22
|
-
|
|
17
|
+
this._ratingElementRef = viewChild('rating', /* @ts-ignore */
|
|
18
|
+
...(ngDevMode ? [{ debugName: "_ratingElementRef" }] : /* istanbul ignore next */ []));
|
|
19
|
+
this.stars = input(5, /* @ts-ignore */
|
|
20
|
+
...(ngDevMode ? [{ debugName: "stars" }] : /* istanbul ignore next */ []));
|
|
21
|
+
this.readonly = input(false, /* @ts-ignore */
|
|
22
|
+
...(ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []));
|
|
23
|
+
this.hover = input(/* @ts-ignore */
|
|
24
|
+
...(ngDevMode ? [undefined, { debugName: "hover" }] : /* istanbul ignore next */ []));
|
|
25
|
+
this.half = input(/* @ts-ignore */
|
|
26
|
+
...(ngDevMode ? [undefined, { debugName: "half" }] : /* istanbul ignore next */ []));
|
|
27
|
+
this.color = input(/* @ts-ignore */
|
|
28
|
+
...(ngDevMode ? [undefined, { debugName: "color" }] : /* istanbul ignore next */ []));
|
|
29
|
+
this.showMode = input('horizontal', /* @ts-ignore */
|
|
30
|
+
...(ngDevMode ? [{ debugName: "showMode" }] : /* istanbul ignore next */ []));
|
|
31
|
+
this.valueChange = output();
|
|
32
|
+
this.starArray = signal([], /* @ts-ignore */
|
|
33
|
+
...(ngDevMode ? [{ debugName: "starArray" }] : /* istanbul ignore next */ []));
|
|
34
|
+
this.currentValue = signal(0, /* @ts-ignore */
|
|
35
|
+
...(ngDevMode ? [{ debugName: "currentValue" }] : /* istanbul ignore next */ []));
|
|
23
36
|
this.stateChanges = new Subject();
|
|
24
37
|
this.focused = false;
|
|
25
38
|
this.touched = false;
|
|
26
39
|
this.controlType = 'cmat-rating';
|
|
27
40
|
this.ngControl = inject(NgControl, { optional: true, self: true });
|
|
41
|
+
this._value = signal(0, /* @ts-ignore */
|
|
42
|
+
...(ngDevMode ? [{ debugName: "_value" }] : /* istanbul ignore next */ []));
|
|
43
|
+
this._placeholder = signal('', /* @ts-ignore */
|
|
44
|
+
...(ngDevMode ? [{ debugName: "_placeholder" }] : /* istanbul ignore next */ []));
|
|
45
|
+
this._required = signal(false, /* @ts-ignore */
|
|
46
|
+
...(ngDevMode ? [{ debugName: "_required" }] : /* istanbul ignore next */ []));
|
|
47
|
+
this._disabled = signal(false, /* @ts-ignore */
|
|
48
|
+
...(ngDevMode ? [{ debugName: "_disabled" }] : /* istanbul ignore next */ []));
|
|
28
49
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
29
50
|
this.onModelChange = () => { };
|
|
30
51
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
31
52
|
this.onTouchedChange = () => { };
|
|
32
|
-
this._placeholder = '';
|
|
33
|
-
this._required = false;
|
|
34
53
|
if (this.ngControl != null) {
|
|
35
54
|
this.ngControl.valueAccessor = this;
|
|
36
55
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
this._initializeStarArray();
|
|
40
|
-
}
|
|
41
|
-
ngOnChanges(changes) {
|
|
42
|
-
if ('stars' in changes) {
|
|
56
|
+
// 监听 stars 变化并初始化星数组
|
|
57
|
+
effect(() => {
|
|
43
58
|
this._initializeStarArray();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
ngOnDestroy() {
|
|
47
|
-
this.stateChanges.complete();
|
|
48
|
-
}
|
|
49
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
50
|
-
onFocus() {
|
|
59
|
+
});
|
|
51
60
|
}
|
|
52
61
|
get placeholder() {
|
|
53
|
-
return this._placeholder;
|
|
62
|
+
return this._placeholder();
|
|
54
63
|
}
|
|
55
64
|
set placeholder(value) {
|
|
56
|
-
this._placeholder
|
|
65
|
+
this._placeholder.set(value);
|
|
57
66
|
this.stateChanges.next();
|
|
58
67
|
}
|
|
59
68
|
get value() {
|
|
60
|
-
return this._value;
|
|
69
|
+
return this._value();
|
|
61
70
|
}
|
|
62
71
|
set value(value) {
|
|
63
|
-
if (value !== this.
|
|
64
|
-
this._value
|
|
72
|
+
if (value !== this._value()) {
|
|
73
|
+
this._value.set(value);
|
|
65
74
|
this.stateChanges.next();
|
|
66
75
|
this.onModelChange(value);
|
|
67
76
|
}
|
|
68
77
|
}
|
|
69
78
|
get empty() {
|
|
70
|
-
return !this._value;
|
|
79
|
+
return !this._value();
|
|
71
80
|
}
|
|
72
81
|
get errorState() {
|
|
73
82
|
if (this.ngControl == null)
|
|
@@ -77,19 +86,21 @@ class CmatRatingComponent {
|
|
|
77
86
|
get shouldLabelFloat() {
|
|
78
87
|
return this.focused || !this.empty;
|
|
79
88
|
}
|
|
80
|
-
get required() {
|
|
89
|
+
get required() {
|
|
90
|
+
return this._required();
|
|
91
|
+
}
|
|
81
92
|
set required(value) {
|
|
82
|
-
this._required
|
|
93
|
+
this._required.set(coerceBooleanProperty(value));
|
|
83
94
|
this.stateChanges.next();
|
|
84
95
|
}
|
|
85
96
|
get disabled() {
|
|
86
97
|
if (!isNil(this.ngControl?.disabled)) {
|
|
87
98
|
return this.ngControl.disabled;
|
|
88
99
|
}
|
|
89
|
-
return this.readonly;
|
|
100
|
+
return this._disabled() || this.readonly();
|
|
90
101
|
}
|
|
91
102
|
set disabled(value) {
|
|
92
|
-
this.
|
|
103
|
+
this._disabled.set(coerceBooleanProperty(value));
|
|
93
104
|
if (this.focused) {
|
|
94
105
|
this.focused = false;
|
|
95
106
|
this.stateChanges.next();
|
|
@@ -111,16 +122,23 @@ class CmatRatingComponent {
|
|
|
111
122
|
this.onTouchedChange = fn;
|
|
112
123
|
}
|
|
113
124
|
setDescribedByIds(ids) {
|
|
125
|
+
const ratingEl = this._ratingElementRef();
|
|
114
126
|
if (ids.length) {
|
|
115
|
-
|
|
127
|
+
ratingEl?.nativeElement.setAttribute('aria-describedby', ids.join(' '));
|
|
116
128
|
}
|
|
117
129
|
else {
|
|
118
|
-
|
|
130
|
+
ratingEl?.nativeElement.removeAttribute('aria-describedby');
|
|
119
131
|
}
|
|
120
132
|
}
|
|
121
133
|
onContainerClick() {
|
|
122
134
|
if (!this.focused) {
|
|
123
|
-
this._ratingElementRef
|
|
135
|
+
this._ratingElementRef()?.nativeElement.focus();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
onFocus() {
|
|
139
|
+
if (!this.focused) {
|
|
140
|
+
this.focused = true;
|
|
141
|
+
this.stateChanges.next();
|
|
124
142
|
}
|
|
125
143
|
}
|
|
126
144
|
isIn(value) {
|
|
@@ -129,9 +147,9 @@ class CmatRatingComponent {
|
|
|
129
147
|
}
|
|
130
148
|
onClick(event, value, half) {
|
|
131
149
|
event.stopPropagation();
|
|
132
|
-
if (!this.readonly) {
|
|
150
|
+
if (!this.readonly()) {
|
|
133
151
|
this.value = value + 1;
|
|
134
|
-
if (half && this.half) {
|
|
152
|
+
if (half && this.half()) {
|
|
135
153
|
this.value -= 0.5;
|
|
136
154
|
}
|
|
137
155
|
this.currentValue.set(this.value);
|
|
@@ -141,9 +159,9 @@ class CmatRatingComponent {
|
|
|
141
159
|
}
|
|
142
160
|
onMouseover(event, value, half) {
|
|
143
161
|
event.stopPropagation();
|
|
144
|
-
if (this.hover && !this.readonly) {
|
|
162
|
+
if (this.hover() && !this.readonly()) {
|
|
145
163
|
this.value = value + 1;
|
|
146
|
-
if (half && this.half) {
|
|
164
|
+
if (half && this.half()) {
|
|
147
165
|
this.value -= 0.5;
|
|
148
166
|
}
|
|
149
167
|
}
|
|
@@ -154,37 +172,22 @@ class CmatRatingComponent {
|
|
|
154
172
|
}
|
|
155
173
|
}
|
|
156
174
|
_initializeStarArray() {
|
|
157
|
-
this.starArray.set(Array.from({ length: this.stars }, (_, i) => i));
|
|
175
|
+
this.starArray.set(Array.from({ length: this.stars() }, (_, i) => i));
|
|
158
176
|
}
|
|
159
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
160
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
177
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: CmatRatingComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
178
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.2", type: CmatRatingComponent, isStandalone: true, selector: "cmat-rating", inputs: { stars: { classPropertyName: "stars", publicName: "stars", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, hover: { classPropertyName: "hover", publicName: "hover", isSignal: true, isRequired: false, transformFunction: null }, half: { classPropertyName: "half", publicName: "half", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, showMode: { classPropertyName: "showMode", publicName: "showMode", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: false, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: false, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: false, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: false, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange" }, host: { properties: { "attr.id": "id" } }, providers: [
|
|
179
|
+
{ provide: MatFormFieldControl, useExisting: CmatRatingComponent },
|
|
180
|
+
], viewQueries: [{ propertyName: "_ratingElementRef", first: true, predicate: ["rating"], descendants: true, isSignal: true }], exportAs: ["cmatRating"], ngImport: i0, template: "<div\r\n #rating\r\n class=\"flex\"\r\n [class.cmat-rating-readonly]=\"readonly() || disabled\"\r\n [ngClass]=\"{\r\n 'flex-col': showMode() === 'vertical',\r\n 'flex-row': showMode() === 'horizontal',\r\n }\"\r\n (focus)=\"onFocus()\"\r\n (mouseleave)=\"onMouseleave()\"\r\n>\r\n @for (star of starArray(); track $index; let i = $index) {\r\n <div class=\"cmat-rating-item\">\r\n @if (half()) {\r\n <div\r\n role=\"presentation\"\r\n class=\"cmat-rating-half\"\r\n [ngStyle]=\"{ opacity: isIn(i) ? 1 : 0 }\"\r\n (focus)=\"onFocus()\"\r\n (mouseover)=\"onMouseover($event, i, true)\"\r\n (click)=\"onClick($event, i, true)\"\r\n >\r\n <mat-icon\r\n [ngClass]=\"{ 'text-current': !color() }\"\r\n [color]=\"color()\"\r\n [svgIcon]=\"\r\n 'mat_outline:' + (!value || i >= value ? 'star_border' : 'star')\r\n \"\r\n >\r\n </mat-icon>\r\n </div>\r\n }\r\n <div\r\n role=\"presentation\"\r\n (mouseover)=\"onMouseover($event, i)\"\r\n (click)=\"onClick($event, i)\"\r\n (focus)=\"onFocus()\"\r\n >\r\n <mat-icon\r\n [color]=\"color()\"\r\n [ngClass]=\"{ 'text-current': !color() }\"\r\n [svgIcon]=\"\r\n 'mat_outline:' +\r\n ((half() && isIn(i)) || !value || i >= value\r\n ? 'star_border'\r\n : 'star')\r\n \"\r\n >\r\n </mat-icon>\r\n </div>\r\n </div>\r\n }\r\n</div>", styles: ["cmat-rating{display:flex;align-items:center}cmat-rating .cmat-rating-item{position:relative;cursor:pointer;line-height:0}cmat-rating .cmat-rating-item div{display:inline-block;font-size:1rem;padding:0 .1rem}cmat-rating .cmat-rating-item .cmat-rating-half{position:absolute;top:0;left:0;width:45%;z-index:10;opacity:0;overflow:hidden;padding-right:0}cmat-rating .cmat-rating-readonly .cmat-rating-item{cursor:not-allowed}\n"], dependencies: [{ kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
161
181
|
}
|
|
162
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
182
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: CmatRatingComponent, decorators: [{
|
|
163
183
|
type: Component,
|
|
164
|
-
args: [{ selector: 'cmat-rating', providers: [
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
type: ViewChild,
|
|
172
|
-
args: ['rating', { static: false }]
|
|
173
|
-
}], stars: [{
|
|
174
|
-
type: Input
|
|
175
|
-
}], readonly: [{
|
|
176
|
-
type: Input
|
|
177
|
-
}], hover: [{
|
|
178
|
-
type: Input
|
|
179
|
-
}], half: [{
|
|
180
|
-
type: Input
|
|
181
|
-
}], color: [{
|
|
182
|
-
type: Input
|
|
183
|
-
}], showMode: [{
|
|
184
|
-
type: Input
|
|
185
|
-
}], valueChange: [{
|
|
186
|
-
type: Output
|
|
187
|
-
}], placeholder: [{
|
|
184
|
+
args: [{ selector: 'cmat-rating', providers: [
|
|
185
|
+
{ provide: MatFormFieldControl, useExisting: CmatRatingComponent },
|
|
186
|
+
], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, exportAs: 'cmatRating', imports: [MatIconModule, NgStyle, NgClass], host: {
|
|
187
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
188
|
+
'[attr.id]': 'id',
|
|
189
|
+
}, template: "<div\r\n #rating\r\n class=\"flex\"\r\n [class.cmat-rating-readonly]=\"readonly() || disabled\"\r\n [ngClass]=\"{\r\n 'flex-col': showMode() === 'vertical',\r\n 'flex-row': showMode() === 'horizontal',\r\n }\"\r\n (focus)=\"onFocus()\"\r\n (mouseleave)=\"onMouseleave()\"\r\n>\r\n @for (star of starArray(); track $index; let i = $index) {\r\n <div class=\"cmat-rating-item\">\r\n @if (half()) {\r\n <div\r\n role=\"presentation\"\r\n class=\"cmat-rating-half\"\r\n [ngStyle]=\"{ opacity: isIn(i) ? 1 : 0 }\"\r\n (focus)=\"onFocus()\"\r\n (mouseover)=\"onMouseover($event, i, true)\"\r\n (click)=\"onClick($event, i, true)\"\r\n >\r\n <mat-icon\r\n [ngClass]=\"{ 'text-current': !color() }\"\r\n [color]=\"color()\"\r\n [svgIcon]=\"\r\n 'mat_outline:' + (!value || i >= value ? 'star_border' : 'star')\r\n \"\r\n >\r\n </mat-icon>\r\n </div>\r\n }\r\n <div\r\n role=\"presentation\"\r\n (mouseover)=\"onMouseover($event, i)\"\r\n (click)=\"onClick($event, i)\"\r\n (focus)=\"onFocus()\"\r\n >\r\n <mat-icon\r\n [color]=\"color()\"\r\n [ngClass]=\"{ 'text-current': !color() }\"\r\n [svgIcon]=\"\r\n 'mat_outline:' +\r\n ((half() && isIn(i)) || !value || i >= value\r\n ? 'star_border'\r\n : 'star')\r\n \"\r\n >\r\n </mat-icon>\r\n </div>\r\n </div>\r\n }\r\n</div>", styles: ["cmat-rating{display:flex;align-items:center}cmat-rating .cmat-rating-item{position:relative;cursor:pointer;line-height:0}cmat-rating .cmat-rating-item div{display:inline-block;font-size:1rem;padding:0 .1rem}cmat-rating .cmat-rating-item .cmat-rating-half{position:absolute;top:0;left:0;width:45%;z-index:10;opacity:0;overflow:hidden;padding-right:0}cmat-rating .cmat-rating-readonly .cmat-rating-item{cursor:not-allowed}\n"] }]
|
|
190
|
+
}], ctorParameters: () => [], propDecorators: { _ratingElementRef: [{ type: i0.ViewChild, args: ['rating', { isSignal: true }] }], stars: [{ type: i0.Input, args: [{ isSignal: true, alias: "stars", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], hover: [{ type: i0.Input, args: [{ isSignal: true, alias: "hover", required: false }] }], half: [{ type: i0.Input, args: [{ isSignal: true, alias: "half", required: false }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], showMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "showMode", required: false }] }], valueChange: [{ type: i0.Output, args: ["valueChange"] }], placeholder: [{
|
|
188
191
|
type: Input
|
|
189
192
|
}], value: [{
|
|
190
193
|
type: Input
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cmat-components-rating.mjs","sources":["../../../projects/cmat/components/rating/rating.component.ts","../../../projects/cmat/components/rating/rating.component.html","../../../projects/cmat/components/rating/cmat-components-rating.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/member-ordering */\r\nimport { coerceBooleanProperty, BooleanInput } from '@angular/cdk/coercion';\r\nimport { NgClass, NgStyle } from '@angular/common';\r\nimport { Component, Input, Output, EventEmitter, ChangeDetectionStrategy, ViewEncapsulation, OnChanges, SimpleChanges, OnInit, ElementRef, HostBinding, ViewChild, OnDestroy, inject, signal } from '@angular/core';\r\nimport { ControlValueAccessor, NgControl } from '@angular/forms';\r\nimport { MatFormFieldControl } from '@angular/material/form-field';\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { isNil } from 'lodash-es';\r\nimport { Subject } from 'rxjs';\r\n\r\nlet NEXT_ID = 0;\r\n\r\n@Component({\r\n selector: 'cmat-rating',\r\n templateUrl: './rating.component.html',\r\n styleUrls: ['./rating.component.scss'],\r\n providers: [{ provide: MatFormFieldControl, useExisting: CmatRatingComponent }],\r\n encapsulation: ViewEncapsulation.None,\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n exportAs: 'cmatRating',\r\n imports: [MatIconModule, NgStyle, NgClass]\r\n})\r\nexport class CmatRatingComponent implements MatFormFieldControl<number>, ControlValueAccessor, OnInit, OnChanges, OnDestroy {\r\n @HostBinding('attr.id')\r\n @Input()\r\n public id = `cmat-chip-input-${NEXT_ID++}`;\r\n\r\n @ViewChild('rating', { static: false }) private _ratingElementRef: ElementRef<HTMLDivElement>;\r\n\r\n @Input() stars: number = 5;\r\n @Input() readonly: boolean = false;\r\n @Input() hover: boolean;\r\n @Input() half: boolean;\r\n @Input() color?: string;\r\n @Input() showMode?: 'horizontal' | 'vertical' = 'horizontal';\r\n @Output() valueChange = new EventEmitter<number>();\r\n\r\n readonly starArray = signal<number[]>([]);\r\n readonly currentValue = signal(0);\r\n\r\n readonly stateChanges: Subject<void> = new Subject<void>();\r\n focused: boolean = false;\r\n touched: boolean = false;\r\n controlType: string = 'cmat-rating';\r\n ngControl = inject(NgControl, { optional: true, self: true })!;\r\n\r\n constructor() {\r\n if (this.ngControl != null) {\r\n this.ngControl.valueAccessor = this;\r\n }\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n onModelChange: (value: number) => void = () => { };\r\n // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n onTouchedChange: () => void = () => { };\r\n\r\n ngOnInit(): void {\r\n this._initializeStarArray();\r\n }\r\n ngOnChanges(changes: SimpleChanges): void {\r\n if ('stars' in changes) {\r\n this._initializeStarArray();\r\n }\r\n }\r\n\r\n ngOnDestroy(): void {\r\n this.stateChanges.complete();\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n onFocus(): void {\r\n\r\n }\r\n\r\n @Input()\r\n get placeholder(): string {\r\n return this._placeholder;\r\n }\r\n set placeholder(value: string) {\r\n this._placeholder = value;\r\n this.stateChanges.next();\r\n }\r\n private _placeholder: string = '';\r\n\r\n @Input()\r\n get value(): number {\r\n return this._value;\r\n }\r\n set value(value: number) {\r\n if (value !== this.value) {\r\n this._value = value;\r\n\r\n this.stateChanges.next();\r\n\r\n this.onModelChange(value);\r\n }\r\n }\r\n protected _value: number;\r\n\r\n get empty(): boolean {\r\n return !this._value;\r\n }\r\n\r\n get errorState(): boolean {\r\n if (this.ngControl == null)\r\n return false;\r\n\r\n return (this.touched && this.ngControl?.invalid) ?? false;\r\n }\r\n\r\n get shouldLabelFloat(): boolean {\r\n return this.focused || !this.empty;\r\n }\r\n\r\n @Input()\r\n get required(): boolean { return this._required; }\r\n set required(value: BooleanInput) {\r\n this._required = coerceBooleanProperty(value);\r\n this.stateChanges.next();\r\n }\r\n protected _required = false;\r\n\r\n @Input()\r\n get disabled(): boolean {\r\n if (!isNil(this.ngControl?.disabled)) {\r\n return this.ngControl.disabled;\r\n }\r\n return this.readonly;\r\n }\r\n set disabled(value: BooleanInput) {\r\n this.readonly = coerceBooleanProperty(value);\r\n\r\n if (this.focused) {\r\n this.focused = false;\r\n this.stateChanges.next();\r\n }\r\n }\r\n\r\n writeValue(value: number | null): void {\r\n if (value !== null && value !== undefined) {\r\n this.value = value;\r\n this.currentValue.set(value);\r\n }\r\n }\r\n\r\n setDisabledState(isDisabled: boolean): void {\r\n this.disabled = isDisabled;\r\n }\r\n\r\n registerOnChange(fn: (value: number) => void): void {\r\n this.onModelChange = fn;\r\n }\r\n\r\n registerOnTouched(fn: () => void): void {\r\n this.onTouchedChange = fn;\r\n }\r\n\r\n setDescribedByIds(ids: string[]): void {\r\n if (ids.length) {\r\n this._ratingElementRef?.nativeElement.setAttribute('aria-describedby', ids.join(' '));\r\n } else {\r\n this._ratingElementRef?.nativeElement.removeAttribute('aria-describedby');\r\n }\r\n }\r\n\r\n onContainerClick(): void {\r\n if (!this.focused) {\r\n this._ratingElementRef.nativeElement.focus();\r\n }\r\n }\r\n\r\n isIn(value: number): boolean {\r\n const ex = this.value - value;\r\n return ex > 0 && ex < 1;\r\n }\r\n\r\n onClick(event: MouseEvent, value: number, half?: boolean): void {\r\n event.stopPropagation();\r\n if (!this.readonly) {\r\n this.value = value + 1;\r\n if (half && this.half) {\r\n this.value -= 0.5;\r\n }\r\n this.currentValue.set(this.value);\r\n this.valueChange.emit(this.currentValue());\r\n this.onModelChange(this.currentValue());\r\n }\r\n }\r\n\r\n onMouseover(event: MouseEvent, value: number, half?: boolean): void {\r\n event.stopPropagation();\r\n if (this.hover && !this.readonly) {\r\n this.value = value + 1;\r\n if (half && this.half) {\r\n this.value -= 0.5;\r\n }\r\n }\r\n }\r\n\r\n onMouseleave(): void {\r\n if (this.value !== this.currentValue()) {\r\n this.value = this.currentValue();\r\n }\r\n }\r\n\r\n private _initializeStarArray(): void {\r\n this.starArray.set(Array.from({ length: this.stars }, (_, i) => i));\r\n }\r\n}\r\n\r\n","<div #rating class=\"flex\" [class.cmat-rating-readonly]=\"readonly||disabled\" [ngClass]=\"{'flex-col':showMode==='vertical','flex-row':showMode==='horizontal'}\"\r\n (focus)=\"onFocus()\" (mouseleave)=\"onMouseleave()\">\r\n @for (star of starArray(); track $index; let i = $index) {\r\n <div class=\"cmat-rating-item\">\r\n @if (half) {\r\n <div role=\"presentation\" class=\"cmat-rating-half\" [ngStyle]=\"{'opacity': isIn(i)?1:0}\" (focus)=\"onFocus()\"\r\n (mouseover)=\"onMouseover($event, i, true)\" (click)=\"onClick($event, i, true)\">\r\n <mat-icon [ngClass]=\"{'text-current': !color}\" [color]=\"color\"\r\n [svgIcon]=\"'mat_outline:'+((!value || i >= value)?'star_border':'star')\">\r\n </mat-icon>\r\n </div>\r\n }\r\n <div role=\"presentation\" (mouseover)=\"onMouseover($event, i)\" (click)=\"onClick($event, i)\" (focus)=\"onFocus()\">\r\n <mat-icon [color]=\"color\" [ngClass]=\"{'text-current': !color}\"\r\n [svgIcon]=\"'mat_outline:'+((half && isIn(i)) || (!value || i >= value)?'star_border':'star')\">\r\n </mat-icon>\r\n </div>\r\n </div>\r\n }\r\n</div>\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AAUA,IAAI,OAAO,GAAG,CAAC;MAYF,mBAAmB,CAAA;AAwB9B,IAAA,WAAA,GAAA;AArBO,QAAA,IAAA,CAAA,EAAE,GAAG,CAAA,gBAAA,EAAmB,OAAO,EAAE,EAAE;QAIjC,IAAA,CAAA,KAAK,GAAW,CAAC;QACjB,IAAA,CAAA,QAAQ,GAAY,KAAK;QAIzB,IAAA,CAAA,QAAQ,GAA+B,YAAY;AAClD,QAAA,IAAA,CAAA,WAAW,GAAG,IAAI,YAAY,EAAU;AAEzC,QAAA,IAAA,CAAA,SAAS,GAAG,MAAM,CAAW,EAAE,gFAAC;AAChC,QAAA,IAAA,CAAA,YAAY,GAAG,MAAM,CAAC,CAAC,mFAAC;AAExB,QAAA,IAA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AE;;sBAErC;;sBACA;;sBACA;;sBACA;;sBACA;;sBACA;;sBACA;;sBAwCA;;sBAUA;;sBA8BA;;sBAQA;;;AE3HH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"cmat-components-rating.mjs","sources":["../../../projects/cmat/components/rating/rating.component.ts","../../../projects/cmat/components/rating/rating.component.html","../../../projects/cmat/components/rating/cmat-components-rating.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/member-ordering */\r\nimport { coerceBooleanProperty, BooleanInput } from '@angular/cdk/coercion';\r\nimport { NgClass, NgStyle } from '@angular/common';\r\nimport {\r\n Component,\r\n ChangeDetectionStrategy,\r\n ViewEncapsulation,\r\n ElementRef,\r\n viewChild,\r\n effect,\r\n inject,\r\n signal,\r\n input,\r\n output,\r\n Input,\r\n} from '@angular/core';\r\nimport { ControlValueAccessor, NgControl } from '@angular/forms';\r\nimport { MatFormFieldControl } from '@angular/material/form-field';\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { isNil } from 'lodash-es';\r\nimport { Subject } from 'rxjs';\r\n\r\nlet NEXT_ID = 0;\r\n\r\n@Component({\r\n selector: 'cmat-rating',\r\n templateUrl: './rating.component.html',\r\n styleUrls: ['./rating.component.scss'],\r\n providers: [\r\n { provide: MatFormFieldControl, useExisting: CmatRatingComponent },\r\n ],\r\n encapsulation: ViewEncapsulation.None,\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n exportAs: 'cmatRating',\r\n imports: [MatIconModule, NgStyle, NgClass],\r\n host: {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n '[attr.id]': 'id',\r\n }\r\n})\r\nexport class CmatRatingComponent implements MatFormFieldControl<number>, ControlValueAccessor {\r\n readonly id = `cmat-chip-input-${NEXT_ID++}`;\r\n\r\n readonly _ratingElementRef = viewChild<ElementRef<HTMLDivElement>>('rating');\r\n\r\n readonly stars = input<number>(5);\r\n readonly readonly = input<boolean>(false);\r\n readonly hover = input<boolean>();\r\n readonly half = input<boolean>();\r\n readonly color = input<string>();\r\n readonly showMode = input<'horizontal' | 'vertical'>('horizontal');\r\n\r\n readonly valueChange = output<number>();\r\n\r\n readonly starArray = signal<number[]>([]);\r\n readonly currentValue = signal(0);\r\n\r\n readonly stateChanges: Subject<void> = new Subject<void>();\r\n focused: boolean = false;\r\n touched: boolean = false;\r\n controlType: string = 'cmat-rating';\r\n ngControl = inject(NgControl, { optional: true, self: true })!;\r\n\r\n private _value = signal<number>(0);\r\n private _placeholder = signal<string>('');\r\n private _required = signal<boolean>(false);\r\n private _disabled = signal<boolean>(false);\r\n\r\n constructor() {\r\n if (this.ngControl != null) {\r\n this.ngControl.valueAccessor = this;\r\n }\r\n\r\n // 监听 stars 变化并初始化星数组\r\n effect(() => {\r\n this._initializeStarArray();\r\n });\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n onModelChange: (value: number) => void = () => { };\r\n // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n onTouchedChange: () => void = () => { };\r\n\r\n @Input()\r\n get placeholder(): string {\r\n return this._placeholder();\r\n }\r\n set placeholder(value: string) {\r\n this._placeholder.set(value);\r\n this.stateChanges.next();\r\n }\r\n\r\n @Input()\r\n get value(): number {\r\n return this._value();\r\n }\r\n set value(value: number) {\r\n if (value !== this._value()) {\r\n this._value.set(value);\r\n this.stateChanges.next();\r\n this.onModelChange(value);\r\n }\r\n }\r\n\r\n get empty(): boolean {\r\n return !this._value();\r\n }\r\n\r\n get errorState(): boolean {\r\n if (this.ngControl == null) return false;\r\n return (this.touched && this.ngControl?.invalid) ?? false;\r\n }\r\n\r\n get shouldLabelFloat(): boolean {\r\n return this.focused || !this.empty;\r\n }\r\n\r\n @Input()\r\n get required(): boolean {\r\n return this._required();\r\n }\r\n set required(value: BooleanInput) {\r\n this._required.set(coerceBooleanProperty(value));\r\n this.stateChanges.next();\r\n }\r\n\r\n @Input()\r\n get disabled(): boolean {\r\n if (!isNil(this.ngControl?.disabled)) {\r\n return this.ngControl.disabled;\r\n }\r\n return this._disabled() || this.readonly();\r\n }\r\n set disabled(value: BooleanInput) {\r\n this._disabled.set(coerceBooleanProperty(value));\r\n\r\n if (this.focused) {\r\n this.focused = false;\r\n this.stateChanges.next();\r\n }\r\n }\r\n\r\n writeValue(value: number | null): void {\r\n if (value !== null && value !== undefined) {\r\n this.value = value;\r\n this.currentValue.set(value);\r\n }\r\n }\r\n\r\n setDisabledState(isDisabled: boolean): void {\r\n this.disabled = isDisabled;\r\n }\r\n\r\n registerOnChange(fn: (value: number) => void): void {\r\n this.onModelChange = fn;\r\n }\r\n\r\n registerOnTouched(fn: () => void): void {\r\n this.onTouchedChange = fn;\r\n }\r\n\r\n setDescribedByIds(ids: string[]): void {\r\n const ratingEl = this._ratingElementRef();\r\n if (ids.length) {\r\n ratingEl?.nativeElement.setAttribute(\r\n 'aria-describedby',\r\n ids.join(' '),\r\n );\r\n } else {\r\n ratingEl?.nativeElement.removeAttribute('aria-describedby');\r\n }\r\n }\r\n\r\n onContainerClick(): void {\r\n if (!this.focused) {\r\n this._ratingElementRef()?.nativeElement.focus();\r\n }\r\n }\r\n\r\n onFocus(): void {\r\n if (!this.focused) {\r\n this.focused = true;\r\n this.stateChanges.next();\r\n }\r\n }\r\n\r\n isIn(value: number): boolean {\r\n const ex = this.value - value;\r\n return ex > 0 && ex < 1;\r\n }\r\n\r\n onClick(event: MouseEvent, value: number, half?: boolean): void {\r\n event.stopPropagation();\r\n if (!this.readonly()) {\r\n this.value = value + 1;\r\n if (half && this.half()) {\r\n this.value -= 0.5;\r\n }\r\n this.currentValue.set(this.value);\r\n this.valueChange.emit(this.currentValue());\r\n this.onModelChange(this.currentValue());\r\n }\r\n }\r\n\r\n onMouseover(event: MouseEvent, value: number, half?: boolean): void {\r\n event.stopPropagation();\r\n if (this.hover() && !this.readonly()) {\r\n this.value = value + 1;\r\n if (half && this.half()) {\r\n this.value -= 0.5;\r\n }\r\n }\r\n }\r\n\r\n onMouseleave(): void {\r\n if (this.value !== this.currentValue()) {\r\n this.value = this.currentValue();\r\n }\r\n }\r\n\r\n private _initializeStarArray(): void {\r\n this.starArray.set(Array.from({ length: this.stars() }, (_, i) => i));\r\n }\r\n}\r\n","<div\r\n #rating\r\n class=\"flex\"\r\n [class.cmat-rating-readonly]=\"readonly() || disabled\"\r\n [ngClass]=\"{\r\n 'flex-col': showMode() === 'vertical',\r\n 'flex-row': showMode() === 'horizontal',\r\n }\"\r\n (focus)=\"onFocus()\"\r\n (mouseleave)=\"onMouseleave()\"\r\n>\r\n @for (star of starArray(); track $index; let i = $index) {\r\n <div class=\"cmat-rating-item\">\r\n @if (half()) {\r\n <div\r\n role=\"presentation\"\r\n class=\"cmat-rating-half\"\r\n [ngStyle]=\"{ opacity: isIn(i) ? 1 : 0 }\"\r\n (focus)=\"onFocus()\"\r\n (mouseover)=\"onMouseover($event, i, true)\"\r\n (click)=\"onClick($event, i, true)\"\r\n >\r\n <mat-icon\r\n [ngClass]=\"{ 'text-current': !color() }\"\r\n [color]=\"color()\"\r\n [svgIcon]=\"\r\n 'mat_outline:' + (!value || i >= value ? 'star_border' : 'star')\r\n \"\r\n >\r\n </mat-icon>\r\n </div>\r\n }\r\n <div\r\n role=\"presentation\"\r\n (mouseover)=\"onMouseover($event, i)\"\r\n (click)=\"onClick($event, i)\"\r\n (focus)=\"onFocus()\"\r\n >\r\n <mat-icon\r\n [color]=\"color()\"\r\n [ngClass]=\"{ 'text-current': !color() }\"\r\n [svgIcon]=\"\r\n 'mat_outline:' +\r\n ((half() && isIn(i)) || !value || i >= value\r\n ? 'star_border'\r\n : 'star')\r\n \"\r\n >\r\n </mat-icon>\r\n </div>\r\n </div>\r\n }\r\n</div>","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AAsBA,IAAI,OAAO,GAAG,CAAC;MAkBF,mBAAmB,CAAA;AA4B9B,IAAA,WAAA,GAAA;AA3BS,QAAA,IAAA,CAAA,EAAE,GAAG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AA,IAAA,EAAA,KAAA,EAAA,OAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,QAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,UAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,WAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,MAAA,EAAA,IAAA,EAAA,CAAA,aAAA,CAAA,EAAA,CAAA,EAAA,WAAA,EAAA,CAAA;sBAyC1E;;sBASA;;sBAyBA;;sBASA;;;AE/HH;;AAEG;;;;"}
|
|
@@ -1,39 +1,36 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { input, effect, ChangeDetectionStrategy, ViewEncapsulation, Component } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/forms';
|
|
4
4
|
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
|
5
5
|
|
|
6
6
|
class CmatRichTextEditorComponent {
|
|
7
7
|
constructor() {
|
|
8
|
-
this.value = ''
|
|
9
|
-
|
|
10
|
-
this.
|
|
11
|
-
|
|
12
|
-
this.
|
|
8
|
+
this.value = input('', /* @ts-ignore */
|
|
9
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
10
|
+
this.placeholder = input('请输入内容', /* @ts-ignore */
|
|
11
|
+
...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
12
|
+
this.readOnly = input(false, /* @ts-ignore */
|
|
13
|
+
...(ngDevMode ? [{ debugName: "readOnly" }] : /* istanbul ignore next */ []));
|
|
14
|
+
this.theme = input('snow', /* @ts-ignore */
|
|
15
|
+
...(ngDevMode ? [{ debugName: "theme" }] : /* istanbul ignore next */ []));
|
|
16
|
+
this.minHeight = input('240px', /* @ts-ignore */
|
|
17
|
+
...(ngDevMode ? [{ debugName: "minHeight" }] : /* istanbul ignore next */ []));
|
|
13
18
|
this.control = new FormControl('');
|
|
19
|
+
// 监听 value 变化并同步到 formControl
|
|
20
|
+
effect(() => {
|
|
21
|
+
const val = this.value();
|
|
22
|
+
this.control.setValue(val ?? '', { emitEvent: false });
|
|
23
|
+
});
|
|
14
24
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.10", ngImport: i0, type: CmatRichTextEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
21
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.10", type: CmatRichTextEditorComponent, isStandalone: true, selector: "cmat-rich-text-editor", inputs: { value: "value", placeholder: "placeholder", readOnly: "readOnly", theme: "theme", minHeight: "minHeight" }, usesOnChanges: true, ngImport: i0, template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n@defer (on viewport) {\r\n <div class=\"rounded-2xl border border-default bg-card shadow-sm\">\r\n <quill-editor class=\"w-full\" [formControl]=\"control\" [placeholder]=\"placeholder\" [readOnly]=\"readOnly\" [theme]=\"theme\" [styles]=\"{ minHeight }\"></quill-editor>\r\n </div>\r\n} @placeholder {\r\n <div class=\"flex items-center justify-center rounded-2xl border border-dashed border-default bg-card px-4 py-6 text-sm text-secondary shadow-sm\" [style.minHeight]=\"minHeight\">\r\n \u5BCC\u6587\u672C\u7F16\u8F91\u5668\u52A0\u8F7D\u4E2D...\r\n </div>\r\n}\r\n<!-- eslint-enable @angular-eslint/template/no-inline-styles -->\r\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush, deferBlockDependencies: [() => [import('ngx-quill').then(m => m.QuillEditorComponent), i1.NgControlStatus, i1.FormControlDirective]] }); }
|
|
25
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: CmatRichTextEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
26
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.2", type: CmatRichTextEditorComponent, isStandalone: true, selector: "cmat-rich-text-editor", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, readOnly: { classPropertyName: "readOnly", publicName: "readOnly", isSignal: true, isRequired: false, transformFunction: null }, theme: { classPropertyName: "theme", publicName: "theme", isSignal: true, isRequired: false, transformFunction: null }, minHeight: { classPropertyName: "minHeight", publicName: "minHeight", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n@defer (on viewport) {\r\n <div class=\"rounded-2xl border border-default bg-card shadow-sm\">\r\n <quill-editor class=\"w-full\" [formControl]=\"control\" [placeholder]=\"placeholder()\" [readOnly]=\"readOnly()\" [theme]=\"theme()\" [styles]=\"{ minHeight: minHeight() }\"></quill-editor>\r\n </div>\r\n} @placeholder {\r\n <div class=\"flex items-center justify-center rounded-2xl border border-dashed border-default bg-card px-4 py-6 text-sm text-secondary shadow-sm\" [style.minHeight]=\"minHeight()\">\r\n \u5BCC\u6587\u672C\u7F16\u8F91\u5668\u52A0\u8F7D\u4E2D...\r\n </div>\r\n}\r\n<!-- eslint-enable @angular-eslint/template/no-inline-styles -->\r\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None, deferBlockDependencies: [() => [/* @ts-ignore */
|
|
27
|
+
import('ngx-quill').then(m => m.QuillEditorComponent), i1.NgControlStatus, i1.FormControlDirective]] }); }
|
|
22
28
|
}
|
|
23
|
-
i0.ɵɵngDeclareClassMetadataAsync({ minVersion: "18.0.0", version: "
|
|
29
|
+
i0.ɵɵngDeclareClassMetadataAsync({ minVersion: "18.0.0", version: "22.0.2", ngImport: i0, type: CmatRichTextEditorComponent, resolveDeferredDeps: () => [/* @ts-ignore */
|
|
30
|
+
import('ngx-quill').then(m => m.QuillEditorComponent)], resolveMetadata: QuillEditorComponent => ({ decorators: [{
|
|
24
31
|
type: Component,
|
|
25
|
-
args: [{ selector: 'cmat-rich-text-editor', changeDetection: ChangeDetectionStrategy.OnPush, imports: [QuillEditorComponent, ReactiveFormsModule], template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n@defer (on viewport) {\r\n <div class=\"rounded-2xl border border-default bg-card shadow-sm\">\r\n <quill-editor class=\"w-full\" [formControl]=\"control\" [placeholder]=\"placeholder\" [readOnly]=\"readOnly\" [theme]=\"theme\" [styles]=\"{ minHeight }\"></quill-editor>\r\n </div>\r\n} @placeholder {\r\n <div class=\"flex items-center justify-center rounded-2xl border border-dashed border-default bg-card px-4 py-6 text-sm text-secondary shadow-sm\" [style.minHeight]=\"minHeight\">\r\n \u5BCC\u6587\u672C\u7F16\u8F91\u5668\u52A0\u8F7D\u4E2D...\r\n </div>\r\n}\r\n<!-- eslint-enable @angular-eslint/template/no-inline-styles -->\r\n", styles: [":host{display:block}\n"] }]
|
|
26
|
-
}], ctorParameters:
|
|
27
|
-
type: Input
|
|
28
|
-
}], placeholder: [{
|
|
29
|
-
type: Input
|
|
30
|
-
}], readOnly: [{
|
|
31
|
-
type: Input
|
|
32
|
-
}], theme: [{
|
|
33
|
-
type: Input
|
|
34
|
-
}], minHeight: [{
|
|
35
|
-
type: Input
|
|
36
|
-
}] } }) });
|
|
32
|
+
args: [{ selector: 'cmat-rich-text-editor', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, imports: [QuillEditorComponent, ReactiveFormsModule], template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n@defer (on viewport) {\r\n <div class=\"rounded-2xl border border-default bg-card shadow-sm\">\r\n <quill-editor class=\"w-full\" [formControl]=\"control\" [placeholder]=\"placeholder()\" [readOnly]=\"readOnly()\" [theme]=\"theme()\" [styles]=\"{ minHeight: minHeight() }\"></quill-editor>\r\n </div>\r\n} @placeholder {\r\n <div class=\"flex items-center justify-center rounded-2xl border border-dashed border-default bg-card px-4 py-6 text-sm text-secondary shadow-sm\" [style.minHeight]=\"minHeight()\">\r\n \u5BCC\u6587\u672C\u7F16\u8F91\u5668\u52A0\u8F7D\u4E2D...\r\n </div>\r\n}\r\n<!-- eslint-enable @angular-eslint/template/no-inline-styles -->\r\n", styles: [":host{display:block}\n"] }]
|
|
33
|
+
}], ctorParameters: () => [], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], readOnly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readOnly", required: false }] }], theme: [{ type: i0.Input, args: [{ isSignal: true, alias: "theme", required: false }] }], minHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "minHeight", required: false }] }] } }) });
|
|
37
34
|
|
|
38
35
|
/**
|
|
39
36
|
* Generated bundle index. Do not edit.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cmat-components-rich-text-editor.mjs","sources":["../../../projects/cmat/components/rich-text-editor/rich-text-editor.component.ts","../../../projects/cmat/components/rich-text-editor/rich-text-editor.component.html","../../../projects/cmat/components/rich-text-editor/cmat-components-rich-text-editor.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component,
|
|
1
|
+
{"version":3,"file":"cmat-components-rich-text-editor.mjs","sources":["../../../projects/cmat/components/rich-text-editor/rich-text-editor.component.ts","../../../projects/cmat/components/rich-text-editor/rich-text-editor.component.html","../../../projects/cmat/components/rich-text-editor/cmat-components-rich-text-editor.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, input, effect, ViewEncapsulation } from '@angular/core';\r\nimport { FormControl, ReactiveFormsModule } from '@angular/forms';\r\nimport { QuillEditorComponent } from 'ngx-quill';\r\n\r\n@Component({\r\n selector: 'cmat-rich-text-editor',\r\n templateUrl: './rich-text-editor.component.html',\r\n styleUrls: ['./rich-text-editor.component.scss'],\r\n encapsulation: ViewEncapsulation.None,\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n imports: [QuillEditorComponent, ReactiveFormsModule]\r\n})\r\nexport class CmatRichTextEditorComponent {\r\n readonly value = input<string>('');\r\n readonly placeholder = input<string>('请输入内容');\r\n readonly readOnly = input<boolean>(false);\r\n readonly theme = input<string>('snow');\r\n readonly minHeight = input<string>('240px');\r\n\r\n readonly control = new FormControl('');\r\n\r\n constructor() {\r\n // 监听 value 变化并同步到 formControl\r\n effect(() => {\r\n const val = this.value();\r\n this.control.setValue(val ?? '', { emitEvent: false });\r\n });\r\n }\r\n}\r\n","<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n@defer (on viewport) {\r\n <div class=\"rounded-2xl border border-default bg-card shadow-sm\">\r\n <quill-editor class=\"w-full\" [formControl]=\"control\" [placeholder]=\"placeholder()\" [readOnly]=\"readOnly()\" [theme]=\"theme()\" [styles]=\"{ minHeight: minHeight() }\"></quill-editor>\r\n </div>\r\n} @placeholder {\r\n <div class=\"flex items-center justify-center rounded-2xl border border-dashed border-default bg-card px-4 py-6 text-sm text-secondary shadow-sm\" [style.minHeight]=\"minHeight()\">\r\n 富文本编辑器加载中...\r\n </div>\r\n}\r\n<!-- eslint-enable @angular-eslint/template/no-inline-styles -->\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAYa,2BAA2B,CAAA;AASpC,IAAA,WAAA,GAAA;QARS,IAAA,CAAA,KAAK,GAAG,KAAK,CAAS,EAAE;kFAAC;QACzB,IAA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