urfu-ui-kit-vanilla 2.2.3 → 2.3.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 CHANGED
@@ -1,5 +1,5 @@
1
- Documentation: https://uikit.my1.urfu.ru
2
-
3
- ## License
4
-
1
+ Documentation: https://uikit.my1.urfu.ru
2
+
3
+ ## License
4
+
5
5
  This project is licensed under the Apache License 2.0 — see the [LICENSE](./LICENSE) file for details.
package/main.js ADDED
@@ -0,0 +1,357 @@
1
+ // UrFU UI-Kit Vanilla - Основной файл
2
+ // Автоматически подключает CSS и добавляет поддержку динамических утилит
3
+ //
4
+ // Использование в HTML:
5
+ // <script src="node_modules/urfu-ui-kit-vanilla/main.js"></script>
6
+ //
7
+ // Использование в TypeScript/JavaScript:
8
+ // import 'urfu-ui-kit-vanilla/main.js';
9
+ // или
10
+ // require('urfu-ui-kit-vanilla/main.js');
11
+
12
+ (function() {
13
+ 'use strict';
14
+
15
+ // Автоматически подключаем CSS
16
+ function loadCSS() {
17
+ // Определяем путь к CSS относительно текущего скрипта
18
+ const currentScript = document.currentScript;
19
+ let cssPath = 'node_modules/urfu-ui-kit-vanilla/src/main.css';
20
+
21
+ if (currentScript) {
22
+ const scriptPath = currentScript.src;
23
+ const scriptDir = scriptPath.substring(0, scriptPath.lastIndexOf('/'));
24
+ cssPath = scriptDir + '/src/main.css';
25
+ }
26
+
27
+ const link = document.createElement('link');
28
+ link.rel = 'stylesheet';
29
+ link.href = cssPath;
30
+ link.id = 'urfu-ui-kit-css';
31
+
32
+ // Проверяем, не подключен ли уже CSS
33
+ if (!document.getElementById('urfu-ui-kit-css')) {
34
+ document.head.appendChild(link);
35
+ }
36
+ }
37
+
38
+ // Подключаем CSS при загрузке
39
+ if (document.readyState === 'loading') {
40
+ document.addEventListener('DOMContentLoaded', loadCSS);
41
+ } else {
42
+ loadCSS();
43
+ }
44
+
45
+ // Кэш для уже созданных стилей
46
+ const styleCache = new Set();
47
+
48
+ // Функция для создания CSS-правила
49
+ function createStyle(selector, property, value) {
50
+ const rule = `${selector} { ${property}: ${value}; }`;
51
+ if (styleCache.has(rule)) return;
52
+
53
+ styleCache.add(rule);
54
+
55
+ // Создаем или находим элемент style
56
+ let styleElement = document.getElementById('dynamic-utils-styles');
57
+ if (!styleElement) {
58
+ styleElement = document.createElement('style');
59
+ styleElement.id = 'dynamic-utils-styles';
60
+ document.head.appendChild(styleElement);
61
+ }
62
+
63
+ // Добавляем правило
64
+ styleElement.textContent += rule + '\n';
65
+ }
66
+
67
+ // Функция для парсинга классов и создания стилей
68
+ function processElement(element) {
69
+ const classList = Array.from(element.classList);
70
+
71
+ classList.forEach(className => {
72
+ // Проверяем паттерны для margin
73
+ const marginMatch = className.match(/^um([lrtb]?)(\d+)$/);
74
+ if (marginMatch) {
75
+ const [, direction, value] = marginMatch;
76
+ const pxValue = value + 'px';
77
+
78
+ switch (direction) {
79
+ case 'l':
80
+ createStyle(`.${className}`, 'margin-left', pxValue);
81
+ break;
82
+ case 'r':
83
+ createStyle(`.${className}`, 'margin-right', pxValue);
84
+ break;
85
+ case 't':
86
+ createStyle(`.${className}`, 'margin-top', pxValue);
87
+ break;
88
+ case 'b':
89
+ createStyle(`.${className}`, 'margin-bottom', pxValue);
90
+ break;
91
+ default:
92
+ createStyle(`.${className}`, 'margin', pxValue);
93
+ break;
94
+ }
95
+ }
96
+
97
+ // Проверяем паттерны для padding
98
+ const paddingMatch = className.match(/^up([lrtb]?)(\d+)$/);
99
+ if (paddingMatch) {
100
+ const [, direction, value] = paddingMatch;
101
+ const pxValue = value + 'px';
102
+
103
+ switch (direction) {
104
+ case 'l':
105
+ createStyle(`.${className}`, 'padding-left', pxValue);
106
+ break;
107
+ case 'r':
108
+ createStyle(`.${className}`, 'padding-right', pxValue);
109
+ break;
110
+ case 't':
111
+ createStyle(`.${className}`, 'padding-top', pxValue);
112
+ break;
113
+ case 'b':
114
+ createStyle(`.${className}`, 'padding-bottom', pxValue);
115
+ break;
116
+ default:
117
+ createStyle(`.${className}`, 'padding', pxValue);
118
+ break;
119
+ }
120
+ }
121
+
122
+ // Проверяем паттерны для width/height
123
+ const sizeMatch = className.match(/^u([wh])(\d+)$/);
124
+ if (sizeMatch) {
125
+ const [, property, value] = sizeMatch;
126
+ const pxValue = value + 'px';
127
+
128
+ if (property === 'w') {
129
+ createStyle(`.${className}`, 'width', pxValue);
130
+ } else if (property === 'h') {
131
+ createStyle(`.${className}`, 'height', pxValue);
132
+ }
133
+ }
134
+
135
+ // Проверяем паттерны для font-size
136
+ const fontSizeMatch = className.match(/^ufos(\d+)$/);
137
+ if (fontSizeMatch) {
138
+ const [, value] = fontSizeMatch;
139
+ const pxValue = value + 'px';
140
+ createStyle(`.${className}`, 'font-size', pxValue);
141
+ }
142
+
143
+ // Проверяем паттерны для gap
144
+ const gapMatch = className.match(/^ug(\d+)$/);
145
+ if (gapMatch) {
146
+ const [, value] = gapMatch;
147
+ const pxValue = value + 'px';
148
+ createStyle(`.${className}`, 'gap', pxValue);
149
+ }
150
+
151
+ // Проверяем паттерны для column-gap
152
+ const columnGapMatch = className.match(/^ucg(\d+)$/);
153
+ if (columnGapMatch) {
154
+ const [, value] = columnGapMatch;
155
+ const pxValue = value + 'px';
156
+ createStyle(`.${className}`, 'column-gap', pxValue);
157
+ }
158
+
159
+ // Проверяем паттерны для row-gap
160
+ const rowGapMatch = className.match(/^urg(\d+)$/);
161
+ if (rowGapMatch) {
162
+ const [, value] = rowGapMatch;
163
+ const pxValue = value + 'px';
164
+ createStyle(`.${className}`, 'row-gap', pxValue);
165
+ }
166
+
167
+ // Проверяем паттерны для min-width
168
+ const minWidthMatch = className.match(/^umnw(\d+)$/);
169
+ if (minWidthMatch) {
170
+ const [, value] = minWidthMatch;
171
+ const pxValue = value + 'px';
172
+ createStyle(`.${className}`, 'min-width', pxValue);
173
+ }
174
+
175
+ // Проверяем паттерны для min-height
176
+ const minHeightMatch = className.match(/^umnh(\d+)$/);
177
+ if (minHeightMatch) {
178
+ const [, value] = minHeightMatch;
179
+ const pxValue = value + 'px';
180
+ createStyle(`.${className}`, 'min-height', pxValue);
181
+ }
182
+
183
+ // Проверяем паттерны для max-width
184
+ const maxWidthMatch = className.match(/^umxw(\d+)$/);
185
+ if (maxWidthMatch) {
186
+ const [, value] = maxWidthMatch;
187
+ const pxValue = value + 'px';
188
+ createStyle(`.${className}`, 'max-width', pxValue);
189
+ }
190
+
191
+ // Проверяем паттерны для max-height
192
+ const maxHeightMatch = className.match(/^umxh(\d+)$/);
193
+ if (maxHeightMatch) {
194
+ const [, value] = maxHeightMatch;
195
+ const pxValue = value + 'px';
196
+ createStyle(`.${className}`, 'max-height', pxValue);
197
+ }
198
+
199
+ // Проверяем паттерны для line-height
200
+ const lineHeightMatch = className.match(/^ulh(\d+)$/);
201
+ if (lineHeightMatch) {
202
+ const [, value] = lineHeightMatch;
203
+ const pxValue = value + 'px';
204
+ createStyle(`.${className}`, 'line-height', pxValue);
205
+ }
206
+
207
+ // Проверяем паттерны для border-width
208
+ const borderWidthMatch = className.match(/^ub(\d+)$/);
209
+ if (borderWidthMatch) {
210
+ const [, value] = borderWidthMatch;
211
+ const pxValue = value + 'px';
212
+ createStyle(`.${className}`, 'border-width', pxValue);
213
+ createStyle(`.${className}`, 'border-style', 'solid');
214
+ }
215
+
216
+ // Проверяем паттерны для border-radius
217
+ const borderRadiusMatch = className.match(/^ubr(\d+)$/);
218
+ if (borderRadiusMatch) {
219
+ const [, value] = borderRadiusMatch;
220
+ const pxValue = value + 'px';
221
+ createStyle(`.${className}`, 'border-radius', pxValue);
222
+ }
223
+
224
+ // Проверяем паттерны для opacity
225
+ const opacityMatch = className.match(/^uop(\d+)$/);
226
+ if (opacityMatch) {
227
+ const [, value] = opacityMatch;
228
+ const opacityValue = (parseInt(value) / 100).toString();
229
+ createStyle(`.${className}`, 'opacity', opacityValue);
230
+ }
231
+
232
+ // Проверяем паттерны для z-index
233
+ const zIndexMatch = className.match(/^uzi(\d+)$/);
234
+ if (zIndexMatch) {
235
+ const [, value] = zIndexMatch;
236
+ createStyle(`.${className}`, 'z-index', value);
237
+ }
238
+
239
+ // Проверяем паттерны для top
240
+ const topMatch = className.match(/^utop(\d+)$/);
241
+ if (topMatch) {
242
+ const [, value] = topMatch;
243
+ const pxValue = value + 'px';
244
+ createStyle(`.${className}`, 'top', pxValue);
245
+ }
246
+
247
+ // Проверяем паттерны для right
248
+ const rightMatch = className.match(/^uright(\d+)$/);
249
+ if (rightMatch) {
250
+ const [, value] = rightMatch;
251
+ const pxValue = value + 'px';
252
+ createStyle(`.${className}`, 'right', pxValue);
253
+ }
254
+
255
+ // Проверяем паттерны для bottom
256
+ const bottomMatch = className.match(/^ubottom(\d+)$/);
257
+ if (bottomMatch) {
258
+ const [, value] = bottomMatch;
259
+ const pxValue = value + 'px';
260
+ createStyle(`.${className}`, 'bottom', pxValue);
261
+ }
262
+
263
+ // Проверяем паттерны для left
264
+ const leftMatch = className.match(/^uleft(\d+)$/);
265
+ if (leftMatch) {
266
+ const [, value] = leftMatch;
267
+ const pxValue = value + 'px';
268
+ createStyle(`.${className}`, 'left', pxValue);
269
+ }
270
+
271
+ // Проверяем паттерны для flex-grow
272
+ const flexGrowMatch = className.match(/^ufg(\d+)$/);
273
+ if (flexGrowMatch) {
274
+ const [, value] = flexGrowMatch;
275
+ createStyle(`.${className}`, 'flex-grow', value);
276
+ }
277
+
278
+ // Проверяем паттерны для flex-shrink
279
+ const flexShrinkMatch = className.match(/^ufs(\d+)$/);
280
+ if (flexShrinkMatch) {
281
+ const [, value] = flexShrinkMatch;
282
+ createStyle(`.${className}`, 'flex-shrink', value);
283
+ }
284
+
285
+ // Проверяем паттерны для flex-basis
286
+ const flexBasisMatch = className.match(/^ufb(\d+)$/);
287
+ if (flexBasisMatch) {
288
+ const [, value] = flexBasisMatch;
289
+ const pxValue = value + 'px';
290
+ createStyle(`.${className}`, 'flex-basis', pxValue);
291
+ }
292
+
293
+ // Проверяем паттерны для order
294
+ const orderMatch = className.match(/^uo(\d+)$/);
295
+ if (orderMatch) {
296
+ const [, value] = orderMatch;
297
+ createStyle(`.${className}`, 'order', value);
298
+ }
299
+
300
+ // Проверяем паттерны для grid-template-columns
301
+ const gridColsMatch = className.match(/^ugtc(\d+)$/);
302
+ if (gridColsMatch) {
303
+ const [, value] = gridColsMatch;
304
+ const gridValue = `repeat(${value}, 1fr)`;
305
+ createStyle(`.${className}`, 'grid-template-columns', gridValue);
306
+ }
307
+
308
+ // Проверяем паттерны для grid-template-rows
309
+ const gridRowsMatch = className.match(/^ugtr(\d+)$/);
310
+ if (gridRowsMatch) {
311
+ const [, value] = gridRowsMatch;
312
+ const gridValue = `repeat(${value}, 1fr)`;
313
+ createStyle(`.${className}`, 'grid-template-rows', gridValue);
314
+ }
315
+ });
316
+ }
317
+
318
+ // Функция для обработки всех элементов на странице
319
+ function processAllElements() {
320
+ const allElements = document.querySelectorAll('*');
321
+ allElements.forEach(processElement);
322
+ }
323
+
324
+ // Обработка новых элементов при изменении DOM
325
+ const observer = new MutationObserver(function(mutations) {
326
+ mutations.forEach(function(mutation) {
327
+ mutation.addedNodes.forEach(function(node) {
328
+ if (node.nodeType === 1) { // Element node
329
+ processElement(node);
330
+ // Обрабатываем также дочерние элементы
331
+ const children = node.querySelectorAll('*');
332
+ children.forEach(processElement);
333
+ }
334
+ });
335
+ });
336
+ });
337
+
338
+ // Запуск при загрузке страницы
339
+ if (document.readyState === 'loading') {
340
+ document.addEventListener('DOMContentLoaded', processAllElements);
341
+ } else {
342
+ processAllElements();
343
+ }
344
+
345
+ // Наблюдение за изменениями DOM
346
+ observer.observe(document.body, {
347
+ childList: true,
348
+ subtree: true
349
+ });
350
+
351
+ // Экспорт для ручного вызова
352
+ window.dynamicUtils = {
353
+ processAll: processAllElements,
354
+ processElement: processElement
355
+ };
356
+
357
+ })();
package/package.json CHANGED
@@ -1,29 +1,31 @@
1
- {
2
- "name": "urfu-ui-kit-vanilla",
3
- "description": "UrFU UI-Kit for Vanilla Web",
4
- "license": "Apache-2.0",
5
- "private": false,
6
- "version": "2.2.3",
7
- "type": "module",
8
- "scripts": {
9
- "start": "npm-run-all --parallel less:watch vite",
10
- "build": "vite build && copy LICENSE dist\\",
11
- "less:watch": "chokidar \"src/**/*.less\" -c \"npx lessc src/main.less src/main.css\"",
12
- "vite": "vite"
13
- },
14
- "devDependencies": {
15
- "@types/node": "^18.15.11",
16
- "chokidar-cli": "^3.0.0",
17
- "less": "^4.1.3",
18
- "npm-run-all": "^4.1.5",
19
- "typescript": "^4.9.3",
20
- "vite": "^4.2.0"
21
- },
22
- "files": [
23
- "src/main.ts",
24
- "src/main.d.ts",
25
- "src/main.css",
26
- "src/ui-icons.css",
27
- "src/fonts/*"
28
- ]
29
- }
1
+ {
2
+ "name": "urfu-ui-kit-vanilla",
3
+ "description": "UrFU UI-Kit for Vanilla Web",
4
+ "license": "Apache-2.0",
5
+ "private": false,
6
+ "version": "2.3.0",
7
+ "type": "module",
8
+ "scripts": {
9
+ "start": "npm-run-all --parallel less:watch vite",
10
+ "build": "npx lessc src/main.less src/main.css && vite build && copy LICENSE dist\\",
11
+ "build:css": "npx lessc src/main.less src/main.css",
12
+ "less:watch": "chokidar \"src/**/*.less\" -c \"npx lessc src/main.less src/main.css\"",
13
+ "vite": "vite",
14
+ "prepublishOnly": "npm run build:css"
15
+ },
16
+ "devDependencies": {
17
+ "@types/node": "^18.15.11",
18
+ "chokidar-cli": "^3.0.0",
19
+ "less": "^4.1.3",
20
+ "npm-run-all": "^4.1.5",
21
+ "typescript": "^4.9.3",
22
+ "vite": "^4.2.0"
23
+ },
24
+ "files": [
25
+ "src/main.css",
26
+ "src/ui-icons.css",
27
+ "src/fonts/*",
28
+ "main.js",
29
+ "LICENSE"
30
+ ]
31
+ }