terrier-engine 4.72.3 → 4.75.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/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "files": [
5
5
  "*"
6
6
  ],
7
- "version": "4.72.3",
7
+ "version": "4.75.0",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Terrier-Tech/terrier-engine"
@@ -17,22 +17,22 @@
17
17
  "dependencies": {
18
18
  "@types/turbolinks": "^5.2.0",
19
19
  "dayjs": "^1.11.7",
20
- "inflection": "^2.0.1",
21
- "mime-types": "^2.1.35",
20
+ "inflection": "^3.0.2",
21
+ "mime-types": "^3.0.2",
22
22
  "tuff-core": "latest",
23
23
  "tuff-plot": "latest",
24
24
  "tuff-sortable": "latest",
25
25
  "turbolinks": "^5.2.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@types/mime-types": "^2.1.4",
29
- "@types/node": "^22.9.0",
30
- "glyphs2font": "^1.2.4",
31
- "prettier": "^2.8.8",
32
- "svgo": "^3.0.2",
33
- "typescript": "^5.6.3",
34
- "vite": "^5.4.19",
28
+ "@terrier-tech/glyphs2font": "^1.4.0",
29
+ "@types/mime-types": "^3.0.1",
30
+ "@types/node": "^26.1.2",
31
+ "prettier": "^3.9.6",
32
+ "svgo": "^4.0.2",
33
+ "typescript": "^6.0.3",
34
+ "vite": "^8.2.1",
35
35
  "vite-plugin-ruby": "^5.1.1",
36
- "vitest": "^2.1.9"
36
+ "vitest": "^4.1.10"
37
37
  }
38
38
  }
