nanosplash 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +151 -17
  3. package/coverage/base.css +224 -0
  4. package/coverage/block-navigation.js +87 -0
  5. package/coverage/clover.xml +555 -0
  6. package/coverage/core/Dom.ts.html +565 -0
  7. package/coverage/core/Service.ts.html +790 -0
  8. package/coverage/core/Splash.ts.html +457 -0
  9. package/coverage/core/index.html +146 -0
  10. package/coverage/coverage-final.json +9043 -0
  11. package/coverage/favicon.png +0 -0
  12. package/coverage/index.html +131 -0
  13. package/coverage/prettify.css +1 -0
  14. package/coverage/prettify.js +2 -0
  15. package/coverage/sort-arrow-sprite.png +0 -0
  16. package/coverage/sorter.js +196 -0
  17. package/coverage/types/Types.ts.html +121 -0
  18. package/coverage/types/index.html +116 -0
  19. package/dist/latest/cjs/ns.cjs +1 -0
  20. package/dist/latest/cjs/style.css +1 -0
  21. package/dist/latest/es/ns.js +306 -0
  22. package/dist/latest/es/style.css +1 -0
  23. package/dist/latest/iife/ns.iife.js +4 -0
  24. package/dist/versioned/3.0.1/cjs/ns.cjs +1 -0
  25. package/dist/versioned/3.0.1/cjs/style.css +1 -0
  26. package/dist/versioned/3.0.1/es/ns.js +306 -0
  27. package/dist/versioned/3.0.1/es/style.css +1 -0
  28. package/dist/versioned/3.0.1/iife/ns.iife.js +2 -0
  29. package/docs/index.6d66a821.js +1 -0
  30. package/docs/index.74dbd99e.css +1 -0
  31. package/docs/index.f34144dc.js +1 -0
  32. package/docs/index.html +107 -0
  33. package/index.html +90 -37
  34. package/package.json +41 -20
  35. package/src/sass/ns.sass +38 -29
  36. package/src/ts/core/Dom.ts +160 -0
  37. package/src/ts/core/Service.ts +235 -0
  38. package/src/ts/core/{Nanosplash/interfaces/NanosplashAPI.ts → ServiceInterface.ts} +17 -7
  39. package/src/ts/core/Splash.ts +124 -0
  40. package/src/ts/core/SplashInterface.ts +54 -0
  41. package/src/ts/main.ts +9 -0
  42. package/src/ts/types/Types.ts +12 -0
  43. package/src/ts/types/global.d.ts +14 -0
  44. package/src/vite-env.d.ts +0 -8
  45. package/tests/Dom.spec.ts +127 -0
  46. package/tests/Guid.spec.ts +2 -2
  47. package/tests/{NanosplashService.spec.ts → Service.spec.ts} +18 -18
  48. package/tests/{Nanosplash.spec.ts → Splash.spec.ts} +9 -9
  49. package/tsconfig.json +20 -20
  50. package/vite.config.ts +28 -22
  51. package/vite.demo.config.ts +16 -0
  52. package/dist/main.css +0 -1
  53. package/dist/ns.cjs.js +0 -1
  54. package/dist/ns.es.js +0 -330
  55. package/dist/ns.iife.js +0 -2
  56. package/src/main.ts +0 -8
  57. package/src/ts/core/Nanosplash/Nanosplash.ts +0 -97
  58. package/src/ts/core/Nanosplash/interfaces/NanosplashInterface.ts +0 -42
  59. package/src/ts/core/Nanosplash/repositories/NanosplashRepository.ts +0 -178
  60. package/src/ts/core/Nanosplash/services/NanosplashService.ts +0 -222
  61. package/src/ts/types/Alias.d.ts +0 -1
  62. package/src/ts/types/Nanosplash.d.ts +0 -18
  63. package/src/ts/types/NanosplashService.d.ts +0 -1
  64. package/src/ts/util/Guid.ts +0 -13
  65. package/src/ts/util/Stack.ts +0 -73
  66. package/tests/NanosplashRepository.spec.ts +0 -91
  67. package/tests/Stack.spec.ts +0 -56
