@ng-prism/plugin-box-model 21.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/box-model-overlay.component.d.ts +29 -0
- package/dist/box-model-overlay.component.d.ts.map +1 -0
- package/dist/box-model-overlay.component.js +254 -0
- package/dist/box-model-panel.component.d.ts +12 -0
- package/dist/box-model-panel.component.d.ts.map +1 -0
- package/dist/box-model-panel.component.js +143 -0
- package/dist/box-model-plugin.d.ts +3 -0
- package/dist/box-model-plugin.d.ts.map +1 -0
- package/dist/box-model-plugin.js +14 -0
- package/dist/box-model-state.service.d.ts +8 -0
- package/dist/box-model-state.service.d.ts.map +1 -0
- package/dist/box-model-state.service.js +11 -0
- package/dist/box-model-utils.d.ts +3 -0
- package/dist/box-model-utils.d.ts.map +1 -0
- package/dist/box-model-utils.js +18 -0
- package/dist/box-model.types.d.ts +14 -0
- package/dist/box-model.types.d.ts.map +1 -0
- package/dist/box-model.types.js +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
interface BoxStyle {
|
|
3
|
+
left: string;
|
|
4
|
+
top: string;
|
|
5
|
+
width: string;
|
|
6
|
+
height: string;
|
|
7
|
+
}
|
|
8
|
+
interface BoxStyles {
|
|
9
|
+
margin: BoxStyle;
|
|
10
|
+
border: BoxStyle;
|
|
11
|
+
padding: BoxStyle;
|
|
12
|
+
content: BoxStyle;
|
|
13
|
+
}
|
|
14
|
+
export declare class BoxModelOverlayComponent {
|
|
15
|
+
private readonly el;
|
|
16
|
+
private readonly destroyRef;
|
|
17
|
+
private readonly rendererService;
|
|
18
|
+
private readonly stateService;
|
|
19
|
+
readonly boxStyles: import("@angular/core").Signal<BoxStyles | null>;
|
|
20
|
+
readonly contentSize: import("@angular/core").Signal<string>;
|
|
21
|
+
labelMargin(side: 'top' | 'right' | 'bottom' | 'left'): string;
|
|
22
|
+
labelPadding(side: 'top' | 'right' | 'bottom' | 'left'): string;
|
|
23
|
+
constructor();
|
|
24
|
+
private handleMouseMove;
|
|
25
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<BoxModelOverlayComponent, never>;
|
|
26
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<BoxModelOverlayComponent, "prism-box-model-overlay", never, {}, {}, never, never, true, never>;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=box-model-overlay.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box-model-overlay.component.d.ts","sourceRoot":"","sources":["../src/box-model-overlay.component.ts"],"names":[],"mappings":";AAeA,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,SAAS;IACjB,MAAM,EAAE,QAAQ,CAAC;IACjB,MAAM,EAAE,QAAQ,CAAC;IACjB,OAAO,EAAE,QAAQ,CAAC;IAClB,OAAO,EAAE,QAAQ,CAAC;CACnB;AAED,qBAiEa,wBAAwB;IACnC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAmC;IACtD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAsB;IACjD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAgC;IAChE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAgC;IAE7D,QAAQ,CAAC,SAAS,mDAyCf;IAEH,QAAQ,CAAC,WAAW,yCAOjB;IAEH,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM;IAO9D,YAAY,CAAC,IAAI,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM;;IA0B/D,OAAO,CAAC,eAAe;yCA3FZ,wBAAwB;2CAAxB,wBAAwB;CA0GpC"}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { afterNextRender, ChangeDetectionStrategy, Component, computed, DestroyRef, ElementRef, inject, } from '@angular/core';
|
|
2
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
3
|
+
import { fromEvent } from 'rxjs';
|
|
4
|
+
import { PrismRendererService } from '@ng-prism/core';
|
|
5
|
+
import { getBoxModel } from './box-model-utils.js';
|
|
6
|
+
import { BoxModelStateService } from './box-model-state.service.js';
|
|
7
|
+
import * as i0 from "@angular/core";
|
|
8
|
+
function BoxModelOverlayComponent_Conditional_0_Conditional_1_Template(rf, ctx) { if (rf & 1) {
|
|
9
|
+
i0.ɵɵdomElementStart(0, "span", 1);
|
|
10
|
+
i0.ɵɵtext(1);
|
|
11
|
+
i0.ɵɵdomElementEnd();
|
|
12
|
+
} if (rf & 2) {
|
|
13
|
+
const ctx_r0 = i0.ɵɵnextContext(2);
|
|
14
|
+
i0.ɵɵadvance();
|
|
15
|
+
i0.ɵɵtextInterpolate(ctx_r0.labelMargin("top"));
|
|
16
|
+
} }
|
|
17
|
+
function BoxModelOverlayComponent_Conditional_0_Conditional_2_Template(rf, ctx) { if (rf & 1) {
|
|
18
|
+
i0.ɵɵdomElementStart(0, "span", 2);
|
|
19
|
+
i0.ɵɵtext(1);
|
|
20
|
+
i0.ɵɵdomElementEnd();
|
|
21
|
+
} if (rf & 2) {
|
|
22
|
+
const ctx_r0 = i0.ɵɵnextContext(2);
|
|
23
|
+
i0.ɵɵadvance();
|
|
24
|
+
i0.ɵɵtextInterpolate(ctx_r0.labelMargin("right"));
|
|
25
|
+
} }
|
|
26
|
+
function BoxModelOverlayComponent_Conditional_0_Conditional_3_Template(rf, ctx) { if (rf & 1) {
|
|
27
|
+
i0.ɵɵdomElementStart(0, "span", 3);
|
|
28
|
+
i0.ɵɵtext(1);
|
|
29
|
+
i0.ɵɵdomElementEnd();
|
|
30
|
+
} if (rf & 2) {
|
|
31
|
+
const ctx_r0 = i0.ɵɵnextContext(2);
|
|
32
|
+
i0.ɵɵadvance();
|
|
33
|
+
i0.ɵɵtextInterpolate(ctx_r0.labelMargin("bottom"));
|
|
34
|
+
} }
|
|
35
|
+
function BoxModelOverlayComponent_Conditional_0_Conditional_4_Template(rf, ctx) { if (rf & 1) {
|
|
36
|
+
i0.ɵɵdomElementStart(0, "span", 4);
|
|
37
|
+
i0.ɵɵtext(1);
|
|
38
|
+
i0.ɵɵdomElementEnd();
|
|
39
|
+
} if (rf & 2) {
|
|
40
|
+
const ctx_r0 = i0.ɵɵnextContext(2);
|
|
41
|
+
i0.ɵɵadvance();
|
|
42
|
+
i0.ɵɵtextInterpolate(ctx_r0.labelMargin("left"));
|
|
43
|
+
} }
|
|
44
|
+
function BoxModelOverlayComponent_Conditional_0_Conditional_7_Template(rf, ctx) { if (rf & 1) {
|
|
45
|
+
i0.ɵɵdomElementStart(0, "span", 1);
|
|
46
|
+
i0.ɵɵtext(1);
|
|
47
|
+
i0.ɵɵdomElementEnd();
|
|
48
|
+
} if (rf & 2) {
|
|
49
|
+
const ctx_r0 = i0.ɵɵnextContext(2);
|
|
50
|
+
i0.ɵɵadvance();
|
|
51
|
+
i0.ɵɵtextInterpolate(ctx_r0.labelPadding("top"));
|
|
52
|
+
} }
|
|
53
|
+
function BoxModelOverlayComponent_Conditional_0_Conditional_8_Template(rf, ctx) { if (rf & 1) {
|
|
54
|
+
i0.ɵɵdomElementStart(0, "span", 2);
|
|
55
|
+
i0.ɵɵtext(1);
|
|
56
|
+
i0.ɵɵdomElementEnd();
|
|
57
|
+
} if (rf & 2) {
|
|
58
|
+
const ctx_r0 = i0.ɵɵnextContext(2);
|
|
59
|
+
i0.ɵɵadvance();
|
|
60
|
+
i0.ɵɵtextInterpolate(ctx_r0.labelPadding("right"));
|
|
61
|
+
} }
|
|
62
|
+
function BoxModelOverlayComponent_Conditional_0_Conditional_9_Template(rf, ctx) { if (rf & 1) {
|
|
63
|
+
i0.ɵɵdomElementStart(0, "span", 3);
|
|
64
|
+
i0.ɵɵtext(1);
|
|
65
|
+
i0.ɵɵdomElementEnd();
|
|
66
|
+
} if (rf & 2) {
|
|
67
|
+
const ctx_r0 = i0.ɵɵnextContext(2);
|
|
68
|
+
i0.ɵɵadvance();
|
|
69
|
+
i0.ɵɵtextInterpolate(ctx_r0.labelPadding("bottom"));
|
|
70
|
+
} }
|
|
71
|
+
function BoxModelOverlayComponent_Conditional_0_Conditional_10_Template(rf, ctx) { if (rf & 1) {
|
|
72
|
+
i0.ɵɵdomElementStart(0, "span", 4);
|
|
73
|
+
i0.ɵɵtext(1);
|
|
74
|
+
i0.ɵɵdomElementEnd();
|
|
75
|
+
} if (rf & 2) {
|
|
76
|
+
const ctx_r0 = i0.ɵɵnextContext(2);
|
|
77
|
+
i0.ɵɵadvance();
|
|
78
|
+
i0.ɵɵtextInterpolate(ctx_r0.labelPadding("left"));
|
|
79
|
+
} }
|
|
80
|
+
function BoxModelOverlayComponent_Conditional_0_Template(rf, ctx) { if (rf & 1) {
|
|
81
|
+
i0.ɵɵdomElementStart(0, "div", 0);
|
|
82
|
+
i0.ɵɵconditionalCreate(1, BoxModelOverlayComponent_Conditional_0_Conditional_1_Template, 2, 1, "span", 1);
|
|
83
|
+
i0.ɵɵconditionalCreate(2, BoxModelOverlayComponent_Conditional_0_Conditional_2_Template, 2, 1, "span", 2);
|
|
84
|
+
i0.ɵɵconditionalCreate(3, BoxModelOverlayComponent_Conditional_0_Conditional_3_Template, 2, 1, "span", 3);
|
|
85
|
+
i0.ɵɵconditionalCreate(4, BoxModelOverlayComponent_Conditional_0_Conditional_4_Template, 2, 1, "span", 4);
|
|
86
|
+
i0.ɵɵdomElementEnd();
|
|
87
|
+
i0.ɵɵdomElement(5, "div", 5);
|
|
88
|
+
i0.ɵɵdomElementStart(6, "div", 6);
|
|
89
|
+
i0.ɵɵconditionalCreate(7, BoxModelOverlayComponent_Conditional_0_Conditional_7_Template, 2, 1, "span", 1);
|
|
90
|
+
i0.ɵɵconditionalCreate(8, BoxModelOverlayComponent_Conditional_0_Conditional_8_Template, 2, 1, "span", 2);
|
|
91
|
+
i0.ɵɵconditionalCreate(9, BoxModelOverlayComponent_Conditional_0_Conditional_9_Template, 2, 1, "span", 3);
|
|
92
|
+
i0.ɵɵconditionalCreate(10, BoxModelOverlayComponent_Conditional_0_Conditional_10_Template, 2, 1, "span", 4);
|
|
93
|
+
i0.ɵɵdomElementEnd();
|
|
94
|
+
i0.ɵɵdomElementStart(11, "div", 7)(12, "span", 8);
|
|
95
|
+
i0.ɵɵtext(13);
|
|
96
|
+
i0.ɵɵdomElementEnd()();
|
|
97
|
+
} if (rf & 2) {
|
|
98
|
+
const styles_r2 = ctx;
|
|
99
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
100
|
+
i0.ɵɵstyleProp("left", styles_r2.margin.left)("top", styles_r2.margin.top)("width", styles_r2.margin.width)("height", styles_r2.margin.height);
|
|
101
|
+
i0.ɵɵadvance();
|
|
102
|
+
i0.ɵɵconditional(ctx_r0.labelMargin("top") ? 1 : -1);
|
|
103
|
+
i0.ɵɵadvance();
|
|
104
|
+
i0.ɵɵconditional(ctx_r0.labelMargin("right") ? 2 : -1);
|
|
105
|
+
i0.ɵɵadvance();
|
|
106
|
+
i0.ɵɵconditional(ctx_r0.labelMargin("bottom") ? 3 : -1);
|
|
107
|
+
i0.ɵɵadvance();
|
|
108
|
+
i0.ɵɵconditional(ctx_r0.labelMargin("left") ? 4 : -1);
|
|
109
|
+
i0.ɵɵadvance();
|
|
110
|
+
i0.ɵɵstyleProp("left", styles_r2.border.left)("top", styles_r2.border.top)("width", styles_r2.border.width)("height", styles_r2.border.height);
|
|
111
|
+
i0.ɵɵadvance();
|
|
112
|
+
i0.ɵɵstyleProp("left", styles_r2.padding.left)("top", styles_r2.padding.top)("width", styles_r2.padding.width)("height", styles_r2.padding.height);
|
|
113
|
+
i0.ɵɵadvance();
|
|
114
|
+
i0.ɵɵconditional(ctx_r0.labelPadding("top") ? 7 : -1);
|
|
115
|
+
i0.ɵɵadvance();
|
|
116
|
+
i0.ɵɵconditional(ctx_r0.labelPadding("right") ? 8 : -1);
|
|
117
|
+
i0.ɵɵadvance();
|
|
118
|
+
i0.ɵɵconditional(ctx_r0.labelPadding("bottom") ? 9 : -1);
|
|
119
|
+
i0.ɵɵadvance();
|
|
120
|
+
i0.ɵɵconditional(ctx_r0.labelPadding("left") ? 10 : -1);
|
|
121
|
+
i0.ɵɵadvance();
|
|
122
|
+
i0.ɵɵstyleProp("left", styles_r2.content.left)("top", styles_r2.content.top)("width", styles_r2.content.width)("height", styles_r2.content.height);
|
|
123
|
+
i0.ɵɵadvance(2);
|
|
124
|
+
i0.ɵɵtextInterpolate(ctx_r0.contentSize());
|
|
125
|
+
} }
|
|
126
|
+
export class BoxModelOverlayComponent {
|
|
127
|
+
el = inject((ElementRef));
|
|
128
|
+
destroyRef = inject(DestroyRef);
|
|
129
|
+
rendererService = inject(PrismRendererService);
|
|
130
|
+
stateService = inject(BoxModelStateService);
|
|
131
|
+
boxStyles = computed(() => {
|
|
132
|
+
const bm = this.stateService.hoveredBoxModel();
|
|
133
|
+
const canvas = this.el.nativeElement.parentElement;
|
|
134
|
+
if (!bm || !canvas)
|
|
135
|
+
return null;
|
|
136
|
+
const canvasRect = canvas.getBoundingClientRect();
|
|
137
|
+
const sl = canvas.scrollLeft;
|
|
138
|
+
const st = canvas.scrollTop;
|
|
139
|
+
const { content, padding, border, margin } = bm;
|
|
140
|
+
const bLeft = content.left - canvasRect.left + sl;
|
|
141
|
+
const bTop = content.top - canvasRect.top + st;
|
|
142
|
+
const bW = content.width;
|
|
143
|
+
const bH = content.height;
|
|
144
|
+
return {
|
|
145
|
+
margin: {
|
|
146
|
+
left: `${bLeft - margin.left}px`,
|
|
147
|
+
top: `${bTop - margin.top}px`,
|
|
148
|
+
width: `${bW + margin.left + margin.right}px`,
|
|
149
|
+
height: `${bH + margin.top + margin.bottom}px`,
|
|
150
|
+
},
|
|
151
|
+
border: {
|
|
152
|
+
left: `${bLeft}px`,
|
|
153
|
+
top: `${bTop}px`,
|
|
154
|
+
width: `${bW}px`,
|
|
155
|
+
height: `${bH}px`,
|
|
156
|
+
},
|
|
157
|
+
padding: {
|
|
158
|
+
left: `${bLeft + border.left}px`,
|
|
159
|
+
top: `${bTop + border.top}px`,
|
|
160
|
+
width: `${bW - border.left - border.right}px`,
|
|
161
|
+
height: `${bH - border.top - border.bottom}px`,
|
|
162
|
+
},
|
|
163
|
+
content: {
|
|
164
|
+
left: `${bLeft + border.left + padding.left}px`,
|
|
165
|
+
top: `${bTop + border.top + padding.top}px`,
|
|
166
|
+
width: `${bW - border.left - border.right - padding.left - padding.right}px`,
|
|
167
|
+
height: `${bH - border.top - border.bottom - padding.top - padding.bottom}px`,
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}, ...(ngDevMode ? [{ debugName: "boxStyles" }] : []));
|
|
171
|
+
contentSize = computed(() => {
|
|
172
|
+
const bm = this.stateService.hoveredBoxModel();
|
|
173
|
+
if (!bm)
|
|
174
|
+
return '';
|
|
175
|
+
const { content, border, padding } = bm;
|
|
176
|
+
const w = Math.round(content.width - border.left - border.right - padding.left - padding.right);
|
|
177
|
+
const h = Math.round(content.height - border.top - border.bottom - padding.top - padding.bottom);
|
|
178
|
+
return `${w} × ${h}`;
|
|
179
|
+
}, ...(ngDevMode ? [{ debugName: "contentSize" }] : []));
|
|
180
|
+
labelMargin(side) {
|
|
181
|
+
const bm = this.stateService.hoveredBoxModel();
|
|
182
|
+
if (!bm)
|
|
183
|
+
return '';
|
|
184
|
+
const v = bm.margin[side];
|
|
185
|
+
return v === 0 ? '' : `${v}px`;
|
|
186
|
+
}
|
|
187
|
+
labelPadding(side) {
|
|
188
|
+
const bm = this.stateService.hoveredBoxModel();
|
|
189
|
+
if (!bm)
|
|
190
|
+
return '';
|
|
191
|
+
const v = bm.padding[side];
|
|
192
|
+
return v === 0 ? '' : `${v}px`;
|
|
193
|
+
}
|
|
194
|
+
constructor() {
|
|
195
|
+
this.destroyRef.onDestroy(() => {
|
|
196
|
+
this.stateService.hoveredBoxModel.set(null);
|
|
197
|
+
});
|
|
198
|
+
afterNextRender(() => {
|
|
199
|
+
const canvas = this.el.nativeElement.parentElement;
|
|
200
|
+
if (!canvas)
|
|
201
|
+
return;
|
|
202
|
+
fromEvent(canvas, 'mousemove')
|
|
203
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
204
|
+
.subscribe((event) => this.handleMouseMove(event));
|
|
205
|
+
fromEvent(canvas, 'mouseleave')
|
|
206
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
207
|
+
.subscribe(() => this.stateService.hoveredBoxModel.set(null));
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
handleMouseMove(event) {
|
|
211
|
+
const renderedEl = this.rendererService.renderedElement();
|
|
212
|
+
if (!renderedEl) {
|
|
213
|
+
this.stateService.hoveredBoxModel.set(null);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const element = document.elementFromPoint(event.clientX, event.clientY);
|
|
217
|
+
if (!element || !renderedEl.contains(element)) {
|
|
218
|
+
this.stateService.hoveredBoxModel.set(null);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
this.stateService.hoveredBoxModel.set(getBoxModel(element));
|
|
222
|
+
}
|
|
223
|
+
static ɵfac = function BoxModelOverlayComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || BoxModelOverlayComponent)(); };
|
|
224
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BoxModelOverlayComponent, selectors: [["prism-box-model-overlay"]], decls: 1, vars: 1, consts: [[1, "prism-bm__box", "prism-bm__box--margin"], [1, "prism-bm__label", "prism-bm__label--top"], [1, "prism-bm__label", "prism-bm__label--right"], [1, "prism-bm__label", "prism-bm__label--bottom"], [1, "prism-bm__label", "prism-bm__label--left"], [1, "prism-bm__box", "prism-bm__box--border"], [1, "prism-bm__box", "prism-bm__box--padding"], [1, "prism-bm__box", "prism-bm__box--content"], [1, "prism-bm__size"]], template: function BoxModelOverlayComponent_Template(rf, ctx) { if (rf & 1) {
|
|
225
|
+
i0.ɵɵconditionalCreate(0, BoxModelOverlayComponent_Conditional_0_Template, 14, 41);
|
|
226
|
+
} if (rf & 2) {
|
|
227
|
+
let tmp_0_0;
|
|
228
|
+
i0.ɵɵconditional((tmp_0_0 = ctx.boxStyles()) ? 0 : -1, tmp_0_0);
|
|
229
|
+
} }, styles: ["[_nghost-%COMP%] {\n position: absolute;\n inset: 0;\n pointer-events: none;\n overflow: hidden;\n }\n .prism-bm__box[_ngcontent-%COMP%] {\n position: absolute;\n box-sizing: border-box;\n }\n .prism-bm__box--margin[_ngcontent-%COMP%] { background: rgba(245, 158, 11, 0.2); outline: 1px solid rgba(245, 158, 11, 0.5); }\n .prism-bm__box--border[_ngcontent-%COMP%] { background: rgba(234, 179, 8, 0.3); }\n .prism-bm__box--padding[_ngcontent-%COMP%] { background: rgba(16, 185, 129, 0.2); outline: 1px solid rgba(16, 185, 129, 0.4); }\n .prism-bm__box--content[_ngcontent-%COMP%] { background: rgba(59, 130, 246, 0.25); display: flex; align-items: center; justify-content: center; }\n .prism-bm__label[_ngcontent-%COMP%] {\n position: absolute;\n font-size: 10px;\n font-family: monospace;\n color: #1f2937;\n background: rgba(255,255,255,0.8);\n padding: 0 3px;\n border-radius: 2px;\n white-space: nowrap;\n line-height: 1.4;\n }\n .prism-bm__label--top[_ngcontent-%COMP%] { top: 2px; left: 50%; transform: translateX(-50%); }\n .prism-bm__label--bottom[_ngcontent-%COMP%] { bottom: 2px; left: 50%; transform: translateX(-50%); }\n .prism-bm__label--left[_ngcontent-%COMP%] { left: 2px; top: 50%; transform: translateY(-50%); }\n .prism-bm__label--right[_ngcontent-%COMP%] { right: 2px; top: 50%; transform: translateY(-50%); }\n .prism-bm__size[_ngcontent-%COMP%] {\n font-size: 11px;\n font-family: monospace;\n color: #1e3a5f;\n background: rgba(255,255,255,0.85);\n padding: 1px 5px;\n border-radius: 3px;\n white-space: nowrap;\n }"], changeDetection: 0 });
|
|
230
|
+
}
|
|
231
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BoxModelOverlayComponent, [{
|
|
232
|
+
type: Component,
|
|
233
|
+
args: [{ selector: 'prism-box-model-overlay', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
234
|
+
@if (boxStyles(); as styles) {
|
|
235
|
+
<div class="prism-bm__box prism-bm__box--margin" [style.left]="styles.margin.left" [style.top]="styles.margin.top" [style.width]="styles.margin.width" [style.height]="styles.margin.height">
|
|
236
|
+
@if (labelMargin('top')) { <span class="prism-bm__label prism-bm__label--top">{{ labelMargin('top') }}</span> }
|
|
237
|
+
@if (labelMargin('right')) { <span class="prism-bm__label prism-bm__label--right">{{ labelMargin('right') }}</span> }
|
|
238
|
+
@if (labelMargin('bottom')) { <span class="prism-bm__label prism-bm__label--bottom">{{ labelMargin('bottom') }}</span> }
|
|
239
|
+
@if (labelMargin('left')) { <span class="prism-bm__label prism-bm__label--left">{{ labelMargin('left') }}</span> }
|
|
240
|
+
</div>
|
|
241
|
+
<div class="prism-bm__box prism-bm__box--border" [style.left]="styles.border.left" [style.top]="styles.border.top" [style.width]="styles.border.width" [style.height]="styles.border.height"></div>
|
|
242
|
+
<div class="prism-bm__box prism-bm__box--padding" [style.left]="styles.padding.left" [style.top]="styles.padding.top" [style.width]="styles.padding.width" [style.height]="styles.padding.height">
|
|
243
|
+
@if (labelPadding('top')) { <span class="prism-bm__label prism-bm__label--top">{{ labelPadding('top') }}</span> }
|
|
244
|
+
@if (labelPadding('right')) { <span class="prism-bm__label prism-bm__label--right">{{ labelPadding('right') }}</span> }
|
|
245
|
+
@if (labelPadding('bottom')) { <span class="prism-bm__label prism-bm__label--bottom">{{ labelPadding('bottom') }}</span> }
|
|
246
|
+
@if (labelPadding('left')) { <span class="prism-bm__label prism-bm__label--left">{{ labelPadding('left') }}</span> }
|
|
247
|
+
</div>
|
|
248
|
+
<div class="prism-bm__box prism-bm__box--content" [style.left]="styles.content.left" [style.top]="styles.content.top" [style.width]="styles.content.width" [style.height]="styles.content.height">
|
|
249
|
+
<span class="prism-bm__size">{{ contentSize() }}</span>
|
|
250
|
+
</div>
|
|
251
|
+
}
|
|
252
|
+
`, styles: ["\n :host {\n position: absolute;\n inset: 0;\n pointer-events: none;\n overflow: hidden;\n }\n .prism-bm__box {\n position: absolute;\n box-sizing: border-box;\n }\n .prism-bm__box--margin { background: rgba(245, 158, 11, 0.2); outline: 1px solid rgba(245, 158, 11, 0.5); }\n .prism-bm__box--border { background: rgba(234, 179, 8, 0.3); }\n .prism-bm__box--padding { background: rgba(16, 185, 129, 0.2); outline: 1px solid rgba(16, 185, 129, 0.4); }\n .prism-bm__box--content { background: rgba(59, 130, 246, 0.25); display: flex; align-items: center; justify-content: center; }\n .prism-bm__label {\n position: absolute;\n font-size: 10px;\n font-family: monospace;\n color: #1f2937;\n background: rgba(255,255,255,0.8);\n padding: 0 3px;\n border-radius: 2px;\n white-space: nowrap;\n line-height: 1.4;\n }\n .prism-bm__label--top { top: 2px; left: 50%; transform: translateX(-50%); }\n .prism-bm__label--bottom { bottom: 2px; left: 50%; transform: translateX(-50%); }\n .prism-bm__label--left { left: 2px; top: 50%; transform: translateY(-50%); }\n .prism-bm__label--right { right: 2px; top: 50%; transform: translateY(-50%); }\n .prism-bm__size {\n font-size: 11px;\n font-family: monospace;\n color: #1e3a5f;\n background: rgba(255,255,255,0.85);\n padding: 1px 5px;\n border-radius: 3px;\n white-space: nowrap;\n }\n "] }]
|
|
253
|
+
}], () => [], null); })();
|
|
254
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(BoxModelOverlayComponent, { className: "BoxModelOverlayComponent", filePath: "box-model-overlay.component.ts", lineNumber: 95 }); })();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BoxModelStateService } from './box-model-state.service.js';
|
|
2
|
+
import type { BoxModelData } from './box-model.types.js';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class BoxModelPanelComponent {
|
|
5
|
+
protected readonly stateService: BoxModelStateService;
|
|
6
|
+
fmt(value: number): string;
|
|
7
|
+
contentW(bm: BoxModelData): string;
|
|
8
|
+
contentH(bm: BoxModelData): string;
|
|
9
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<BoxModelPanelComponent, never>;
|
|
10
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<BoxModelPanelComponent, "prism-box-model-panel", never, {}, {}, never, never, true, never>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=box-model-panel.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box-model-panel.component.d.ts","sourceRoot":"","sources":["../src/box-model-panel.component.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;;AAEzD,qBAiGa,sBAAsB;IACjC,SAAS,CAAC,QAAQ,CAAC,YAAY,uBAAgC;IAE/D,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAI1B,QAAQ,CAAC,EAAE,EAAE,YAAY,GAAG,MAAM;IAIlC,QAAQ,CAAC,EAAE,EAAE,YAAY,GAAG,MAAM;yCAXvB,sBAAsB;2CAAtB,sBAAsB;CAclC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
|
|
2
|
+
import { BoxModelStateService } from './box-model-state.service.js';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
function BoxModelPanelComponent_Conditional_1_Template(rf, ctx) { if (rf & 1) {
|
|
5
|
+
i0.ɵɵdomElementStart(0, "div", 1)(1, "div", 3)(2, "span", 4);
|
|
6
|
+
i0.ɵɵtext(3, "margin");
|
|
7
|
+
i0.ɵɵdomElementEnd();
|
|
8
|
+
i0.ɵɵdomElementStart(4, "div", 5)(5, "span", 6);
|
|
9
|
+
i0.ɵɵtext(6);
|
|
10
|
+
i0.ɵɵdomElementEnd();
|
|
11
|
+
i0.ɵɵdomElementStart(7, "div", 7)(8, "span", 6);
|
|
12
|
+
i0.ɵɵtext(9);
|
|
13
|
+
i0.ɵɵdomElementEnd();
|
|
14
|
+
i0.ɵɵdomElementStart(10, "div", 8)(11, "span", 4);
|
|
15
|
+
i0.ɵɵtext(12, "border");
|
|
16
|
+
i0.ɵɵdomElementEnd();
|
|
17
|
+
i0.ɵɵdomElementStart(13, "div", 7)(14, "span", 9);
|
|
18
|
+
i0.ɵɵtext(15);
|
|
19
|
+
i0.ɵɵdomElementEnd();
|
|
20
|
+
i0.ɵɵdomElementStart(16, "div", 10)(17, "span", 4);
|
|
21
|
+
i0.ɵɵtext(18, "padding");
|
|
22
|
+
i0.ɵɵdomElementEnd();
|
|
23
|
+
i0.ɵɵdomElementStart(19, "div", 5)(20, "span", 6);
|
|
24
|
+
i0.ɵɵtext(21);
|
|
25
|
+
i0.ɵɵdomElementEnd();
|
|
26
|
+
i0.ɵɵdomElementStart(22, "div", 7)(23, "span", 6);
|
|
27
|
+
i0.ɵɵtext(24);
|
|
28
|
+
i0.ɵɵdomElementEnd();
|
|
29
|
+
i0.ɵɵdomElementStart(25, "div", 11);
|
|
30
|
+
i0.ɵɵtext(26);
|
|
31
|
+
i0.ɵɵdomElementEnd();
|
|
32
|
+
i0.ɵɵdomElementStart(27, "span", 6);
|
|
33
|
+
i0.ɵɵtext(28);
|
|
34
|
+
i0.ɵɵdomElementEnd()();
|
|
35
|
+
i0.ɵɵdomElementStart(29, "span", 6);
|
|
36
|
+
i0.ɵɵtext(30);
|
|
37
|
+
i0.ɵɵdomElementEnd()()();
|
|
38
|
+
i0.ɵɵdomElementStart(31, "span", 9);
|
|
39
|
+
i0.ɵɵtext(32);
|
|
40
|
+
i0.ɵɵdomElementEnd()()();
|
|
41
|
+
i0.ɵɵdomElementStart(33, "span", 6);
|
|
42
|
+
i0.ɵɵtext(34);
|
|
43
|
+
i0.ɵɵdomElementEnd()();
|
|
44
|
+
i0.ɵɵdomElementStart(35, "span", 6);
|
|
45
|
+
i0.ɵɵtext(36);
|
|
46
|
+
i0.ɵɵdomElementEnd()()()();
|
|
47
|
+
} if (rf & 2) {
|
|
48
|
+
const bm_r1 = ctx;
|
|
49
|
+
const ctx_r1 = i0.ɵɵnextContext();
|
|
50
|
+
i0.ɵɵadvance(6);
|
|
51
|
+
i0.ɵɵtextInterpolate(ctx_r1.fmt(bm_r1.margin.top));
|
|
52
|
+
i0.ɵɵadvance(3);
|
|
53
|
+
i0.ɵɵtextInterpolate(ctx_r1.fmt(bm_r1.margin.left));
|
|
54
|
+
i0.ɵɵadvance(6);
|
|
55
|
+
i0.ɵɵtextInterpolate(ctx_r1.fmt(bm_r1.border.left));
|
|
56
|
+
i0.ɵɵadvance(6);
|
|
57
|
+
i0.ɵɵtextInterpolate(ctx_r1.fmt(bm_r1.padding.top));
|
|
58
|
+
i0.ɵɵadvance(3);
|
|
59
|
+
i0.ɵɵtextInterpolate(ctx_r1.fmt(bm_r1.padding.left));
|
|
60
|
+
i0.ɵɵadvance(2);
|
|
61
|
+
i0.ɵɵtextInterpolate2("", ctx_r1.contentW(bm_r1), " \u00D7 ", ctx_r1.contentH(bm_r1));
|
|
62
|
+
i0.ɵɵadvance(2);
|
|
63
|
+
i0.ɵɵtextInterpolate(ctx_r1.fmt(bm_r1.padding.right));
|
|
64
|
+
i0.ɵɵadvance(2);
|
|
65
|
+
i0.ɵɵtextInterpolate(ctx_r1.fmt(bm_r1.padding.bottom));
|
|
66
|
+
i0.ɵɵadvance(2);
|
|
67
|
+
i0.ɵɵtextInterpolate(ctx_r1.fmt(bm_r1.border.right));
|
|
68
|
+
i0.ɵɵadvance(2);
|
|
69
|
+
i0.ɵɵtextInterpolate(ctx_r1.fmt(bm_r1.margin.right));
|
|
70
|
+
i0.ɵɵadvance(2);
|
|
71
|
+
i0.ɵɵtextInterpolate(ctx_r1.fmt(bm_r1.margin.bottom));
|
|
72
|
+
} }
|
|
73
|
+
function BoxModelPanelComponent_Conditional_2_Template(rf, ctx) { if (rf & 1) {
|
|
74
|
+
i0.ɵɵdomElementStart(0, "div", 2);
|
|
75
|
+
i0.ɵɵtext(1, "Hover over an element to inspect its box model.");
|
|
76
|
+
i0.ɵɵdomElementEnd();
|
|
77
|
+
} }
|
|
78
|
+
export class BoxModelPanelComponent {
|
|
79
|
+
stateService = inject(BoxModelStateService);
|
|
80
|
+
fmt(value) {
|
|
81
|
+
return value === 0 ? '-' : `${value}`;
|
|
82
|
+
}
|
|
83
|
+
contentW(bm) {
|
|
84
|
+
return String(Math.round(bm.content.width - bm.border.left - bm.border.right - bm.padding.left - bm.padding.right));
|
|
85
|
+
}
|
|
86
|
+
contentH(bm) {
|
|
87
|
+
return String(Math.round(bm.content.height - bm.border.top - bm.border.bottom - bm.padding.top - bm.padding.bottom));
|
|
88
|
+
}
|
|
89
|
+
static ɵfac = function BoxModelPanelComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || BoxModelPanelComponent)(); };
|
|
90
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BoxModelPanelComponent, selectors: [["prism-box-model-panel"]], decls: 3, vars: 1, consts: [[1, "prism-bmp"], [1, "prism-bmp__diagram"], [1, "prism-bmp__empty"], [1, "prism-bmp__region", "prism-bmp__region--margin"], [1, "prism-bmp__region-label"], [1, "prism-bmp__sides"], [1, "prism-bmp__side"], [1, "prism-bmp__inner-row"], [1, "prism-bmp__region", "prism-bmp__region--border"], [1, "prism-bmp__side", "prism-bmp__side--dim"], [1, "prism-bmp__region", "prism-bmp__region--padding"], [1, "prism-bmp__content-box"]], template: function BoxModelPanelComponent_Template(rf, ctx) { if (rf & 1) {
|
|
91
|
+
i0.ɵɵdomElementStart(0, "div", 0);
|
|
92
|
+
i0.ɵɵconditionalCreate(1, BoxModelPanelComponent_Conditional_1_Template, 37, 12, "div", 1)(2, BoxModelPanelComponent_Conditional_2_Template, 2, 0, "div", 2);
|
|
93
|
+
i0.ɵɵdomElementEnd();
|
|
94
|
+
} if (rf & 2) {
|
|
95
|
+
let tmp_0_0;
|
|
96
|
+
i0.ɵɵadvance();
|
|
97
|
+
i0.ɵɵconditional((tmp_0_0 = ctx.stateService.hoveredBoxModel()) ? 1 : 2, tmp_0_0);
|
|
98
|
+
} }, styles: ["[_nghost-%COMP%] { display: block; height: 100%; overflow: auto; }\n .prism-bmp[_ngcontent-%COMP%] {\n padding: 16px;\n font-family: var(--prism-font-sans, system-ui);\n font-size: 12px;\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100%;\n }\n .prism-bmp__diagram[_ngcontent-%COMP%] { width: 100%; max-width: 340px; }\n .prism-bmp__region[_ngcontent-%COMP%] { padding: 6px; border-radius: 4px; position: relative; }\n .prism-bmp__region--margin[_ngcontent-%COMP%] { background: rgba(245, 158, 11, 0.15); border: 1px solid rgba(245, 158, 11, 0.4); }\n .prism-bmp__region--border[_ngcontent-%COMP%] { background: rgba(234, 179, 8, 0.2); border: 1px solid rgba(234, 179, 8, 0.5); flex: 1; }\n .prism-bmp__region--padding[_ngcontent-%COMP%] { background: rgba(16, 185, 129, 0.15); border: 1px solid rgba(16, 185, 129, 0.4); flex: 1; }\n .prism-bmp__region-label[_ngcontent-%COMP%] {\n position: absolute;\n top: 3px;\n left: 6px;\n font-size: 10px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n color: var(--prism-text-muted, #6b7280);\n opacity: 0.8;\n }\n .prism-bmp__sides[_ngcontent-%COMP%] { display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 14px; }\n .prism-bmp__inner-row[_ngcontent-%COMP%] { display: flex; align-items: center; gap: 2px; width: 100%; }\n .prism-bmp__inner-row[_ngcontent-%COMP%] > .prism-bmp__region[_ngcontent-%COMP%] { flex: 1; }\n .prism-bmp__side[_ngcontent-%COMP%] {\n font-family: monospace;\n font-size: 11px;\n color: var(--prism-text, #1f2937);\n min-width: 28px;\n text-align: center;\n padding: 1px 4px;\n }\n .prism-bmp__side--dim[_ngcontent-%COMP%] { color: var(--prism-text-muted, #6b7280); }\n .prism-bmp__content-box[_ngcontent-%COMP%] {\n flex: 1;\n text-align: center;\n font-family: monospace;\n font-size: 11px;\n color: var(--prism-text, #1f2937);\n background: rgba(59, 130, 246, 0.2);\n border: 1px solid rgba(59, 130, 246, 0.4);\n border-radius: 3px;\n padding: 6px 4px;\n }\n .prism-bmp__empty[_ngcontent-%COMP%] { color: var(--prism-text-muted, #6b7280); font-size: 13px; }"], changeDetection: 0 });
|
|
99
|
+
}
|
|
100
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BoxModelPanelComponent, [{
|
|
101
|
+
type: Component,
|
|
102
|
+
args: [{ selector: 'prism-box-model-panel', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
103
|
+
<div class="prism-bmp">
|
|
104
|
+
@if (stateService.hoveredBoxModel(); as bm) {
|
|
105
|
+
<div class="prism-bmp__diagram">
|
|
106
|
+
<div class="prism-bmp__region prism-bmp__region--margin">
|
|
107
|
+
<span class="prism-bmp__region-label">margin</span>
|
|
108
|
+
<div class="prism-bmp__sides">
|
|
109
|
+
<span class="prism-bmp__side">{{ fmt(bm.margin.top) }}</span>
|
|
110
|
+
<div class="prism-bmp__inner-row">
|
|
111
|
+
<span class="prism-bmp__side">{{ fmt(bm.margin.left) }}</span>
|
|
112
|
+
<div class="prism-bmp__region prism-bmp__region--border">
|
|
113
|
+
<span class="prism-bmp__region-label">border</span>
|
|
114
|
+
<div class="prism-bmp__inner-row">
|
|
115
|
+
<span class="prism-bmp__side prism-bmp__side--dim">{{ fmt(bm.border.left) }}</span>
|
|
116
|
+
<div class="prism-bmp__region prism-bmp__region--padding">
|
|
117
|
+
<span class="prism-bmp__region-label">padding</span>
|
|
118
|
+
<div class="prism-bmp__sides">
|
|
119
|
+
<span class="prism-bmp__side">{{ fmt(bm.padding.top) }}</span>
|
|
120
|
+
<div class="prism-bmp__inner-row">
|
|
121
|
+
<span class="prism-bmp__side">{{ fmt(bm.padding.left) }}</span>
|
|
122
|
+
<div class="prism-bmp__content-box">{{ contentW(bm) }} × {{ contentH(bm) }}</div>
|
|
123
|
+
<span class="prism-bmp__side">{{ fmt(bm.padding.right) }}</span>
|
|
124
|
+
</div>
|
|
125
|
+
<span class="prism-bmp__side">{{ fmt(bm.padding.bottom) }}</span>
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
<span class="prism-bmp__side prism-bmp__side--dim">{{ fmt(bm.border.right) }}</span>
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
<span class="prism-bmp__side">{{ fmt(bm.margin.right) }}</span>
|
|
132
|
+
</div>
|
|
133
|
+
<span class="prism-bmp__side">{{ fmt(bm.margin.bottom) }}</span>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
} @else {
|
|
138
|
+
<div class="prism-bmp__empty">Hover over an element to inspect its box model.</div>
|
|
139
|
+
}
|
|
140
|
+
</div>
|
|
141
|
+
`, styles: ["\n :host { display: block; height: 100%; overflow: auto; }\n .prism-bmp {\n padding: 16px;\n font-family: var(--prism-font-sans, system-ui);\n font-size: 12px;\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100%;\n }\n .prism-bmp__diagram { width: 100%; max-width: 340px; }\n .prism-bmp__region { padding: 6px; border-radius: 4px; position: relative; }\n .prism-bmp__region--margin { background: rgba(245, 158, 11, 0.15); border: 1px solid rgba(245, 158, 11, 0.4); }\n .prism-bmp__region--border { background: rgba(234, 179, 8, 0.2); border: 1px solid rgba(234, 179, 8, 0.5); flex: 1; }\n .prism-bmp__region--padding { background: rgba(16, 185, 129, 0.15); border: 1px solid rgba(16, 185, 129, 0.4); flex: 1; }\n .prism-bmp__region-label {\n position: absolute;\n top: 3px;\n left: 6px;\n font-size: 10px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n color: var(--prism-text-muted, #6b7280);\n opacity: 0.8;\n }\n .prism-bmp__sides { display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 14px; }\n .prism-bmp__inner-row { display: flex; align-items: center; gap: 2px; width: 100%; }\n .prism-bmp__inner-row > .prism-bmp__region { flex: 1; }\n .prism-bmp__side {\n font-family: monospace;\n font-size: 11px;\n color: var(--prism-text, #1f2937);\n min-width: 28px;\n text-align: center;\n padding: 1px 4px;\n }\n .prism-bmp__side--dim { color: var(--prism-text-muted, #6b7280); }\n .prism-bmp__content-box {\n flex: 1;\n text-align: center;\n font-family: monospace;\n font-size: 11px;\n color: var(--prism-text, #1f2937);\n background: rgba(59, 130, 246, 0.2);\n border: 1px solid rgba(59, 130, 246, 0.4);\n border-radius: 3px;\n padding: 6px 4px;\n }\n .prism-bmp__empty { color: var(--prism-text-muted, #6b7280); font-size: 13px; }\n "] }]
|
|
142
|
+
}], null, null); })();
|
|
143
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(BoxModelPanelComponent, { className: "BoxModelPanelComponent", filePath: "box-model-panel.component.ts", lineNumber: 102 }); })();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box-model-plugin.d.ts","sourceRoot":"","sources":["../src/box-model-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,wBAAgB,cAAc,IAAI,aAAa,CAe9C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function boxModelPlugin() {
|
|
2
|
+
return {
|
|
3
|
+
name: 'box-model',
|
|
4
|
+
panels: [
|
|
5
|
+
{
|
|
6
|
+
id: 'box-model',
|
|
7
|
+
label: 'Box Model',
|
|
8
|
+
loadComponent: () => import('./box-model-panel.component.js').then((m) => m.BoxModelPanelComponent),
|
|
9
|
+
loadOverlayComponent: () => import('./box-model-overlay.component.js').then((m) => m.BoxModelOverlayComponent),
|
|
10
|
+
position: 'bottom',
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BoxModelData } from './box-model.types.js';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class BoxModelStateService {
|
|
4
|
+
readonly hoveredBoxModel: import("@angular/core").WritableSignal<BoxModelData | null>;
|
|
5
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<BoxModelStateService, never>;
|
|
6
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<BoxModelStateService>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=box-model-state.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box-model-state.service.d.ts","sourceRoot":"","sources":["../src/box-model-state.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;;AAEzD,qBACa,oBAAoB;IAC/B,QAAQ,CAAC,eAAe,8DAAqC;yCADlD,oBAAoB;6CAApB,oBAAoB;CAEhC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Injectable, signal } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export class BoxModelStateService {
|
|
4
|
+
hoveredBoxModel = signal(null, ...(ngDevMode ? [{ debugName: "hoveredBoxModel" }] : []));
|
|
5
|
+
static ɵfac = function BoxModelStateService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || BoxModelStateService)(); };
|
|
6
|
+
static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: BoxModelStateService, factory: BoxModelStateService.ɵfac, providedIn: 'root' });
|
|
7
|
+
}
|
|
8
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BoxModelStateService, [{
|
|
9
|
+
type: Injectable,
|
|
10
|
+
args: [{ providedIn: 'root' }]
|
|
11
|
+
}], null, null); })();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box-model-utils.d.ts","sourceRoot":"","sources":["../src/box-model-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAY,MAAM,sBAAsB,CAAC;AAcnE,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,CAS1D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function parseSides(style, props) {
|
|
2
|
+
return {
|
|
3
|
+
top: parseFloat(style.getPropertyValue(props[0])) || 0,
|
|
4
|
+
right: parseFloat(style.getPropertyValue(props[1])) || 0,
|
|
5
|
+
bottom: parseFloat(style.getPropertyValue(props[2])) || 0,
|
|
6
|
+
left: parseFloat(style.getPropertyValue(props[3])) || 0,
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export function getBoxModel(element) {
|
|
10
|
+
const style = window.getComputedStyle(element);
|
|
11
|
+
return {
|
|
12
|
+
element,
|
|
13
|
+
content: element.getBoundingClientRect(),
|
|
14
|
+
padding: parseSides(style, ['padding-top', 'padding-right', 'padding-bottom', 'padding-left']),
|
|
15
|
+
border: parseSides(style, ['border-top-width', 'border-right-width', 'border-bottom-width', 'border-left-width']),
|
|
16
|
+
margin: parseSides(style, ['margin-top', 'margin-right', 'margin-bottom', 'margin-left']),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface BoxSides {
|
|
2
|
+
top: number;
|
|
3
|
+
right: number;
|
|
4
|
+
bottom: number;
|
|
5
|
+
left: number;
|
|
6
|
+
}
|
|
7
|
+
export interface BoxModelData {
|
|
8
|
+
element: Element;
|
|
9
|
+
content: DOMRect;
|
|
10
|
+
padding: BoxSides;
|
|
11
|
+
border: BoxSides;
|
|
12
|
+
margin: BoxSides;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=box-model.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box-model.types.d.ts","sourceRoot":"","sources":["../src/box-model.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,QAAQ,CAAC;IAClB,MAAM,EAAE,QAAQ,CAAC;IACjB,MAAM,EAAE,QAAQ,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { boxModelPlugin } from './box-model-plugin.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ng-prism/plugin-box-model",
|
|
3
|
+
"version": "21.0.0",
|
|
4
|
+
"description": "CSS box model inspector for ng-prism.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"@ng-prism/core",
|
|
7
|
+
"box-model",
|
|
8
|
+
"inspector",
|
|
9
|
+
"plugin",
|
|
10
|
+
"angular",
|
|
11
|
+
"styleguide"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"module": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
"./package.json": "./package.json",
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"!**/*.tsbuildinfo"
|
|
29
|
+
],
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@angular/core": ">=20.0.0",
|
|
32
|
+
"rxjs": ">=7.0.0",
|
|
33
|
+
"@ng-prism/core": ">=21.0.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@ng-prism/core": "*"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"tslib": "^2.3.0"
|
|
40
|
+
},
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "https://github.com/dyingangel666/ng-prism.git",
|
|
44
|
+
"directory": "packages/plugin-box-model"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://dyingangel666.github.io/ng-prism/",
|
|
47
|
+
"bugs": "https://github.com/dyingangel666/ng-prism/issues"
|
|
48
|
+
}
|