@maggioli-design-system/mds-modal 4.7.3 → 4.9.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/dist/cjs/mds-modal.cjs.entry.js +2 -2
- package/dist/cjs/mds-modal.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/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-modal/mds-modal.css +152 -24
- package/dist/collection/components/mds-modal/mds-modal.js +1 -1
- package/dist/collection/components/mds-modal/test/mds-modal.e2e.js +1 -21
- package/dist/collection/components/mds-modal/test/mds-modal.stories.js +1 -1
- 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-modal.js +2 -2
- package/dist/documentation.json +3 -3
- package/dist/esm/mds-modal.entry.js +2 -2
- package/dist/esm/mds-modal.js +1 -1
- package/dist/esm-es5/mds-modal.entry.js +1 -1
- package/dist/mds-modal/mds-modal.esm.js +1 -1
- package/dist/mds-modal/mds-modal.js +1 -1
- package/dist/mds-modal/p-444a6a47.system.entry.js +1 -0
- package/{www/build/p-88c57c56.system.js → dist/mds-modal/p-5cf75b06.system.js} +1 -1
- package/dist/mds-modal/p-83ebb238.entry.js +1 -0
- package/dist/stats.json +65 -23
- package/dist/types/common/file.d.ts +12 -0
- package/dist/types/common/icon.d.ts +5 -0
- 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 +58 -13
- package/package.json +4 -3
- package/readme.md +8 -0
- package/src/common/file.ts +63 -0
- package/src/common/icon.ts +25 -0
- 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/components/mds-modal/css/mds-modal-animate-left.css +4 -4
- package/src/components/mds-modal/css/mds-modal-animate-right.css +4 -4
- package/src/components/mds-modal/mds-modal.css +12 -7
- package/src/components/mds-modal/mds-modal.tsx +1 -1
- package/src/components/mds-modal/test/mds-modal.e2e.ts +1 -23
- package/src/components/mds-modal/test/mds-modal.stories.tsx +9 -9
- 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 +10 -0
- package/src/fixtures/iconsauce.json +3 -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-modal.esm.js +1 -1
- package/www/build/mds-modal.js +1 -1
- package/www/build/p-444a6a47.system.entry.js +1 -0
- package/{dist/mds-modal/p-88c57c56.system.js → www/build/p-5cf75b06.system.js} +1 -1
- package/www/build/p-83ebb238.entry.js +1 -0
- package/dist/mds-modal/p-59a0095c.system.entry.js +0 -1
- package/dist/mds-modal/p-6086db8a.entry.js +0 -1
- package/www/build/p-59a0095c.system.entry.js +0 -1
- package/www/build/p-6086db8a.entry.js +0 -1
package/documentation.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"timestamp": "2024-
|
|
2
|
+
"timestamp": "2024-02-09T14:18:39",
|
|
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
|
{
|
|
@@ -193,8 +193,18 @@
|
|
|
193
193
|
"dependents": [
|
|
194
194
|
"mds-header"
|
|
195
195
|
],
|
|
196
|
-
"dependencies": [
|
|
196
|
+
"dependencies": [
|
|
197
|
+
"mds-button"
|
|
198
|
+
],
|
|
197
199
|
"dependencyGraph": {
|
|
200
|
+
"mds-modal": [
|
|
201
|
+
"mds-button"
|
|
202
|
+
],
|
|
203
|
+
"mds-button": [
|
|
204
|
+
"mds-spinner",
|
|
205
|
+
"mds-icon",
|
|
206
|
+
"mds-text"
|
|
207
|
+
],
|
|
198
208
|
"mds-header": [
|
|
199
209
|
"mds-modal"
|
|
200
210
|
]
|
|
@@ -222,6 +232,16 @@
|
|
|
222
232
|
"docstring": "",
|
|
223
233
|
"path": "src/components/mds-accordion-timer-item/meta/event-detail.ts"
|
|
224
234
|
},
|
|
235
|
+
"src/type/variant.ts::ToneMinimalVariantType": {
|
|
236
|
+
"declaration": "export type ToneMinimalVariantType =\n| 'strong'\n| 'weak'",
|
|
237
|
+
"docstring": "",
|
|
238
|
+
"path": "src/type/variant.ts"
|
|
239
|
+
},
|
|
240
|
+
"src/type/variant.ts::ThemeFullVariantAvatarType": {
|
|
241
|
+
"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'",
|
|
242
|
+
"docstring": "",
|
|
243
|
+
"path": "src/type/variant.ts"
|
|
244
|
+
},
|
|
225
245
|
"src/type/variant.ts::ThemeFullVariantType": {
|
|
226
246
|
"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'",
|
|
227
247
|
"docstring": "",
|
|
@@ -327,16 +347,26 @@
|
|
|
327
347
|
"docstring": "",
|
|
328
348
|
"path": "src/components/mds-dropdown/meta/event-detail.ts"
|
|
329
349
|
},
|
|
330
|
-
"src/
|
|
331
|
-
"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'",
|
|
350
|
+
"src/type/file-types.ts::ExtensionSuffixType": {
|
|
351
|
+
"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'",
|
|
332
352
|
"docstring": "",
|
|
333
|
-
"path": "src/
|
|
353
|
+
"path": "src/type/file-types.ts"
|
|
334
354
|
},
|
|
335
355
|
"src/components/mds-file/meta/event-detail.ts::MdsFileEventDetail": {
|
|
336
356
|
"declaration": "export interface MdsFileEventDetail {\n description: string\n extension: string\n filename: string\n target: HTMLMdsFileElement\n type: string\n}",
|
|
337
357
|
"docstring": "",
|
|
338
358
|
"path": "src/components/mds-file/meta/event-detail.ts"
|
|
339
359
|
},
|
|
360
|
+
"src/type/text.ts::TypographyTruncateType": {
|
|
361
|
+
"declaration": "export type TypographyTruncateType =\n | 'all'\n | 'none'\n | 'word'",
|
|
362
|
+
"docstring": "",
|
|
363
|
+
"path": "src/type/text.ts"
|
|
364
|
+
},
|
|
365
|
+
"src/components/mds-file-preview/meta/event-detail.ts::MdsFilePreviewEventDetail": {
|
|
366
|
+
"declaration": "export interface MdsFilePreviewEventDetail {\n extension: string\n filename: string\n target: HTMLMdsFileElement\n}",
|
|
367
|
+
"docstring": "",
|
|
368
|
+
"path": "src/components/mds-file-preview/meta/event-detail.ts"
|
|
369
|
+
},
|
|
340
370
|
"src/components/mds-filter/meta/event-detail.ts::MdsFilterEventDetail": {
|
|
341
371
|
"declaration": "export interface MdsFilterEventDetail {\n children: NodeListOf<HTMLMdsFilterItemElement>\n value: string\n}",
|
|
342
372
|
"docstring": "",
|
|
@@ -472,6 +502,11 @@
|
|
|
472
502
|
"docstring": "",
|
|
473
503
|
"path": "src/type/input.ts"
|
|
474
504
|
},
|
|
505
|
+
"src/components/mds-input-upload/meta/types.ts::AttachmentSort": {
|
|
506
|
+
"declaration": "enum AttachmentSort {\n status = 'status',\n date = 'date',\n}",
|
|
507
|
+
"docstring": "",
|
|
508
|
+
"path": "src/components/mds-input-upload/meta/types.ts"
|
|
509
|
+
},
|
|
475
510
|
"src/type/typography.ts::TypographyType": {
|
|
476
511
|
"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'",
|
|
477
512
|
"docstring": "",
|
|
@@ -512,6 +547,11 @@
|
|
|
512
547
|
"docstring": "",
|
|
513
548
|
"path": "src/components/mds-progress/meta/types.ts"
|
|
514
549
|
},
|
|
550
|
+
"src/components/mds-push-notification/meta/types.ts::NotificationPreviewType": {
|
|
551
|
+
"declaration": "export type NotificationPreviewType =\n | 'avatar'\n | 'image'",
|
|
552
|
+
"docstring": "",
|
|
553
|
+
"path": "src/components/mds-push-notification/meta/types.ts"
|
|
554
|
+
},
|
|
515
555
|
"src/components/mds-stepper-bar/meta/event-detail.ts::MdsStepperBarEventDetail": {
|
|
516
556
|
"declaration": "export interface MdsStepperBarEventDetail {\n step: number\n value: string\n}",
|
|
517
557
|
"docstring": "",
|
|
@@ -523,7 +563,7 @@
|
|
|
523
563
|
"path": "src/components/mds-stepper-bar-item/meta/event-detail.ts"
|
|
524
564
|
},
|
|
525
565
|
"src/components/mds-tab/meta/event-detail.ts::MdsTabEventDetail": {
|
|
526
|
-
"declaration": "export interface MdsTabEventDetail {\n id: number\n}",
|
|
566
|
+
"declaration": "export interface MdsTabEventDetail {\n id: number\n value?: string\n}",
|
|
527
567
|
"docstring": "",
|
|
528
568
|
"path": "src/components/mds-tab/meta/event-detail.ts"
|
|
529
569
|
},
|
|
@@ -537,6 +577,16 @@
|
|
|
537
577
|
"docstring": "",
|
|
538
578
|
"path": "src/type/typography.ts"
|
|
539
579
|
},
|
|
580
|
+
"src/components/mds-tab-item/meta/event-detail.ts::MdsTabItemEventDetail": {
|
|
581
|
+
"declaration": "export interface MdsTabItemEventDetail {\n target: HTMLMdsTabItemElement\n value?: string\n}",
|
|
582
|
+
"docstring": "",
|
|
583
|
+
"path": "src/components/mds-tab-item/meta/event-detail.ts"
|
|
584
|
+
},
|
|
585
|
+
"src/components/mds-text/meta/types.ts::TextAnimationType": {
|
|
586
|
+
"declaration": "export type TextAnimationType =\n | 'none'\n | 'yugop'",
|
|
587
|
+
"docstring": "",
|
|
588
|
+
"path": "src/components/mds-text/meta/types.ts"
|
|
589
|
+
},
|
|
540
590
|
"src/components/mds-text/meta/types.ts::TypographyTagType": {
|
|
541
591
|
"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'",
|
|
542
592
|
"docstring": "",
|
|
@@ -547,11 +597,6 @@
|
|
|
547
597
|
"docstring": "",
|
|
548
598
|
"path": "src/type/variant.ts"
|
|
549
599
|
},
|
|
550
|
-
"src/type/variant.ts::ToneMinimalVariantType": {
|
|
551
|
-
"declaration": "export type ToneMinimalVariantType =\n| 'strong'\n| 'weak'",
|
|
552
|
-
"docstring": "",
|
|
553
|
-
"path": "src/type/variant.ts"
|
|
554
|
-
},
|
|
555
600
|
"src/components/mds-toast/meta/types.ts::ToastPosition": {
|
|
556
601
|
"declaration": "export type ToastPosition =\n | 'top-left'\n | 'top-center'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-center'\n | 'bottom-right'",
|
|
557
602
|
"docstring": "",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maggioli-design-system/mds-modal",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.9.0",
|
|
4
4
|
"description": "mds-modal 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",
|
|
@@ -24,8 +24,9 @@
|
|
|
24
24
|
"test": "stencil test --spec --e2e"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@maggioli-design-system/
|
|
28
|
-
"@
|
|
27
|
+
"@maggioli-design-system/mds-button": "4.16.0",
|
|
28
|
+
"@maggioli-design-system/styles": "14.2.1",
|
|
29
|
+
"@stencil/core": "4.10.0",
|
|
29
30
|
"clsx": "2.1.0"
|
|
30
31
|
},
|
|
31
32
|
"license": "MIT",
|
package/readme.md
CHANGED
|
@@ -57,9 +57,17 @@ This is a web-component from Maggioli Design System [Magma](https://magma.maggio
|
|
|
57
57
|
|
|
58
58
|
- [mds-header](../mds-header)
|
|
59
59
|
|
|
60
|
+
### Depends on
|
|
61
|
+
|
|
62
|
+
- [mds-button](../mds-button)
|
|
63
|
+
|
|
60
64
|
### Graph
|
|
61
65
|
```mermaid
|
|
62
66
|
graph TD;
|
|
67
|
+
mds-modal --> mds-button
|
|
68
|
+
mds-button --> mds-spinner
|
|
69
|
+
mds-button --> mds-icon
|
|
70
|
+
mds-button --> mds-text
|
|
63
71
|
mds-header --> mds-modal
|
|
64
72
|
style mds-modal fill:#f9f,stroke:#333,stroke-width:4px
|
|
65
73
|
```
|
|
@@ -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
|
+
}
|
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
|
+
}
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
@apply animate-left-opened;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
:host( .to-left-opened ) .close,
|
|
23
|
-
:host( .to-left-opened.to-left-outro ) .close {
|
|
22
|
+
:host( .to-left-opened ) .button-close,
|
|
23
|
+
:host( .to-left-opened.to-left-outro ) .button-close {
|
|
24
24
|
@apply opacity-100;
|
|
25
25
|
|
|
26
26
|
transform: translate(-24px, 24px) rotate(0);
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
@apply animate-left-outro;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
:host( .to-left-outro ) .close {
|
|
34
|
+
:host( .to-left-outro ) .button-close {
|
|
35
35
|
transform: translate(24px, 24px) rotate(-90deg);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
:host( .to-left ) .close {
|
|
38
|
+
:host( .to-left ) .button-close {
|
|
39
39
|
@apply right-0;
|
|
40
40
|
|
|
41
41
|
transform: translate(36px, 24px) rotate(90deg);
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
@apply animate-right-opened;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
:host( .to-right-opened ) .close,
|
|
23
|
-
:host( .to-right-opened.to-right-outro ) .close {
|
|
22
|
+
:host( .to-right-opened ) .button-close,
|
|
23
|
+
:host( .to-right-opened.to-right-outro ) .button-close {
|
|
24
24
|
@apply opacity-100;
|
|
25
25
|
|
|
26
26
|
transform: translate(24px, 24px) rotate(0);
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
@apply animate-right-outro;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
:host( .to-right-outro ) .close {
|
|
34
|
+
:host( .to-right-outro ) .button-close {
|
|
35
35
|
transform: translate(-24px, 24px) rotate(90deg);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
:host( .to-right ) .close {
|
|
38
|
+
:host( .to-right ) .button-close {
|
|
39
39
|
@apply left-0;
|
|
40
40
|
|
|
41
41
|
transform: translate(-36px, 24px) rotate(-90deg);
|
|
@@ -60,25 +60,30 @@
|
|
|
60
60
|
pointer-events: auto;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
.close {
|
|
63
|
+
.button-close {
|
|
64
64
|
@apply
|
|
65
65
|
duration-500
|
|
66
66
|
ease-in-out-quart
|
|
67
|
-
h-900
|
|
68
67
|
opacity-0
|
|
69
68
|
rounded-full
|
|
70
|
-
|
|
71
|
-
top-0
|
|
72
|
-
w-900;
|
|
69
|
+
top-0;
|
|
73
70
|
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
--mds-button-icon-color: theme('colors.tone-neutral');
|
|
72
|
+
--mds-button-background: transparent;
|
|
73
|
+
|
|
74
|
+
height: auto;
|
|
76
75
|
position: absolute;
|
|
77
76
|
transform: translate(0, 24px) rotate(90deg);
|
|
78
77
|
transform-origin: center;
|
|
79
78
|
transition-property: opacity, outline, outline-offset, transform;
|
|
80
79
|
}
|
|
81
80
|
|
|
81
|
+
.button-close::part(icon) {
|
|
82
|
+
@apply
|
|
83
|
+
h-900
|
|
84
|
+
w-900;
|
|
85
|
+
}
|
|
86
|
+
|
|
82
87
|
.window {
|
|
83
88
|
@apply
|
|
84
89
|
gap-0
|
|
@@ -138,7 +138,7 @@ export class MdsModal {
|
|
|
138
138
|
}
|
|
139
139
|
</div>
|
|
140
140
|
}
|
|
141
|
-
{ !this.window && <
|
|
141
|
+
{ !this.window && <mds-button icon={miBaselineClose} onClick={(e: Event) => { this.closeModal(e) }} class="button-close"></mds-button> }
|
|
142
142
|
</Host>
|
|
143
143
|
)
|
|
144
144
|
}
|
|
@@ -16,17 +16,6 @@ describe('mds-modal', () => {
|
|
|
16
16
|
expect(element.getAttribute('position')).toBe('right')
|
|
17
17
|
|
|
18
18
|
expect(element).not.toHaveAttribute('opened')
|
|
19
|
-
|
|
20
|
-
expect(element.shadowRoot).toEqualHtml(`
|
|
21
|
-
<div class="window" part="window" role="dialog">
|
|
22
|
-
<slot></slot>
|
|
23
|
-
</div>
|
|
24
|
-
<i class="close focus-bounce-light svg" tabindex="0">
|
|
25
|
-
<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
|
|
26
|
-
<path d="M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12z"></path>
|
|
27
|
-
</svg>
|
|
28
|
-
</i>
|
|
29
|
-
`)
|
|
30
19
|
})
|
|
31
20
|
|
|
32
21
|
it('renders opened', async () => {
|
|
@@ -35,18 +24,7 @@ describe('mds-modal', () => {
|
|
|
35
24
|
|
|
36
25
|
const element = await page.find('mds-modal')
|
|
37
26
|
|
|
38
|
-
expect(element.
|
|
39
|
-
|
|
40
|
-
expect(element.shadowRoot).toEqualHtml(`
|
|
41
|
-
<div class="window" part="window" role="dialog">
|
|
42
|
-
<slot></slot>
|
|
43
|
-
</div>
|
|
44
|
-
<i class="close focus-bounce-light svg" tabindex="0">
|
|
45
|
-
<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
|
|
46
|
-
<path d="M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12z"></path>
|
|
47
|
-
</svg>
|
|
48
|
-
</i>
|
|
49
|
-
`)
|
|
27
|
+
expect(element).toHaveAttribute('opened')
|
|
50
28
|
})
|
|
51
29
|
|
|
52
30
|
it('can be closed', async () => {
|