@@ -1,91 +0,0 @@
1
- // @ts-strict
2
-
3
- import { JSDOM } from 'jsdom'
4
- import { beforeEach, describe, expect, it } from 'vitest'
5
- import Nanosplash from '../src/ts/core/Nanosplash/Nanosplash'
6
- import {
7
- createElement,
8
- injectAsFirstChild,
9
- prepareParentOf,
10
- cleanNSParentOf,
11
- showElement,
12
- hideElement,
13
- setNSHostClass,
14
- move,
15
- } from '../src/ts/core/Nanosplash/repositories/NanosplashRepository'
16
-
17
- describe('NanosplashRepository', () => {
18
- // Reset the DOM before each test
19
- beforeEach(() => {
20
- const dom = new JSDOM()
21
- // @ts-ignore
22
- globalThis.window = dom.window
23
- globalThis.document = dom.window.document
24
- globalThis.DOMParser = dom.window.DOMParser
25
- globalThis.Node = dom.window.Node
26
- })
27
-
28
- it('Should be able to create a Nanosplash component', () => {
29
- const getClass = (element: Element) => element.classList[0]
30
- const element = createElement()
31
- const contentElement = <Element>element.firstElementChild
32
- const textElement = <Element>contentElement.firstElementChild
33
- const spinnerElement = <Element>textElement.nextElementSibling
34
-
35
- expect(getClass(element)).toBe('ns')
36
- expect(getClass(contentElement)).toBe('ns-content')
37
- expect(getClass(textElement)).toBe('ns-text')
38
- expect(getClass(spinnerElement)).toBe('ns-spinner')
39
- })
40
-
41
- it('Should be able to inject a Nanosplash component', () => {
42
- const element = createElement()
43
- const destinationElement = document.createElement('div')
44
- injectAsFirstChild(element, destinationElement)
45
- expect(destinationElement.firstElementChild).toBe(element)
46
- })
47
-
48
- it('Should be able to prepare the parent of a Nanosplash component', () => {
49
- const ns = new Nanosplash()
50
- const parent = document.createElement('div')
51
- parent.appendChild(ns.getNSElement())
52
- prepareParentOf(ns)
53
- expect(parent.classList.contains(Nanosplash.nsHostClassName)).toBe(true)
54
- })
55
-
56
- it('Should be able to clean the parent of a Nanosplash component', () => {
57
- const ns = new Nanosplash()
58
- const parent = document.createElement('div')
59
- parent.appendChild(ns.getNSElement())
60
- parent.classList.add(Nanosplash.nsHostClassName)
61
- cleanNSParentOf(ns)
62
- expect(parent.classList.contains(Nanosplash.nsHostClassName)).toBe(false)
63
- })
64
-
65
- it('Should be able to show an element', () => {
66
- const element = document.createElement('div')
67
- showElement(element)
68
- expect(element.style.display).toBe('flex')
69
- })
70
-
71
- it('Should be able to hide an element', () => {
72
- const element = document.createElement('div')
73
- hideElement(element)
74
- expect(element.style.display).toBe('none')
75
- })
76
-
77
- it('Should be able to alter the class of a Nanosplash host', () => {
78
- const div = document.createElement('div')
79
- setNSHostClass(div, 'add')
80
- expect(div.classList.contains(Nanosplash.nsHostClassName)).toBe(true)
81
- setNSHostClass(div, 'remove')
82
- expect(div.classList.contains(Nanosplash.nsHostClassName)).toBe(false)
83
- })
84
-
85
- it('Should be able to move a Nanosplash component', () => {
86
- const ns = new Nanosplash()
87
- const destination = document.createElement('div')
88
- move(ns.getNSElement(), destination)
89
- expect(destination.firstElementChild).toBe(ns.getNSElement())
90
- })
91
- })
@@ -1,56 +0,0 @@
1
- // @ts-strict
2
-
3
- import { it, expect, describe } from 'vitest'
4
- import Stack from '../src/ts/util/Stack'
5
-
6
- describe('Stack', () => {
7
- it('Should add items to the stack', () => {
8
- const stack = new Stack<number>()
9
- stack.push(1)
10
- stack.push(2)
11
- stack.push(3)
12
- expect(stack.size()).toBe(3)
13
- })
14
-
15
- it('Should remove and return the item at the top of the stack', () => {
16
- const stack = new Stack<string>()
17
- stack.push('a')
18
- stack.push('b')
19
- stack.push('c')
20
- const item = stack.pop()
21
- expect(item).toBe('c')
22
- expect(stack.size()).toBe(2)
23
- })
24
-
25
- it('Should return the item at the top of the stack without removing it', () => {
26
- const stack = new Stack<number>()
27
- stack.push(1)
28
- stack.push(2)
29
- stack.push(3)
30
- const topItem = stack.peek()
31
- expect(topItem).toBe(3)
32
- expect(stack.size()).toBe(3)
33
- })
34
-
35
- it('Should return true if the stack is empty', () => {
36
- const stack = new Stack<boolean>()
37
- expect(stack.isEmpty()).toBe(true)
38
- })
39
-
40
- it('Should return the number of items in the stack', () => {
41
- const stack = new Stack<string>()
42
- stack.push('a')
43
- stack.push('b')
44
- stack.push('c')
45
- expect(stack.size()).toBe(3)
46
- })
47
-
48
- it('Should clear the stack', () => {
49
- const stack = new Stack<number>()
50
- stack.push(1)
51
- stack.push(2)
52
- stack.push(3)
53
- stack.clear()
54
- expect(stack.isEmpty()).toBe(true)
55
- })
56
- })