@furystack/shades-common-components 5.0.20 → 7.0.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/esm/components/command-palette/command-palette-input.d.ts.map +1 -1
- package/esm/components/command-palette/command-palette-input.js +26 -23
- package/esm/components/command-palette/command-palette-input.js.map +1 -1
- package/esm/components/command-palette/command-palette-suggestion-list.d.ts.map +1 -1
- package/esm/components/command-palette/command-palette-suggestion-list.js +33 -29
- package/esm/components/command-palette/command-palette-suggestion-list.js.map +1 -1
- package/esm/components/command-palette/index.d.ts.map +1 -1
- package/esm/components/command-palette/index.js +48 -44
- package/esm/components/command-palette/index.js.map +1 -1
- package/esm/components/data-grid/data-grid-row.d.ts.map +1 -1
- package/esm/components/data-grid/data-grid-row.js +37 -33
- package/esm/components/data-grid/data-grid-row.js.map +1 -1
- package/esm/components/data-grid/header.d.ts.map +1 -1
- package/esm/components/data-grid/header.js +28 -22
- package/esm/components/data-grid/header.js.map +1 -1
- package/esm/components/data-grid/selection-cell.d.ts.map +1 -1
- package/esm/components/data-grid/selection-cell.js +5 -3
- package/esm/components/data-grid/selection-cell.js.map +1 -1
- package/esm/components/inputs/input.js +1 -1
- package/esm/components/inputs/input.js.map +1 -1
- package/esm/components/noty-list.d.ts.map +1 -1
- package/esm/components/noty-list.js +6 -6
- package/esm/components/noty-list.js.map +1 -1
- package/esm/components/suggest/index.js +2 -2
- package/esm/components/suggest/index.js.map +1 -1
- package/esm/components/suggest/suggest-input.d.ts.map +1 -1
- package/esm/components/suggest/suggest-input.js +12 -9
- package/esm/components/suggest/suggest-input.js.map +1 -1
- package/esm/components/suggest/suggest-manager.d.ts +4 -3
- package/esm/components/suggest/suggest-manager.d.ts.map +1 -1
- package/esm/components/suggest/suggest-manager.js +7 -7
- package/esm/components/suggest/suggest-manager.js.map +1 -1
- package/esm/components/suggest/suggestion-list.js +32 -27
- package/esm/components/suggest/suggestion-list.js.map +1 -1
- package/esm/services/collection-service.d.ts.map +1 -1
- package/esm/services/collection-service.js +3 -2
- package/esm/services/collection-service.js.map +1 -1
- package/esm/services/collection-service.spec.d.ts +2 -0
- package/esm/services/collection-service.spec.d.ts.map +1 -0
- package/esm/services/collection-service.spec.js +28 -0
- package/esm/services/collection-service.spec.js.map +1 -0
- package/esm/services/noty-service.d.ts +11 -7
- package/esm/services/noty-service.d.ts.map +1 -1
- package/esm/services/noty-service.js +25 -14
- package/esm/services/noty-service.js.map +1 -1
- package/esm/services/noty-service.spec.d.ts +2 -0
- package/esm/services/noty-service.spec.d.ts.map +1 -0
- package/esm/services/noty-service.spec.js +20 -0
- package/esm/services/noty-service.spec.js.map +1 -0
- package/package.json +6 -6
- package/src/components/command-palette/command-palette-input.tsx +26 -28
- package/src/components/command-palette/command-palette-suggestion-list.tsx +42 -38
- package/src/components/command-palette/index.tsx +55 -51
- package/src/components/data-grid/data-grid-row.tsx +6 -7
- package/src/components/data-grid/header.tsx +27 -21
- package/src/components/data-grid/selection-cell.tsx +4 -2
- package/src/components/inputs/input.tsx +1 -1
- package/src/components/noty-list.tsx +16 -12
- package/src/components/suggest/index.tsx +2 -2
- package/src/components/suggest/suggest-input.tsx +4 -6
- package/src/components/suggest/suggest-manager.ts +7 -7
- package/src/components/suggest/suggestion-list.tsx +32 -32
- package/src/services/collection-service.spec.ts +37 -0
- package/src/services/collection-service.ts +3 -2
- package/src/services/noty-service.spec.ts +26 -0
- package/src/services/noty-service.ts +23 -11
|
@@ -13,10 +13,9 @@ export const SuggestionList: <T>(props: { manager: SuggestManager<T> }, children
|
|
|
13
13
|
|
|
14
14
|
const [suggestions] = useObservable('suggestions', manager.currentSuggestions)
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
(idx) => {
|
|
16
|
+
// todo: GetLast is eliminated, do we need it?
|
|
17
|
+
const [selectedIndex] = useObservable('selectedIndex', manager.selectedIndex, {
|
|
18
|
+
onChange: (idx) => {
|
|
20
19
|
;([...element.querySelectorAll('.suggestion-item')] as HTMLDivElement[]).map((s, i) => {
|
|
21
20
|
if (i === idx) {
|
|
22
21
|
s.style.background = theme.background.paper
|
|
@@ -27,35 +26,36 @@ export const SuggestionList: <T>(props: { manager: SuggestManager<T> }, children
|
|
|
27
26
|
}
|
|
28
27
|
})
|
|
29
28
|
},
|
|
30
|
-
|
|
31
|
-
)
|
|
29
|
+
})
|
|
32
30
|
|
|
33
|
-
const [isListOpened] = useObservable('isOpened', manager.isOpened,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
31
|
+
const [isListOpened] = useObservable('isOpened', manager.isOpened, {
|
|
32
|
+
onChange: async (isOpened) => {
|
|
33
|
+
const container = element.firstElementChild as HTMLDivElement
|
|
34
|
+
if (isOpened) {
|
|
35
|
+
container.style.zIndex = '1'
|
|
36
|
+
container.style.width = `calc(${Math.round(
|
|
37
|
+
element.parentElement?.getBoundingClientRect().width || 200,
|
|
38
|
+
)}px - 3em)`
|
|
39
|
+
await promisifyAnimation(
|
|
40
|
+
container,
|
|
41
|
+
[
|
|
42
|
+
{ opacity: 0, transform: 'translate(0, -50px)' },
|
|
43
|
+
{ opacity: 1, transform: 'translate(0, 0)' },
|
|
44
|
+
],
|
|
45
|
+
{ fill: 'forwards', duration: 500 },
|
|
46
|
+
)
|
|
47
|
+
} else {
|
|
48
|
+
await promisifyAnimation(
|
|
49
|
+
container,
|
|
50
|
+
[
|
|
51
|
+
{ opacity: 1, transform: 'translate(0, 0)' },
|
|
52
|
+
{ opacity: 0, transform: 'translate(0, -50px)' },
|
|
53
|
+
],
|
|
54
|
+
{ fill: 'forwards', duration: 200 },
|
|
55
|
+
)
|
|
56
|
+
container.style.zIndex = '-1'
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
59
|
})
|
|
60
60
|
|
|
61
61
|
return (
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { usingAsync } from '@furystack/utils'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
|
+
import { CollectionService } from './collection-service.js'
|
|
4
|
+
|
|
5
|
+
const testEntries = [{ foo: 1 }, { foo: 2 }, { foo: 3 }]
|
|
6
|
+
|
|
7
|
+
describe('CollectionService', () => {
|
|
8
|
+
describe('Selection', () => {
|
|
9
|
+
it('Should add and remove selection', async () => {
|
|
10
|
+
await usingAsync(
|
|
11
|
+
new CollectionService({
|
|
12
|
+
defaultSettings: {},
|
|
13
|
+
loader: async () => ({ count: 3, entries: testEntries }),
|
|
14
|
+
}),
|
|
15
|
+
async (collectionService) => {
|
|
16
|
+
await collectionService.getEntries({})
|
|
17
|
+
testEntries.forEach((entry) => {
|
|
18
|
+
expect(collectionService.isSelected(entry)).toBe(false)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
collectionService.addToSelection(testEntries[0])
|
|
22
|
+
|
|
23
|
+
expect(collectionService.isSelected(testEntries[0])).toBe(true)
|
|
24
|
+
expect(collectionService.isSelected(testEntries[1])).toBe(false)
|
|
25
|
+
expect(collectionService.isSelected(testEntries[2])).toBe(false)
|
|
26
|
+
|
|
27
|
+
collectionService.removeFromSelection(testEntries[0])
|
|
28
|
+
|
|
29
|
+
expect(collectionService.isSelected(testEntries[0])).toBe(false)
|
|
30
|
+
|
|
31
|
+
collectionService.toggleSelection(testEntries[1])
|
|
32
|
+
expect(collectionService.isSelected(testEntries[1])).toBe(true)
|
|
33
|
+
},
|
|
34
|
+
)
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
})
|
|
@@ -79,7 +79,7 @@ export class CollectionService<T> implements Disposable {
|
|
|
79
79
|
|
|
80
80
|
public querySettings: ObservableValue<FindOptions<T, Array<keyof T>>>
|
|
81
81
|
|
|
82
|
-
public focusedEntry = new ObservableValue<T | undefined>()
|
|
82
|
+
public focusedEntry = new ObservableValue<T | undefined>(undefined)
|
|
83
83
|
|
|
84
84
|
public selection = new ObservableValue<T[]>([])
|
|
85
85
|
|
|
@@ -217,7 +217,8 @@ export class CollectionService<T> implements Disposable {
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
this.querySettings.subscribe((val) => this.getEntries(val)
|
|
220
|
+
this.querySettings.subscribe((val) => this.getEntries(val))
|
|
221
|
+
this.getEntries(this.querySettings.getValue())
|
|
221
222
|
}
|
|
222
223
|
|
|
223
224
|
public async handleRowDoubleClick(entry: T) {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import type { NotyModel } from './noty-service.js'
|
|
3
|
+
import { NotyService } from './noty-service.js'
|
|
4
|
+
import { using } from '@furystack/utils'
|
|
5
|
+
|
|
6
|
+
describe('NotyService', () => {
|
|
7
|
+
it('Should add and removea noty', () => {
|
|
8
|
+
using(new NotyService(), (notyService) => {
|
|
9
|
+
expect(notyService.getNotyList()).toEqual([])
|
|
10
|
+
|
|
11
|
+
const exampleNoty: NotyModel = {
|
|
12
|
+
type: 'info',
|
|
13
|
+
title: 'Test',
|
|
14
|
+
body: 'Test',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
notyService.emit('onNotyAdded', exampleNoty)
|
|
18
|
+
|
|
19
|
+
expect(notyService.getNotyList()).toEqual([exampleNoty])
|
|
20
|
+
|
|
21
|
+
notyService.emit('onNotyRemoved', exampleNoty)
|
|
22
|
+
|
|
23
|
+
expect(notyService.getNotyList()).toEqual([])
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EventHub } from '@furystack/utils'
|
|
2
2
|
import { Injectable } from '@furystack/inject'
|
|
3
3
|
|
|
4
4
|
export interface NotyModel {
|
|
@@ -9,19 +9,31 @@ export interface NotyModel {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
@Injectable({ lifetime: 'singleton' })
|
|
12
|
-
export class NotyService
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
export class NotyService extends EventHub<
|
|
13
|
+
'onNotyAdded' | 'onNotyRemoved',
|
|
14
|
+
{ onNotyAdded: NotyModel; onNotyRemoved: NotyModel }
|
|
15
|
+
> {
|
|
16
|
+
private notyList: NotyModel[] = []
|
|
15
17
|
|
|
16
|
-
public
|
|
18
|
+
public getNotyList = () => [...this.notyList]
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
this.
|
|
20
|
-
this.notys.setValue([...this.notys.getValue(), noty])
|
|
20
|
+
private onNotyAddListener(newNoty: NotyModel) {
|
|
21
|
+
this.notyList = [...this.notyList, newNoty]
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
this.
|
|
25
|
-
|
|
24
|
+
private onNotyRemoveListener(removedNoty: NotyModel) {
|
|
25
|
+
this.notyList = this.notyList.filter((noty) => noty !== removedNoty)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public dispose(): void {
|
|
29
|
+
this.notyList = []
|
|
30
|
+
this.removeListener('onNotyAdded', this.onNotyAddListener.bind(this))
|
|
31
|
+
this.removeListener('onNotyRemoved', this.onNotyRemoveListener.bind(this))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
constructor() {
|
|
35
|
+
super()
|
|
36
|
+
this.addListener('onNotyAdded', this.onNotyAddListener.bind(this))
|
|
37
|
+
this.addListener('onNotyRemoved', this.onNotyRemoveListener.bind(this))
|
|
26
38
|
}
|
|
27
39
|
}
|