@maggioli-design-system/mds-table-row 4.4.3 → 4.5.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.
Files changed (84) hide show
  1. package/dist/cjs/mds-table-row.cjs.entry.js +1 -1
  2. package/dist/cjs/mds-table-row.cjs.js +1 -1
  3. package/dist/collection/collection-manifest.json +2 -2
  4. package/dist/collection/common/file.js +48 -0
  5. package/dist/collection/common/icon.js +15 -0
  6. package/dist/collection/common/unit.js +15 -3
  7. package/dist/collection/common/yugop/core.js +16 -0
  8. package/dist/collection/common/yugop/index.js +3 -0
  9. package/dist/collection/common/yugop/random-text.js +59 -0
  10. package/dist/collection/common/yugop/utils/math.js +11 -0
  11. package/dist/collection/common/yugop/utils/noop.js +1 -0
  12. package/dist/collection/common/yugop/utils/prng.js +21 -0
  13. package/dist/collection/common/yugop/utils/string.js +2 -0
  14. package/dist/collection/components/mds-table-row/mds-table-row.css +144 -0
  15. package/dist/collection/dictionary/file-extensions.js +64 -0
  16. package/dist/collection/dictionary/icon.js +6 -1
  17. package/dist/collection/dictionary/text.js +6 -0
  18. package/dist/collection/dictionary/variant.js +18 -1
  19. package/dist/collection/fixtures/filenames.js +57 -0
  20. package/dist/collection/type/file-types.js +1 -0
  21. package/dist/collection/type/text.js +1 -0
  22. package/dist/collection/type/variant-file-format.js +111 -0
  23. package/dist/components/mds-table-row.js +1 -1
  24. package/dist/documentation.json +3 -3
  25. package/dist/esm/mds-table-row.entry.js +1 -1
  26. package/dist/esm/mds-table-row.js +1 -1
  27. package/dist/esm-es5/mds-table-row.entry.js +1 -1
  28. package/dist/mds-table-row/mds-table-row.esm.js +1 -1
  29. package/dist/mds-table-row/mds-table-row.js +1 -1
  30. package/{www/build/p-fe4b1f1b.system.js → dist/mds-table-row/p-65fbbba9.system.js} +1 -1
  31. package/dist/mds-table-row/p-ab9fb13e.entry.js +1 -0
  32. package/dist/mds-table-row/p-f8b0aa6b.system.entry.js +1 -0
  33. package/dist/stats.json +57 -18
  34. package/dist/types/common/file.d.ts +12 -0
  35. package/dist/types/common/icon.d.ts +5 -0
  36. package/dist/types/common/unit.d.ts +2 -1
  37. package/dist/types/common/yugop/core.d.ts +10 -0
  38. package/dist/types/common/yugop/index.d.ts +1 -0
  39. package/dist/types/common/yugop/random-text.d.ts +31 -0
  40. package/dist/types/common/yugop/utils/math.d.ts +3 -0
  41. package/dist/types/common/yugop/utils/noop.d.ts +1 -0
  42. package/dist/types/common/yugop/utils/prng.d.ts +8 -0
  43. package/dist/types/common/yugop/utils/string.d.ts +1 -0
  44. package/dist/types/dictionary/file-extensions.d.ts +11 -0
  45. package/dist/types/dictionary/icon.d.ts +2 -1
  46. package/dist/types/dictionary/text.d.ts +2 -0
  47. package/dist/types/dictionary/variant.d.ts +2 -1
  48. package/dist/types/fixtures/filenames.d.ts +2 -0
  49. package/dist/types/type/file-types.d.ts +1 -0
  50. package/dist/types/type/text.d.ts +1 -0
  51. package/dist/types/type/variant-file-format.d.ts +11 -0
  52. package/dist/types/type/variant.d.ts +1 -0
  53. package/documentation.json +47 -12
  54. package/package.json +4 -4
  55. package/src/common/file.ts +63 -0
  56. package/src/common/icon.ts +25 -0
  57. package/src/common/unit.ts +21 -2
  58. package/src/common/yugop/core.ts +47 -0
  59. package/src/common/yugop/index.ts +4 -0
  60. package/src/common/yugop/random-text.ts +95 -0
  61. package/src/common/yugop/utils/math.ts +21 -0
  62. package/src/common/yugop/utils/noop.ts +1 -0
  63. package/src/common/yugop/utils/prng.ts +35 -0
  64. package/src/common/yugop/utils/string.ts +4 -0
  65. package/src/dictionary/file-extensions.ts +81 -0
  66. package/src/dictionary/icon.ts +6 -0
  67. package/src/dictionary/text.ts +9 -0
  68. package/src/dictionary/variant.ts +19 -0
  69. package/src/fixtures/filenames.ts +60 -0
  70. package/src/fixtures/icons.json +10 -0
  71. package/src/fixtures/iconsauce.json +3 -0
  72. package/src/type/file-types.ts +55 -0
  73. package/src/type/text.ts +4 -0
  74. package/src/type/variant-file-format.ts +128 -0
  75. package/src/type/variant.ts +17 -0
  76. package/www/build/mds-table-row.esm.js +1 -1
  77. package/www/build/mds-table-row.js +1 -1
  78. package/{dist/mds-table-row/p-fe4b1f1b.system.js → www/build/p-65fbbba9.system.js} +1 -1
  79. package/www/build/p-ab9fb13e.entry.js +1 -0
  80. package/www/build/p-f8b0aa6b.system.entry.js +1 -0
  81. package/dist/mds-table-row/p-0f958c61.entry.js +0 -1
  82. package/dist/mds-table-row/p-8da35bc4.system.entry.js +0 -1
  83. package/www/build/p-0f958c61.entry.js +0 -1
  84. package/www/build/p-8da35bc4.system.entry.js +0 -1
