@maggioli-design-system/mds-push-notification 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/dist/cjs/index-04ec0413.js +1642 -0
  2. package/dist/cjs/index.cjs.js +2 -0
  3. package/dist/cjs/loader.cjs.js +13 -0
  4. package/dist/cjs/mds-push-notification.cjs.entry.js +34 -0
  5. package/dist/cjs/mds-push-notification.cjs.js +23 -0
  6. package/dist/collection/collection-manifest.json +12 -0
  7. package/dist/collection/common/aria.js +29 -0
  8. package/dist/collection/common/file.js +48 -0
  9. package/dist/collection/common/icon.js +15 -0
  10. package/dist/collection/common/keyboard-manager.js +40 -0
  11. package/dist/collection/common/unit.js +22 -0
  12. package/dist/collection/common/yugop/core.js +16 -0
  13. package/dist/collection/common/yugop/index.js +3 -0
  14. package/dist/collection/common/yugop/random-text.js +59 -0
  15. package/dist/collection/common/yugop/utils/math.js +11 -0
  16. package/dist/collection/common/yugop/utils/noop.js +1 -0
  17. package/dist/collection/common/yugop/utils/prng.js +21 -0
  18. package/dist/collection/common/yugop/utils/string.js +2 -0
  19. package/dist/collection/components/mds-push-notification/mds-push-notification.css +668 -0
  20. package/dist/collection/components/mds-push-notification/mds-push-notification.js +202 -0
  21. package/dist/collection/components/mds-push-notification/meta/dictionary.js +5 -0
  22. package/dist/collection/components/mds-push-notification/meta/types.js +1 -0
  23. package/dist/collection/components/mds-push-notification/test/mds-push-notification.e2e.js +9 -0
  24. package/dist/collection/components/mds-push-notification/test/mds-push-notification.spec.js +23 -0
  25. package/dist/collection/components/mds-push-notification/test/mds-push-notification.stories.js +105 -0
  26. package/dist/collection/dictionary/autocomplete.js +59 -0
  27. package/dist/collection/dictionary/button.js +30 -0
  28. package/dist/collection/dictionary/color.js +19 -0
  29. package/dist/collection/dictionary/file-extensions.js +64 -0
  30. package/dist/collection/dictionary/floating-ui.js +19 -0
  31. package/dist/collection/dictionary/icon.js +10 -0
  32. package/dist/collection/dictionary/input.js +37 -0
  33. package/dist/collection/dictionary/loading.js +5 -0
  34. package/dist/collection/dictionary/text.js +6 -0
  35. package/dist/collection/dictionary/typography.js +67 -0
  36. package/dist/collection/dictionary/variant.js +90 -0
  37. package/dist/collection/fixtures/cities.js +110 -0
  38. package/dist/collection/fixtures/filenames.js +57 -0
  39. package/dist/collection/interface/input-value.js +1 -0
  40. package/dist/collection/type/autocomplete.js +1 -0
  41. package/dist/collection/type/button.js +1 -0
  42. package/dist/collection/type/file-types.js +1 -0
  43. package/dist/collection/type/floating-ui.js +1 -0
  44. package/dist/collection/type/form-rel.js +1 -0
  45. package/dist/collection/type/input.js +1 -0
  46. package/dist/collection/type/loading.js +1 -0
  47. package/dist/collection/type/text.js +1 -0
  48. package/dist/collection/type/typography.js +1 -0
  49. package/dist/collection/type/variant-file-format.js +111 -0
  50. package/dist/collection/type/variant.js +1 -0
  51. package/dist/components/index.d.ts +33 -0
  52. package/dist/components/index.js +1 -0
  53. package/dist/components/mds-push-notification.d.ts +11 -0
  54. package/dist/components/mds-push-notification.js +57 -0
  55. package/dist/documentation.d.ts +401 -0
  56. package/dist/documentation.json +370 -0
  57. package/dist/esm/index-55392a50.js +1614 -0
  58. package/dist/esm/index.js +1 -0
  59. package/dist/esm/loader.js +9 -0
  60. package/dist/esm/mds-push-notification.entry.js +30 -0
  61. package/dist/esm/mds-push-notification.js +18 -0
  62. package/dist/esm/polyfills/core-js.js +11 -0
  63. package/dist/esm/polyfills/dom.js +79 -0
  64. package/dist/esm/polyfills/es5-html-element.js +1 -0
  65. package/dist/esm/polyfills/index.js +34 -0
  66. package/dist/esm/polyfills/system.js +6 -0
  67. package/dist/esm-es5/index-55392a50.js +1 -0
  68. package/dist/esm-es5/index.js +0 -0
  69. package/dist/esm-es5/loader.js +1 -0
  70. package/dist/esm-es5/mds-push-notification.entry.js +1 -0
  71. package/dist/esm-es5/mds-push-notification.js +1 -0
  72. package/dist/index.cjs.js +1 -0
  73. package/dist/index.js +1 -0
  74. package/dist/mds-push-notification/index.esm.js +0 -0
  75. package/dist/mds-push-notification/mds-push-notification.esm.js +1 -0
  76. package/dist/mds-push-notification/mds-push-notification.js +127 -0
  77. package/dist/mds-push-notification/p-34044354.entry.js +1 -0
  78. package/dist/mds-push-notification/p-50ea2036.system.js +1 -0
  79. package/dist/mds-push-notification/p-8a9749fc.system.entry.js +1 -0
  80. package/dist/mds-push-notification/p-8cb59c6e.system.js +1 -0
  81. package/dist/mds-push-notification/p-a4428770.js +2 -0
  82. package/dist/mds-push-notification/p-b107cf73.system.js +2 -0
  83. package/dist/stats.json +835 -0
  84. package/dist/types/common/aria.d.ts +5 -0
  85. package/dist/types/common/file.d.ts +12 -0
  86. package/dist/types/common/icon.d.ts +5 -0
  87. package/dist/types/common/keyboard-manager.d.ts +11 -0
  88. package/dist/types/common/unit.d.ts +3 -0
  89. package/dist/types/common/yugop/core.d.ts +10 -0
  90. package/dist/types/common/yugop/index.d.ts +1 -0
  91. package/dist/types/common/yugop/random-text.d.ts +31 -0
  92. package/dist/types/common/yugop/utils/math.d.ts +3 -0
  93. package/dist/types/common/yugop/utils/noop.d.ts +1 -0
  94. package/dist/types/common/yugop/utils/prng.d.ts +8 -0
  95. package/dist/types/common/yugop/utils/string.d.ts +1 -0
  96. package/dist/types/components/mds-push-notification/meta/dictionary.d.ts +2 -0
  97. package/dist/types/components/mds-push-notification/meta/types.d.ts +1 -0
  98. package/dist/types/components/mds-push-notification/test/mds-push-notification.stories.d.ts +77 -0
  99. package/dist/types/components.d.ts +105 -0
  100. package/dist/types/dictionary/autocomplete.d.ts +2 -0
  101. package/dist/types/dictionary/button.d.ts +6 -0
  102. package/dist/types/dictionary/color.d.ts +3 -0
  103. package/dist/types/dictionary/file-extensions.d.ts +11 -0
  104. package/dist/types/dictionary/floating-ui.d.ts +3 -0
  105. package/dist/types/dictionary/icon.d.ts +4 -0
  106. package/dist/types/dictionary/input.d.ts +5 -0
  107. package/dist/types/dictionary/loading.d.ts +2 -0
  108. package/dist/types/dictionary/text.d.ts +2 -0
  109. package/dist/types/dictionary/typography.d.ts +11 -0
  110. package/dist/types/dictionary/variant.d.ts +11 -0
  111. package/dist/types/fixtures/cities.d.ts +2 -0
  112. package/dist/types/fixtures/filenames.d.ts +2 -0
  113. package/dist/types/interface/input-value.d.ts +4 -0
  114. package/dist/types/stencil-public-runtime.d.ts +1681 -0
  115. package/dist/types/type/autocomplete.d.ts +2 -0
  116. package/dist/types/type/button.d.ts +5 -0
  117. package/dist/types/type/file-types.d.ts +1 -0
  118. package/dist/types/type/floating-ui.d.ts +2 -0
  119. package/dist/types/type/form-rel.d.ts +1 -0
  120. package/dist/types/type/input.d.ts +4 -0
  121. package/dist/types/type/loading.d.ts +1 -0
  122. package/dist/types/type/text.d.ts +1 -0
  123. package/dist/types/type/typography.d.ts +10 -0
  124. package/dist/types/type/variant-file-format.d.ts +11 -0
  125. package/dist/types/type/variant.d.ts +12 -0
  126. package/documentation.json +788 -0
  127. package/loader/cdn.js +3 -0
  128. package/loader/index.cjs.js +3 -0
  129. package/loader/index.d.ts +21 -0
  130. package/loader/index.es2017.js +3 -0
  131. package/loader/index.js +4 -0
  132. package/loader/package.json +11 -0
  133. package/package.json +51 -0
  134. package/readme.md +67 -0
  135. package/src/common/aria.ts +39 -0
  136. package/src/common/file.ts +63 -0
  137. package/src/common/icon.ts +25 -0
  138. package/src/common/keyboard-manager.ts +46 -0
  139. package/src/common/unit.ts +33 -0
  140. package/src/common/yugop/core.ts +47 -0
  141. package/src/common/yugop/index.ts +4 -0
  142. package/src/common/yugop/random-text.ts +95 -0
  143. package/src/common/yugop/utils/math.ts +21 -0
  144. package/src/common/yugop/utils/noop.ts +1 -0
  145. package/src/common/yugop/utils/prng.ts +35 -0
  146. package/src/common/yugop/utils/string.ts +4 -0
  147. package/src/components/mds-push-notification/.gitlab-ci.yml +25 -0
  148. package/src/components/mds-push-notification/css/mds-push-notification-variant-label.css +191 -0
  149. package/src/components/mds-push-notification/css/mds-push-notification-variant-primary.css +20 -0
  150. package/src/components/mds-push-notification/css/mds-push-notification-variant-state.css +77 -0
  151. package/src/components/mds-push-notification/mds-push-notification.css +130 -0
  152. package/src/components/mds-push-notification/mds-push-notification.tsx +84 -0
  153. package/src/components/mds-push-notification/meta/dictionary.ts +8 -0
  154. package/src/components/mds-push-notification/meta/types.ts +3 -0
  155. package/src/components/mds-push-notification/readme.md +42 -0
  156. package/src/components/mds-push-notification/test/mds-push-notification.e2e.ts +11 -0
  157. package/src/components/mds-push-notification/test/mds-push-notification.spec.tsx +24 -0
  158. package/src/components/mds-push-notification/test/mds-push-notification.stories.tsx +137 -0
  159. package/src/components.d.ts +105 -0
  160. package/src/dictionary/autocomplete.ts +62 -0
  161. package/src/dictionary/button.ts +41 -0
  162. package/src/dictionary/color.ts +24 -0
  163. package/src/dictionary/file-extensions.ts +81 -0
  164. package/src/dictionary/floating-ui.ts +25 -0
  165. package/src/dictionary/icon.ts +15 -0
  166. package/src/dictionary/input.ts +48 -0
  167. package/src/dictionary/loading.ts +9 -0
  168. package/src/dictionary/text.ts +9 -0
  169. package/src/dictionary/typography.ts +88 -0
  170. package/src/dictionary/variant.ts +111 -0
  171. package/src/fixtures/cities.ts +116 -0
  172. package/src/fixtures/filenames.ts +60 -0
  173. package/src/fixtures/icons.json +314 -0
  174. package/src/fixtures/iconsauce.json +235 -0
  175. package/src/interface/input-value.ts +5 -0
  176. package/src/tailwind/components.css +15 -0
  177. package/src/type/autocomplete.ts +69 -0
  178. package/src/type/button.ts +28 -0
  179. package/src/type/file-types.ts +55 -0
  180. package/src/type/floating-ui.ts +17 -0
  181. package/src/type/form-rel.ts +11 -0
  182. package/src/type/input.ts +25 -0
  183. package/src/type/loading.ts +3 -0
  184. package/src/type/text.ts +4 -0
  185. package/src/type/typography.ts +65 -0
  186. package/src/type/variant-file-format.ts +128 -0
  187. package/src/type/variant.ts +99 -0
  188. package/www/build/index.esm.js +0 -0
  189. package/www/build/mds-push-notification.esm.js +1 -0
  190. package/www/build/mds-push-notification.js +127 -0
  191. package/www/build/p-34044354.entry.js +1 -0
  192. package/www/build/p-50ea2036.system.js +1 -0
  193. package/www/build/p-8a9749fc.system.entry.js +1 -0
  194. package/www/build/p-8cb59c6e.system.js +1 -0
  195. package/www/build/p-a4428770.js +2 -0
  196. package/www/build/p-b107cf73.system.js +2 -0
  197. package/www/host.config.json +15 -0
