@globalbrain/sefirot 4.35.3 → 4.36.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.
@@ -1,3 +1,5 @@
1
+ import { xor } from 'lodash-es'
2
+ import { type DropdownSection } from '../../../composables/Dropdown'
1
3
  import { type TableCell } from '../../../composables/Table'
2
4
  import { type RelatedManyFieldData } from '../FieldData'
3
5
  import { type FilterOperator } from '../FilterOperator'
@@ -14,6 +16,34 @@ export class RelatedManyField extends Field<RelatedManyFieldData> {
14
16
  this.fetcher = fetcher
15
17
  }
16
18
 
19
+ override async tableFilterMenu(filters: any[], onFilterUpdated: (filters: any[]) => void): Promise<DropdownSection | null> {
20
+ const method = this.data.resourceEndpointMethod
21
+ const url = this.data.resourceEndpointPath
22
+ const key = this.data.resourceEndpointDataKey
23
+
24
+ if (!url) {
25
+ return null
26
+ }
27
+
28
+ const selected = this.inFilterValueFor(this.data.key, filters)
29
+
30
+ const res = await this.fetcher(method, url)
31
+ const data = key ? res[key] : res
32
+
33
+ const options = data.map((item: any) => ({
34
+ label: item[this.data.resourceTitle],
35
+ value: item[this.data.filterKey]
36
+ }))
37
+
38
+ return {
39
+ type: 'filter',
40
+ search: true,
41
+ selected,
42
+ options,
43
+ onClick: (v) => { onFilterUpdated?.([this.data.key, 'in', xor(selected, [v])]) }
44
+ }
45
+ }
46
+
17
47
  override tableCell(v: any, _r: any): TableCell {
18
48
  return {
19
49
  type: 'pills',
package/lib/http/Http.ts CHANGED
@@ -61,7 +61,9 @@ export class Http {
61
61
  }
62
62
 
63
63
  private async performRequestRaw<T>(url: string, options: FetchOptions = {}): Promise<FetchResponse<T>> {
64
- return this.config.client.raw(...(await this.buildRequest(url, options)))
64
+ // 'raw' is unavailable in useRequestFetch() during SSR, but performRequestRaw is only
65
+ // called by download, which runs client-side, so asserting raw's existence is safe
66
+ return this.config.client.raw!(...(await this.buildRequest(url, options)))
65
67
  }
66
68
 
67
69
  async get<T = any>(url: string, options?: FetchOptions): Promise<T> {
@@ -8,7 +8,7 @@ type Awaitable<T> = T | PromiseLike<T>
8
8
 
9
9
  export interface HttpClient {
10
10
  (request: FetchRequest, options?: Omit<FetchOptions, 'method'>): Promise<any>
11
- raw(request: FetchRequest, options?: Omit<FetchOptions, 'method'>): Promise<FetchResponse<any>>
11
+ raw?(request: FetchRequest, options?: Omit<FetchOptions, 'method'>): Promise<FetchResponse<any>>
12
12
  }
13
13
 
14
14
  export interface HttpOptions {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@globalbrain/sefirot",
3
- "version": "4.35.3",
3
+ "version": "4.36.0",
4
4
  "description": "Vue Components for Global Brain Design System.",
5
5
  "keywords": [
6
6
  "components",