@taiga-ui/cdk 2.49.1 → 2.50.1
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/bundles/taiga-ui-cdk-directives-auto-focus.umd.js +3 -2
- package/bundles/taiga-ui-cdk-directives-auto-focus.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-auto-focus.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-directives-auto-focus.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-services.umd.js +3 -1
- package/bundles/taiga-ui-cdk-services.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-services.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-tokens.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-tokens.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-utils-dom.umd.js +46 -0
- package/bundles/taiga-ui-cdk-utils-dom.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-utils-dom.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-utils-dom.umd.min.js.map +1 -1
- package/directives/auto-focus/autofocus.options.d.ts +1 -1
- package/directives/auto-focus/taiga-ui-cdk-directives-auto-focus.metadata.json +1 -1
- package/esm2015/directives/auto-focus/autofocus.options.js +5 -4
- package/esm2015/services/directive-styles.service.js +4 -2
- package/esm2015/tokens/is-cypress.js +1 -1
- package/esm2015/utils/dom/get-viewport-height.js +21 -0
- package/esm2015/utils/dom/get-viewport-width.js +21 -0
- package/esm2015/utils/dom/index.js +3 -1
- package/esm5/directives/auto-focus/autofocus.options.js +5 -4
- package/esm5/services/directive-styles.service.js +4 -2
- package/esm5/tokens/is-cypress.js +1 -1
- package/esm5/utils/dom/get-viewport-height.js +22 -0
- package/esm5/utils/dom/get-viewport-width.js +22 -0
- package/esm5/utils/dom/index.js +3 -1
- package/fesm2015/taiga-ui-cdk-directives-auto-focus.js +4 -3
- package/fesm2015/taiga-ui-cdk-directives-auto-focus.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-services.js +3 -1
- package/fesm2015/taiga-ui-cdk-services.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-tokens.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-utils-dom.js +43 -1
- package/fesm2015/taiga-ui-cdk-utils-dom.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-auto-focus.js +4 -3
- package/fesm5/taiga-ui-cdk-directives-auto-focus.js.map +1 -1
- package/fesm5/taiga-ui-cdk-services.js +3 -1
- package/fesm5/taiga-ui-cdk-services.js.map +1 -1
- package/fesm5/taiga-ui-cdk-tokens.js.map +1 -1
- package/fesm5/taiga-ui-cdk-utils-dom.js +45 -1
- package/fesm5/taiga-ui-cdk-utils-dom.js.map +1 -1
- package/package.json +3 -1
- package/schematics/ng-add/steps/add-taiga-icons.d.ts +1 -2
- package/schematics/ng-add/steps/add-taiga-icons.js +9 -15
- package/schematics/ng-add/steps/add-taiga-styles.d.ts +1 -2
- package/schematics/ng-add/steps/add-taiga-styles.js +12 -16
- package/schematics/ng-update/constants/consts.js +11 -0
- package/schematics/ng-update/constants/functions.d.ts +0 -0
- package/schematics/ng-update/constants/functions.js +1 -0
- package/schematics/ng-update/constants/templates.js +59 -1
- package/schematics/ng-update/constants/types.js +45 -0
- package/schematics/ng-update/constants/warnings.js +10 -0
- package/schematics/ng-update/index.js +4 -0
- package/schematics/ng-update/steps/migrate-sliders/migrate-input-slider.js +58 -13
- package/schematics/ng-update/steps/migrate-templates.js +60 -14
- package/schematics/ng-update/steps/miscellaneous.d.ts +1 -0
- package/schematics/ng-update/steps/miscellaneous.js +65 -0
- package/schematics/ng-update/steps/replace-functions.d.ts +1 -0
- package/schematics/ng-update/steps/replace-functions.js +61 -0
- package/schematics/utils/get-project.js +2 -1
- package/schematics/utils/templates/elements.d.ts +4 -2
- package/schematics/utils/templates/elements.js +7 -4
- package/schematics/utils/templates/ng-component-input-manipulations.d.ts +32 -1
- package/schematics/utils/templates/ng-component-input-manipulations.js +70 -11
- package/services/directive-styles.service.d.ts +3 -1
- package/tokens/taiga-ui-cdk-tokens.metadata.json +1 -1
- package/utils/dom/get-viewport-height.d.ts +18 -0
- package/utils/dom/get-viewport-width.d.ts +18 -0
- package/utils/dom/index.d.ts +2 -0
- package/utils/dom/taiga-ui-cdk-utils-dom.metadata.json +1 -1
|
@@ -6,24 +6,40 @@ const elements_1 = require("../../utils/templates/elements");
|
|
|
6
6
|
const devkit_file_system_1 = require("ng-morph/project/classes/devkit-file-system");
|
|
7
7
|
const ng_component_input_manipulations_1 = require("../../utils/templates/ng-component-input-manipulations");
|
|
8
8
|
const template_resource_1 = require("../../utils/templates/template-resource");
|
|
9
|
+
const ng_morph_1 = require("ng-morph");
|
|
9
10
|
const START_TAG_OFFSET = 1;
|
|
10
11
|
const END_TAG_OFFSET = 2;
|
|
11
12
|
function migrateTemplates(tree) {
|
|
12
|
-
const templateResources = get_component_templates_1.getComponentTemplates('**/**');
|
|
13
13
|
const fileSystem = new devkit_file_system_1.DevkitFileSystem(tree);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
const componentWithTemplatesPaths = get_component_templates_1.getComponentTemplates('**/**').map(({ componentPath }) => componentPath);
|
|
15
|
+
const actions = [
|
|
16
|
+
replaceTags,
|
|
17
|
+
replaceAttrs,
|
|
18
|
+
replaceAttrsByDirective,
|
|
19
|
+
replaceBreadcrumbs,
|
|
20
|
+
];
|
|
21
|
+
actions.forEach(action => {
|
|
22
|
+
componentWithTemplatesPaths.forEach(componentPath => {
|
|
23
|
+
// get updated version of template after the previous action
|
|
24
|
+
const [resource] = get_component_templates_1.getComponentTemplates(componentPath);
|
|
25
|
+
const path = fileSystem.resolve(template_resource_1.getPathFromTemplateResource(resource));
|
|
26
|
+
const recorder = fileSystem.edit(path);
|
|
27
|
+
action({ resource, fileSystem, recorder });
|
|
28
|
+
});
|
|
29
|
+
save(fileSystem);
|
|
23
30
|
});
|
|
24
31
|
}
|
|
25
32
|
exports.migrateTemplates = migrateTemplates;
|
|
26
|
-
|
|
33
|
+
/**
|
|
34
|
+
* We should update virtual file tree
|
|
35
|
+
* otherwise all following ng-morph commands will overwrite all previous template manipulations
|
|
36
|
+
* */
|
|
37
|
+
function save(fileSystem) {
|
|
38
|
+
fileSystem.commitEdits();
|
|
39
|
+
ng_morph_1.saveActiveProject();
|
|
40
|
+
ng_morph_1.setActiveProject(ng_morph_1.createProject(fileSystem.tree, '/', '**/**'));
|
|
41
|
+
}
|
|
42
|
+
function replaceAttrsByDirective({ resource, fileSystem, }) {
|
|
27
43
|
templates_1.ATTR_TO_DIRECTIVE.forEach(({ componentSelector, directiveModule, directive, inputProperty }) => {
|
|
28
44
|
ng_component_input_manipulations_1.replaceInputPropertyByDirective({
|
|
29
45
|
componentSelector,
|
|
@@ -31,11 +47,13 @@ function replaceAttrsByDirective(fileSystem, templateResource) {
|
|
|
31
47
|
directive,
|
|
32
48
|
inputProperty,
|
|
33
49
|
fileSystem,
|
|
34
|
-
templateResource,
|
|
50
|
+
templateResource: resource,
|
|
35
51
|
});
|
|
36
52
|
});
|
|
37
53
|
}
|
|
38
|
-
function replaceAttrs(
|
|
54
|
+
function replaceAttrs({ resource, recorder, fileSystem, }) {
|
|
55
|
+
const template = template_resource_1.getTemplateFromTemplateResource(resource, fileSystem);
|
|
56
|
+
const templateOffset = template_resource_1.getTemplateOffset(resource);
|
|
39
57
|
templates_1.ATTRS_TO_REPLACE.forEach(({ from, to }) => {
|
|
40
58
|
const offsets = [
|
|
41
59
|
...elements_1.findAttributeOnElementWithTag(template, from.attrName, from.withTagNames || []),
|
|
@@ -47,7 +65,9 @@ function replaceAttrs(template, recorder, templateOffset = 0) {
|
|
|
47
65
|
});
|
|
48
66
|
});
|
|
49
67
|
}
|
|
50
|
-
function replaceTags(
|
|
68
|
+
function replaceTags({ resource, recorder, fileSystem, }) {
|
|
69
|
+
const template = template_resource_1.getTemplateFromTemplateResource(resource, fileSystem);
|
|
70
|
+
const templateOffset = template_resource_1.getTemplateOffset(resource);
|
|
51
71
|
templates_1.TAGS_TO_REPLACE.forEach(({ from, to, addAttributes }) => {
|
|
52
72
|
const elements = elements_1.findElementsByTagName(template, from);
|
|
53
73
|
elements.forEach(({ sourceCodeLocation }) => {
|
|
@@ -65,3 +85,29 @@ function replaceTags(template, recorder, templateOffset = 0) {
|
|
|
65
85
|
});
|
|
66
86
|
});
|
|
67
87
|
}
|
|
88
|
+
function replaceBreadcrumbs({ resource, recorder, fileSystem, }) {
|
|
89
|
+
const template = template_resource_1.getTemplateFromTemplateResource(resource, fileSystem);
|
|
90
|
+
const templateOffset = template_resource_1.getTemplateOffset(resource);
|
|
91
|
+
const elements = elements_1.findElementsByTagName(template, 'tui-breadcrumbs');
|
|
92
|
+
elements.forEach(element => {
|
|
93
|
+
var _a, _b, _c;
|
|
94
|
+
const itemsAttr = element.attrs.find(attr => attr.name === '[items]');
|
|
95
|
+
const itemsValue = itemsAttr === null || itemsAttr === void 0 ? void 0 : itemsAttr.value;
|
|
96
|
+
const insertTo = (_a = element === null || element === void 0 ? void 0 : element.sourceCodeLocation) === null || _a === void 0 ? void 0 : _a.startTag.endOffset;
|
|
97
|
+
if (!itemsValue || !insertTo) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
recorder.insertRight(insertTo + templateOffset, `
|
|
101
|
+
<ng-container *ngFor="let item of ${itemsValue}">
|
|
102
|
+
<a
|
|
103
|
+
*tuiBreadcrumb
|
|
104
|
+
tuiLink
|
|
105
|
+
[routerLink]="item.routerLink"
|
|
106
|
+
>
|
|
107
|
+
{{ item.caption }}
|
|
108
|
+
</a>
|
|
109
|
+
</ng-container>`);
|
|
110
|
+
const { startOffset = 0, endOffset = 0 } = ((_c = (_b = element.sourceCodeLocation) === null || _b === void 0 ? void 0 : _b.attrs) === null || _c === void 0 ? void 0 : _c['[items]']) || {};
|
|
111
|
+
recorder.remove(templateOffset + startOffset - 1, endOffset - startOffset + 1);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function miscellaneousMigrations(): void;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const get_named_import_references_1 = require("../../utils/get-named-import-references");
|
|
4
|
+
const ng_morph_1 = require("ng-morph");
|
|
5
|
+
function miscellaneousMigrations() {
|
|
6
|
+
replaceEnumProperty({
|
|
7
|
+
enumName: 'TuiCurrency',
|
|
8
|
+
from: 'HongKong_dollar',
|
|
9
|
+
to: 'HongKongDollar',
|
|
10
|
+
});
|
|
11
|
+
replaceEnumProperty({
|
|
12
|
+
enumName: 'TuiCurrencyCode',
|
|
13
|
+
from: 'HongKong_dollar',
|
|
14
|
+
to: 'HongKongDollar',
|
|
15
|
+
});
|
|
16
|
+
addWarningToMethod('TuiDirectiveStylesService', 'addStyle', 'addStyle method has been removed. Use components approach');
|
|
17
|
+
}
|
|
18
|
+
exports.miscellaneousMigrations = miscellaneousMigrations;
|
|
19
|
+
function addWarningToMethod(className, method, message) {
|
|
20
|
+
const references = get_named_import_references_1.getNamedImportReferences(className);
|
|
21
|
+
references.forEach(ref => {
|
|
22
|
+
const parent = ref.getParent();
|
|
23
|
+
if (ng_morph_1.Node.isTypeReferenceNode(parent)) {
|
|
24
|
+
checkMethod(parent, method, message);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function replaceEnumProperty({ enumName, from, to, }) {
|
|
29
|
+
const references = get_named_import_references_1.getNamedImportReferences(enumName);
|
|
30
|
+
references.forEach(ref => {
|
|
31
|
+
const parent = ref.getParent();
|
|
32
|
+
if (!ng_morph_1.Node.isPropertyAccessExpression(parent)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
parent.getChildren().forEach(node => {
|
|
36
|
+
if (node.getText() === from) {
|
|
37
|
+
node.replaceWithText(to);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function checkMethod(node, method, message) {
|
|
43
|
+
const statement = node.getParent();
|
|
44
|
+
const identifier = statement.getChildrenOfKind(ng_morph_1.SyntaxKind.Identifier)[0];
|
|
45
|
+
identifier.findReferencesAsNodes().forEach(ref => {
|
|
46
|
+
let parent = ref.getParent();
|
|
47
|
+
if ((ng_morph_1.Node.isPropertyAccessExpression(parent) &&
|
|
48
|
+
parent.getText().startsWith('this.')) ||
|
|
49
|
+
ng_morph_1.Node.isCallExpression(parent)) {
|
|
50
|
+
parent = parent.getParentIfKind(ng_morph_1.SyntaxKind.PropertyAccessExpression);
|
|
51
|
+
}
|
|
52
|
+
if (ng_morph_1.Node.isPropertyAccessExpression(parent)) {
|
|
53
|
+
parent.getChildrenOfKind(ng_morph_1.SyntaxKind.Identifier).forEach(identifier => {
|
|
54
|
+
if (identifier.getText() === method) {
|
|
55
|
+
insertTodo(identifier, message);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function insertTodo(identifier, message) {
|
|
62
|
+
const startLinePos = identifier.getStartLinePos();
|
|
63
|
+
const sourceFile = identifier.getSourceFile();
|
|
64
|
+
sourceFile.insertText(startLinePos, `// TODO: ${message}\n`);
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function replaceFunctions(): void;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const get_named_import_references_1 = require("../../utils/get-named-import-references");
|
|
4
|
+
const ng_morph_1 = require("ng-morph");
|
|
5
|
+
const import_manipulations_1 = require("../../utils/import-manipulations");
|
|
6
|
+
function replaceFunctions() {
|
|
7
|
+
replacePadStart(get_named_import_references_1.getNamedImportReferences('padStart', '@taiga-ui/cdk'));
|
|
8
|
+
replaceFallbackValue(get_named_import_references_1.getNamedImportReferences('fallbackValue', '@taiga-ui/cdk'));
|
|
9
|
+
replaceCustomEvent(get_named_import_references_1.getNamedImportReferences('tuiCustomEvent', '@taiga-ui/cdk'));
|
|
10
|
+
replaceClosestElement(get_named_import_references_1.getNamedImportReferences('getClosestElement', '@taiga-ui/cdk'));
|
|
11
|
+
}
|
|
12
|
+
exports.replaceFunctions = replaceFunctions;
|
|
13
|
+
function replacePadStart(references) {
|
|
14
|
+
references.forEach(ref => {
|
|
15
|
+
var _a;
|
|
16
|
+
const parent = ref.getParent();
|
|
17
|
+
if (ng_morph_1.Node.isImportSpecifier(parent)) {
|
|
18
|
+
import_manipulations_1.removeImport(parent);
|
|
19
|
+
}
|
|
20
|
+
else if (ng_morph_1.Node.isCallExpression(parent)) {
|
|
21
|
+
const [targetString, length, pad] = parent.getArguments();
|
|
22
|
+
parent.replaceWithText(`${targetString.getText()}.padStart(${length.getText()}, ${(_a = pad === null || pad === void 0 ? void 0 : pad.getText()) !== null && _a !== void 0 ? _a : '" "'})`);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function replaceClosestElement(references) {
|
|
27
|
+
references.forEach(ref => {
|
|
28
|
+
const parent = ref.getParent();
|
|
29
|
+
if (ng_morph_1.Node.isImportSpecifier(parent)) {
|
|
30
|
+
import_manipulations_1.removeImport(parent);
|
|
31
|
+
}
|
|
32
|
+
else if (ng_morph_1.Node.isCallExpression(parent)) {
|
|
33
|
+
const [firstArg, secondArg] = parent.getArguments();
|
|
34
|
+
parent.replaceWithText(`${firstArg.getText()}.closest(${secondArg.getText()})`);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function replaceCustomEvent(references) {
|
|
39
|
+
references.forEach(ref => {
|
|
40
|
+
const parent = ref.getParent();
|
|
41
|
+
if (ng_morph_1.Node.isImportSpecifier(parent)) {
|
|
42
|
+
import_manipulations_1.removeImport(parent);
|
|
43
|
+
}
|
|
44
|
+
else if (ng_morph_1.Node.isCallExpression(parent)) {
|
|
45
|
+
const [firstArg, secondArg] = parent.getArguments();
|
|
46
|
+
parent.replaceWithText(`new CustomEvent(${firstArg.getText()}, ${secondArg.getText()})`);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function replaceFallbackValue(references) {
|
|
51
|
+
references.forEach(ref => {
|
|
52
|
+
const parent = ref.getParent();
|
|
53
|
+
if (ng_morph_1.Node.isImportSpecifier(parent)) {
|
|
54
|
+
import_manipulations_1.removeImport(parent);
|
|
55
|
+
}
|
|
56
|
+
else if (ng_morph_1.Node.isCallExpression(parent)) {
|
|
57
|
+
const [firstArg, secondArg] = parent.getArguments();
|
|
58
|
+
parent.replaceWithText(`${firstArg.getText()} ?? ${secondArg.getText()}`);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
4
4
|
function getProject(options, workspace) {
|
|
5
|
-
|
|
5
|
+
var _a;
|
|
6
|
+
const projectName = options.project || ((_a = workspace.extensions.defaultProject) === null || _a === void 0 ? void 0 : _a.toString()) || '';
|
|
6
7
|
const project = workspace.projects.get(projectName);
|
|
7
8
|
if (!project) {
|
|
8
9
|
throw new schematics_1.SchematicsException(`Unable to find project '${projectName}' in the workspace`);
|
|
@@ -9,11 +9,13 @@ export declare function findElementsWithAttribute(html: string, attributeName: s
|
|
|
9
9
|
* Finds elements with explicit tag names that also contain the specified attribute. Returns the
|
|
10
10
|
* attribute start offset based on the specified HTML.
|
|
11
11
|
*/
|
|
12
|
-
export declare function findAttributeOnElementWithTag(html: string, name: string, tagNames: string[]): number[];
|
|
12
|
+
export declare function findAttributeOnElementWithTag(html: string, name: string, tagNames: string[], filterFn?: (element: Element) => boolean): number[];
|
|
13
13
|
/**
|
|
14
14
|
* Finds elements that contain the given attribute and contain at least one of the other
|
|
15
15
|
* specified attributes. Returns the primary attribute's start offset based on the specified HTML.
|
|
16
16
|
*/
|
|
17
|
-
export declare function findAttributeOnElementWithAttrs(html: string, name: string, attrs: string[]): number[];
|
|
17
|
+
export declare function findAttributeOnElementWithAttrs(html: string, name: string, attrs: string[], filterFn?: (element: Element) => boolean): number[];
|
|
18
|
+
/** Shorthand function that checks if the specified element contains the given attribute. */
|
|
19
|
+
export declare function hasElementAttribute(element: Element, attributeName: string): boolean;
|
|
18
20
|
/** Gets the start offset of the given attribute from a Parse5 element. */
|
|
19
21
|
export declare function getStartOffsetOfAttribute(element: Element, attributeName: string): number;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const parse5_1 = require("parse5");
|
|
4
|
+
const ALWAYS_TRUE_HANDLER = () => true;
|
|
4
5
|
function findElementsByTagName(html, tagName) {
|
|
5
6
|
const document = parse5_1.parseFragment(html, { sourceCodeLocationInfo: true });
|
|
6
7
|
const elements = [];
|
|
@@ -46,9 +47,9 @@ exports.findElementsWithAttribute = findElementsWithAttribute;
|
|
|
46
47
|
* Finds elements with explicit tag names that also contain the specified attribute. Returns the
|
|
47
48
|
* attribute start offset based on the specified HTML.
|
|
48
49
|
*/
|
|
49
|
-
function findAttributeOnElementWithTag(html, name, tagNames) {
|
|
50
|
+
function findAttributeOnElementWithTag(html, name, tagNames, filterFn = ALWAYS_TRUE_HANDLER) {
|
|
50
51
|
return findElementsWithAttribute(html, name)
|
|
51
|
-
.filter(element => tagNames.includes(element.tagName))
|
|
52
|
+
.filter(element => tagNames.includes(element.tagName) && filterFn(element))
|
|
52
53
|
.map(element => getStartOffsetOfAttribute(element, name));
|
|
53
54
|
}
|
|
54
55
|
exports.findAttributeOnElementWithTag = findAttributeOnElementWithTag;
|
|
@@ -56,9 +57,10 @@ exports.findAttributeOnElementWithTag = findAttributeOnElementWithTag;
|
|
|
56
57
|
* Finds elements that contain the given attribute and contain at least one of the other
|
|
57
58
|
* specified attributes. Returns the primary attribute's start offset based on the specified HTML.
|
|
58
59
|
*/
|
|
59
|
-
function findAttributeOnElementWithAttrs(html, name, attrs) {
|
|
60
|
+
function findAttributeOnElementWithAttrs(html, name, attrs, filterFn = ALWAYS_TRUE_HANDLER) {
|
|
60
61
|
return findElementsWithAttribute(html, name)
|
|
61
|
-
.filter(element => attrs.some(attr => hasElementAttribute(element, attr))
|
|
62
|
+
.filter(element => attrs.some(attr => hasElementAttribute(element, attr)) &&
|
|
63
|
+
filterFn(element))
|
|
62
64
|
.map(element => getStartOffsetOfAttribute(element, name));
|
|
63
65
|
}
|
|
64
66
|
exports.findAttributeOnElementWithAttrs = findAttributeOnElementWithAttrs;
|
|
@@ -67,6 +69,7 @@ function hasElementAttribute(element, attributeName) {
|
|
|
67
69
|
return (element.attrs &&
|
|
68
70
|
element.attrs.some(attr => attr.name === attributeName.toLowerCase()));
|
|
69
71
|
}
|
|
72
|
+
exports.hasElementAttribute = hasElementAttribute;
|
|
70
73
|
/** Gets the start offset of the given attribute from a Parse5 element. */
|
|
71
74
|
function getStartOffsetOfAttribute(element, attributeName) {
|
|
72
75
|
var _a, _b;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DevkitFileSystem } from 'ng-morph/project/classes/devkit-file-system';
|
|
2
|
+
import { Element } from 'parse5';
|
|
2
3
|
import { TemplateResource } from '../../ng-update/interfaces/template-resourse';
|
|
3
4
|
/**
|
|
4
5
|
* Replace component input property by new value
|
|
@@ -25,13 +26,31 @@ import { TemplateResource } from '../../ng-update/interfaces/template-resourse';
|
|
|
25
26
|
* ___
|
|
26
27
|
* @return true if something was changed
|
|
27
28
|
*/
|
|
28
|
-
export declare function replaceInputProperty({ templateResource, fileSystem, componentSelector, from, to, }: {
|
|
29
|
+
export declare function replaceInputProperty({ templateResource, fileSystem, componentSelector, from, to, newValue, filterFn, }: {
|
|
29
30
|
templateResource: TemplateResource;
|
|
30
31
|
fileSystem: DevkitFileSystem;
|
|
31
32
|
componentSelector: string | string[];
|
|
32
33
|
from: string;
|
|
33
34
|
to: string;
|
|
35
|
+
newValue?: string;
|
|
36
|
+
filterFn?: (element: Element) => boolean;
|
|
34
37
|
}): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* @example
|
|
40
|
+
* // 10 symbols before property `size` and string `size="s"` has 8-symbols length
|
|
41
|
+
* const template = '<tui-card size="s"></tui-card>';
|
|
42
|
+
*
|
|
43
|
+
* getInputPropertyOffsets(template, 'size', ['tui-card']) // [[10, 18]]
|
|
44
|
+
*/
|
|
45
|
+
export declare function getInputPropertyOffsets(html: string, attrName: string, tags: string[], filterFn?: (element: Element) => boolean): [number, number][];
|
|
46
|
+
/**
|
|
47
|
+
* @example
|
|
48
|
+
* // `<tui-card size="` has 16-symbols length
|
|
49
|
+
* const template = '<tui-card size="xl"></tui-card>';
|
|
50
|
+
*
|
|
51
|
+
* getInputPropertyValueOffsets(template, 'size', ['tui-card']) // [ [16, 18] ]
|
|
52
|
+
*/
|
|
53
|
+
export declare function getInputPropertyValueOffsets(template: string, attrName: string, tags: string[]): [number, number][];
|
|
35
54
|
export declare function replaceInputPropertyByDirective({ templateResource, fileSystem, componentSelector, inputProperty, directive, directiveModule, }: {
|
|
36
55
|
templateResource: TemplateResource;
|
|
37
56
|
fileSystem: DevkitFileSystem;
|
|
@@ -43,3 +62,15 @@ export declare function replaceInputPropertyByDirective({ templateResource, file
|
|
|
43
62
|
moduleSpecifier: string;
|
|
44
63
|
};
|
|
45
64
|
}): void;
|
|
65
|
+
/**
|
|
66
|
+
* After removing property from the tag (which uses multi lines inside template) it can leave redundant space.
|
|
67
|
+
* It is not critical because html is valid even with this extra space.
|
|
68
|
+
* TODO: Find a way to fix it
|
|
69
|
+
*/
|
|
70
|
+
export declare function removeInputProperty({ templateResource, fileSystem, componentSelector, inputProperty, filterFn, }: {
|
|
71
|
+
templateResource: TemplateResource;
|
|
72
|
+
fileSystem: DevkitFileSystem;
|
|
73
|
+
componentSelector: string;
|
|
74
|
+
inputProperty: string;
|
|
75
|
+
filterFn?: (element: Element) => boolean;
|
|
76
|
+
}): void;
|
|
@@ -31,7 +31,7 @@ const elements_1 = require("./elements");
|
|
|
31
31
|
* ___
|
|
32
32
|
* @return true if something was changed
|
|
33
33
|
*/
|
|
34
|
-
function replaceInputProperty({ templateResource, fileSystem, componentSelector, from, to, }) {
|
|
34
|
+
function replaceInputProperty({ templateResource, fileSystem, componentSelector, from, to, newValue = '', filterFn, }) {
|
|
35
35
|
const template = template_resource_1.getTemplateFromTemplateResource(templateResource, fileSystem);
|
|
36
36
|
const path = fileSystem.resolve(template_resource_1.getPathFromTemplateResource(templateResource));
|
|
37
37
|
const recorder = fileSystem.edit(path);
|
|
@@ -40,27 +40,67 @@ function replaceInputProperty({ templateResource, fileSystem, componentSelector,
|
|
|
40
40
|
? componentSelector
|
|
41
41
|
: [componentSelector];
|
|
42
42
|
const stringProperties = [
|
|
43
|
-
...elements_1.findAttributeOnElementWithTag(template, from, selector),
|
|
44
|
-
...elements_1.findAttributeOnElementWithAttrs(template, from, selector),
|
|
45
|
-
];
|
|
43
|
+
...elements_1.findAttributeOnElementWithTag(template, from, selector, filterFn),
|
|
44
|
+
...elements_1.findAttributeOnElementWithAttrs(template, from, selector, filterFn),
|
|
45
|
+
].map(offset => templateOffset + offset);
|
|
46
46
|
const propertyBindings = [
|
|
47
|
-
...elements_1.findAttributeOnElementWithTag(template, `[${from}]`, selector),
|
|
48
|
-
...elements_1.findAttributeOnElementWithAttrs(template, `[${from}]`, selector),
|
|
49
|
-
];
|
|
47
|
+
...elements_1.findAttributeOnElementWithTag(template, `[${from}]`, selector, filterFn),
|
|
48
|
+
...elements_1.findAttributeOnElementWithAttrs(template, `[${from}]`, selector, filterFn),
|
|
49
|
+
].map(offset => templateOffset + offset);
|
|
50
|
+
const propertyValues = newValue
|
|
51
|
+
? getInputPropertyValueOffsets(template, from, selector).map(([start, end]) => [
|
|
52
|
+
templateOffset + start,
|
|
53
|
+
templateOffset + end,
|
|
54
|
+
])
|
|
55
|
+
: [];
|
|
50
56
|
if (!stringProperties.length && !propertyBindings.length) {
|
|
51
57
|
return false;
|
|
52
58
|
}
|
|
53
59
|
stringProperties.forEach(offset => {
|
|
54
|
-
recorder.remove(offset
|
|
55
|
-
recorder.insertRight(offset
|
|
60
|
+
recorder.remove(offset, from.length);
|
|
61
|
+
recorder.insertRight(offset, to);
|
|
56
62
|
});
|
|
57
63
|
propertyBindings.forEach(offset => {
|
|
58
|
-
recorder.remove(offset
|
|
59
|
-
recorder.insertRight(offset
|
|
64
|
+
recorder.remove(offset, `[${from}]`.length);
|
|
65
|
+
recorder.insertRight(offset, to.startsWith('[') ? to : `[${to}]`);
|
|
66
|
+
});
|
|
67
|
+
propertyValues.forEach(([startOffset, endOffset]) => {
|
|
68
|
+
recorder.remove(startOffset, endOffset - startOffset);
|
|
69
|
+
recorder.insertRight(startOffset, newValue);
|
|
60
70
|
});
|
|
61
71
|
return true;
|
|
62
72
|
}
|
|
63
73
|
exports.replaceInputProperty = replaceInputProperty;
|
|
74
|
+
/**
|
|
75
|
+
* @example
|
|
76
|
+
* // 10 symbols before property `size` and string `size="s"` has 8-symbols length
|
|
77
|
+
* const template = '<tui-card size="s"></tui-card>';
|
|
78
|
+
*
|
|
79
|
+
* getInputPropertyOffsets(template, 'size', ['tui-card']) // [[10, 18]]
|
|
80
|
+
*/
|
|
81
|
+
function getInputPropertyOffsets(html, attrName, tags, filterFn = () => true) {
|
|
82
|
+
return elements_1.findElementsWithAttribute(html, attrName)
|
|
83
|
+
.filter(element => tags.includes(element.tagName) && filterFn(element))
|
|
84
|
+
.map((element) => {
|
|
85
|
+
var _a, _b;
|
|
86
|
+
const { startOffset = 0, endOffset = 0 } = ((_b = (_a = element.sourceCodeLocation) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b[attrName.toLowerCase()]) || {};
|
|
87
|
+
return [startOffset, endOffset];
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
exports.getInputPropertyOffsets = getInputPropertyOffsets;
|
|
91
|
+
/**
|
|
92
|
+
* @example
|
|
93
|
+
* // `<tui-card size="` has 16-symbols length
|
|
94
|
+
* const template = '<tui-card size="xl"></tui-card>';
|
|
95
|
+
*
|
|
96
|
+
* getInputPropertyValueOffsets(template, 'size', ['tui-card']) // [ [16, 18] ]
|
|
97
|
+
*/
|
|
98
|
+
function getInputPropertyValueOffsets(template, attrName, tags) {
|
|
99
|
+
const stringProperties = getInputPropertyOffsets(template, attrName, tags).map(([start, end]) => [start + attrName.length + '="'.length, end - 1]);
|
|
100
|
+
const propertyBindings = getInputPropertyOffsets(template, `[${attrName}]`, tags).map(([start, end]) => [start + `[${attrName}]`.length + '="'.length, end - 1]);
|
|
101
|
+
return [...stringProperties, ...propertyBindings];
|
|
102
|
+
}
|
|
103
|
+
exports.getInputPropertyValueOffsets = getInputPropertyValueOffsets;
|
|
64
104
|
function replaceInputPropertyByDirective({ templateResource, fileSystem, componentSelector, inputProperty, directive, directiveModule, }) {
|
|
65
105
|
const wasModified = replaceInputProperty({
|
|
66
106
|
templateResource,
|
|
@@ -81,3 +121,22 @@ function replaceInputPropertyByDirective({ templateResource, fileSystem, compone
|
|
|
81
121
|
}
|
|
82
122
|
}
|
|
83
123
|
exports.replaceInputPropertyByDirective = replaceInputPropertyByDirective;
|
|
124
|
+
/**
|
|
125
|
+
* After removing property from the tag (which uses multi lines inside template) it can leave redundant space.
|
|
126
|
+
* It is not critical because html is valid even with this extra space.
|
|
127
|
+
* TODO: Find a way to fix it
|
|
128
|
+
*/
|
|
129
|
+
function removeInputProperty({ templateResource, fileSystem, componentSelector, inputProperty, filterFn, }) {
|
|
130
|
+
const template = template_resource_1.getTemplateFromTemplateResource(templateResource, fileSystem);
|
|
131
|
+
const templateOffset = template_resource_1.getTemplateOffset(templateResource);
|
|
132
|
+
const path = fileSystem.resolve(template_resource_1.getPathFromTemplateResource(templateResource));
|
|
133
|
+
const recorder = fileSystem.edit(path);
|
|
134
|
+
const propertyOffsets = [
|
|
135
|
+
...getInputPropertyOffsets(template, inputProperty, [componentSelector], filterFn),
|
|
136
|
+
...getInputPropertyOffsets(template, `[${inputProperty}]`, [componentSelector], filterFn),
|
|
137
|
+
].map(([start, end]) => [templateOffset + start, templateOffset + end]);
|
|
138
|
+
propertyOffsets.forEach(([start, end]) => {
|
|
139
|
+
recorder.remove(start, end - start);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
exports.removeInputProperty = removeInputProperty;
|
|
@@ -11,6 +11,8 @@ export declare class TuiDirectiveStylesService {
|
|
|
11
11
|
private readonly map;
|
|
12
12
|
constructor(resolver: ComponentFactoryResolver, injector: Injector, documentRef: Document, renderer: Renderer2);
|
|
13
13
|
addComponent(component: Type<unknown>): void;
|
|
14
|
-
/** @deprecated use components approach
|
|
14
|
+
/** @deprecated use components approach
|
|
15
|
+
* TODO: delete in v3.0
|
|
16
|
+
*/
|
|
15
17
|
addStyle(styles: string, attribute: string): void;
|
|
16
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"__symbolic":"module","version":4,"metadata":{"TUI_ACTIVE_ELEMENT":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":22,"character":38},"arguments":["Active element on the document for ActiveZone",{"__symbolic":"error","message":"Lambda not supported","line":25,"character":17,"module":"./active-element"}]},"TUI_ALERTS":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":4,"character":30},"arguments":["A stream of alerts",{"__symbolic":"error","message":"Lambda not supported","line":7,"character":13,"module":"./alerts"}]},"TUI_DEFAULT_RENDERER":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":3,"character":40},"arguments":["A Renderer2 for global services",{"__symbolic":"error","message":"Lambda not supported","line":7,"character":17,"module":"./default-renderer"}]},"TUI_DIALOGS":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":4,"character":31},"arguments":["A stream of dialogs",{"__symbolic":"error","message":"Lambda not supported","line":7,"character":13,"module":"./dialogs"}]},"TUI_FOCUSABLE_ITEM_ACCESSOR":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":4,"character":8},"arguments":["A component that can be focused"]},"TUI_IS_ANDROID":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":5,"character":34},"arguments":["Mobile browser that is not iOS (technically includes Windows Phone, Blackberry etc.)",{"__symbolic":"error","message":"Lambda not supported","line":8,"character":17,"module":"./is-android"}]},"TUI_IS_APPLE":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":4,"character":32},"arguments":["Apple(safari/webkit) detection",{"__symbolic":"error","message":"Lambda not supported","line":6,"character":14,"module":"./is-apple"}]},"TUI_IS_CHROMIUM":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":3,"character":35},"arguments":["Chromium browser engine detection",{"__symbolic":"error","message":"Lambda not supported","line":6,"character":17,"module":"./is-chromium"}]},"WindowWithCypress":{"__symbolic":"interface"},"TUI_IS_CYPRESS":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":
|
|
1
|
+
{"__symbolic":"module","version":4,"metadata":{"TUI_ACTIVE_ELEMENT":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":22,"character":38},"arguments":["Active element on the document for ActiveZone",{"__symbolic":"error","message":"Lambda not supported","line":25,"character":17,"module":"./active-element"}]},"TUI_ALERTS":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":4,"character":30},"arguments":["A stream of alerts",{"__symbolic":"error","message":"Lambda not supported","line":7,"character":13,"module":"./alerts"}]},"TUI_DEFAULT_RENDERER":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":3,"character":40},"arguments":["A Renderer2 for global services",{"__symbolic":"error","message":"Lambda not supported","line":7,"character":17,"module":"./default-renderer"}]},"TUI_DIALOGS":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":4,"character":31},"arguments":["A stream of dialogs",{"__symbolic":"error","message":"Lambda not supported","line":7,"character":13,"module":"./dialogs"}]},"TUI_FOCUSABLE_ITEM_ACCESSOR":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":4,"character":8},"arguments":["A component that can be focused"]},"TUI_IS_ANDROID":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":5,"character":34},"arguments":["Mobile browser that is not iOS (technically includes Windows Phone, Blackberry etc.)",{"__symbolic":"error","message":"Lambda not supported","line":8,"character":17,"module":"./is-android"}]},"TUI_IS_APPLE":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":4,"character":32},"arguments":["Apple(safari/webkit) detection",{"__symbolic":"error","message":"Lambda not supported","line":6,"character":14,"module":"./is-apple"}]},"TUI_IS_CHROMIUM":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":3,"character":35},"arguments":["Chromium browser engine detection",{"__symbolic":"error","message":"Lambda not supported","line":6,"character":17,"module":"./is-chromium"}]},"WindowWithCypress":{"__symbolic":"interface"},"TUI_IS_CYPRESS":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":11,"character":34},"arguments":["Detect if app is running under Cypress",{"__symbolic":"error","message":"Lambda not supported","line":14,"character":17,"module":"./is-cypress"}]},"TUI_IS_FIREFOX":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":3,"character":34},"arguments":["Firefox browser engine detection",{"__symbolic":"error","message":"Lambda not supported","line":6,"character":17,"module":"./is-firefox"}]},"TUI_IS_IOS":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":4,"character":30},"arguments":["iOS browser detection",{"__symbolic":"error","message":"Lambda not supported","line":5,"character":13,"module":"./is-ios"}]},"TUI_IS_MOBILE":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":9,"character":33},"arguments":["Mobile browser detection",{"__symbolic":"error","message":"Lambda not supported","line":10,"character":13,"module":"./is-mobile"}]},"TUI_IS_WEBKIT":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":3,"character":33},"arguments":["Webkit browser engine detection",{"__symbolic":"error","message":"Lambda not supported","line":6,"character":17,"module":"./is-webkit"}]},"TUI_REMOVED_ELEMENT":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":5,"character":39},"arguments":["Element currently being removed by AnimationEngine",{"__symbolic":"error","message":"Lambda not supported","line":8,"character":17,"module":"./removed-element"}]},"TUI_SANITIZER":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":3,"character":33},"arguments":["A custom Sanitizer to sanitize source before inlining"]},"TUI_SWIPE_OPTIONS":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":3,"character":37},"arguments":["Swipe options",{"__symbolic":"error","message":"Lambda not supported","line":4,"character":13,"module":"./swipe-options"}]},"TUI_TAKE_ONLY_TRUSTED_EVENTS":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":9,"character":8},"arguments":["This token need for override behavior the `pressedObservable` function",{"__symbolic":"error","message":"Lambda not supported","line":12,"character":21,"module":"./take-only-trusted-events"}]},"TUI_TOUCH_SUPPORTED":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":3,"character":39},"arguments":["Touch support detection",{"__symbolic":"error","message":"Lambda not supported","line":4,"character":13,"module":"./touch-supported"}]},"TUI_WINDOW_HEIGHT":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":6,"character":37},"arguments":["Window height accounting for disappearing address bar",{"__symbolic":"error","message":"Lambda not supported","line":9,"character":17,"module":"./window-height"}]},"TUI_ZOOM_OPTIONS":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":3,"character":36},"arguments":["Zoom options",{"__symbolic":"error","message":"Lambda not supported","line":4,"character":13,"module":"./zoom-options"}]}},"origins":{"TUI_ACTIVE_ELEMENT":"./active-element","TUI_ALERTS":"./alerts","TUI_DEFAULT_RENDERER":"./default-renderer","TUI_DIALOGS":"./dialogs","TUI_FOCUSABLE_ITEM_ACCESSOR":"./focusable-item-accessor","TUI_IS_ANDROID":"./is-android","TUI_IS_APPLE":"./is-apple","TUI_IS_CHROMIUM":"./is-chromium","WindowWithCypress":"./is-cypress","TUI_IS_CYPRESS":"./is-cypress","TUI_IS_FIREFOX":"./is-firefox","TUI_IS_IOS":"./is-ios","TUI_IS_MOBILE":"./is-mobile","TUI_IS_WEBKIT":"./is-webkit","TUI_REMOVED_ELEMENT":"./removed-element","TUI_SANITIZER":"./sanitizer","TUI_SWIPE_OPTIONS":"./swipe-options","TUI_TAKE_ONLY_TRUSTED_EVENTS":"./take-only-trusted-events","TUI_TOUCH_SUPPORTED":"./touch-supported","TUI_WINDOW_HEIGHT":"./window-height","TUI_ZOOM_OPTIONS":"./zoom-options"},"importAs":"@taiga-ui/cdk/tokens"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description:
|
|
3
|
+
* Cross-browser @media (height)
|
|
4
|
+
*
|
|
5
|
+
* 1. window.innerWidth
|
|
6
|
+
* 1.1. gets CSS viewport @media (height) which include scrollbars
|
|
7
|
+
* 1.2. initial-scale and zoom variations may cause mobile values to
|
|
8
|
+
* wrongly scale down to what PPK calls the visual
|
|
9
|
+
* viewport and be smaller than the @media values
|
|
10
|
+
* 1.3. zoom may cause values to be 1px off due to native rounding
|
|
11
|
+
*
|
|
12
|
+
* 2. document.documentElement.clientHeight
|
|
13
|
+
* 2.1. equals CSS viewport width minus scrollbar width
|
|
14
|
+
* 2.2. matches @media (height) when there is no scrollbar
|
|
15
|
+
* 2.3. available cross-browser
|
|
16
|
+
* 2.4. inaccurate if doctype is missing
|
|
17
|
+
*/
|
|
18
|
+
export declare function tuiGetViewportHeight({ document, innerHeight }: Window): number;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description:
|
|
3
|
+
* Cross-browser @media (width)
|
|
4
|
+
*
|
|
5
|
+
* 1. window.innerWidth
|
|
6
|
+
* 1.1. gets CSS viewport @media (width) which include scrollbars
|
|
7
|
+
* 1.2. initial-scale and zoom variations may cause mobile values to
|
|
8
|
+
* wrongly scale down to what PPK calls the visual
|
|
9
|
+
* viewport and be smaller than the @media values
|
|
10
|
+
* 1.3. zoom may cause values to be 1px off due to native rounding
|
|
11
|
+
*
|
|
12
|
+
* 2. document.documentElement.clientWidth
|
|
13
|
+
* 2.1. equals CSS viewport width minus scrollbar width
|
|
14
|
+
* 2.2. matches @media (width) when there is no scrollbar
|
|
15
|
+
* 2.3. available cross-browser
|
|
16
|
+
* 2.4. inaccurate if doctype is missing
|
|
17
|
+
*/
|
|
18
|
+
export declare function tuiGetViewportWidth({ document, innerWidth }: Window): number;
|
package/utils/dom/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export * from './get-document-or-shadow-root';
|
|
|
8
8
|
export * from './get-element-obscurers';
|
|
9
9
|
export * from './get-element-offset';
|
|
10
10
|
export * from './get-scroll-parent';
|
|
11
|
+
export * from './get-viewport-height';
|
|
12
|
+
export * from './get-viewport-width';
|
|
11
13
|
export * from './is-current-target';
|
|
12
14
|
export * from './is-inside-iframe';
|
|
13
15
|
export * from './is-node-in';
|