@furystack/shades-common-components 12.0.0 → 12.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 (49) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +26 -0
  3. package/esm/components/cache-view.d.ts +46 -0
  4. package/esm/components/cache-view.d.ts.map +1 -0
  5. package/esm/components/cache-view.js +65 -0
  6. package/esm/components/cache-view.js.map +1 -0
  7. package/esm/components/cache-view.spec.d.ts +2 -0
  8. package/esm/components/cache-view.spec.d.ts.map +1 -0
  9. package/esm/components/cache-view.spec.js +183 -0
  10. package/esm/components/cache-view.spec.js.map +1 -0
  11. package/esm/components/command-palette/command-palette-input.spec.js +148 -148
  12. package/esm/components/command-palette/command-palette-input.spec.js.map +1 -1
  13. package/esm/components/command-palette/command-palette-suggestion-list.spec.js +258 -258
  14. package/esm/components/command-palette/command-palette-suggestion-list.spec.js.map +1 -1
  15. package/esm/components/context-menu/context-menu-manager.spec.js +211 -217
  16. package/esm/components/context-menu/context-menu-manager.spec.js.map +1 -1
  17. package/esm/components/data-grid/body.spec.js +173 -173
  18. package/esm/components/data-grid/body.spec.js.map +1 -1
  19. package/esm/components/data-grid/data-grid.spec.js +39 -130
  20. package/esm/components/data-grid/data-grid.spec.js.map +1 -1
  21. package/esm/components/index.d.ts +1 -0
  22. package/esm/components/index.d.ts.map +1 -1
  23. package/esm/components/index.js +1 -0
  24. package/esm/components/index.js.map +1 -1
  25. package/esm/components/skeleton.d.ts.map +1 -1
  26. package/esm/components/skeleton.js +2 -11
  27. package/esm/components/skeleton.js.map +1 -1
  28. package/esm/components/skeleton.spec.js +6 -55
  29. package/esm/components/skeleton.spec.js.map +1 -1
  30. package/esm/services/click-away-service.spec.js +14 -12
  31. package/esm/services/click-away-service.spec.js.map +1 -1
  32. package/esm/services/list-service.spec.js +170 -141
  33. package/esm/services/list-service.spec.js.map +1 -1
  34. package/esm/services/tree-service.spec.js +190 -159
  35. package/esm/services/tree-service.spec.js.map +1 -1
  36. package/package.json +8 -8
  37. package/src/components/cache-view.spec.tsx +210 -0
  38. package/src/components/cache-view.tsx +103 -0
  39. package/src/components/command-palette/command-palette-input.spec.tsx +183 -194
  40. package/src/components/command-palette/command-palette-suggestion-list.spec.tsx +303 -321
  41. package/src/components/context-menu/context-menu-manager.spec.ts +213 -258
  42. package/src/components/data-grid/body.spec.tsx +266 -276
  43. package/src/components/data-grid/data-grid.spec.tsx +137 -232
  44. package/src/components/index.ts +1 -0
  45. package/src/components/skeleton.spec.tsx +6 -73
  46. package/src/components/skeleton.tsx +2 -11
  47. package/src/services/click-away-service.spec.ts +14 -16
  48. package/src/services/list-service.spec.ts +170 -172
  49. package/src/services/tree-service.spec.ts +191 -207
@@ -46,7 +46,7 @@ describe('Skeleton', () => {
46
46
  vi.restoreAllMocks()
47
47
  })
48
48
 