@@ -1,9 +1,9 @@
1
1
  {
2
- "timestamp": "2024-01-10T08:00:22",
2
+ "timestamp": "2024-02-09T14:18:39",
3
3
  "compiler": {
4
4
  "name": "@stencil/core",
5
- "version": "4.9.1",
6
- "typescriptVersion": "5.2.2"
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/components/mds-file/meta/types.ts::ExtensionSuffixType": {
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/components/mds-file/meta/types.ts"
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": "",
@@ -336,6 +356,11 @@
336
356
  "docstring": "",
337
357
  "path": "src/type/input.ts"
338
358
  },
359
+ "src/components/mds-input-upload/meta/types.ts::AttachmentSort": {
360
+ "declaration": "enum AttachmentSort {\n status = 'status',\n date = 'date',\n}",
361
+ "docstring": "",
362
+ "path": "src/components/mds-input-upload/meta/types.ts"
363
+ },
339
364
  "src/type/typography.ts::TypographyType": {
340
365
  "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'",
341
366
  "docstring": "",
@@ -376,6 +401,11 @@
376
401
  "docstring": "",
377
402
  "path": "src/components/mds-progress/meta/types.ts"
378
403
  },
404
+ "src/components/mds-push-notification/meta/types.ts::NotificationPreviewType": {
405
+ "declaration": "export type NotificationPreviewType =\n | 'avatar'\n | 'image'",
406
+ "docstring": "",
407
+ "path": "src/components/mds-push-notification/meta/types.ts"
408
+ },
379
409
  "src/components/mds-stepper-bar/meta/event-detail.ts::MdsStepperBarEventDetail": {
380
410
  "declaration": "export interface MdsStepperBarEventDetail {\n step: number\n value: string\n}",
381
411
  "docstring": "",
@@ -387,7 +417,7 @@
387
417
  "path": "src/components/mds-stepper-bar-item/meta/event-detail.ts"
388
418
  },
389
419
  "src/components/mds-tab/meta/event-detail.ts::MdsTabEventDetail": {
390
- "declaration": "export interface MdsTabEventDetail {\n id: number\n}",
420
+ "declaration": "export interface MdsTabEventDetail {\n id: number\n value?: string\n}",
391
421
  "docstring": "",
392
422
  "path": "src/components/mds-tab/meta/event-detail.ts"
393
423
  },
@@ -401,6 +431,16 @@
401
431
  "docstring": "",
402
432
  "path": "src/type/typography.ts"
403
433
  },
