@zenit-hosting/zenit-ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +400 -0
- package/fesm2022/zenit-hosting-zenit-ui.mjs +11289 -0
- package/fesm2022/zenit-hosting-zenit-ui.mjs.map +1 -0
- package/llms-full.txt +5120 -0
- package/llms.txt +179 -0
- package/package.json +44 -0
- package/schematics/collection.json +15 -0
- package/schematics/migrate-material/component.js +241 -0
- package/schematics/migrate-material/index.js +463 -0
- package/schematics/migrate-material/report.js +125 -0
- package/schematics/migrate-material/schema.js +2 -0
- package/schematics/migrate-material/schema.json +32 -0
- package/schematics/migrate-material/tables.js +138 -0
- package/schematics/migrate-material/template.js +871 -0
- package/schematics/ng-add/html.js +151 -0
- package/schematics/ng-add/index.js +609 -0
- package/schematics/ng-add/init-script.js +108 -0
- package/schematics/ng-add/schema.js +2 -0
- package/schematics/ng-add/schema.json +34 -0
- package/schematics/package.json +3 -0
- package/styles/_daten.css +138 -0
- package/styles/_formulare.css +97 -0
- package/styles/_grundlage.css +424 -0
- package/styles/_konfigurator.css +216 -0
- package/styles/_navigation.css +179 -0
- package/styles/_overlays.css +86 -0
- package/styles/_rueckmeldung.css +100 -0
- package/styles/_werkzeuge.css +119 -0
- package/styles/themes/accents.css +91 -0
- package/styles/themes/base.css +26 -0
- package/styles/themes/contrast.css +67 -0
- package/styles/themes/light.css +74 -0
- package/styles/themes.css +21 -0
- package/styles/tokens.css +76 -0
- package/styles/zenit-ui.css +12 -0
- package/types/zenit-hosting-zenit-ui.d.ts +5957 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.openingTags = openingTags;
|
|
4
|
+
exports.applyEdits = applyEdits;
|
|
5
|
+
exports.planIndexHtml = planIndexHtml;
|
|
6
|
+
/**
|
|
7
|
+
* A tolerant scanner over the opening tags of an HTML document and the edits
|
|
8
|
+
* `ng add` makes to `index.html`. No parser dependency: the schematic only has
|
|
9
|
+
* to find `<html>`, `<head>`, `<meta charset>` and `<body>` and must not be
|
|
10
|
+
* fooled by comments, raw text, `>` inside attribute values or unquoted values.
|
|
11
|
+
*
|
|
12
|
+
* Every edit is computed against the original text and applied in one pass.
|
|
13
|
+
*/
|
|
14
|
+
const eol_1 = require("@schematics/angular/utility/eol");
|
|
15
|
+
/** Elements whose content is text, so a `<html` in there is not a tag. */
|
|
16
|
+
const RAW_TEXT = new Set(['script', 'style', 'textarea', 'title']);
|
|
17
|
+
/** Opening tags in document order. Comments, raw text and closing tags are skipped. */
|
|
18
|
+
function openingTags(html) {
|
|
19
|
+
const lower = html.toLowerCase();
|
|
20
|
+
const tagName = /<([a-zA-Z][^\s/>]*)/y;
|
|
21
|
+
const attribute = /([^\s"'>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/y;
|
|
22
|
+
const tags = [];
|
|
23
|
+
let index = 0;
|
|
24
|
+
while ((index = html.indexOf('<', index)) !== -1) {
|
|
25
|
+
if (html.startsWith('<!--', index)) {
|
|
26
|
+
const close = html.indexOf('-->', index + 4);
|
|
27
|
+
if (close === -1) {
|
|
28
|
+
break; // an unterminated comment swallows the rest of the document
|
|
29
|
+
}
|
|
30
|
+
index = close + 3;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
tagName.lastIndex = index;
|
|
34
|
+
const opened = tagName.exec(html);
|
|
35
|
+
if (!opened) {
|
|
36
|
+
index += 1; // closing tag, doctype or a stray `<`
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const tag = {
|
|
40
|
+
name: opened[1].toLowerCase(),
|
|
41
|
+
start: index,
|
|
42
|
+
nameEnd: tagName.lastIndex,
|
|
43
|
+
end: -1,
|
|
44
|
+
attributes: [],
|
|
45
|
+
};
|
|
46
|
+
let position = tag.nameEnd;
|
|
47
|
+
while (position < html.length && html[position] !== '>') {
|
|
48
|
+
attribute.lastIndex = position;
|
|
49
|
+
const found = attribute.exec(html);
|
|
50
|
+
if (!found) {
|
|
51
|
+
position += 1; // whitespace, `/` or a stray quote
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
tag.attributes.push({
|
|
55
|
+
name: found[1].toLowerCase(),
|
|
56
|
+
value: found[2] ?? found[3] ?? found[4],
|
|
57
|
+
start: position,
|
|
58
|
+
end: attribute.lastIndex,
|
|
59
|
+
});
|
|
60
|
+
position = attribute.lastIndex;
|
|
61
|
+
}
|
|
62
|
+
if (position >= html.length) {
|
|
63
|
+
break; // the tag never closes
|
|
64
|
+
}
|
|
65
|
+
tag.end = position + 1;
|
|
66
|
+
tags.push(tag);
|
|
67
|
+
index = tag.end;
|
|
68
|
+
if (RAW_TEXT.has(tag.name)) {
|
|
69
|
+
const close = lower.indexOf(`</${tag.name}`, index);
|
|
70
|
+
index = close === -1 ? html.length : close;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return tags;
|
|
74
|
+
}
|
|
75
|
+
/** Applies edits whose offsets all refer to the original text. */
|
|
76
|
+
function applyEdits(text, edits) {
|
|
77
|
+
let out = '';
|
|
78
|
+
let cursor = 0;
|
|
79
|
+
// The sort is stable, so insertions at the same offset keep their order.
|
|
80
|
+
for (const edit of [...edits].sort((a, b) => a.start - b.start)) {
|
|
81
|
+
out += text.slice(cursor, edit.start) + edit.text;
|
|
82
|
+
cursor = edit.end;
|
|
83
|
+
}
|
|
84
|
+
return out + text.slice(cursor);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Plans `z-root` on `<html>` and `<body>`, `lang="de"` when `<html>` has no
|
|
88
|
+
* `lang`, and, when `scriptLines` is given, that block right after
|
|
89
|
+
* `<meta charset>` or else as the first child of `<head>`.
|
|
90
|
+
*/
|
|
91
|
+
function planIndexHtml(html, scriptLines) {
|
|
92
|
+
const tags = openingTags(html);
|
|
93
|
+
const find = (name) => tags.find((tag) => tag.name === name);
|
|
94
|
+
const plan = { edits: [], missing: [], lang: undefined };
|
|
95
|
+
const root = find('html');
|
|
96
|
+
if (root) {
|
|
97
|
+
const lang = root.attributes.find((attribute) => attribute.name === 'lang');
|
|
98
|
+
plan.lang = lang ? (lang.value ?? '') : undefined;
|
|
99
|
+
if (!lang) {
|
|
100
|
+
plan.edits.push({ start: root.nameEnd, end: root.nameEnd, text: ' lang="de"' });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
for (const [label, tag] of [
|
|
104
|
+
['<html>', root],
|
|
105
|
+
['<body>', find('body')],
|
|
106
|
+
]) {
|
|
107
|
+
if (tag) {
|
|
108
|
+
plan.edits.push(...classEdit(tag));
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
plan.missing.push(label);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (scriptLines) {
|
|
115
|
+
const head = find('head');
|
|
116
|
+
const charset = tags.find((tag) => tag.name === 'meta' &&
|
|
117
|
+
tag.attributes.some(({ name, value }) => name === 'charset' ||
|
|
118
|
+
(name === 'http-equiv' && value?.toLowerCase() === 'content-type')));
|
|
119
|
+
const anchor = head && charset && charset.start > head.start ? charset : head;
|
|
120
|
+
if (anchor) {
|
|
121
|
+
const lineStart = html.lastIndexOf('\n', anchor.start) + 1;
|
|
122
|
+
const before = html.slice(lineStart, anchor.start);
|
|
123
|
+
const indent = (/^\s*$/.test(before) ? before : '') + (anchor === head ? ' ' : '');
|
|
124
|
+
const eol = (0, eol_1.getEOL)(html);
|
|
125
|
+
plan.edits.push({
|
|
126
|
+
start: anchor.end,
|
|
127
|
+
end: anchor.end,
|
|
128
|
+
text: scriptLines.map((line) => `${eol}${indent}${line}`).join(''),
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
plan.missing.push('<head>');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return plan;
|
|
136
|
+
}
|
|
137
|
+
/** Merges `z-root` into the class list of a tag, whatever the quoting. */
|
|
138
|
+
function classEdit(tag) {
|
|
139
|
+
const existing = tag.attributes.find((attribute) => attribute.name === 'class');
|
|
140
|
+
if (!existing) {
|
|
141
|
+
const at = tag.attributes.at(-1)?.end ?? tag.nameEnd;
|
|
142
|
+
return [{ start: at, end: at, text: ' class="z-root"' }];
|
|
143
|
+
}
|
|
144
|
+
const classes = (existing.value ?? '').split(/\s+/).filter(Boolean);
|
|
145
|
+
if (classes.includes('z-root')) {
|
|
146
|
+
return [];
|
|
147
|
+
}
|
|
148
|
+
const value = [...classes, 'z-root'].join(' ');
|
|
149
|
+
const quote = value.includes('"') ? "'" : '"';
|
|
150
|
+
return [{ start: existing.start, end: existing.end, text: `class=${quote}${value}${quote}` }];
|
|
151
|
+
}
|