UNPKG

2.63 kBJavaScriptView Raw
1import { __decorate, __metadata, __param } from "tslib";
2import { inject, injectable, Syringe } from 'mana-syringe';
3import { PropertyName } from './types';
4export var LayoutEdgesFactory = Syringe.defineToken('LayoutEdgesFactory');
5export var LayoutEdgesOptions = Syringe.defineToken('LayoutEdgesOptions');
6var SCROLLBAR_SIZES = [0, 0, 0, 0];
7/**
8 * https://drafts.css-houdini.org/css-layout-api/#layoutedges
9 * the size of border, scrollbar, padding
10 */
11
12var LayoutEdges =
13/** @class */
14function () {
15 function LayoutEdges(options) {
16 var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
17
18 this.options = options;
19 var node = options.node;
20 var styleMap = node.getAllStyle();
21 var borderTopWidth = (_b = (_a = styleMap.get(PropertyName.PADDING_TOP)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0;
22 var borderRightWidth = (_d = (_c = styleMap.get(PropertyName.PADDING_END)) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : 0;
23 var borderBottomWidth = (_f = (_e = styleMap.get(PropertyName.PADDING_BOTTOM)) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : 0;
24 var borderLeftWidth = (_h = (_g = styleMap.get(PropertyName.PADDING_START)) === null || _g === void 0 ? void 0 : _g.value) !== null && _h !== void 0 ? _h : 0;
25 var paddingTopWidth = (_k = (_j = styleMap.get(PropertyName.PADDING_TOP)) === null || _j === void 0 ? void 0 : _j.value) !== null && _k !== void 0 ? _k : 0;
26 var paddingRightWidth = (_m = (_l = styleMap.get(PropertyName.PADDING_END)) === null || _l === void 0 ? void 0 : _l.value) !== null && _m !== void 0 ? _m : 0;
27 var paddingBottomWidth = (_p = (_o = styleMap.get(PropertyName.PADDING_BOTTOM)) === null || _o === void 0 ? void 0 : _o.value) !== null && _p !== void 0 ? _p : 0;
28 var paddingLeftWidth = (_r = (_q = styleMap.get(PropertyName.PADDING_START)) === null || _q === void 0 ? void 0 : _q.value) !== null && _r !== void 0 ? _r : 0;
29 this.blockStart = borderTopWidth + SCROLLBAR_SIZES[0] + paddingTopWidth;
30 this.inlineStart = borderRightWidth + SCROLLBAR_SIZES[1] + paddingRightWidth;
31 this.blockEnd = borderBottomWidth + SCROLLBAR_SIZES[2] + paddingBottomWidth;
32 this.inlineEnd = borderLeftWidth + SCROLLBAR_SIZES[3] + paddingLeftWidth;
33 this.block = this.blockStart + this.blockEnd;
34 this.inline = this.inlineStart + this.inlineEnd;
35 }
36
37 LayoutEdges = __decorate([injectable(), __param(0, inject(LayoutEdgesOptions)), __metadata("design:paramtypes", [Object])], LayoutEdges);
38 return LayoutEdges;
39}();
40
41export { LayoutEdges };
\No newline at end of file