@@ -247,7 +247,7 @@ type PollingResponse<TResult> = (ApiResponse & SubscriptionEvent<TResult>) | { e
247
247
  export class PollingSubscriber<TResult, TParams extends SubscriptionParams> extends ApiSubscriber<TResult, TParams, (SubscriptionOptions & GetSubscriberOptions)> {
248
248
 
249
249
  // used to ensure we only schedule one interval at a time and allows for cancellation.
250
- private timeoutHandle: NodeJS.Timeout | null = null
250
+ private timeoutHandle: number | null = null
251
251
 
252
252
  /**
253
253
  * @param url the url to make a request to.
@@ -342,7 +342,7 @@ export class PollingSubscriber<TResult, TParams extends SubscriptionParams> exte
342
342
 
343
343
  this.logger?.debug("polling in", intervalMs, "milliseconds")
344
344
 
345
- this.timeoutHandle = setTimeout(this.makeRequest.bind(this), intervalMs)
345
+ this.timeoutHandle = window.setTimeout(this.makeRequest.bind(this), intervalMs)
346
346
  }
347
347
  }
348
348
 
package/terrier/api.ts CHANGED
@@ -1,9 +1,11 @@
1
- import {Logger} from "tuff-core/logging"
2
- import {QueryParams, RawQueryParams} from "tuff-core/urls"
3
- import {LogEntry} from "./logging"
4
- import {ErrorEvent} from "./api-subscriber"
5
- import Strings from "tuff-core/strings";
6
- import dayjs from "dayjs";
1
+ import dayjs from "dayjs"
2
+ import { HtmlParentTag } from "tuff-core/html"
3
+ import { Logger } from "tuff-core/logging"
4
+ import { TuffError } from "tuff-core/parts"
5
+ import Strings from "tuff-core/strings"
6
+ import { QueryParams, RawQueryParams } from "tuff-core/urls"
7
+ import { ErrorEvent } from "./api-subscriber"
8
+ import { LogEntry } from "./logging"
7
9
 
8
10
  const log = new Logger('Api')
9
11
 
@@ -22,9 +24,14 @@ export type ApiResponse = {
22
24
  /**
23
25
  * Exception that gets thrown when an API call fails.
24
26
  */
25
- export class ApiException extends Error {
27
+ export class ApiException extends TuffError {
26
28
  constructor(message: string) {
27
- super(`ApiException: ${message}`)
29
+ super(message)
30
+ this.name = "ApiException"
31
+ }
32
+
33
+ render(parent: HtmlParentTag) {
34
+ parent.p().text(this.message)
28
35
  }
29
36
  }
30
37
 
package/terrier/glyps.ts CHANGED
@@ -1,4 +1,4 @@
1
- // This file was automatically generated by glyps:compile on 07/01/26 12:59 PM, DO NOT MANUALLY EDIT!
1
+ // This file was automatically generated by glyps:compile on 08/11/26 10:33 AM, DO NOT MANUALLY EDIT!
2
2
 
3
3
  import Strings from "tuff-core/strings"
4
4
 
@@ -0,0 +1,138 @@
1
+ import Messages from "tuff-core/messages"
2
+ import { PartTag } from "tuff-core/parts"
3
+ import { SelectOption, SelectOptions } from "tuff-core/forms"
4
+ import TerrierPart from "./terrier-part"
5
+
6
+ export type MultiSelectFieldState = {
7
+ options: SelectOptions
8
+ selected_values: string[]
9
+ placeholder?: string
10
+ name?: string
11
+ disabled?: boolean
12
+ }
13
+
14
+ export class MultiSelectFieldPart extends TerrierPart<MultiSelectFieldState> {
15
+ selectionChangedKey = Messages.typedKey<{ selected_values: string[] }>()
16
+ protected addOptionKey = Messages.untypedKey()
17
+ protected removeValueKey = Messages.typedKey<{ value: string }>()
18
+
19
+ async init() {
20
+ await super.init()
21
+
22
+ this.onChange(this.addOptionKey, m => {
23
+ if (m.value?.length) this.addValue(m.value)
24
+ })
25
+
26
+ this.onClick(this.removeValueKey, m => {
27
+ this.removeValue(m.data.value)
28
+ })
29
+ }
30
+
31
+ get parentClasses(): Array<string> {
32
+ const classes = ['tt-multi-select-field', ...super.parentClasses]
33
+ if (this.state.disabled) classes.push('disabled')
34
+ return classes
35
+ }
36
+
37
+
38
+ /// Selection
39
+
40
+ get selectedValues(): string[] {
41
+ return this.state.selected_values
42
+ }
43
+
44
+ setSelectedValues(values: string[]) {
45
+ this.state.selected_values = [...values]
46
+ this.onSelectionChanged()
47
+ }
48
+
49
+ addValue(value: string) {
50
+ if (this.state.selected_values.includes(value)) return
51
+ this.state.selected_values = [...this.state.selected_values, value]
52
+ this.onSelectionChanged()
53
+ }
54
+
55
+ removeValue(value: string) {
56
+ if (!this.state.selected_values.includes(value)) return
57
+ this.state.selected_values = this.state.selected_values.filter(v => v != value)
58
+ this.onSelectionChanged()
59
+ }
60
+
61
+ protected onSelectionChanged() {
62
+ this.dirty()
63
+ this.emitMessage(this.selectionChangedKey, { selected_values: this.state.selected_values })
64
+ }
65
+
66
+
67
+ /// Options
68
+
69
+ protected get flatOptions(): SelectOption[] {
70
+ return this.state.options.flatMap(opt => 'group' in opt ? opt.options : [opt])
71
+ }
72
+
73
+ titleForValue(value: string): string {
74
+ return this.flatOptions.find(opt => `${opt.value}` == value)?.title ?? value
75
+ }
76
+
77
+ protected isSelectable(opt: SelectOption): boolean {
78
+ return opt.value != null && `${opt.value}`.length > 0
79
+ }
80
+
81
+ protected isSelected(value: string | null): boolean {
82
+ return value != null && this.state.selected_values.includes(`${value}`)
83
+ }
84
+
85
+
86
+ /// Rendering
87
+
88
+ render(parent: PartTag) {
89
+ parent.div('.tt-multi-select-field-container', container => {
90
+ this.renderAddSelect(container)
91
+ this.renderChips(container)
92
+ if (this.state.name) {
93
+ container.input('.tt-multi-select-values', {
94
+ type: 'hidden',
95
+ name: this.state.name,
96
+ value: this.state.selected_values.join(',')
97
+ })
98
+ }
99
+ })
100
+ }
101
+ protected renderAddSelect(parent: PartTag) {
102
+ const blankText = this.state.selected_values.length ? '' : (this.state.placeholder ?? 'Select…')
103
+ parent.select('.tt-multi-select-add', this.state.disabled ? { disabled: true } : {}, select => {
104
+ select.option({ value: '', text: blankText })
105
+ for (const opt of this.state.options) {
106
+ if ('group' in opt) {
107
+ const available = opt.options.filter(o => this.isSelectable(o) && !this.isSelected(o.value))
108
+ if (!available.length) continue
109
+ select.optgroup({ label: opt.group }, group => {
110
+ for (const o of available) this.renderAddOption(group, o)
111
+ })
112
+ } else if (this.isSelectable(opt) && !this.isSelected(opt.value)) {
113
+ this.renderAddOption(select, opt)
114
+ }
115
+ }
116
+ }).emitChange(this.addOptionKey)
117
+ }
118
+
119
+ protected renderAddOption(parent: PartTag, opt: SelectOption) {
120
+ parent.option({ value: `${opt.value}`, text: opt.title })
121
+ }
122
+ protected renderChips(parent: PartTag) {
123
+ parent.div('.tt-multi-select-chips', container => {
124
+ for (const value of this.state.selected_values) {
125
+ container.div('.tt-multi-select-chip', chip => {
126
+ chip.div('.tt-multi-select-chip-label', { text: this.titleForValue(value) })
127
+ if (!this.state.disabled) {
128
+ chip.a('.tt-multi-select-chip-remove')
129
+ .emitClick(this.removeValueKey, { value })
130
+ }
131
+ })
132
+ }
133
+ })
134
+ }
135
+
136
+ }
137
+
138
+ export default MultiSelectFieldPart
package/tsconfig.json CHANGED
@@ -8,6 +8,7 @@
8
8
  "ESNext",
9
9
  "DOM"
10
10
  ],
11
+ "types" : ["vite/client"],
11
12
  "moduleResolution" : "bundler",
12
13
  "strict" : true,
13
14
  "sourceMap" : true,