434
+ "src/components/mds-tab-item/meta/event-detail.ts::MdsTabItemEventDetail": {
435
+ "declaration": "export interface MdsTabItemEventDetail {\n target: HTMLMdsTabItemElement\n value?: string\n}",
436
+ "docstring": "",
437
+ "path": "src/components/mds-tab-item/meta/event-detail.ts"
438
+ },
439
+ "src/components/mds-text/meta/types.ts::TextAnimationType": {
440
+ "declaration": "export type TextAnimationType =\n | 'none'\n | 'yugop'",
441
+ "docstring": "",
442
+ "path": "src/components/mds-text/meta/types.ts"
443
+ },
404
444
  "src/components/mds-text/meta/types.ts::TypographyTagType": {
405
445
  "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
446
  "docstring": "",
@@ -411,11 +451,6 @@
411
451
  "docstring": "",
412
452
  "path": "src/type/variant.ts"
413
453
  },
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
454
  "src/components/mds-toast/meta/types.ts::ToastPosition": {
420
455
  "declaration": "export type ToastPosition =\n | 'top-left'\n | 'top-center'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-center'\n | 'bottom-right'",
421
456
  "docstring": "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maggioli-design-system/mds-table-row",
3
- "version": "4.4.3",
3
+ "version": "4.5.0",
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.4.3",
27
- "@maggioli-design-system/styles": "14.1.0",
28
- "@stencil/core": "4.9.1"
26
+ "@maggioli-design-system/mds-table-cell": "4.5.0",
27
+ "@maggioli-design-system/styles": "14.2.1",
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,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
- if (duration.includes('ms')) {
7
- return Number(duration.replace('s', ''))
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,4 @@
1
+ // taken from https://github.com/zenoplex/random-text
2
+
3
+ // @flow
4
+ export { default } from './random-text'
@@ -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,4 @@
1
+ // export const strToCharCodeArray: string => number[] = str => str.split('').map(item => item.charCodeAt(0));
2
+
3
+ export const strToCharCodeArray: (arg0: string) => number[] = str =>
4
+ str.split('').map(item => item.charCodeAt(0))
@@ -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
+ }
@@ -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
  }
@@ -0,0 +1,9 @@
1
+ const truncateDictionary = [
2
+ 'all',
3
+ 'none',
4
+ 'word',
5
+ ]
6
+
7
+ export {
8
+ truncateDictionary,
9
+ }
@@ -39,6 +39,24 @@ const themeFullVariantDictionary = [
39
39
  'yellow',
40
40
  ]
41
41
 
42
+ const themeFullVariantAvatarDictionary = [
43
+ 'amaranth',
44
+ 'aqua',
45
+ 'blue',
46
+ 'error',
47
+ 'green',
48
+ 'info',
49
+ 'lime',
50
+ 'orange',
51
+ 'orchid',
52
+ 'primary',
53
+ 'sky',
54
+ 'success',
55
+ 'violet',
56
+ 'warning',
57
+ 'yellow',
58
+ ]
59
+
42
60
  const themeLabelVariantDictionary = [
43
61
  'amaranth',
44
62
  'aqua',
@@ -80,6 +98,7 @@ const toneMinimalVariantDictionary = [
80
98
  ]
81
99
 
82
100
  export {
101
+ themeFullVariantAvatarDictionary,
83
102
  themeFullVariantDictionary,
84
103
  themeLabelVariantDictionary,
85
104
  themeLuminanceVariantDictionary,