@maggioli-design-system/mds-table-row 4.4.3 → 4.5.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/dist/cjs/mds-table-row.cjs.entry.js +1 -1
- package/dist/cjs/mds-table-row.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/common/file.js +48 -0
- package/dist/collection/common/icon.js +15 -0
- package/dist/collection/common/keyboard-manager.js +16 -11
- package/dist/collection/common/unit.js +15 -3
- package/dist/collection/common/yugop/core.js +16 -0
- package/dist/collection/common/yugop/index.js +3 -0
- package/dist/collection/common/yugop/random-text.js +59 -0
- package/dist/collection/common/yugop/utils/math.js +11 -0
- package/dist/collection/common/yugop/utils/noop.js +1 -0
- package/dist/collection/common/yugop/utils/prng.js +21 -0
- package/dist/collection/common/yugop/utils/string.js +2 -0
- package/dist/collection/components/mds-table-row/mds-table-row.css +144 -0
- package/dist/collection/dictionary/file-extensions.js +64 -0
- package/dist/collection/dictionary/icon.js +6 -1
- package/dist/collection/dictionary/text.js +6 -0
- package/dist/collection/dictionary/variant.js +18 -1
- package/dist/collection/fixtures/filenames.js +57 -0
- package/dist/collection/type/file-types.js +1 -0
- package/dist/collection/type/text.js +1 -0
- package/dist/collection/type/variant-file-format.js +111 -0
- package/dist/components/mds-table-row.js +1 -1
- package/dist/documentation.json +3 -3
- package/dist/esm/mds-table-row.entry.js +1 -1
- package/dist/esm/mds-table-row.js +1 -1
- package/dist/esm-es5/mds-table-row.entry.js +1 -1
- package/dist/mds-table-row/mds-table-row.esm.js +1 -1
- package/dist/mds-table-row/mds-table-row.js +1 -1
- package/{www/build/p-fe4b1f1b.system.js → dist/mds-table-row/p-65fbbba9.system.js} +1 -1
- package/dist/mds-table-row/p-ab9fb13e.entry.js +1 -0
- package/dist/mds-table-row/p-f8b0aa6b.system.entry.js +1 -0
- package/dist/stats.json +57 -18
- package/dist/types/common/file.d.ts +12 -0
- package/dist/types/common/icon.d.ts +5 -0
- package/dist/types/common/keyboard-manager.d.ts +2 -1
- package/dist/types/common/unit.d.ts +2 -1
- package/dist/types/common/yugop/core.d.ts +10 -0
- package/dist/types/common/yugop/index.d.ts +1 -0
- package/dist/types/common/yugop/random-text.d.ts +31 -0
- package/dist/types/common/yugop/utils/math.d.ts +3 -0
- package/dist/types/common/yugop/utils/noop.d.ts +1 -0
- package/dist/types/common/yugop/utils/prng.d.ts +8 -0
- package/dist/types/common/yugop/utils/string.d.ts +1 -0
- package/dist/types/dictionary/file-extensions.d.ts +11 -0
- package/dist/types/dictionary/icon.d.ts +2 -1
- package/dist/types/dictionary/text.d.ts +2 -0
- package/dist/types/dictionary/variant.d.ts +2 -1
- package/dist/types/fixtures/filenames.d.ts +2 -0
- package/dist/types/type/file-types.d.ts +1 -0
- package/dist/types/type/text.d.ts +1 -0
- package/dist/types/type/variant-file-format.d.ts +11 -0
- package/dist/types/type/variant.d.ts +1 -0
- package/documentation.json +55 -15
- package/package.json +4 -4
- package/src/common/file.ts +63 -0
- package/src/common/icon.ts +25 -0
- package/src/common/keyboard-manager.ts +16 -12
- package/src/common/unit.ts +21 -2
- package/src/common/yugop/core.ts +47 -0
- package/src/common/yugop/index.ts +4 -0
- package/src/common/yugop/random-text.ts +95 -0
- package/src/common/yugop/utils/math.ts +21 -0
- package/src/common/yugop/utils/noop.ts +1 -0
- package/src/common/yugop/utils/prng.ts +35 -0
- package/src/common/yugop/utils/string.ts +4 -0
- package/src/dictionary/file-extensions.ts +81 -0
- package/src/dictionary/icon.ts +6 -0
- package/src/dictionary/text.ts +9 -0
- package/src/dictionary/variant.ts +19 -0
- package/src/fixtures/filenames.ts +60 -0
- package/src/fixtures/icons.json +11 -0
- package/src/fixtures/iconsauce.json +4 -0
- package/src/type/file-types.ts +55 -0
- package/src/type/text.ts +4 -0
- package/src/type/variant-file-format.ts +128 -0
- package/src/type/variant.ts +17 -0
- package/www/build/mds-table-row.esm.js +1 -1
- package/www/build/mds-table-row.js +1 -1
- package/{dist/mds-table-row/p-fe4b1f1b.system.js → www/build/p-65fbbba9.system.js} +1 -1
- package/www/build/p-ab9fb13e.entry.js +1 -0
- package/www/build/p-f8b0aa6b.system.entry.js +1 -0
- package/dist/mds-table-row/p-0f958c61.entry.js +0 -1
- package/dist/mds-table-row/p-8da35bc4.system.entry.js +0 -1
- package/www/build/p-0f958c61.entry.js +0 -1
- package/www/build/p-8da35bc4.system.entry.js +0 -1
package/documentation.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"timestamp": "2024-
|
|
2
|
+
"timestamp": "2024-02-19T11:09:01",
|
|
3
3
|
"compiler": {
|
|
4
4
|
"name": "@stencil/core",
|
|
5
|
-
"version": "4.
|
|
6
|
-
"typescriptVersion": "5.
|
|
5
|
+
"version": "4.10.0",
|
|
6
|
+
"typescriptVersion": "5.3.3"
|
|
7
7
|
},
|
|
8
8
|
"components": [
|
|
9
9
|
{
|
|
@@ -86,6 +86,16 @@
|
|
|
86
86
|
"docstring": "",
|
|
87
87
|
"path": "src/components/mds-accordion-timer-item/meta/event-detail.ts"
|
|
88
88
|
},
|
|
89
|
+
"src/type/variant.ts::ToneMinimalVariantType": {
|
|
90
|
+
"declaration": "export type ToneMinimalVariantType =\n| 'strong'\n| 'weak'",
|
|
91
|
+
"docstring": "",
|
|
92
|
+
"path": "src/type/variant.ts"
|
|
93
|
+
},
|
|
94
|
+
"src/type/variant.ts::ThemeFullVariantAvatarType": {
|
|
95
|
+
"declaration": "export type ThemeFullVariantAvatarType =\n | 'amaranth'\n | 'aqua'\n | 'blue'\n | 'error'\n | 'green'\n | 'info'\n | 'lime'\n | 'orange'\n | 'orchid'\n | 'primary'\n | 'sky'\n | 'success'\n | 'violet'\n | 'warning'\n | 'yellow'",
|
|
96
|
+
"docstring": "",
|
|
97
|
+
"path": "src/type/variant.ts"
|
|
98
|
+
},
|
|
89
99
|
"src/type/variant.ts::ThemeFullVariantType": {
|
|
90
100
|
"declaration": "export type ThemeFullVariantType =\n | 'amaranth'\n | 'aqua'\n | 'blue'\n | 'dark'\n | 'error'\n | 'green'\n | 'info'\n | 'light'\n | 'lime'\n | 'orange'\n | 'orchid'\n | 'sky'\n | 'success'\n | 'violet'\n | 'warning'\n | 'yellow'",
|
|
91
101
|
"docstring": "",
|
|
@@ -191,16 +201,26 @@
|
|
|
191
201
|
"docstring": "",
|
|
192
202
|
"path": "src/components/mds-dropdown/meta/event-detail.ts"
|
|
193
203
|
},
|
|
194
|
-
"src/
|
|
195
|
-
"declaration": "export type ExtensionSuffixType =\n | '7z'\n | 'ace'\n | 'ai'\n | 'db'\n | 'default'\n | 'dmg'\n | 'doc'\n | 'docm'\n | 'docx'\n | 'eml'\n | 'eps'\n | 'exe'\n | 'flac'\n | 'gif'\n | 'htm'\n | 'html'\n | 'jpe'\n | 'jpeg'\n | 'jpg'\n | 'js'\n | 'json'\n | 'jsx'\n | 'm2v'\n | 'mp2'\n | 'mp3'\n | 'mp4'\n | 'mp4v'\n | 'mpeg'\n | 'mpg'\n | 'mpg4'\n | 'mpga'\n | 'odp'\n | 'ods'\n | 'odt'\n | 'pdf'\n | 'php'\n | 'png'\n | 'ppt'\n | 'rar'\n | 'rtf'\n | 'sass'\n | 'shtml'\n | 'svg'\n | 'tar'\n | 'ts'\n | 'txt'\n | 'wav'\n | 'xar'\n | 'xls'\n | 'xlsx'\n | 'zip'",
|
|
204
|
+
"src/type/file-types.ts::ExtensionSuffixType": {
|
|
205
|
+
"declaration": "export type ExtensionSuffixType =\n | '7z'\n | 'ace'\n | 'ai'\n | 'db'\n | 'default'\n | 'dmg'\n | 'doc'\n | 'docm'\n | 'docx'\n | 'eml'\n | 'eps'\n | 'exe'\n | 'flac'\n | 'gif'\n | 'heic'\n | 'htm'\n | 'html'\n | 'jpe'\n | 'jpeg'\n | 'jpg'\n | 'js'\n | 'json'\n | 'jsx'\n | 'm2v'\n | 'mp2'\n | 'mp3'\n | 'mp4'\n | 'mp4v'\n | 'mpeg'\n | 'mpg'\n | 'mpg4'\n | 'mpga'\n | 'odp'\n | 'ods'\n | 'odt'\n | 'pdf'\n | 'php'\n | 'png'\n | 'ppt'\n | 'rar'\n | 'rtf'\n | 'sass'\n | 'shtml'\n | 'svg'\n | 'tar'\n | 'tiff'\n | 'ts'\n | 'txt'\n | 'wav'\n | 'webp'\n | 'xar'\n | 'xls'\n | 'xlsx'\n | 'zip'",
|
|
196
206
|
"docstring": "",
|
|
197
|
-
"path": "src/
|
|
207
|
+
"path": "src/type/file-types.ts"
|
|
198
208
|
},
|
|
199
209
|
"src/components/mds-file/meta/event-detail.ts::MdsFileEventDetail": {
|
|
200
210
|
"declaration": "export interface MdsFileEventDetail {\n description: string\n extension: string\n filename: string\n target: HTMLMdsFileElement\n type: string\n}",
|
|
201
211
|
"docstring": "",
|
|
202
212
|
"path": "src/components/mds-file/meta/event-detail.ts"
|
|
203
213
|
},
|
|
214
|
+
"src/type/text.ts::TypographyTruncateType": {
|
|
215
|
+
"declaration": "export type TypographyTruncateType =\n | 'all'\n | 'none'\n | 'word'",
|
|
216
|
+
"docstring": "",
|
|
217
|
+
"path": "src/type/text.ts"
|
|
218
|
+
},
|
|
219
|
+
"src/components/mds-file-preview/meta/event-detail.ts::MdsFilePreviewEventDetail": {
|
|
220
|
+
"declaration": "export interface MdsFilePreviewEventDetail {\n extension: string\n filename: string\n target: HTMLMdsFileElement\n}",
|
|
221
|
+
"docstring": "",
|
|
222
|
+
"path": "src/components/mds-file-preview/meta/event-detail.ts"
|
|
223
|
+
},
|
|
204
224
|
"src/components/mds-filter/meta/event-detail.ts::MdsFilterEventDetail": {
|
|
205
225
|
"declaration": "export interface MdsFilterEventDetail {\n children: NodeListOf<HTMLMdsFilterItemElement>\n value: string\n}",
|
|
206
226
|
"docstring": "",
|
|
@@ -241,6 +261,11 @@
|
|
|
241
261
|
"docstring": "",
|
|
242
262
|
"path": "src/components/mds-header/meta/event-detail.ts"
|
|
243
263
|
},
|
|
264
|
+
"src/components/mds-horizontal-scroll/meta/types.ts::ViewportType": {
|
|
265
|
+
"declaration": "export type ViewportType =\n | 'all'\n | 'tv'\n | 'xlarge'\n | 'large'\n | 'wide'\n | 'desktop'\n | 'tablet'\n | 'none'",
|
|
266
|
+
"docstring": "",
|
|
267
|
+
"path": "src/components/mds-horizontal-scroll/meta/types.ts"
|
|
268
|
+
},
|
|
244
269
|
"src/components/mds-horizontal-scroll/meta/types.ts::SnapType": {
|
|
245
270
|
"declaration": "export type SnapType =\n | 'center'\n | 'end'\n | 'none'\n | 'start'",
|
|
246
271
|
"docstring": "",
|
|
@@ -331,10 +356,15 @@
|
|
|
331
356
|
"docstring": "",
|
|
332
357
|
"path": "src/components/mds-input-switch/meta/types.ts"
|
|
333
358
|
},
|
|
334
|
-
"src/
|
|
335
|
-
"declaration": "export
|
|
359
|
+
"src/components/mds-input-switch/meta/event-detail.ts::MdsInputSwitchEventDetail": {
|
|
360
|
+
"declaration": "export interface MdsInputSwitchEventDetail {\n name: string\n checked: boolean\n value: string\n}",
|
|
336
361
|
"docstring": "",
|
|
337
|
-
"path": "src/
|
|
362
|
+
"path": "src/components/mds-input-switch/meta/event-detail.ts"
|
|
363
|
+
},
|
|
364
|
+
"src/components/mds-input-upload/meta/types.ts::AttachmentSort": {
|
|
365
|
+
"declaration": "type AttachmentSort =\n 'status' |\n 'date'",
|
|
366
|
+
"docstring": "",
|
|
367
|
+
"path": "src/components/mds-input-upload/meta/types.ts"
|
|
338
368
|
},
|
|
339
369
|
"src/type/typography.ts::TypographyType": {
|
|
340
370
|
"declaration": "export type TypographyType =\n | 'action'\n | 'caption'\n | 'snippet'\n | 'detail'\n | 'h1'\n | 'h2'\n | 'h3'\n | 'h4'\n | 'h5'\n | 'h6'\n | 'hack'\n | 'label'\n | 'option'\n | 'paragraph'\n | 'tip'",
|
|
@@ -376,6 +406,11 @@
|
|
|
376
406
|
"docstring": "",
|
|
377
407
|
"path": "src/components/mds-progress/meta/types.ts"
|
|
378
408
|
},
|
|
409
|
+
"src/components/mds-push-notification/meta/types.ts::NotificationPreviewType": {
|
|
410
|
+
"declaration": "export type NotificationPreviewType =\n | 'avatar'\n | 'image'",
|
|
411
|
+
"docstring": "",
|
|
412
|
+
"path": "src/components/mds-push-notification/meta/types.ts"
|
|
413
|
+
},
|
|
379
414
|
"src/components/mds-stepper-bar/meta/event-detail.ts::MdsStepperBarEventDetail": {
|
|
380
415
|
"declaration": "export interface MdsStepperBarEventDetail {\n step: number\n value: string\n}",
|
|
381
416
|
"docstring": "",
|
|
@@ -387,7 +422,7 @@
|
|
|
387
422
|
"path": "src/components/mds-stepper-bar-item/meta/event-detail.ts"
|
|
388
423
|
},
|
|
389
424
|
"src/components/mds-tab/meta/event-detail.ts::MdsTabEventDetail": {
|
|
390
|
-
"declaration": "export interface MdsTabEventDetail {\n id: number\n}",
|
|
425
|
+
"declaration": "export interface MdsTabEventDetail {\n id: number\n value?: string\n}",
|
|
391
426
|
"docstring": "",
|
|
392
427
|
"path": "src/components/mds-tab/meta/event-detail.ts"
|
|
393
428
|
},
|
|
@@ -401,6 +436,16 @@
|
|
|
401
436
|
"docstring": "",
|
|
402
437
|
"path": "src/type/typography.ts"
|
|
403
438
|
},
|
|
439
|
+
"src/components/mds-tab-item/meta/event-detail.ts::MdsTabItemEventDetail": {
|
|
440
|
+
"declaration": "export interface MdsTabItemEventDetail {\n target: HTMLMdsTabItemElement\n value?: string\n}",
|
|
441
|
+
"docstring": "",
|
|
442
|
+
"path": "src/components/mds-tab-item/meta/event-detail.ts"
|
|
443
|
+
},
|
|
444
|
+
"src/components/mds-text/meta/types.ts::TextAnimationType": {
|
|
445
|
+
"declaration": "export type TextAnimationType =\n | 'none'\n | 'yugop'",
|
|
446
|
+
"docstring": "",
|
|
447
|
+
"path": "src/components/mds-text/meta/types.ts"
|
|
448
|
+
},
|
|
404
449
|
"src/components/mds-text/meta/types.ts::TypographyTagType": {
|
|
405
450
|
"declaration": "export type TypographyTagType =\n | 'abbr'\n | 'address'\n | 'article'\n | 'b'\n | 'bdo'\n | 'blockquote'\n | 'cite'\n | 'code'\n | 'dd'\n | 'del'\n | 'details'\n | 'dfn'\n | 'div'\n | 'dl'\n | 'dt'\n | 'em'\n | 'figcaption'\n | 'h1'\n | 'h2'\n | 'h3'\n | 'h4'\n | 'h5'\n | 'h6'\n | 'i'\n | 'ins'\n | 'kbd'\n | 'label'\n | 'legend'\n | 'li'\n | 'mark'\n | 'ol'\n | 'p'\n | 'pre'\n | 'q'\n | 'rb'\n | 'rt'\n | 'ruby'\n | 's'\n | 'samp'\n | 'small'\n | 'span'\n | 'strong'\n | 'sub'\n | 'summary'\n | 'sup'\n | 'time'\n | 'u'\n | 'ul'\n | 'var'",
|
|
406
451
|
"docstring": "",
|
|
@@ -411,11 +456,6 @@
|
|
|
411
456
|
"docstring": "",
|
|
412
457
|
"path": "src/type/variant.ts"
|
|
413
458
|
},
|
|
414
|
-
"src/type/variant.ts::ToneMinimalVariantType": {
|
|
415
|
-
"declaration": "export type ToneMinimalVariantType =\n| 'strong'\n| 'weak'",
|
|
416
|
-
"docstring": "",
|
|
417
|
-
"path": "src/type/variant.ts"
|
|
418
|
-
},
|
|
419
459
|
"src/components/mds-toast/meta/types.ts::ToastPosition": {
|
|
420
460
|
"declaration": "export type ToastPosition =\n | 'top-left'\n | 'top-center'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-center'\n | 'bottom-right'",
|
|
421
461
|
"docstring": "",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maggioli-design-system/mds-table-row",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.1",
|
|
4
4
|
"description": "mds-table-row is a web-component from Magma Design System, built with StencilJS, TypeScript, Storybook. It's based on the web-component standard and it's designed to be agnostic from the JavaScirpt framework you are using.",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"prepublishOnly": "npm run build"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@maggioli-design-system/mds-table-cell": "4.
|
|
27
|
-
"@maggioli-design-system/styles": "14.
|
|
28
|
-
"@stencil/core": "4.
|
|
26
|
+
"@maggioli-design-system/mds-table-cell": "4.5.0",
|
|
27
|
+
"@maggioli-design-system/styles": "14.2.2",
|
|
28
|
+
"@stencil/core": "4.10.0"
|
|
29
29
|
},
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"author": {
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { fileExtensionsDictionary, ExtensionInfo } from '@dictionary/file-extensions'
|
|
2
|
+
import { fileFormatsVariant } from '@type/variant-file-format'
|
|
3
|
+
|
|
4
|
+
interface FileFormatsVariants {
|
|
5
|
+
color: string
|
|
6
|
+
icon: string
|
|
7
|
+
iconBackground: string
|
|
8
|
+
variant: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const sanitizeFilename = (filename: string, error: string = 'Attribute "filename" is undefined.') => {
|
|
12
|
+
if (filename === undefined ) {
|
|
13
|
+
throw console.error(error)
|
|
14
|
+
}
|
|
15
|
+
if (filename.includes('/')) {
|
|
16
|
+
return filename.split('/').pop() ?? ''
|
|
17
|
+
}
|
|
18
|
+
return filename
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const sanitizeSuffix = (rawFilename: string) => {
|
|
22
|
+
const filename = sanitizeFilename(rawFilename)
|
|
23
|
+
if (filename.includes('.')) {
|
|
24
|
+
return filename.split('.').pop() ?? ''
|
|
25
|
+
}
|
|
26
|
+
return filename
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const getName = (rawFilename: string): string => {
|
|
30
|
+
const filename = sanitizeFilename(rawFilename)
|
|
31
|
+
if (filename.includes('.')) {
|
|
32
|
+
return filename.split('.')[0] ?? ''
|
|
33
|
+
}
|
|
34
|
+
return filename
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const getSuffix = (rawFilename: string, suffixOverride?: string): string => {
|
|
38
|
+
const suffix = sanitizeSuffix(rawFilename)
|
|
39
|
+
const filename = sanitizeFilename(rawFilename)
|
|
40
|
+
if (suffixOverride !== null && suffixOverride !== undefined) {
|
|
41
|
+
return suffixOverride.toLowerCase()
|
|
42
|
+
}
|
|
43
|
+
if (suffix !== filename) {
|
|
44
|
+
return suffix
|
|
45
|
+
}
|
|
46
|
+
return 'default'
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const getExtensionInfos = (rawFilename: string, suffixOverride?: string): ExtensionInfo => {
|
|
50
|
+
const suffix = getSuffix(rawFilename, suffixOverride).toLocaleLowerCase()
|
|
51
|
+
return fileExtensionsDictionary[suffix] ?? fileExtensionsDictionary.default
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const getFormatsVariant = (rawFilename: string, suffixOverride?: string): FileFormatsVariants => {
|
|
55
|
+
return fileFormatsVariant[getExtensionInfos(rawFilename, suffixOverride).format]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
getExtensionInfos,
|
|
60
|
+
getFormatsVariant,
|
|
61
|
+
getSuffix,
|
|
62
|
+
getName,
|
|
63
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const BASE64_SVG_ICON = 'data:image/svg+xml;base64,'
|
|
2
|
+
const MARKUP_SVG_ICON = '<svg '
|
|
3
|
+
|
|
4
|
+
const isIconFormatIsBase64 = (icon?: string): boolean => {
|
|
5
|
+
if (!icon) {
|
|
6
|
+
return false
|
|
7
|
+
}
|
|
8
|
+
return icon.startsWith(BASE64_SVG_ICON)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const isIconFormatIsSVG = (icon?: string): boolean => {
|
|
12
|
+
if (!icon) {
|
|
13
|
+
return false
|
|
14
|
+
}
|
|
15
|
+
return icon.startsWith(MARKUP_SVG_ICON)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
isIconFormatIsBase64,
|
|
22
|
+
isIconFormatIsSVG,
|
|
23
|
+
BASE64_SVG_ICON,
|
|
24
|
+
MARKUP_SVG_ICON,
|
|
25
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export class KeyboardManager {
|
|
2
2
|
private escapeCallback: () => void
|
|
3
|
-
private elements =
|
|
3
|
+
private elements = new Map<string, HTMLElement>()
|
|
4
4
|
|
|
5
5
|
private handleClickBehaviorDispatchEvent = (event: KeyboardEvent): void => {
|
|
6
|
-
if (event.code === '
|
|
6
|
+
if (event.code === 'Enter' || event.code === 'NumpadEnter') {
|
|
7
7
|
(event.target as HTMLElement).click()
|
|
8
8
|
}
|
|
9
9
|
}
|
|
@@ -15,30 +15,34 @@ export class KeyboardManager {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
addElement = (el: HTMLElement, name = 'element'): void => {
|
|
18
|
-
|
|
18
|
+
if (!el) {
|
|
19
|
+
throw Error(`Passed an ${el} element parameter to KeyboardManager.addElement`)
|
|
20
|
+
}
|
|
21
|
+
this.elements.set(name, el)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
removeElement = (name: string = 'element'): void => {
|
|
25
|
+
this.detachClickBehavior(name)
|
|
26
|
+
this.elements.delete(name)
|
|
19
27
|
}
|
|
20
28
|
|
|
21
29
|
attachClickBehavior = (name = 'element'): void => {
|
|
22
|
-
|
|
23
|
-
this.elements[name].addEventListener('keydown', this.handleClickBehaviorDispatchEvent)
|
|
24
|
-
}
|
|
30
|
+
this.elements.get(name)?.addEventListener('keydown', this.handleClickBehaviorDispatchEvent)
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
detachClickBehavior = (name = 'element'): void => {
|
|
28
|
-
|
|
29
|
-
this.elements[name].removeEventListener('keydown', this.handleClickBehaviorDispatchEvent)
|
|
30
|
-
}
|
|
34
|
+
this.elements.get(name)?.removeEventListener('keydown', this.handleClickBehaviorDispatchEvent)
|
|
31
35
|
}
|
|
32
36
|
|
|
33
|
-
attachEscapeBehavior = (
|
|
34
|
-
this.escapeCallback =
|
|
37
|
+
attachEscapeBehavior = (callback: () => void): void => {
|
|
38
|
+
this.escapeCallback = callback
|
|
35
39
|
if (window !== undefined) {
|
|
36
40
|
window.addEventListener('keydown', this.handleEscapeBehaviorDispatchEvent.bind(this))
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
detachEscapeBehavior = (): void => {
|
|
41
|
-
this.escapeCallback = () => {return}
|
|
45
|
+
this.escapeCallback = () => { return }
|
|
42
46
|
if (window !== undefined) {
|
|
43
47
|
window.removeEventListener('keydown', this.handleEscapeBehaviorDispatchEvent.bind(this))
|
|
44
48
|
}
|
package/src/common/unit.ts
CHANGED
|
@@ -1,14 +1,33 @@
|
|
|
1
1
|
const cssDurationToMilliseconds = (duration: string, defaultValue = 1000): number => {
|
|
2
|
+
|
|
3
|
+
if (duration.includes('ms')) {
|
|
4
|
+
return Number(duration.replace('ms', ''))
|
|
5
|
+
}
|
|
6
|
+
|
|
2
7
|
if (duration.includes('s')) {
|
|
3
8
|
return Number(duration.replace('s', '')) * 1000
|
|
4
9
|
}
|
|
5
10
|
|
|
6
|
-
|
|
7
|
-
|
|
11
|
+
return defaultValue
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const cssSizeToNumber = (size: string, defaultValue = 0): number => {
|
|
15
|
+
if (size.includes('px')) {
|
|
16
|
+
return Number(size.replace('px', ''))
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (size.includes('rem')) {
|
|
20
|
+
return Number(size.replace('rem', '')) * 16
|
|
8
21
|
}
|
|
9
22
|
|
|
23
|
+
if (size.includes('em')) {
|
|
24
|
+
return Number(size.replace('em', '')) * 16
|
|
25
|
+
}
|
|
26
|
+
|
|
10
27
|
return defaultValue
|
|
11
28
|
}
|
|
29
|
+
|
|
12
30
|
export {
|
|
13
31
|
cssDurationToMilliseconds,
|
|
32
|
+
cssSizeToNumber,
|
|
14
33
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { generator } from './utils/prng'
|
|
2
|
+
import { strToCharCodeArray } from './utils/string'
|
|
3
|
+
import { randomSign, minMaxLooped } from './utils/math'
|
|
4
|
+
const rand = generator()
|
|
5
|
+
|
|
6
|
+
const random: (arg0: number, arg1: number) => () => number = (
|
|
7
|
+
base,
|
|
8
|
+
offset,
|
|
9
|
+
) => () => (base + rand.range(0, offset)) * randomSign()
|
|
10
|
+
|
|
11
|
+
export const generateRandomCharCodeArray: (
|
|
12
|
+
arg0: number,
|
|
13
|
+
arg1: number
|
|
14
|
+
) => (arg0: string) => number[] = (base, offset) => str =>
|
|
15
|
+
strToCharCodeArray(str).map(random(base, offset))
|
|
16
|
+
type Options = {
|
|
17
|
+
str: string
|
|
18
|
+
minCharCode: number
|
|
19
|
+
maxCharCode: number
|
|
20
|
+
placeholderChar: string
|
|
21
|
+
charStep: number
|
|
22
|
+
}
|
|
23
|
+
export const charCodeArrayToString: (
|
|
24
|
+
arg0: Options
|
|
25
|
+
) => (arg0: number[]) => string = ({
|
|
26
|
+
str,
|
|
27
|
+
minCharCode,
|
|
28
|
+
maxCharCode,
|
|
29
|
+
placeholderChar,
|
|
30
|
+
charStep,
|
|
31
|
+
}) => charCodes =>
|
|
32
|
+
charCodes.reduce((acc, item, index) => {
|
|
33
|
+
if (item !== 0) {
|
|
34
|
+
if (Math.abs(item) > charStep) {
|
|
35
|
+
return acc + placeholderChar
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
acc +
|
|
40
|
+
String.fromCharCode(
|
|
41
|
+
minMaxLooped(minCharCode, maxCharCode)(str.charCodeAt(index) + item),
|
|
42
|
+
)
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return acc + str.charAt(index)
|
|
47
|
+
}, '')
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { generateRandomCharCodeArray, charCodeArrayToString } from './core'
|
|
2
|
+
import { noop } from './utils/noop'
|
|
3
|
+
|
|
4
|
+
type Options = {
|
|
5
|
+
str: string
|
|
6
|
+
speed?: number
|
|
7
|
+
placeholderChar?: string
|
|
8
|
+
frameOffset?: number
|
|
9
|
+
charOffset?: number
|
|
10
|
+
charStep?: number
|
|
11
|
+
minCharCode?: number
|
|
12
|
+
maxCharCode?: number
|
|
13
|
+
onProgress?: (arg0: string) => void
|
|
14
|
+
onComplete?: (arg0: string) => void
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
class RandomText {
|
|
18
|
+
static defaults: Options = {
|
|
19
|
+
str: '',
|
|
20
|
+
speed: 2,
|
|
21
|
+
placeholderChar: '_',
|
|
22
|
+
frameOffset: 30,
|
|
23
|
+
charOffset: 20,
|
|
24
|
+
charStep: 10,
|
|
25
|
+
minCharCode: 32,
|
|
26
|
+
maxCharCode: 122,
|
|
27
|
+
onProgress: noop,
|
|
28
|
+
onComplete: noop,
|
|
29
|
+
}
|
|
30
|
+
str: string
|
|
31
|
+
speed: number
|
|
32
|
+
placeholderChar: string
|
|
33
|
+
frameOffset: number
|
|
34
|
+
charOffset: number
|
|
35
|
+
charStep: number
|
|
36
|
+
minCharCode: number
|
|
37
|
+
maxCharCode: number
|
|
38
|
+
onProgress: (...args: Array<string>) => string
|
|
39
|
+
onComplete: (...args: Array<string>) => string
|
|
40
|
+
rafId: number // TODO: should be #rafId for private
|
|
41
|
+
|
|
42
|
+
constructor (options: Options) {
|
|
43
|
+
Object.assign(this, { ...RandomText.defaults, ...options })
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
start = (): void => {
|
|
47
|
+
const { frameOffset, charOffset, str, speed } = this
|
|
48
|
+
const randoms = generateRandomCharCodeArray(frameOffset, charOffset)(str)
|
|
49
|
+
this.stop()
|
|
50
|
+
this.rafId = requestAnimationFrame(() => {
|
|
51
|
+
this.step(randoms, speed, speed)
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
stop (): void {
|
|
56
|
+
cancelAnimationFrame(this.rafId)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
step (randoms: number[], stepCount: number, speed: number): void {
|
|
60
|
+
const {
|
|
61
|
+
str,
|
|
62
|
+
charStep,
|
|
63
|
+
minCharCode,
|
|
64
|
+
maxCharCode,
|
|
65
|
+
placeholderChar,
|
|
66
|
+
onProgress,
|
|
67
|
+
onComplete,
|
|
68
|
+
} = this
|
|
69
|
+
const stepArray = randoms.slice(0, stepCount)
|
|
70
|
+
const steppedArray = stepArray.map(item => {
|
|
71
|
+
if (item > 0) return item - 1
|
|
72
|
+
if (item < 0) return item + 1
|
|
73
|
+
return 0
|
|
74
|
+
})
|
|
75
|
+
const output = charCodeArrayToString({
|
|
76
|
+
str,
|
|
77
|
+
minCharCode,
|
|
78
|
+
maxCharCode,
|
|
79
|
+
placeholderChar,
|
|
80
|
+
charStep,
|
|
81
|
+
})(steppedArray)
|
|
82
|
+
const updatedRandoms = [...steppedArray, ...randoms.slice(stepCount)]
|
|
83
|
+
onProgress(output)
|
|
84
|
+
|
|
85
|
+
if (output !== str) {
|
|
86
|
+
this.rafId = requestAnimationFrame(() => {
|
|
87
|
+
this.step(updatedRandoms, stepCount + speed, speed)
|
|
88
|
+
})
|
|
89
|
+
} else {
|
|
90
|
+
onComplete(output)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export default RandomText
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { generator } from './prng'
|
|
2
|
+
|
|
3
|
+
const rand = generator()
|
|
4
|
+
export const randomSign: () => number = () =>
|
|
5
|
+
(Math.round(Math.random()) - 0.5) * 2
|
|
6
|
+
export const generateRandomNumbers: (
|
|
7
|
+
arg0: number
|
|
8
|
+
) => (
|
|
9
|
+
arg0: number
|
|
10
|
+
) => (arg0: number) => number[] = base => charOffset => length =>
|
|
11
|
+
[...Array(length)].map(
|
|
12
|
+
() => (base + rand.range(0, charOffset)) * randomSign(),
|
|
13
|
+
)
|
|
14
|
+
export const minMaxLooped: (
|
|
15
|
+
arg0: number,
|
|
16
|
+
arg1: number
|
|
17
|
+
) => (arg0: number) => number = (min, max) => value => {
|
|
18
|
+
if (value > max) return min + (value - max)
|
|
19
|
+
if (value < min) return max + (value - min)
|
|
20
|
+
return value
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const noop: (...rest: unknown[]) => unknown = () => {}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const int32 = 2147483647
|
|
2
|
+
|
|
3
|
+
const gen: (arg0: number) => number = v => (v * 16807) % int32
|
|
4
|
+
|
|
5
|
+
const randomFloat: (arg0: number) => number = v => gen(v) / int32
|
|
6
|
+
|
|
7
|
+
const randomInt: (arg0: number) => number = v => gen(v)
|
|
8
|
+
|
|
9
|
+
type Generator = (
|
|
10
|
+
_?: number
|
|
11
|
+
) => {
|
|
12
|
+
random: () => number
|
|
13
|
+
randomFloat: () => number
|
|
14
|
+
range: (min: number, max: number) => number
|
|
15
|
+
rangeFloat: (min: number, max: number) => number
|
|
16
|
+
}
|
|
17
|
+
export const generator: Generator = (seed = 1) => {
|
|
18
|
+
let value = seed < 1 ? 1 : seed
|
|
19
|
+
|
|
20
|
+
const next: () => number = () => {
|
|
21
|
+
value = randomInt(value)
|
|
22
|
+
return value
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
random: () => next(),
|
|
27
|
+
randomFloat: () => randomFloat(next()),
|
|
28
|
+
range: (min, max) => {
|
|
29
|
+
const minimum = min - 0.4999
|
|
30
|
+
const maximum = max + 0.4999
|
|
31
|
+
return Math.round(minimum + (maximum - minimum) * randomFloat(next()))
|
|
32
|
+
},
|
|
33
|
+
rangeFloat: (min, max) => min + (max - min) * randomFloat(next()),
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
interface FileExtenstion {
|
|
2
|
+
[key: string]: ExtensionInfo
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
interface ExtensionInfo {
|
|
6
|
+
preview?: boolean
|
|
7
|
+
format: string
|
|
8
|
+
description: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const fileExtensionsDictionary: FileExtenstion = {
|
|
12
|
+
'7z': { format: 'archive', description: 'Archivio compresso' },
|
|
13
|
+
ace: { format: 'archive', description: 'Archivio compresso' },
|
|
14
|
+
ai: { format: 'vector', description: 'Vettoriale Adobe Illustrator' },
|
|
15
|
+
dart: { format: 'code', description: 'Dart' },
|
|
16
|
+
db: { format: 'data', description: 'File di database' },
|
|
17
|
+
default: { format: 'attachment', description: 'Formato sconosciuto' },
|
|
18
|
+
dmg: { format: 'executable', description: 'Apple Disk Image' },
|
|
19
|
+
doc: { format: 'text', description: 'Documento Microsoft Word' },
|
|
20
|
+
docm: { format: 'text', description: 'Documento Microsoft Word' },
|
|
21
|
+
docx: { format: 'text', description: 'Documento Microsoft Word Compresso' },
|
|
22
|
+
eml: { format: 'email', description: 'E-mail di posta elettronica' },
|
|
23
|
+
eps: { format: 'vector', description: 'Vettoriale Corel Draw' },
|
|
24
|
+
exe: { format: 'executable', description: 'File eseguibile Windows' },
|
|
25
|
+
flac: { format: 'audio', description: 'Audio non compresso' },
|
|
26
|
+
gif: { format: 'image', description: 'Immagine compressa', preview: true },
|
|
27
|
+
htm: { format: 'markup', description: 'Pagina web' },
|
|
28
|
+
heic: { format: 'image', description: 'High Efficiency Image File Format' },
|
|
29
|
+
html: { format: 'markup', description: 'Pagina web' },
|
|
30
|
+
jpe: { format: 'image', description: 'Immagine compressa', preview: true },
|
|
31
|
+
jpeg: { format: 'image', description: 'Immagine compressa', preview: true },
|
|
32
|
+
jpg: { format: 'image', description: 'Immagine compressa', preview: true },
|
|
33
|
+
js: { format: 'code', description: 'JavaScript' },
|
|
34
|
+
json: { format: 'data', description: 'JavaScript Object Notation' },
|
|
35
|
+
jsx: { format: 'code', description: 'JavaScript' },
|
|
36
|
+
m2v: { format: 'video', description: 'Filmato SD' },
|
|
37
|
+
mp2: { format: 'audio', description: 'Audio compresso' },
|
|
38
|
+
mp3: { format: 'audio', description: 'Audio compresso' },
|
|
39
|
+
mp4: { format: 'video', description: 'Filmato HD' },
|
|
40
|
+
mp4v: { format: 'video', description: 'Filmato HD' },
|
|
41
|
+
mpeg: { format: 'video', description: 'Filmato SD' },
|
|
42
|
+
mpg4: { format: 'video', description: 'Filmato SD' },
|
|
43
|
+
mpg: { format: 'video', description: 'Filmato SD' },
|
|
44
|
+
mpga: { format: 'audio', description: 'Audio compresso' },
|
|
45
|
+
odp: { format: 'slide', description: 'Slide di presentazione LibreOffice' },
|
|
46
|
+
ods: { format: 'spreadsheet', description: 'Foglio di calcolo LibreOffice' },
|
|
47
|
+
odt: { format: 'text', description: 'File di testo LibreOffice' },
|
|
48
|
+
pdf: { format: 'document', description: 'Documento Adobe' },
|
|
49
|
+
php: { format: 'code', description: 'Hypertext Preprocessor' },
|
|
50
|
+
png: { format: 'image', description: 'Immagine Portable Network Graphics', preview: true },
|
|
51
|
+
ppt: { format: 'slide', description: 'Slide di presentazione PowerPoint' },
|
|
52
|
+
rar: { format: 'archive', description: 'Archivio compresso' },
|
|
53
|
+
rtf: { format: 'text', description: 'Documento di testo Rich Text Format' },
|
|
54
|
+
sass: { format: 'code', description: 'Syntactically Awesome StyleSheets' },
|
|
55
|
+
shtml: { format: 'markup', description: 'Pagina web' },
|
|
56
|
+
svg: { format: 'vector', description: 'Scalable Vector Graphics', preview: true },
|
|
57
|
+
tar: { format: 'archive', description: 'Archivio non compresso' },
|
|
58
|
+
tiff: { format: 'image', description: 'Tag Image File Format' },
|
|
59
|
+
ts: { format: 'code', description: 'TypeScript' },
|
|
60
|
+
tsx: { format: 'code', description: 'TypeScript Extended Syntax' },
|
|
61
|
+
txt: { format: 'text', description: 'Documento di testo non formattato' },
|
|
62
|
+
wav: { format: 'audio', description: 'Audio non compresso' },
|
|
63
|
+
webp: { format: 'image', description: 'Immagine Web Picture', preview: true },
|
|
64
|
+
xar: { format: 'archive', description: 'Archivio compresso' },
|
|
65
|
+
xls: { format: 'spreadsheet', description: 'Foglio di calcolo Office' },
|
|
66
|
+
xlsx: { format: 'spreadsheet', description: 'Foglio di calcolo Office' },
|
|
67
|
+
zip: { format: 'archive', description: 'Archivio compresso' },
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const genericMimeToExt: Map<string, string[]> = new Map([
|
|
71
|
+
['image', ['.png', '.jpg', '.jpeg', '.tiff', '.webp', '.jpe', '.gif', '.heic']],
|
|
72
|
+
['audio', ['.mp2', '.mp3', '.mpga', '.wav', '.flac']],
|
|
73
|
+
['video', ['.mv2', '.mp4', '.mp4v', '.mpeg', '.mpg4', '.mpg']],
|
|
74
|
+
])
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
FileExtenstion,
|
|
78
|
+
ExtensionInfo,
|
|
79
|
+
fileExtensionsDictionary,
|
|
80
|
+
genericMimeToExt,
|
|
81
|
+
}
|
package/src/dictionary/icon.ts
CHANGED
|
@@ -2,8 +2,14 @@ import jsonIconsDictionary from '../fixtures/icons.json'
|
|
|
2
2
|
import jsonMggIconsDictionary from '../fixtures/iconsauce.json'
|
|
3
3
|
const iconsDictionary = jsonIconsDictionary
|
|
4
4
|
const mggIconsDictionary = jsonMggIconsDictionary
|
|
5
|
+
const svgIconsDictionary = [
|
|
6
|
+
`${location.origin}/svg/mi/baseline/email.svg`,
|
|
7
|
+
'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgLTk2MCA5NjAgOTYwIiB3aWR0aD0iMjQiPjxwYXRoIGQ9Im0yMzMtODAgNjUtMjgxTDgwLTU1MGwyODgtMjUgMTEyLTI2NSAxMTIgMjY1IDI4OCAyNS0yMTggMTg5IDY1IDI4MS0yNDctMTQ5TDIzMy04MFoiLz48L3N2Zz4=',
|
|
8
|
+
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6s-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8s-3.58-8-8-8z"/></svg>',
|
|
9
|
+
]
|
|
5
10
|
|
|
6
11
|
export {
|
|
7
12
|
iconsDictionary,
|
|
8
13
|
mggIconsDictionary,
|
|
14
|
+
svgIconsDictionary,
|
|
9
15
|
}
|