feat: Reinitialize frontend with SvelteKit and TypeScript

- Delete old Vite+Svelte frontend
- Initialize new SvelteKit project with TypeScript
- Configure Tailwind CSS v4 + DaisyUI
- Implement JWT authentication with auto-refresh
- Create login page with form validation (Zod)
- Add protected route guards
- Update Docker configuration for single-stage build
- Add E2E tests with Playwright (6/11 passing)
- Fix Svelte 5 reactivity with $state() runes

Known issues:
- 5 E2E tests failing (timing/async issues)
- Token refresh implementation needs debugging
- Validation error display timing
This commit is contained in:
2026-02-17 16:19:59 -05:00
parent 54df6018f5
commit de2d83092e
28274 changed files with 3816354 additions and 90 deletions

View File

@@ -0,0 +1,575 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const CSSStyleDeclarationValueParser_js_1 = __importDefault(require("./CSSStyleDeclarationValueParser.cjs"));
/**
* Computed style property parser.
*/
class CSSStyleDeclarationPropertyGetParser {
/**
* Returns margin.
*
* @param properties Properties.
* @returns Property value
*/
static getMargin(properties) {
return this.getPaddingLikeProperty(['margin-top', 'margin-right', 'margin-bottom', 'margin-left'], properties);
}
/**
* Returns padding.
*
* @param properties Properties.
* @returns Property value
*/
static getPadding(properties) {
return this.getPaddingLikeProperty(['padding-top', 'padding-right', 'padding-bottom', 'padding-left'], properties);
}
/**
* Returns outline.
*
* @param properties Properties.
* @returns Property value
*/
static getOutline(properties) {
if (!properties['outline-color']?.value ||
!properties['outline-style']?.value ||
!properties['outline-width']?.value) {
return null;
}
const important = properties['outline-color'].important &&
properties['outline-style'].important &&
properties['outline-width'].important;
if (CSSStyleDeclarationValueParser_js_1.default.getGlobalExceptInitial(properties['outline-width'].value) &&
properties['outline-width'].value === properties['outline-style'].value &&
properties['outline-width'].value === properties['outline-color'].value) {
return {
important,
value: properties['outline-width'].value
};
}
const values = [];
if (!CSSStyleDeclarationValueParser_js_1.default.getInitial(properties['outline-color']?.value)) {
values.push(properties['outline-color'].value);
}
if (!CSSStyleDeclarationValueParser_js_1.default.getInitial(properties['outline-style']?.value)) {
values.push(properties['outline-style'].value);
}
if (!CSSStyleDeclarationValueParser_js_1.default.getInitial(properties['outline-width'].value)) {
values.push(properties['outline-width'].value);
}
return {
important,
value: values.join(' ')
};
}
/**
* Returns border.
*
* @param properties Properties.
* @returns Property value
*/
static getBorder(properties) {
if (!properties['border-top-width']?.value ||
properties['border-top-width']?.value !== properties['border-right-width']?.value ||
properties['border-top-width']?.value !== properties['border-bottom-width']?.value ||
properties['border-top-width']?.value !== properties['border-left-width']?.value ||
!properties['border-top-style']?.value ||
properties['border-top-style']?.value !== properties['border-right-style']?.value ||
properties['border-top-style']?.value !== properties['border-bottom-style']?.value ||
properties['border-top-style']?.value !== properties['border-left-style']?.value ||
!properties['border-top-color']?.value ||
properties['border-top-color']?.value !== properties['border-right-color']?.value ||
properties['border-top-color']?.value !== properties['border-bottom-color']?.value ||
properties['border-top-color']?.value !== properties['border-left-color']?.value ||
!properties['border-image-source']?.value ||
!properties['border-image-slice']?.value ||
!properties['border-image-width']?.value ||
!properties['border-image-outset']?.value ||
!properties['border-image-repeat']?.value) {
return null;
}
const important = properties['border-top-width'].important &&
properties['border-right-width'].important &&
properties['border-bottom-width'].important &&
properties['border-left-width'].important &&
properties['border-top-style'].important &&
properties['border-right-style'].important &&
properties['border-bottom-style'].important &&
properties['border-left-style'].important &&
properties['border-top-color'].important &&
properties['border-right-color'].important &&
properties['border-bottom-color'].important &&
properties['border-left-color'].important &&
properties['border-image-source'].important &&
properties['border-image-slice'].important &&
properties['border-image-width'].important &&
properties['border-image-outset'].important &&
properties['border-image-repeat'].important;
if (CSSStyleDeclarationValueParser_js_1.default.getGlobalExceptInitial(properties['border-top-width'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobalExceptInitial(properties['border-top-style'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobalExceptInitial(properties['border-top-color'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobalExceptInitial(properties['border-image-source'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobalExceptInitial(properties['border-image-slice'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobalExceptInitial(properties['border-image-width'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobalExceptInitial(properties['border-image-outset'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobalExceptInitial(properties['border-image-repeat'].value)) {
if (properties['border-top-width'].value !== properties['border-top-style'].value ||
properties['border-top-width'].value !== properties['border-top-color'].value ||
properties['border-top-width'].value !== properties['border-image-source'].value ||
properties['border-top-width'].value !== properties['border-image-slice'].value ||
properties['border-top-width'].value !== properties['border-image-width'].value ||
properties['border-top-width'].value !== properties['border-image-outset'].value ||
properties['border-top-width'].value !== properties['border-image-repeat'].value) {
return null;
}
return {
important,
value: properties['border-top-width'].value
};
}
const values = [];
if (!CSSStyleDeclarationValueParser_js_1.default.getInitial(properties['border-top-width'].value)) {
values.push(properties['border-top-width'].value);
}
if (!CSSStyleDeclarationValueParser_js_1.default.getInitial(properties['border-top-style'].value)) {
values.push(properties['border-top-style'].value);
}
if (!CSSStyleDeclarationValueParser_js_1.default.getInitial(properties['border-top-color'].value)) {
values.push(properties['border-top-color'].value);
}
return {
important,
value: values.join(' ')
};
}
/**
* Returns border.
*
* @param properties Properties.
* @returns Property value
*/
static getBorderTop(properties) {
return this.getBorderTopRightBottomLeft('top', properties);
}
/**
* Returns border.
*
* @param properties Properties.
* @returns Property value
*/
static getBorderRight(properties) {
return this.getBorderTopRightBottomLeft('right', properties);
}
/**
* Returns border.
*
* @param properties Properties.
* @returns Property value
*/
static getBorderBottom(properties) {
return this.getBorderTopRightBottomLeft('bottom', properties);
}
/**
* Returns border.
*
* @param properties Properties.
* @returns Property value
*/
static getBorderLeft(properties) {
return this.getBorderTopRightBottomLeft('left', properties);
}
/**
* Returns border.
*
* @param properties Properties.
* @returns Property value
*/
static getBorderColor(properties) {
return this.getPaddingLikeProperty(['border-top-color', 'border-right-color', 'border-bottom-color', 'border-left-color'], properties);
}
/**
* Returns border.
*
* @param properties Properties.
* @returns Property value
*/
static getBorderWidth(properties) {
return this.getPaddingLikeProperty(['border-top-width', 'border-right-width', 'border-bottom-width', 'border-left-width'], properties);
}
/**
* Returns border.
*
* @param properties Properties.
* @returns Property value
*/
static getBorderStyle(properties) {
return this.getPaddingLikeProperty(['border-top-style', 'border-right-style', 'border-bottom-style', 'border-left-style'], properties);
}
/**
* Returns border radius.
*
* @param properties Properties.
* @returns Property value
*/
static getBorderRadius(properties) {
return this.getPaddingLikeProperty([
'border-top-left-radius',
'border-top-right-radius',
'border-bottom-right-radius',
'border-bottom-left-radius'
], properties);
}
/**
* Returns border image.
*
* @param properties Properties.
* @returns Property value
*/
static getBorderImage(properties) {
if (!properties['border-image-source']?.value ||
!properties['border-image-slice']?.value ||
!properties['border-image-width']?.value ||
!properties['border-image-outset']?.value ||
!properties['border-image-repeat']?.value) {
return null;
}
const important = properties['border-image-source'].important &&
properties['border-image-slice'].important &&
properties['border-image-width'].important &&
properties['border-image-outset'].important &&
properties['border-image-repeat'].important;
if (CSSStyleDeclarationValueParser_js_1.default.getGlobal(properties['border-image-source'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobal(properties['border-image-slice'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobal(properties['border-image-width'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobal(properties['border-image-outset'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobal(properties['border-image-repeat'].value)) {
if (properties['border-image-source'].value !== properties['border-image-slice'].value ||
properties['border-image-source'].value !== properties['border-image-width'].value ||
properties['border-image-source'].value !== properties['border-image-outset'].value ||
properties['border-image-source'].value !== properties['border-image-repeat'].value) {
return null;
}
return {
important,
value: properties['border-image-source'].value
};
}
return {
important,
value: `${properties['border-image-source'].value} ${properties['border-image-slice'].value} / ${properties['border-image-width'].value} / ${properties['border-image-outset'].value} ${properties['border-image-repeat'].value}`
};
}
/**
* Returns background.
*
* @param properties Properties.
* @returns Property value
*/
static getBackground(properties) {
if (!properties['background-image']?.value ||
!properties['background-repeat']?.value ||
!properties['background-attachment']?.value ||
!properties['background-position-x']?.value ||
!properties['background-position-y']?.value ||
!properties['background-color']?.value ||
!properties['background-size']?.value ||
!properties['background-origin']?.value ||
!properties['background-clip']?.value) {
return null;
}
const important = properties['background-image'].important &&
properties['background-repeat'].important &&
properties['background-attachment'].important &&
properties['background-position-x'].important &&
properties['background-position-y'].important &&
properties['background-color'].important &&
properties['background-size'].important &&
properties['background-origin'].important &&
properties['background-clip'].important;
if (CSSStyleDeclarationValueParser_js_1.default.getGlobalExceptInitial(properties['background-image'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobalExceptInitial(properties['background-repeat'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobalExceptInitial(properties['background-attachment'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobalExceptInitial(properties['background-position-x'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobalExceptInitial(properties['background-position-y'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobalExceptInitial(properties['background-color'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobalExceptInitial(properties['background-size'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobalExceptInitial(properties['background-origin'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobalExceptInitial(properties['background-clip'].value)) {
if (properties['background-image'].value !== properties['background-repeat'].value ||
properties['background-image'].value !== properties['background-attachment'].value ||
properties['background-image'].value !== properties['background-position-x'].value ||
properties['background-image'].value !== properties['background-position-y'].value ||
properties['background-image'].value !== properties['background-color'].value ||
properties['background-image'].value !== properties['background-size'].value ||
properties['background-image'].value !== properties['background-origin'].value ||
properties['background-image'].value !== properties['background-clip'].value) {
return null;
}
return {
important,
value: properties['background-image'].value
};
}
const values = [];
if (!CSSStyleDeclarationValueParser_js_1.default.getInitial(properties['background-image'].value)) {
values.push(properties['background-image'].value);
}
if (!CSSStyleDeclarationValueParser_js_1.default.getInitial(properties['background-position-x'].value) &&
!CSSStyleDeclarationValueParser_js_1.default.getInitial(properties['background-position-y'].value) &&
!CSSStyleDeclarationValueParser_js_1.default.getInitial(properties['background-size'].value)) {
values.push(`${properties['background-position-x'].value} ${properties['background-position-y'].value} / ${properties['background-size'].value}`);
}
else if (!CSSStyleDeclarationValueParser_js_1.default.getInitial(properties['background-position-x'].value) &&
!CSSStyleDeclarationValueParser_js_1.default.getInitial(properties['background-position-y'].value)) {
values.push(`${properties['background-position-x'].value} ${properties['background-position-y'].value}`);
}
if (!CSSStyleDeclarationValueParser_js_1.default.getInitial(properties['background-repeat'].value)) {
values.push(properties['background-repeat'].value);
}
if (!CSSStyleDeclarationValueParser_js_1.default.getInitial(properties['background-attachment'].value)) {
values.push(properties['background-attachment'].value);
}
if (!CSSStyleDeclarationValueParser_js_1.default.getInitial(properties['background-origin'].value)) {
values.push(properties['background-origin'].value);
}
if (!CSSStyleDeclarationValueParser_js_1.default.getInitial(properties['background-clip'].value)) {
values.push(properties['background-clip'].value);
}
if (!CSSStyleDeclarationValueParser_js_1.default.getInitial(properties['background-color'].value)) {
values.push(properties['background-color'].value);
}
return {
important,
value: values.join(' ')
};
}
/**
* Returns background position.
*
* @param properties Properties.
* @returns Property value
*/
static getBackgroundPosition(properties) {
if (!properties['background-position-x']?.value ||
!properties['background-position-y']?.value) {
return null;
}
const important = properties['background-position-x'].important &&
properties['background-position-y'].important;
if (CSSStyleDeclarationValueParser_js_1.default.getGlobal(properties['background-position-x'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobal(properties['background-position-y'].value)) {
if (properties['background-position-x'].value !== properties['background-position-y'].value) {
return null;
}
return {
important,
value: properties['background-position-x'].value
};
}
const positionX = properties['background-position-x'].value.replace(/ *, */g, ',').split(',');
const positionY = properties['background-position-y'].value.replace(/ *, */g, ',').split(',');
const parts = [];
for (let i = 0; i < positionX.length; i++) {
parts.push(`${positionX[i]} ${positionY[i]}`);
}
return {
important,
value: parts.join(', ')
};
}
/**
* Returns flex.
*
* @param properties Properties.
* @returns Property value
*/
static getFlex(properties) {
if (!properties['flex-grow']?.value ||
!properties['flex-shrink']?.value ||
!properties['flex-basis']?.value) {
return null;
}
const important = properties['flex-grow'].important &&
properties['flex-shrink'].important &&
properties['flex-basis'].important;
if (CSSStyleDeclarationValueParser_js_1.default.getGlobal(properties['flex-grow'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobal(properties['flex-shrink'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobal(properties['flex-basis'].value)) {
if (properties['flex-grow'].value !== properties['flex-shrink'].value ||
properties['flex-grow'].value !== properties['flex-basis'].value) {
return null;
}
return {
important,
value: properties['flex-grow'].value
};
}
return {
important,
value: `${properties['flex-grow'].value} ${properties['flex-shrink'].value} ${properties['flex-basis'].value}`
};
}
/**
* Returns flex.
*
* @param properties Properties.
* @returns Property value
*/
static getFont(properties) {
if (!properties['font-size']?.value ||
!properties['font-family']?.value ||
!properties['font-weight']?.value ||
!properties['font-style']?.value ||
!properties['font-variant']?.value ||
!properties['font-stretch']?.value ||
!properties['line-height']?.value) {
return null;
}
const important = properties['font-size'].important &&
properties['font-family'].important &&
properties['font-weight'].important &&
properties['font-style'].important &&
properties['font-variant'].important &&
properties['font-stretch'].important &&
properties['line-height'].important;
if (CSSStyleDeclarationValueParser_js_1.default.getGlobal(properties['font-size'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobal(properties['font-family'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobal(properties['font-weight'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobal(properties['font-style'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobal(properties['font-variant'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobal(properties['font-stretch'].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobal(properties['line-height'].value)) {
if (properties['font-size'].value !== properties['font-family'].value ||
properties['font-size'].value !== properties['font-weight'].value ||
properties['font-size'].value !== properties['font-style'].value ||
properties['font-size'].value !== properties['font-variant'].value ||
properties['font-size'].value !== properties['font-stretch'].value ||
properties['font-size'].value !== properties['line-height'].value) {
return null;
}
return {
important,
value: properties['font-size'].value
};
}
const values = [];
if (properties['font-style'].value !== 'normal') {
values.push(properties['font-style'].value);
}
if (properties['font-variant'].value !== 'normal') {
values.push(properties['font-variant'].value);
}
if (properties['font-weight'].value !== 'normal') {
values.push(properties['font-weight'].value);
}
if (properties['font-stretch'].value !== 'normal') {
values.push(properties['font-stretch'].value);
}
if (properties['line-height'].value !== 'normal') {
values.push(`${properties['font-size'].value} / ${properties['line-height'].value}`);
}
else {
values.push(properties['font-size'].value);
}
values.push(properties['font-family'].value);
return {
important,
value: values.join(' ')
};
}
/**
* Returns border.
*
* @param properties Properties.
* @param position
* @returns Property value
*/
static getBorderTopRightBottomLeft(position, properties) {
if (!properties[`border-${position}-width`]?.value ||
!properties[`border-${position}-style`]?.value ||
!properties[`border-${position}-color`]?.value) {
return null;
}
const important = properties[`border-${position}-width`].important &&
properties[`border-${position}-style`].important &&
properties[`border-${position}-color`].important;
if (CSSStyleDeclarationValueParser_js_1.default.getGlobalExceptInitial(properties[`border-${position}-width`].value) &&
properties[`border-${position}-width`].value ===
properties[`border-${position}-style`].value &&
properties[`border-${position}-width`].value === properties[`border-${position}-color`].value) {
return {
important,
value: properties[`border-${position}-width`].value
};
}
const values = [];
if (!CSSStyleDeclarationValueParser_js_1.default.getInitial(properties[`border-${position}-width`].value)) {
values.push(properties[`border-${position}-width`].value);
}
if (!CSSStyleDeclarationValueParser_js_1.default.getInitial(properties[`border-${position}-style`]?.value)) {
values.push(properties[`border-${position}-style`].value);
}
if (!CSSStyleDeclarationValueParser_js_1.default.getInitial(properties[`border-${position}-color`]?.value)) {
values.push(properties[`border-${position}-color`].value);
}
return {
important,
value: values.join(' ')
};
}
/**
* Returns a padding like property.
*
* @param properties Properties.
* @param position
* @param propertyNames
* @returns Property value
*/
static getPaddingLikeProperty(propertyNames, properties) {
if (!properties[propertyNames[0]]?.value ||
!properties[propertyNames[1]]?.value ||
!properties[propertyNames[2]]?.value ||
!properties[propertyNames[3]]?.value) {
return null;
}
const important = properties[propertyNames[0]].important &&
properties[propertyNames[1]].important &&
properties[propertyNames[2]].important &&
properties[propertyNames[3]].important;
if (CSSStyleDeclarationValueParser_js_1.default.getGlobal(properties[propertyNames[0]].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobal(properties[propertyNames[1]].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobal(properties[propertyNames[2]].value) ||
CSSStyleDeclarationValueParser_js_1.default.getGlobal(properties[propertyNames[3]].value)) {
if (properties[propertyNames[0]].value !== properties[propertyNames[1]].value ||
properties[propertyNames[0]].value !== properties[propertyNames[2]].value ||
properties[propertyNames[0]].value !== properties[propertyNames[3]].value) {
return null;
}
return {
important,
value: properties[propertyNames[0]].value
};
}
const values = [properties[propertyNames[0]].value];
if (properties[propertyNames[1]].value !== properties[propertyNames[0]].value ||
properties[propertyNames[2]].value !== properties[propertyNames[0]].value ||
properties[propertyNames[3]].value !== properties[propertyNames[1]].value) {
values.push(properties[propertyNames[1]].value);
}
if (properties[propertyNames[2]].value !== properties[propertyNames[0]].value ||
properties[propertyNames[3]].value !== properties[propertyNames[1]].value) {
values.push(properties[propertyNames[2]].value);
}
if (properties[propertyNames[3]].value !== properties[propertyNames[1]].value) {
values.push(properties[propertyNames[3]].value);
}
return {
important,
value: values.join(' ')
};
}
}
exports.default = CSSStyleDeclarationPropertyGetParser;
//# sourceMappingURL=CSSStyleDeclarationPropertyGetParser.cjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,177 @@
import ICSSStyleDeclarationPropertyValue from './ICSSStyleDeclarationPropertyValue.cjs';
/**
* Computed style property parser.
*/
export default class CSSStyleDeclarationPropertyGetParser {
/**
* Returns margin.
*
* @param properties Properties.
* @returns Property value
*/
static getMargin(properties: {
[k: string]: ICSSStyleDeclarationPropertyValue;
}): ICSSStyleDeclarationPropertyValue | null;
/**
* Returns padding.
*
* @param properties Properties.
* @returns Property value
*/
static getPadding(properties: {
[k: string]: ICSSStyleDeclarationPropertyValue;
}): ICSSStyleDeclarationPropertyValue | null;
/**
* Returns outline.
*
* @param properties Properties.
* @returns Property value
*/
static getOutline(properties: {
[k: string]: ICSSStyleDeclarationPropertyValue;
}): ICSSStyleDeclarationPropertyValue | null;
/**
* Returns border.
*
* @param properties Properties.
* @returns Property value
*/
static getBorder(properties: {
[k: string]: ICSSStyleDeclarationPropertyValue;
}): ICSSStyleDeclarationPropertyValue | null;
/**
* Returns border.
*
* @param properties Properties.
* @returns Property value
*/
static getBorderTop(properties: {
[k: string]: ICSSStyleDeclarationPropertyValue;
}): ICSSStyleDeclarationPropertyValue | null;
/**
* Returns border.
*
* @param properties Properties.
* @returns Property value
*/
static getBorderRight(properties: {
[k: string]: ICSSStyleDeclarationPropertyValue;
}): ICSSStyleDeclarationPropertyValue | null;
/**
* Returns border.
*
* @param properties Properties.
* @returns Property value
*/
static getBorderBottom(properties: {
[k: string]: ICSSStyleDeclarationPropertyValue;
}): ICSSStyleDeclarationPropertyValue | null;
/**
* Returns border.
*
* @param properties Properties.
* @returns Property value
*/
static getBorderLeft(properties: {
[k: string]: ICSSStyleDeclarationPropertyValue;
}): ICSSStyleDeclarationPropertyValue | null;
/**
* Returns border.
*
* @param properties Properties.
* @returns Property value
*/
static getBorderColor(properties: {
[k: string]: ICSSStyleDeclarationPropertyValue;
}): ICSSStyleDeclarationPropertyValue | null;
/**
* Returns border.
*
* @param properties Properties.
* @returns Property value
*/
static getBorderWidth(properties: {
[k: string]: ICSSStyleDeclarationPropertyValue;
}): ICSSStyleDeclarationPropertyValue | null;
/**
* Returns border.
*
* @param properties Properties.
* @returns Property value
*/
static getBorderStyle(properties: {
[k: string]: ICSSStyleDeclarationPropertyValue;
}): ICSSStyleDeclarationPropertyValue | null;
/**
* Returns border radius.
*
* @param properties Properties.
* @returns Property value
*/
static getBorderRadius(properties: {
[k: string]: ICSSStyleDeclarationPropertyValue;
}): ICSSStyleDeclarationPropertyValue | null;
/**
* Returns border image.
*
* @param properties Properties.
* @returns Property value
*/
static getBorderImage(properties: {
[k: string]: ICSSStyleDeclarationPropertyValue;
}): ICSSStyleDeclarationPropertyValue | null;
/**
* Returns background.
*
* @param properties Properties.
* @returns Property value
*/
static getBackground(properties: {
[k: string]: ICSSStyleDeclarationPropertyValue;
}): ICSSStyleDeclarationPropertyValue | null;
/**
* Returns background position.
*
* @param properties Properties.
* @returns Property value
*/
static getBackgroundPosition(properties: {
[k: string]: ICSSStyleDeclarationPropertyValue;
}): ICSSStyleDeclarationPropertyValue | null;
/**
* Returns flex.
*
* @param properties Properties.
* @returns Property value
*/
static getFlex(properties: {
[k: string]: ICSSStyleDeclarationPropertyValue;
}): ICSSStyleDeclarationPropertyValue | null;
/**
* Returns flex.
*
* @param properties Properties.
* @returns Property value
*/
static getFont(properties: {
[k: string]: ICSSStyleDeclarationPropertyValue;
}): ICSSStyleDeclarationPropertyValue | null;
/**
* Returns border.
*
* @param properties Properties.
* @param position
* @returns Property value
*/
private static getBorderTopRightBottomLeft;
/**
* Returns a padding like property.
*
* @param properties Properties.
* @param position
* @param propertyNames
* @returns Property value
*/
private static getPaddingLikeProperty;
}
//# sourceMappingURL=CSSStyleDeclarationPropertyGetParser.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CSSStyleDeclarationPropertyGetParser.d.ts","sourceRoot":"","sources":["../../../../src/css/declaration/property-manager/CSSStyleDeclarationPropertyGetParser.ts"],"names":[],"mappings":"AACA,OAAO,iCAAiC,MAAM,wCAAwC,CAAC;AAEvF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,oCAAoC;IACxD;;;;;OAKG;WACW,SAAS,CAAC,UAAU,EAAE;QACnC,CAAC,CAAC,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAC/C,GAAG,iCAAiC,GAAG,IAAI;IAO5C;;;;;OAKG;WACW,UAAU,CAAC,UAAU,EAAE;QACpC,CAAC,CAAC,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAC/C,GAAG,iCAAiC,GAAG,IAAI;IAO5C;;;;;OAKG;WACW,UAAU,CAAC,UAAU,EAAE;QACpC,CAAC,CAAC,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAC/C,GAAG,iCAAiC,GAAG,IAAI;IA2C5C;;;;;OAKG;WACW,SAAS,CAAC,UAAU,EAAE;QACnC,CAAC,CAAC,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAC/C,GAAG,iCAAiC,GAAG,IAAI;IAkG5C;;;;;OAKG;WACW,YAAY,CAAC,UAAU,EAAE;QACtC,CAAC,CAAC,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAC/C,GAAG,iCAAiC,GAAG,IAAI;IAI5C;;;;;OAKG;WACW,cAAc,CAAC,UAAU,EAAE;QACxC,CAAC,CAAC,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAC/C,GAAG,iCAAiC,GAAG,IAAI;IAI5C;;;;;OAKG;WACW,eAAe,CAAC,UAAU,EAAE;QACzC,CAAC,CAAC,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAC/C,GAAG,iCAAiC,GAAG,IAAI;IAI5C;;;;;OAKG;WACW,aAAa,CAAC,UAAU,EAAE;QACvC,CAAC,CAAC,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAC/C,GAAG,iCAAiC,GAAG,IAAI;IAI5C;;;;;OAKG;WACW,cAAc,CAAC,UAAU,EAAE;QACxC,CAAC,CAAC,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAC/C,GAAG,iCAAiC,GAAG,IAAI;IAO5C;;;;;OAKG;WACW,cAAc,CAAC,UAAU,EAAE;QACxC,CAAC,CAAC,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAC/C,GAAG,iCAAiC,GAAG,IAAI;IAO5C;;;;;OAKG;WACW,cAAc,CAAC,UAAU,EAAE;QACxC,CAAC,CAAC,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAC/C,GAAG,iCAAiC,GAAG,IAAI;IAO5C;;;;;OAKG;WACW,eAAe,CAAC,UAAU,EAAE;QACzC,CAAC,CAAC,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAC/C,GAAG,iCAAiC,GAAG,IAAI;IAY5C;;;;;OAKG;WACW,cAAc,CAAC,UAAU,EAAE;QACxC,CAAC,CAAC,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAC/C,GAAG,iCAAiC,GAAG,IAAI;IA6C5C;;;;;OAKG;WACW,aAAa,CAAC,UAAU,EAAE;QACvC,CAAC,CAAC,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAC/C,GAAG,iCAAiC,GAAG,IAAI;IAmH5C;;;;;OAKG;WACW,qBAAqB,CAAC,UAAU,EAAE;QAC/C,CAAC,CAAC,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAC/C,GAAG,iCAAiC,GAAG,IAAI;IAuC5C;;;;;OAKG;WACW,OAAO,CAAC,UAAU,EAAE;QACjC,CAAC,CAAC,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAC/C,GAAG,iCAAiC,GAAG,IAAI;IAsC5C;;;;;OAKG;WACW,OAAO,CAAC,UAAU,EAAE;QACjC,CAAC,CAAC,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAC/C,GAAG,iCAAiC,GAAG,IAAI;IA6E5C;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,2BAA2B;IAmD1C;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;CAkErC"}

View File

@@ -0,0 +1,600 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const CSSStyleDeclarationPropertySetParser_js_1 = __importDefault(require("./CSSStyleDeclarationPropertySetParser.cjs"));
const CSSStyleDeclarationValueParser_js_1 = __importDefault(require("./CSSStyleDeclarationValueParser.cjs"));
const CSSStyleDeclarationPropertyGetParser_js_1 = __importDefault(require("./CSSStyleDeclarationPropertyGetParser.cjs"));
const CSSStyleDeclarationCSSParser_js_1 = __importDefault(require("../css-parser/CSSStyleDeclarationCSSParser.cjs"));
const TO_STRING_SHORTHAND_PROPERTIES = [
['margin'],
['padding'],
['border', ['border-width', 'border-style', 'border-color', 'border-image']],
['border-radius'],
['background', 'background-position'],
['font']
];
/**
* Computed this.properties property parser.
*/
class CSSStyleDeclarationPropertyManager {
properties = {};
definedPropertyNames = {};
/**
* Class construtor.
*
* @param [options] Options.
* @param [options.cssText] CSS string.
*/
constructor(options) {
if (options?.cssText) {
const { rules } = CSSStyleDeclarationCSSParser_js_1.default.parse(options.cssText);
for (const rule of rules) {
if (rule.important || !this.get(rule.name)?.important) {
this.set(rule.name, rule.value, rule.important);
}
}
}
}
/**
* Returns property value.
*
* @param name Property name.
* @returns Property value.
*/
get(name) {
if (this.properties[name]) {
return this.properties[name];
}
switch (name) {
case 'margin':
return CSSStyleDeclarationPropertyGetParser_js_1.default.getMargin(this.properties);
case 'padding':
return CSSStyleDeclarationPropertyGetParser_js_1.default.getPadding(this.properties);
case 'border':
return CSSStyleDeclarationPropertyGetParser_js_1.default.getBorder(this.properties);
case 'border-top':
return CSSStyleDeclarationPropertyGetParser_js_1.default.getBorderTop(this.properties);
case 'border-right':
return CSSStyleDeclarationPropertyGetParser_js_1.default.getBorderRight(this.properties);
case 'border-bottom':
return CSSStyleDeclarationPropertyGetParser_js_1.default.getBorderBottom(this.properties);
case 'border-left':
return CSSStyleDeclarationPropertyGetParser_js_1.default.getBorderLeft(this.properties);
case 'border-color':
return CSSStyleDeclarationPropertyGetParser_js_1.default.getBorderColor(this.properties);
case 'border-style':
return CSSStyleDeclarationPropertyGetParser_js_1.default.getBorderStyle(this.properties);
case 'border-width':
return CSSStyleDeclarationPropertyGetParser_js_1.default.getBorderWidth(this.properties);
case 'border-radius':
return CSSStyleDeclarationPropertyGetParser_js_1.default.getBorderRadius(this.properties);
case 'border-image':
return CSSStyleDeclarationPropertyGetParser_js_1.default.getBorderImage(this.properties);
case 'outline':
return CSSStyleDeclarationPropertyGetParser_js_1.default.getOutline(this.properties);
case 'background':
return CSSStyleDeclarationPropertyGetParser_js_1.default.getBackground(this.properties);
case 'background-position':
return CSSStyleDeclarationPropertyGetParser_js_1.default.getBackgroundPosition(this.properties);
case 'flex':
return CSSStyleDeclarationPropertyGetParser_js_1.default.getFlex(this.properties);
case 'font':
return CSSStyleDeclarationPropertyGetParser_js_1.default.getFont(this.properties);
}
return this.properties[name] || null;
}
/**
* Removes a property.
*
* @param name Property name.
*/
remove(name) {
delete this.properties[name];
delete this.definedPropertyNames[name];
switch (name) {
case 'border':
delete this.properties['border-top-width'];
delete this.properties['border-right-width'];
delete this.properties['border-bottom-width'];
delete this.properties['border-left-width'];
delete this.properties['border-top-style'];
delete this.properties['border-right-style'];
delete this.properties['border-bottom-style'];
delete this.properties['border-left-style'];
delete this.properties['border-top-color'];
delete this.properties['border-right-color'];
delete this.properties['border-bottom-color'];
delete this.properties['border-left-color'];
delete this.properties['border-image-source'];
delete this.properties['border-image-slice'];
delete this.properties['border-image-width'];
delete this.properties['border-image-outset'];
delete this.properties['border-image-repeat'];
break;
case 'border-top':
delete this.properties['border-top-width'];
delete this.properties['border-top-style'];
delete this.properties['border-top-color'];
delete this.properties['border-image-source'];
delete this.properties['border-image-slice'];
delete this.properties['border-image-width'];
delete this.properties['border-image-outset'];
delete this.properties['border-image-repeat'];
break;
case 'border-right':
delete this.properties['border-right-width'];
delete this.properties['border-right-style'];
delete this.properties['border-right-color'];
delete this.properties['border-image-source'];
delete this.properties['border-image-slice'];
delete this.properties['border-image-width'];
delete this.properties['border-image-outset'];
delete this.properties['border-image-repeat'];
break;
case 'border-bottom':
delete this.properties['border-bottom-width'];
delete this.properties['border-bottom-style'];
delete this.properties['border-bottom-color'];
delete this.properties['border-image-source'];
delete this.properties['border-image-slice'];
delete this.properties['border-image-width'];
delete this.properties['border-image-outset'];
delete this.properties['border-image-repeat'];
break;
case 'border-left':
delete this.properties['border-left-width'];
delete this.properties['border-left-style'];
delete this.properties['border-left-color'];
delete this.properties['border-image-source'];
delete this.properties['border-image-slice'];
delete this.properties['border-image-width'];
delete this.properties['border-image-outset'];
delete this.properties['border-image-repeat'];
break;
case 'border-width':
delete this.properties['border-top-width'];
delete this.properties['border-right-width'];
delete this.properties['border-bottom-width'];
delete this.properties['border-left-width'];
break;
case 'border-style':
delete this.properties['border-top-style'];
delete this.properties['border-right-style'];
delete this.properties['border-bottom-style'];
delete this.properties['border-left-style'];
break;
case 'border-color':
delete this.properties['border-top-color'];
delete this.properties['border-right-color'];
delete this.properties['border-bottom-color'];
delete this.properties['border-left-color'];
break;
case 'border-image':
delete this.properties['border-image-source'];
delete this.properties['border-image-slice'];
delete this.properties['border-image-width'];
delete this.properties['border-image-outset'];
delete this.properties['border-image-repeat'];
break;
case 'border-radius':
delete this.properties['border-top-left-radius'];
delete this.properties['border-top-right-radius'];
delete this.properties['border-bottom-right-radius'];
delete this.properties['border-bottom-left-radius'];
break;
case 'outline':
delete this.properties['outline-color'];
delete this.properties['outline-style'];
delete this.properties['outline-width'];
break;
case 'background':
delete this.properties['background-color'];
delete this.properties['background-image'];
delete this.properties['background-repeat'];
delete this.properties['background-attachment'];
delete this.properties['background-position-x'];
delete this.properties['background-position-y'];
delete this.properties['background-size'];
delete this.properties['background-origin'];
delete this.properties['background-clip'];
break;
case 'background-position':
delete this.properties['background-position-x'];
delete this.properties['background-position-y'];
break;
case 'flex':
delete this.properties['flex-grow'];
delete this.properties['flex-shrink'];
delete this.properties['flex-basis'];
break;
case 'font':
delete this.properties['font-style'];
delete this.properties['font-variant'];
delete this.properties['font-weight'];
delete this.properties['font-stretch'];
delete this.properties['font-size'];
delete this.properties['line-height'];
delete this.properties['font-family'];
break;
case 'padding':
delete this.properties['padding-top'];
delete this.properties['padding-right'];
delete this.properties['padding-bottom'];
delete this.properties['padding-left'];
break;
case 'margin':
delete this.properties['margin-top'];
delete this.properties['margin-right'];
delete this.properties['margin-bottom'];
delete this.properties['margin-left'];
break;
}
}
/**
* Sets a property
*
* @param name Name.
* @param value Value.
* @param important Important.
*/
set(name, value, important) {
if (value === null) {
this.remove(name);
return;
}
let properties = null;
switch (name) {
case 'border':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorder(value, important);
break;
case 'border-top':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderTop(value, important);
break;
case 'border-right':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderRight(value, important);
break;
case 'border-bottom':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderBottom(value, important);
break;
case 'border-left':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderLeft(value, important);
break;
case 'border-width':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderWidth(value, important);
break;
case 'border-style':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderStyle(value, important);
break;
case 'border-color':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderColor(value, important);
break;
case 'border-image':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderImage(value, important);
break;
case 'border-image-source':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderImageSource(value, important);
break;
case 'border-image-slice':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderImageSlice(value, important);
break;
case 'border-image-width':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderImageWidth(value, important);
break;
case 'border-image-outset':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderImageOutset(value, important);
break;
case 'border-image-repeat':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderImageRepeat(value, important);
break;
case 'border-top-width':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderTopWidth(value, important);
break;
case 'border-right-width':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderRightWidth(value, important);
break;
case 'border-bottom-width':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderBottomWidth(value, important);
break;
case 'border-left-width':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderLeftWidth(value, important);
break;
case 'border-top-color':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderTopColor(value, important);
break;
case 'border-right-color':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderRightColor(value, important);
break;
case 'border-bottom-color':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderBottomColor(value, important);
break;
case 'border-left-color':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderLeftColor(value, important);
break;
case 'border-top-style':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderTopStyle(value, important);
break;
case 'border-right-style':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderRightStyle(value, important);
break;
case 'border-bottom-style':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderBottomStyle(value, important);
break;
case 'border-left-style':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderLeftStyle(value, important);
break;
case 'border-radius':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderRadius(value, important);
break;
case 'border-top-left-radius':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderTopLeftRadius(value, important);
break;
case 'border-top-right-radius':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderTopRightRadius(value, important);
break;
case 'border-bottom-right-radius':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderBottomRightRadius(value, important);
break;
case 'border-bottom-left-radius':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderBottomLeftRadius(value, important);
break;
case 'border-collapse':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBorderCollapse(value, important);
break;
case 'outline':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getOutline(value, important);
break;
case 'outline-width':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getOutlineWidth(value, important);
break;
case 'outline-style':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getOutlineStyle(value, important);
break;
case 'outline-color':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getOutlineColor(value, important);
break;
case 'letter-spacing':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getLetterSpacing(value, important);
break;
case 'word-spacing':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getWordSpacing(value, important);
break;
case 'clear':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getClear(value, important);
break;
case 'clip':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getClip(value, important);
break;
case 'css-float':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getCSSFloat(value, important);
break;
case 'float':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getFloat(value, important);
break;
case 'display':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getDisplay(value, important);
break;
case 'direction':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getDirection(value, important);
break;
case 'flex':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getFlex(value, important);
break;
case 'flex-shrink':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getFlexShrink(value, important);
break;
case 'flex-grow':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getFlexGrow(value, important);
break;
case 'flex-basis':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getFlexBasis(value, important);
break;
case 'padding':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getPadding(value, important);
break;
case 'padding-top':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getPaddingTop(value, important);
break;
case 'padding-right':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getPaddingRight(value, important);
break;
case 'padding-bottom':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getPaddingBottom(value, important);
break;
case 'padding-left':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getPaddingLeft(value, important);
break;
case 'margin':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getMargin(value, important);
break;
case 'margin-top':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getMarginTop(value, important);
break;
case 'margin-right':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getMarginRight(value, important);
break;
case 'margin-bottom':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getMarginBottom(value, important);
break;
case 'margin-left':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getMarginLeft(value, important);
break;
case 'background':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBackground(value, important);
break;
case 'background-image':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBackgroundImage(value, important);
break;
case 'background-color':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBackgroundColor(value, important);
break;
case 'background-repeat':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBackgroundRepeat(value, important);
break;
case 'background-attachment':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBackgroundAttachment(value, important);
break;
case 'background-position':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBackgroundPosition(value, important);
break;
case 'width':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getWidth(value, important);
break;
case 'height':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getHeight(value, important);
break;
case 'top':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getTop(value, important);
break;
case 'right':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getRight(value, important);
break;
case 'bottom':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getBottom(value, important);
break;
case 'left':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getLeft(value, important);
break;
case 'font':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getFont(value, important);
break;
case 'font-style':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getFontStyle(value, important);
break;
case 'font-variant':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getFontVariant(value, important);
break;
case 'font-weight':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getFontWeight(value, important);
break;
case 'font-stretch':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getFontStretch(value, important);
break;
case 'font-size':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getFontSize(value, important);
break;
case 'line-height':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getLineHeight(value, important);
break;
case 'text-indent':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getTextIndent(value, important);
break;
case 'font-family':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getFontFamily(value, important);
break;
case 'color':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getColor(value, important);
break;
case 'flood-color':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getFloodColor(value, important);
break;
case 'text-transform':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getTextTransform(value, important);
break;
case 'visibility':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getVisibility(value, important);
break;
case 'aspect-ratio':
properties = CSSStyleDeclarationPropertySetParser_js_1.default.getAspectRatio(value, important);
break;
default:
const trimmedValue = value.trim();
if (trimmedValue) {
const globalValue = CSSStyleDeclarationValueParser_js_1.default.getGlobal(trimmedValue);
properties = {
[name]: { value: globalValue || trimmedValue, important }
};
}
break;
}
if (properties !== null && Object.keys(properties).length > 0) {
this.definedPropertyNames[name] = true;
Object.assign(this.properties, properties);
}
}
/**
* Returns a clone.
*
* @returns Clone.
*/
clone() {
const _class = this.constructor;
const clone = new _class();
clone.properties = JSON.parse(JSON.stringify(this.properties));
clone.definedPropertyNames = Object.assign({}, this.definedPropertyNames);
return clone;
}
/**
* Returns size.
*
* @returns Size.
*/
size() {
return Object.keys(this.properties).length;
}
/**
* Returns property name.
*
* @param index Index.
* @returns Property name.
*/
item(index) {
return Object.keys(this.properties)[index] || '';
}
/**
* Converts properties to string.
*
* @returns String.
*/
toString() {
const result = [];
const clone = this.clone();
const properties = {};
for (const shorthandPropertyGroup of TO_STRING_SHORTHAND_PROPERTIES) {
for (const shorthandProperty of shorthandPropertyGroup) {
if (Array.isArray(shorthandProperty)) {
let isMatch = false;
for (const childShorthandProperty of shorthandProperty) {
const property = clone.get(childShorthandProperty);
if (property) {
properties[childShorthandProperty] = property;
clone.remove(childShorthandProperty);
isMatch = true;
}
}
if (isMatch) {
break;
}
}
else {
const property = clone.get(shorthandProperty);
if (property) {
properties[shorthandProperty] = property;
clone.remove(shorthandProperty);
break;
}
}
}
}
for (const name of Object.keys(clone.properties)) {
properties[name] = clone.get(name);
}
for (const definedPropertyName of Object.keys(this.definedPropertyNames)) {
const property = properties[definedPropertyName];
if (property) {
result.push(`${definedPropertyName}: ${property.value}${property.important ? ' !important' : ''};`);
delete properties[definedPropertyName];
}
}
for (const propertyName of Object.keys(properties)) {
const property = properties[propertyName];
if (property) {
result.push(`${propertyName}: ${property.value}${property.important ? ' !important' : ''};`);
}
}
return result.join(' ');
}
}
exports.default = CSSStyleDeclarationPropertyManager;
//# sourceMappingURL=CSSStyleDeclarationPropertyManager.cjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,66 @@
import ICSSStyleDeclarationPropertyValue from './ICSSStyleDeclarationPropertyValue.cjs';
/**
* Computed this.properties property parser.
*/
export default class CSSStyleDeclarationPropertyManager {
properties: {
[k: string]: ICSSStyleDeclarationPropertyValue;
};
private definedPropertyNames;
/**
* Class construtor.
*
* @param [options] Options.
* @param [options.cssText] CSS string.
*/
constructor(options?: {
cssText?: string;
});
/**
* Returns property value.
*
* @param name Property name.
* @returns Property value.
*/
get(name: string): ICSSStyleDeclarationPropertyValue | null;
/**
* Removes a property.
*
* @param name Property name.
*/
remove(name: string): void;
/**
* Sets a property
*
* @param name Name.
* @param value Value.
* @param important Important.
*/
set(name: string, value: string, important: boolean): void;
/**
* Returns a clone.
*
* @returns Clone.
*/
clone(): CSSStyleDeclarationPropertyManager;
/**
* Returns size.
*
* @returns Size.
*/
size(): number;
/**
* Returns property name.
*
* @param index Index.
* @returns Property name.
*/
item(index: number): string;
/**
* Converts properties to string.
*
* @returns String.
*/
toString(): string;
}
//# sourceMappingURL=CSSStyleDeclarationPropertyManager.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CSSStyleDeclarationPropertyManager.d.ts","sourceRoot":"","sources":["../../../../src/css/declaration/property-manager/CSSStyleDeclarationPropertyManager.ts"],"names":[],"mappings":"AAAA,OAAO,iCAAiC,MAAM,wCAAwC,CAAC;AAevF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,kCAAkC;IAC/C,UAAU,EAAE;QAClB,CAAC,CAAC,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAC/C,CAAM;IACP,OAAO,CAAC,oBAAoB,CAAgC;IAE5D;;;;;OAKG;gBACS,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IAW1C;;;;;OAKG;IACI,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,iCAAiC,GAAG,IAAI;IA4ClE;;;;OAIG;IACI,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAgJjC;;;;;;OAMG;IACI,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI;IA6RjE;;;;OAIG;IACI,KAAK,IAAI,kCAAkC;IAUlD;;;;OAIG;IACI,IAAI,IAAI,MAAM;IAIrB;;;;;OAKG;IACI,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAIlC;;;;OAIG;IACI,QAAQ,IAAI,MAAM;CAwDzB"}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,910 @@
import ICSSStyleDeclarationPropertyValue from './ICSSStyleDeclarationPropertyValue.cjs';
/**
* Computed style property parser.
*/
export default class CSSStyleDeclarationPropertySetParser {
/**
* Returns border collapse.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderCollapse(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns display.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getDisplay(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns direction.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getDirection(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns letter spacing.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getLetterSpacing(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns word spacing.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getWordSpacing(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns text indent.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getTextIndent(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns width.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getWidth(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns height.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getHeight(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns top.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getTop(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns top.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getRight(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns top.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBottom(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns top.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getLeft(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns clear.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getClear(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns clip
*
* Based on:
* https://github.com/jsdom/cssstyle/blob/master/lib/properties/clip.js
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getClip(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns float.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getFloat(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns float.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getCSSFloat(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns outline.
*
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getOutline(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns outline color.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getOutlineColor(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns outline offset.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getOutlineOffset(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns outline style.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getOutlineStyle(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns outline width.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getOutlineWidth(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border.
*
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getBorder(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border width.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderWidth(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border style.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderStyle(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border color.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderColor(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border image.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderImage(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border source.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderImageSource(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border slice.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderImageSlice(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border width.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderImageWidth(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border outset.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderImageOutset(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border repeat.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderImageRepeat(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border width.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderTopWidth(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border width.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderRightWidth(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border width.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderBottomWidth(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border width.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderLeftWidth(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border style.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderTopStyle(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border style.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderRightStyle(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border style.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderBottomStyle(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border style.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderLeftStyle(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border color.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderTopColor(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border color.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderRightColor(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border color.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderBottomColor(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border color.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBorderLeftColor(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border radius.
*
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getBorderRadius(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border radius.
*
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getBorderTopLeftRadius(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border radius.
*
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getBorderTopRightRadius(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border radius.
*
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getBorderBottomRightRadius(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border radius.
*
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getBorderBottomLeftRadius(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border top, right, bottom or left.
*
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getBorderTop(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border top, right, bottom or left.
*
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getBorderRight(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border top, right, bottom or left.
*
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getBorderBottom(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns border top, right, bottom or left.
*
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getBorderLeft(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns padding.
*
* @param value Value.
* @param important Important.
*/
static getPadding(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns padding top.
*
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getPaddingTop(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns padding right.
*
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getPaddingRight(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns padding bottom.
*
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getPaddingBottom(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns padding left.
*
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getPaddingLeft(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns margin.
*
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getMargin(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns margin top.
*
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getMarginTop(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns margin right.
*
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getMarginRight(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns margin right.
*
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getMarginBottom(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns margin left.
*
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getMarginLeft(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns flex.
*
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getFlex(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns flex basis.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getFlexBasis(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns flex shrink.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getFlexShrink(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns flex grow.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getFlexGrow(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns background.
*
* @param name Name.
* @param value Value.
* @param important Important.
* @returns Property values.
*/
static getBackground(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns background size.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBackgroundSize(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns background origin.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBackgroundOrigin(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns background clip.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBackgroundClip(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns background repeat.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBackgroundRepeat(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns background attachment.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBackgroundAttachment(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns background position.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBackgroundPosition(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns background position.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBackgroundPositionX(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns background position.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getBackgroundPositionY(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns background color.
*
* @param value Value.
* @param important Important.
* @returns Property value.
*/
static getBackgroundColor(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns background image.
*
* @param value Value.
* @param important Important.
* @returns Property value.
*/
static getBackgroundImage(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns color.
*
* @param value Value.
* @param important Important.
* @returns Property value.
*/
static getColor(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns color.
*
* @param value Value.
* @param important Important.
* @returns Property value.
*/
static getFloodColor(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns font.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getFont(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns font style.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getFontStyle(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns font variant.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getFontVariant(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns font strech.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getFontStretch(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns font weight.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getFontWeight(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns font size.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getFontSize(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns line height.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getLineHeight(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns font family.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getFontFamily(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns font family.
*
* @param value Value.
* @param important Important.
* @returns Property values
*/
static getTextTransform(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns visibility.
*
* @param value Value.
* @param important Important.
* @returns Property
*/
static getVisibility(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
/**
* Returns aspect ratio.
*
* @param value Value.
* @param important Important.
* @returns Property
*/
static getAspectRatio(value: string, important: boolean): {
[key: string]: ICSSStyleDeclarationPropertyValue;
};
}
//# sourceMappingURL=CSSStyleDeclarationPropertySetParser.d.ts.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,432 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const COLOR_REGEXP = /^#([0-9a-fA-F]{3,4}){1,2}$|^rgb\(([^)]*)\)$|^rgba\(([^)]*)\)$|^hsla?\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*(,\s*(-?\d+|-?\d*.\d+)\s*)?\)|(?:(rgba?|hsla?)\((var\(\s*(--[^)\s]+)\))\))/;
const LENGTH_REGEXP = /^(0|[-+]?[0-9]*\.?[0-9]+)(in|cm|em|mm|pt|pc|px|ex|rem|vh|vw|ch|vw|vh|vmin|vmax|Q)$/;
const PERCENTAGE_REGEXP = /^[-+]?[0-9]*\.?[0-9]+%$/;
const DEGREE_REGEXP = /^[0-9]+deg$/;
const URL_REGEXP = /^url\(\s*([^)]*)\s*\)$/;
const INTEGER_REGEXP = /^[0-9]+$/;
const FLOAT_REGEXP = /^[0-9.]+$/;
const CALC_REGEXP = /^calc\([^^)]+\)$/;
const CSS_VARIABLE_REGEXP = /^var\(\s*(--[^)\s]+)\)$/;
const FIT_CONTENT_REGEXP = /^fit-content\([^^)]+\)$/;
const GRADIENT_REGEXP = /^((repeating-linear|linear|radial|repeating-radial|conic|repeating-conic)-gradient)\(([^)]+)\)$/;
const GLOBALS = ['inherit', 'initial', 'unset', 'revert'];
const COLORS = [
'none',
'currentcolor',
'transparent',
'silver',
'gray',
'white',
'maroon',
'red',
'purple',
'fuchsia',
'green',
'lime',
'olive',
'yellow',
'navy',
'blue',
'teal',
'aliceblue',
'aqua',
'antiquewhite',
'aquamarine',
'azure',
'beige',
'bisque',
'black',
'blanchedalmond',
'blueviolet',
'brown',
'burlywood',
'cadetblue',
'chartreuse',
'chocolate',
'coral',
'cornflowerblue',
'cornsilk',
'crimson',
'cyan',
'darkblue',
'darkcyan',
'darkgoldenrod',
'darkgray',
'darkgreen',
'darkgrey',
'darkkhaki',
'darkmagenta',
'darkolivegreen',
'darkorange',
'darkorchid',
'darkred',
'darksalmon',
'darkseagreen',
'darkslateblue',
'darkslategray',
'darkslategrey',
'darkturquoise',
'darkviolet',
'deeppink',
'deepskyblue',
'dimgray',
'dimgrey',
'dodgerblue',
'firebrick',
'floralwhite',
'forestgreen',
'gainsboro',
'ghostwhite',
'gold',
'goldenrod',
'greenyellow',
'grey',
'honeydew',
'hotpink',
'indianred',
'indigo',
'ivory',
'khaki',
'lavender',
'lavenderblush',
'lawngreen',
'lemonchiffon',
'lightblue',
'lightcoral',
'lightcyan',
'lightgoldenrodyellow',
'lightgray',
'lightgreen',
'lightgrey',
'lightpink',
'lightsalmon',
'lightseagreen',
'lightskyblue',
'lightslategray',
'lightslategrey',
'lightsteelblue',
'lightyellow',
'limegreen',
'linen',
'magenta',
'mediumaquamarine',
'mediumblue',
'mediumorchid',
'mediumpurple',
'mediumseagreen',
'mediumslateblue',
'mediumspringgreen',
'mediumturquoise',
'mediumvioletred',
'midnightblue',
'mintcream',
'mistyrose',
'moccasin',
'navajowhite',
'oldlace',
'olivedrab',
'orange',
'orangered',
'orchid',
'palegoldenrod',
'palegreen',
'paleturquoise',
'palevioletred',
'papayawhip',
'peachpuff',
'peru',
'pink',
'plum',
'powderblue',
'rebeccapurple',
'rosybrown',
'royalblue',
'saddlebrown',
'salmon',
'sandybrown',
'seagreen',
'seashell',
'sienna',
'skyblue',
'slateblue',
'slategray',
'slategrey',
'snow',
'springgreen',
'steelblue',
'tan',
'thistle',
'tomato',
'turquoise',
'violet',
'wheat',
'whitesmoke',
'yellowgreen'
];
/**
* Style declaration value parser.
*/
class CSSStyleDeclarationValueParser {
/**
* Returns length.
*
* @param value Value.
* @returns Parsed value.
*/
static getLength(value) {
if (value === '0') {
return '0px';
}
const match = value.match(LENGTH_REGEXP);
if (match) {
const number = parseFloat(match[1]);
if (isNaN(number)) {
return null;
}
const unit = match[2];
return `${Math.round(number * 1000000) / 1000000}${unit}`;
}
return null;
}
/**
* Returns percentance.
*
* @param value Value.
* @returns Parsed value.
*/
static getPercentage(value) {
if (value === '0') {
return '0%';
}
if (PERCENTAGE_REGEXP.test(value)) {
return value;
}
return null;
}
/**
* Returns degree.
*
* @param value Value.
* @returns Parsed value.
*/
static getDegree(value) {
if (value === '0') {
return '0deg';
}
if (DEGREE_REGEXP.test(value)) {
return value;
}
return null;
}
/**
* Returns calc.
*
* @param value Value.
* @returns Parsed value.
*/
static getCalc(value) {
if (CALC_REGEXP.test(value)) {
return value;
}
return null;
}
/**
* Returns fit content.
*
* @param value Value.
* @returns Parsed value.
*/
static getFitContent(value) {
const lowerValue = value.toLowerCase();
if (lowerValue === 'auto' ||
lowerValue === 'max-content' ||
lowerValue === 'min-content' ||
lowerValue === 'fit-content') {
return lowerValue;
}
if (FIT_CONTENT_REGEXP.test(lowerValue)) {
return lowerValue;
}
return null;
}
/**
* Returns measurement.
*
* @param value Value.
* @returns Parsed value.
*/
static getMeasurement(value) {
return this.getLength(value) || this.getPercentage(value) || this.getCalc(value);
}
/**
* Returns measurement or auto, min-content, max-content or fit-content.
*
* @param value Value.
* @returns Parsed value.
*/
static getContentMeasurement(value) {
return this.getFitContent(value) || this.getMeasurement(value);
}
/**
* Returns measurement or auto, min-content, max-content or fit-content.
*
* @param value Value.
* @returns Parsed value.
*/
static getAutoMeasurement(value) {
if (value.toLocaleLowerCase() === 'auto') {
return 'auto';
}
return this.getMeasurement(value);
}
/**
* Returns integer.
*
* @param value Value.
* @returns Parsed value.
*/
static getInteger(value) {
if (INTEGER_REGEXP.test(value)) {
return value;
}
return null;
}
/**
* Returns float.
*
* @param value Value.
* @returns Parsed value.
*/
static getFloat(value) {
if (FLOAT_REGEXP.test(value)) {
const number = parseFloat(value);
if (isNaN(number)) {
return null;
}
return String(Math.round(number * 1000000) / 1000000);
}
return null;
}
/**
* Returns gradient.
*
* @param value Value.
* @returns Parsed value.
*/
static getGradient(value) {
const match = value.match(GRADIENT_REGEXP);
if (match) {
return `${match[1]}(${match[3]
.trim()
.split(/\s*,\s*/)
.join(', ')})`;
}
return null;
}
/**
* Returns color.
*
* @param value Value.
* @returns Parsed value.
*/
static getColor(value) {
const lowerValue = value.toLowerCase();
if (COLORS.includes(lowerValue)) {
return lowerValue;
}
if (COLOR_REGEXP.test(value)) {
return value.replace(/,([^ ])/g, ', $1');
}
return null;
}
/**
* Returns URL.
*
* Based on:
* https://github.com/jsdom/cssstyle/blob/master/lib/parsers.js#L222
*
* @param value Value.
* @returns Parsed value.
*/
static getURL(value) {
if (!value) {
return null;
}
if (value.toLowerCase() === 'none') {
return 'none';
}
const result = URL_REGEXP.exec(value);
if (!result) {
return null;
}
let url = result[1].trim();
if ((url[0] === '"' || url[0] === "'") && url[0] !== url[url.length - 1]) {
return null;
}
if (url[0] === '"' || url[0] === "'") {
url = url.substring(1, url.length - 1);
}
for (let i = 0; i < url.length; i++) {
switch (url[i]) {
case '(':
case ')':
case ' ':
case '\t':
case '\n':
case "'":
case '"':
return null;
case '\\':
i++;
break;
}
}
return `url("${url}")`;
}
/**
* Returns global initial value.
*
* @param value Value.
* @returns Parsed value.
*/
static getInitial(value) {
return value.toLowerCase() === 'initial' ? 'initial' : null;
}
/**
* Returns CSS variable.
*
* @param value Value.
* @returns Parsed value.
*/
static getVariable(value) {
const cssVariableMatch = value.match(CSS_VARIABLE_REGEXP);
if (cssVariableMatch) {
return `var(${cssVariableMatch[1]})`;
}
return null;
}
/**
* Returns global.
*
* @param value Value.
* @returns Parsed value.
*/
static getGlobal(value) {
const lowerValue = value.toLowerCase();
return GLOBALS.includes(lowerValue) ? lowerValue : null;
}
/**
* Returns global, unless it is not set to 'initial' as it is sometimes treated different.
*
* @param value Value.
* @returns Parsed value.
*/
static getGlobalExceptInitial(value) {
const lowerValue = value.toLowerCase();
return lowerValue !== 'initial' && GLOBALS.includes(lowerValue) ? lowerValue : null;
}
}
exports.default = CSSStyleDeclarationValueParser;
//# sourceMappingURL=CSSStyleDeclarationValueParser.cjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,128 @@
/**
* Style declaration value parser.
*/
export default class CSSStyleDeclarationValueParser {
/**
* Returns length.
*
* @param value Value.
* @returns Parsed value.
*/
static getLength(value: string): string;
/**
* Returns percentance.
*
* @param value Value.
* @returns Parsed value.
*/
static getPercentage(value: string): string;
/**
* Returns degree.
*
* @param value Value.
* @returns Parsed value.
*/
static getDegree(value: string): string;
/**
* Returns calc.
*
* @param value Value.
* @returns Parsed value.
*/
static getCalc(value: string): string;
/**
* Returns fit content.
*
* @param value Value.
* @returns Parsed value.
*/
static getFitContent(value: string): string;
/**
* Returns measurement.
*
* @param value Value.
* @returns Parsed value.
*/
static getMeasurement(value: string): string;
/**
* Returns measurement or auto, min-content, max-content or fit-content.
*
* @param value Value.
* @returns Parsed value.
*/
static getContentMeasurement(value: string): string;
/**
* Returns measurement or auto, min-content, max-content or fit-content.
*
* @param value Value.
* @returns Parsed value.
*/
static getAutoMeasurement(value: string): string;
/**
* Returns integer.
*
* @param value Value.
* @returns Parsed value.
*/
static getInteger(value: string): string;
/**
* Returns float.
*
* @param value Value.
* @returns Parsed value.
*/
static getFloat(value: string): string;
/**
* Returns gradient.
*
* @param value Value.
* @returns Parsed value.
*/
static getGradient(value: string): string;
/**
* Returns color.
*
* @param value Value.
* @returns Parsed value.
*/
static getColor(value: string): string;
/**
* Returns URL.
*
* Based on:
* https://github.com/jsdom/cssstyle/blob/master/lib/parsers.js#L222
*
* @param value Value.
* @returns Parsed value.
*/
static getURL(value: string): string;
/**
* Returns global initial value.
*
* @param value Value.
* @returns Parsed value.
*/
static getInitial(value: string): string;
/**
* Returns CSS variable.
*
* @param value Value.
* @returns Parsed value.
*/
static getVariable(value: string): string;
/**
* Returns global.
*
* @param value Value.
* @returns Parsed value.
*/
static getGlobal(value: string): string;
/**
* Returns global, unless it is not set to 'initial' as it is sometimes treated different.
*
* @param value Value.
* @returns Parsed value.
*/
static getGlobalExceptInitial(value: string): string;
}
//# sourceMappingURL=CSSStyleDeclarationValueParser.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CSSStyleDeclarationValueParser.d.ts","sourceRoot":"","sources":["../../../../src/css/declaration/property-manager/CSSStyleDeclarationValueParser.ts"],"names":[],"mappings":"AA0KA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,8BAA8B;IAClD;;;;;OAKG;WACW,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAgB9C;;;;;OAKG;WACW,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAUlD;;;;;OAKG;WACW,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAU9C;;;;;OAKG;WACW,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAO5C;;;;;OAKG;WACW,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAgBlD;;;;;OAKG;WACW,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAInD;;;;;OAKG;WACW,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAI1D;;;;;OAKG;WACW,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAOvD;;;;;OAKG;WACW,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAO/C;;;;;OAKG;WACW,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAW7C;;;;;OAKG;WACW,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAWhD;;;;;OAKG;WACW,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAW7C;;;;;;;;OAQG;WACW,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IA4C3C;;;;;OAKG;WACW,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAI/C;;;;;OAKG;WACW,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAQhD;;;;;OAKG;WACW,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAK9C;;;;;OAKG;WACW,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;CAI3D"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=ICSSStyleDeclarationPropertyValue.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICSSStyleDeclarationPropertyValue.cjs","sourceRoot":"","sources":["../../../../src/css/declaration/property-manager/ICSSStyleDeclarationPropertyValue.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,5 @@
export default interface ICSSStyleDeclarationPropertyValue {
value: string;
important: boolean;
}
//# sourceMappingURL=ICSSStyleDeclarationPropertyValue.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICSSStyleDeclarationPropertyValue.d.ts","sourceRoot":"","sources":["../../../../src/css/declaration/property-manager/ICSSStyleDeclarationPropertyValue.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,WAAW,iCAAiC;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;CACnB"}