package/loader/cdn.js ADDED
@@ -0,0 +1,3 @@
1
+
2
+ module.exports = require('../dist/cjs/loader.cjs.js');
3
+ module.exports.applyPolyfills = function() { return Promise.resolve() };
@@ -0,0 +1,3 @@
1
+
2
+ module.exports = require('../dist/cjs/loader.cjs.js');
3
+ module.exports.applyPolyfills = function() { return Promise.resolve() };
@@ -0,0 +1,21 @@
1
+ export * from '../dist/types/components';
2
+ export interface CustomElementsDefineOptions {
3
+ exclude?: string[];
4
+ resourcesUrl?: string;
5
+ syncQueue?: boolean;
6
+ jmp?: (c: Function) => any;
7
+ raf?: (c: FrameRequestCallback) => number;
8
+ ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
9
+ rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
10
+ }
11
+ export declare function defineCustomElements(win?: Window, opts?: CustomElementsDefineOptions): void;
12
+ export declare function applyPolyfills(): Promise<void>;
13
+
14
+ /**
15
+ * Used to specify a nonce value that corresponds with an application's CSP.
16
+ * When set, the nonce will be added to all dynamically created script and style tags at runtime.
17
+ * Alternatively, the nonce value can be set on a meta tag in the DOM head
18
+ * (<meta name="csp-nonce" content="{ nonce value here }" />) which
19
+ * will result in the same behavior.
20
+ */
21
+ export declare function setNonce(nonce: string): void;
@@ -0,0 +1,3 @@
1
+
2
+ export * from '../dist/esm/polyfills/index.js';
3
+ export * from '../dist/esm/loader.js';
@@ -0,0 +1,4 @@
1
+
2
+ (function(){if("undefined"!==typeof window&&void 0!==window.Reflect&&void 0!==window.customElements){var a=HTMLElement;window.HTMLElement=function(){return Reflect.construct(a,[],this.constructor)};HTMLElement.prototype=a.prototype;HTMLElement.prototype.constructor=HTMLElement;Object.setPrototypeOf(HTMLElement,a)}})();
3
+ export * from '../dist/esm/polyfills/index.js';
4
+ export * from '../dist/esm-es5/loader.js';
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "mds-push-notification-loader",
3
+ "private": true,
4
+ "typings": "./index.d.ts",
5
+ "module": "./index.js",
6
+ "main": "./index.cjs.js",
7
+ "jsnext:main": "./index.es2017.js",
8
+ "es2015": "./index.es2017.js",
9
+ "es2017": "./index.es2017.js",
10
+ "unpkg": "./cdn.js"
11
+ }
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@maggioli-design-system/mds-push-notification",
3
+ "version": "1.1.0",
4
+ "description": "mds-push-notification 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
+ "main": "dist/index.cjs.js",
6
+ "module": "dist/index.js",
7
+ "es2015": "dist/esm/index.mjs",
8
+ "es2017": "dist/esm/index.mjs",
9
+ "types": "dist/types/components.d.ts",
10
+ "collection": "dist/collection/collection-manifest.json",
11
+ "collection:main": "dist/collection/index.js",
12
+ "unpkg": "dist/mds-push-notification/mds-push-notification.esm.js",
13
+ "files": [
14
+ "dist/",
15
+ "documentation.json",
16
+ "loader/",
17
+ "readme.md",
18
+ "src/",
19
+ "www/"
20
+ ],
21
+ "scripts": {
22
+ "build": "rm src/components.d.ts || true && stencil build --docs-readme",
23
+ "prepublishOnly": "npm run build",
24
+ "test": "stencil test --spec --e2e"
25
+ },
26
+ "dependencies": {
27
+ "@maggioli-design-system/mds-button": "4.15.0",
28
+ "@maggioli-design-system/mds-icon": "2.9.0",
29
+ "@maggioli-design-system/mds-text": "4.2.0",
30
+ "@maggioli-design-system/styles": "14.2.1",
31
+ "@stencil/core": "4.10.0"
32
+ },
33
+ "license": "MIT",
34
+ "author": {
35
+ "name": "Vittorio Vittori",
36
+ "email": "vittorio.vittori@maggioli.it",
37
+ "url": "https://vitto.github.io/vit.to/"
38
+ },
39
+ "contributors": [
40
+ {
41
+ "name": "Nicola Tamburini",
42
+ "email": "nicola.tamburini@maggioli.it",
43
+ "role": "Software Engineer"
44
+ },
45
+ {
46
+ "name": "Vittorio Vittori",
47
+ "email": "vittorio.vittori@maggioli.it",
48
+ "role": "Product Designer"
49
+ }
50
+ ]
51
+ }
package/readme.md ADDED
@@ -0,0 +1,67 @@
1
+ # mds-push-notification
2
+
3
+
4
+
5
+ <!-- Auto Generated Below -->
6
+
7
+
8
+ ## Properties
9
+
10
+ | Property | Attribute | Description | Type | Default |
11
+ | ---------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |
12
+ | `icon` | `icon` | Specifies the icon to be displayed | `string \| undefined` | `undefined` |
13
+ | `initials` | `initials` | The user's inizials displayed if there's no image available, initials will override tone and variant senttings to keep user recognizable from others | `string \| undefined` | `undefined` |
14
+ | `message` | `message` | Specifies the message of the component | `string` | `'Nessun messaggio disponibile'` |
15
+ | `preview` | `preview` | Specifies if the `src` attribute is used to show a the image as avatar or full image | `"avatar" \| "image" \| undefined` | `'image'` |
16
+ | `src` | `src` | Specifies the path to the image | `string \| undefined` | `undefined` |
17
+ | `subject` | `subject` | Specifies the subject of the component | `string \| undefined` | `undefined` |
18
+ | `tone` | `tone` | Specifies the color tone of the component | `"strong" \| "weak" \| undefined` | `'weak'` |
19
+ | `variant` | `variant` | Specifies the color variant of the component | `"amaranth" \| "aqua" \| "blue" \| "error" \| "green" \| "info" \| "lime" \| "orange" \| "orchid" \| "primary" \| "sky" \| "success" \| "violet" \| "warning" \| "yellow" \| undefined` | `undefined` |
20
+
21
+
22
+ ## Slots
23
+
24
+ | Slot | Description |
25
+ | ----------- | --------------------------------------------------------------------------------------- |
26
+ | `"actions"` | Add `HTML elements` or `components`, it is **recommended** to use `mds-button` element. |
27
+
28
+
29
+ ## Shadow Parts
30
+
31
+ | Part | Description |
32
+ | ----------- | ------------------------------------------ |
33
+ | `"actions"` | The actions wrapper |
34
+ | `"avatar"` | |
35
+ | `"content"` | The content wrapper of the message |
36
+ | `"icon"` | The icon set by `icon` attribute |
37
+ | `"picture"` | The picture image added by `src` attribute |
38
+
39
+
40
+ ## Dependencies
41
+
42
+ ### Depends on
43
+
44
+ - [mds-avatar](../mds-avatar)
45
+ - [mds-img](../mds-img)
46
+ - [mds-text](../mds-text)
47
+ - [mds-button](../mds-button)
48
+
49
+ ### Graph
50
+ ```mermaid
51
+ graph TD;
52
+ mds-push-notification --> mds-avatar
53
+ mds-push-notification --> mds-img
54
+ mds-push-notification --> mds-text
55
+ mds-push-notification --> mds-button
56
+ mds-avatar --> mds-text
57
+ mds-avatar --> mds-img
58
+ mds-avatar --> mds-icon
59
+ mds-button --> mds-spinner
60
+ mds-button --> mds-icon
61
+ mds-button --> mds-text
62
+ style mds-push-notification fill:#f9f,stroke:#333,stroke-width:4px
63
+ ```
64
+
65
+ ----------------------------------------------
66
+
67
+ Built with love @ [Gruppo Maggioli](https://www.maggioli.com) from [R&D Department](https://www.maggioli.com/it-it/chi-siamo/ricerca-sviluppo)
@@ -0,0 +1,39 @@
1
+ const hash = (s: string): string => {
2
+ let i: number, h: number
3
+ for (i = 0, h = 0; i < s.length; i ++) {
4
+ h = Math.imul(31, h) + s.charCodeAt(i) | 0
5
+ }
6
+ return h.toString()
7
+ }
8
+
9
+ const randomInt = (max: number): number => Math.floor(Math.random() * max)
10
+
11
+ const unslugName = (name: string): string => {
12
+ return name.split('/')?.slice(-1).pop()?.replace(/-/g, ' ') ?? name
13
+ }
14
+
15
+ const setAttributeIfEmpty = (element: HTMLElement, attribute: string, value: string): string => {
16
+ if (element.hasAttribute(attribute)) {
17
+ return element.getAttribute(attribute) ?? ''
18
+ }
19
+ element.setAttribute(attribute, value)
20
+ return value
21
+ }
22
+
23
+ const hashValue = (value: string): string => `${value}-${hash(value)}`
24
+
25
+ const hashRandomValue = (value?: string): string => {
26
+ const randomValue = randomInt(1000000)
27
+ if (value) {
28
+ return `${value}-${hash(randomValue.toString())}`
29
+ }
30
+
31
+ return hash(randomValue.toString())
32
+ }
33
+
34
+ export {
35
+ unslugName,
36
+ setAttributeIfEmpty,
37
+ hashRandomValue,
38
+ hashValue,
39
+ }
@@ -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
+ }
@@ -0,0 +1,46 @@
1
+ export class KeyboardManager {
2
+ private escapeCallback: () => void
3
+ private elements = []
4
+
5
+ private handleClickBehaviorDispatchEvent = (event: KeyboardEvent): void => {
6
+ if (event.code === 'Space' || event.code === 'Enter' || event.code === 'NumpadEnter') {
7
+ (event.target as HTMLElement).click()
8
+ }
9
+ }
10
+
11
+ private handleEscapeBehaviorDispatchEvent = (event: KeyboardEvent): void => {
12
+ if (event.code === 'Escape' && this.escapeCallback) {
13
+ this.escapeCallback()
14
+ }
15
+ }
16
+
17
+ addElement = (el: HTMLElement, name = 'element'): void => {
18
+ this.elements[name] = el
19
+ }
20
+
21
+ attachClickBehavior = (name = 'element'): void => {
22
+ if (this.elements[name]) {
23
+ this.elements[name].addEventListener('keydown', this.handleClickBehaviorDispatchEvent)
24
+ }
25
+ }
26
+
27
+ detachClickBehavior = (name = 'element'): void => {
28
+ if (this.elements[name]) {
29
+ this.elements[name].removeEventListener('keydown', this.handleClickBehaviorDispatchEvent)
30
+ }
31
+ }
32
+
33
+ attachEscapeBehavior = (callBack: () => void): void => {
34
+ this.escapeCallback = callBack
35
+ if (window !== undefined) {
36
+ window.addEventListener('keydown', this.handleEscapeBehaviorDispatchEvent.bind(this))
37
+ }
38
+ }
39
+
40
+ detachEscapeBehavior = (): void => {
41
+ this.escapeCallback = () => {return}
42
+ if (window !== undefined) {
43
+ window.removeEventListener('keydown', this.handleEscapeBehaviorDispatchEvent.bind(this))
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,33 @@
1
+ const cssDurationToMilliseconds = (duration: string, defaultValue = 1000): number => {
2
+
3
+ if (duration.includes('ms')) {
4
+ return Number(duration.replace('ms', ''))
5
+ }
6
+
7
+ if (duration.includes('s')) {
8
+ return Number(duration.replace('s', '')) * 1000
9
+ }
10
+
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
21
+ }
22
+
23
+ if (size.includes('em')) {
24
+ return Number(size.replace('em', '')) * 16
25
+ }
26
+
27
+ return defaultValue
28
+ }
29
+
30
+ export {
31
+ cssDurationToMilliseconds,
32
+ cssSizeToNumber,
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,25 @@
1
+ .base-push-notification:
2
+ variables:
3
+ COMPONENT: mds-push-notification
4
+
5
+ # ISOLATE
6
+ push-notification-isolate:
7
+ extends: [.base-isolate, .base-push-notification]
8
+ dependencies: [base-stencil-build]
9
+
10
+ # TEST
11
+ push-notification-publish-test:
12
+ extends: [.base-stencil-publish-test, .base-push-notification]
13
+ dependencies: [base-stencil-build, push-notification-isolate]
14
+
15
+ # PUBLISH
16
+ push-notification-publish:
17
+ extends: [.base-stencil-publish, .base-push-notification]
18
+ dependencies: [base-stencil-build, push-notification-isolate]
19
+ needs: [base-stencil-build, push-notification-isolate, push-notification-publish-test]
20
+
21
+ # INSTALL TEST
22
+ push-notification-install-test:
23
+ extends: [.base-stencil-install-test, .base-push-notification]
24
+ dependencies: [base-stencil-build, push-notification-isolate]
25
+ needs: [base-stencil-build, push-notification-isolate, push-notification-publish]