49
- it('should render with shadow DOM', async () => {
49
+ it('should render with correct initial state and default delay', async () => {
50
50
  await usingAsync(new Injector(), async (injector) => {
51
51
  const rootElement = document.getElementById('root') as HTMLDivElement
52
52
 
@@ -60,40 +60,13 @@ describe('Skeleton', () => {
60
60
 
61
61
  const skeleton = document.querySelector('shade-skeleton')
62
62
  expect(skeleton).not.toBeNull()
63
- })
64
- })
65
-
66
- it('should have initial opacity of 0', async () => {
67
- await usingAsync(new Injector(), async (injector) => {
68
- const rootElement = document.getElementById('root') as HTMLDivElement
69
-
70
- initializeShadeRoot({
71
- injector,
72
- rootElement,
73
- jsxElement: <Skeleton />,
74
- })
75
-
76
- await sleepAsync(50)
77
63
 
78
- const skeleton = document.querySelector('shade-skeleton') as HTMLElement
79
- expect(skeleton).not.toBeNull()
64
+ const skeletonDiv = document.querySelector('shade-skeleton div') as HTMLElement
65
+ expect(skeletonDiv).not.toBeNull()
80
66
 
81
- const computedStyle = window.getComputedStyle(skeleton)
67
+ const computedStyle = window.getComputedStyle(skeletonDiv)
82
68
  expect(computedStyle.opacity).toBe('0')
83
- })
84
- })
85
-
86
- it('should use default delay of 1500ms', async () => {
87
- await usingAsync(new Injector(), async (injector) => {
88
- const rootElement = document.getElementById('root') as HTMLDivElement
89
-
90
- initializeShadeRoot({
91
- injector,
92
- rootElement,
93
- jsxElement: <Skeleton />,
94
- })
95
-
96
- await sleepAsync(50)
69
+ expect(computedStyle.display).toBe('inline-block')
97
70
 
98
71
  const fadeInCall = animateCalls.find(
99
72
  (call) => Array.isArray(call.keyframes) && call.keyframes.some((kf: Keyframe) => 'opacity' in kf),
@@ -125,26 +98,6 @@ describe('Skeleton', () => {
125
98
  })
126
99
  })
127
100
 
128
- it('should have correct css styles applied', async () => {
129
- await usingAsync(new Injector(), async (injector) => {
130
- const rootElement = document.getElementById('root') as HTMLDivElement
131
-
132
- initializeShadeRoot({
133
- injector,
134
- rootElement,
135
- jsxElement: <Skeleton />,
136
- })
137
-
138
- await sleepAsync(50)
139
-
140
- const skeleton = document.querySelector('shade-skeleton') as HTMLElement
141
- expect(skeleton).not.toBeNull()
142
-
143
- const computedStyle = window.getComputedStyle(skeleton)
144
- expect(computedStyle.display).toBe('inline-block')
145
- })
146
- })
147
-
148
101
  it('should start fade-in animation with correct parameters', async () => {
149
102
  await usingAsync(new Injector(), async (injector) => {
150
103
  const rootElement = document.getElementById('root') as HTMLDivElement
@@ -175,7 +128,7 @@ describe('Skeleton', () => {
175
128
  })
176
129
  })
177
130
 
178
- it('should start background animation after fade-in completes', async () => {
131
+ it('should start background animation with correct keyframes after fade-in completes', async () => {
179
132
  await usingAsync(new Injector(), async (injector) => {
180
133
  const rootElement = document.getElementById('root') as HTMLDivElement
181
134
 
@@ -196,26 +149,6 @@ describe('Skeleton', () => {
196
149
  const options = backgroundAnimation?.options as KeyframeAnimationOptions
197
150
  expect(options.duration).toBe(10000)
198
151
  expect(options.iterations).toBe(Infinity)
199
- })
200
- })
201
-
202
- it('should have gradient background animation keyframes', async () => {
203
- await usingAsync(new Injector(), async (injector) => {
204
- const rootElement = document.getElementById('root') as HTMLDivElement
205
-
206
- initializeShadeRoot({
207
- injector,
208
- rootElement,
209
- jsxElement: <Skeleton delay={0} />,
210
- })
211
-
212
- await sleepAsync(100)
213
-
214
- const backgroundAnimation = animateCalls.find(
215
- (call) => Array.isArray(call.keyframes) && call.keyframes.some((kf: Keyframe) => 'backgroundPosition' in kf),
216
- )
217
-
218
- expect(backgroundAnimation).toBeDefined()
219
152
 
220
153
  const keyframes = backgroundAnimation?.keyframes as Keyframe[]
221
154
  expect(keyframes).toHaveLength(3)
@@ -11,15 +11,6 @@ export type SkeletonProps = {
11
11
 
12
12
  export const Skeleton = Shade<SkeletonProps>({
13
13
  shadowDomName: 'shade-skeleton',
14
- css: {
15
- opacity: '0',
16
- display: 'inline-block',
17
- background: `linear-gradient(-45deg, color-mix(in srgb, ${cssVariableTheme.text.secondary} 10%, transparent), color-mix(in srgb, ${cssVariableTheme.text.secondary} 30%, transparent), color-mix(in srgb, ${cssVariableTheme.text.secondary} 10%, transparent))`,
18
- backgroundSize: '400% 400%',
19
- width: '100%',
20
- height: '100%',
21
- minHeight: '1em',
22
- },
23
14
  render: ({ props, useRef }) => {
24
15
  const wrapperRef = useRef<HTMLDivElement>('wrapper')
25
16
  const { delay = 1500 } = props
@@ -49,8 +40,8 @@ export const Skeleton = Shade<SkeletonProps>({
49
40
  style={{
50
41
  opacity: '0',
51
42
  display: 'inline-block',
52
- background: 'inherit',
53
- backgroundSize: 'inherit',
43
+ background: `linear-gradient(-45deg, color-mix(in srgb, ${cssVariableTheme.text.secondary} 10%, transparent), color-mix(in srgb, ${cssVariableTheme.text.secondary} 30%, transparent), color-mix(in srgb, ${cssVariableTheme.text.secondary} 10%, transparent))`,
44
+ backgroundSize: '400% 400%',
54
45
  width: '100%',
55
46
  height: '100%',
56
47
  minHeight: '1em',
@@ -1,35 +1,33 @@
1
+ import { using } from '@furystack/utils'
1
2
  import { describe, expect, it, vi } from 'vitest'
2
3
  import { ClickAwayService } from './click-away-service.js'
3
4
 
4
5
  describe('ClickAwayService', () => {
5
6
  it('Should be constructed and disposed', () => {
6
- const service = new ClickAwayService(document.createElement('div'), () => {})
7
- service[Symbol.dispose]()
7
+ using(new ClickAwayService(document.createElement('div'), () => {}), () => {
8
+ // Constructed and disposed automatically
9
+ })
8
10
  })
9
11
 
10
12
  it('Should call onClickAway when clicking outside the element', () => {
11
13
  const onClickAway = vi.fn()
12
14
  const div = document.createElement('div')
13
- const service = new ClickAwayService(div, onClickAway)
15
+ using(new ClickAwayService(div, onClickAway), () => {
16
+ document.body.appendChild(div)
17
+ document.body.click()
14
18
 
15
- document.body.appendChild(div)
16
- document.body.click()
17
-
18
- expect(onClickAway).toBeCalled()
19
-
20
- service[Symbol.dispose]()
19
+ expect(onClickAway).toBeCalled()
20
+ })
21
21
  })
22
22
 
23
23
  it('Should not call onClickAway when clicking inside the element', () => {
24
24
  const onClickAway = vi.fn()
25
25
  const div = document.createElement('div')
26
- const service = new ClickAwayService(div, onClickAway)
27
-
28
- document.body.appendChild(div)
29
- div.click()
30
-
31
- expect(onClickAway).not.toBeCalled()
26
+ using(new ClickAwayService(div, onClickAway), () => {
27
+ document.body.appendChild(div)
28
+ div.click()
32
29
 
33
- service[Symbol.dispose]()
30
+ expect(onClickAway).not.toBeCalled()
31
+ })
34
32
  })
35
33
  })