@humandialog/forms.svelte 1.4.10 → 1.5.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.
@@ -262,7 +262,7 @@ async function dblclick(e) {
262
262
  </button-->
263
263
  </h2>
264
264
  </header>
265
- <ul class="w-full border-stone-700 pb-20" bind:this={column_element}>
265
+ <ul class="w-full border-stone-400 dark:border-stone-700 pb-20" bind:this={column_element}>
266
266
  {#if showInserterAfterId === KanbanColumnTop}
267
267
  <Inserter onInsert={async (title, summary) => {await onInsert(currentColumnIdx, title, summary, KanbanColumnTop)}}
268
268
  bind:this={inserter} />
@@ -185,7 +185,7 @@
185
185
  </script>
186
186
 
187
187
  {#if view==TAGS_PALETTE}
188
- <menu class="{userClass} flex flex-column {gap} flex-wrap mr-1 sm:mr-0 sm:w-72">
188
+ <menu class="{userClass} flex flex-column {gap} flex-wrap mr-1 sm:mr-0 sm:w-72 text-stone-600 dark:text-stone-300">
189
189
  <p class="flex flex-row {gap} flex-wrap ">
190
190
  {#key filteredTags}
191
191
  {#if filteredTags.length > 0}
@@ -206,7 +206,7 @@
206
206
 
207
207
  <input type="text" name="text" id="text"
208
208
  autocomplete="off"
209
- class="block bg-stone-100 dark:bg-stone-800 flex-1"
209
+ class="block bg-stone-100 dark:bg-stone-800 flex-1 text-stone-700 dark:text-stone-200"
210
210
  bind:value={inputText}
211
211
  on:input={onTextInput}
212
212
  on:blur={onTextBlur}
package/index.d.ts CHANGED
@@ -71,3 +71,4 @@ export { default as IcH1 } from './components/document/internal/h1.icon.svelte';
71
71
  export { default as IcH2 } from './components/document/internal/h2.icon.svelte';
72
72
  export { default as IcH3 } from './components/document/internal/h3.icon.svelte';
73
73
  export { default as IcH4 } from './components/document/internal/h4.icon.svelte';
74
+ export { registerKicksObserver, unregisterKicksObserver, forceKicksChecking } from './kicks.js';
package/index.js CHANGED
@@ -77,3 +77,4 @@ export { default as IcH1 } from './components/document/internal/h1.icon.svelte';
77
77
  export { default as IcH2 } from './components/document/internal/h2.icon.svelte';
78
78
  export { default as IcH3 } from './components/document/internal/h3.icon.svelte';
79
79
  export { default as IcH4 } from './components/document/internal/h4.icon.svelte';
80
+ export { registerKicksObserver, unregisterKicksObserver, forceKicksChecking } from './kicks.js';
package/kicks.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export function registerKicksObserver(labels: any, interval: any, callback: any): number;
2
+ export function unregisterKicksObserver(regId: any): void;
3
+ export function forceKicksChecking(): void;
package/kicks.js ADDED
@@ -0,0 +1,155 @@
1
+ import {reef, session} from '@humandialog/auth.svelte'
2
+ import {get} from 'svelte/store'
3
+
4
+ let nextObserverId = 1000
5
+ let registeredObservers = []
6
+ let minInterval = 0
7
+ let lastCheckAt = 0
8
+ let timerId = 0;
9
+
10
+ let lastKicks = new Map();
11
+
12
+ export function registerKicksObserver(labels, interval, callback)
13
+ {
14
+ let lbs = []
15
+ if(labels && Array.isArray(labels))
16
+ lbs = labels
17
+ else
18
+ lbs = [labels]
19
+
20
+ registeredObservers.push( {
21
+ labels: lbs,
22
+ interval: interval,
23
+ callback: callback,
24
+ id: nextObserverId
25
+ })
26
+
27
+ const res = nextObserverId;
28
+ nextObserverId++;
29
+
30
+ updateTimer()
31
+ return res
32
+ }
33
+
34
+ export function unregisterKicksObserver(regId)
35
+ {
36
+ const fIdx = registeredObservers.findIndex( (o) => o.id == regId)
37
+ if(fIdx >=0)
38
+ registeredObservers.splice(fIdx, 1)
39
+
40
+ updateTimer()
41
+ }
42
+
43
+ export function forceKicksChecking()
44
+ {
45
+ checkKicks();
46
+
47
+
48
+ if(timerId > 0)
49
+ {
50
+ clearTimeout(timerId)
51
+ timerId = 0
52
+ }
53
+
54
+ if(minInterval > 0)
55
+ timerId = setTimeout(timerHandler, minInterval*1000)
56
+ }
57
+
58
+ function getMinInterval()
59
+ {
60
+ if(registeredObservers.length == 0)
61
+ return 0;
62
+
63
+ let minInterval = Number.MAX_SAFE_INTEGER;
64
+ registeredObservers.forEach((o) => {
65
+ if(o.interval < minInterval)
66
+ minInterval = o.interval
67
+ })
68
+
69
+ return minInterval;
70
+ }
71
+
72
+ function timerHandler()
73
+ {
74
+ checkKicks();
75
+ timerId = setTimeout(timerHandler, minInterval*1000)
76
+ }
77
+
78
+ function updateTimer()
79
+ {
80
+ const newInterval = getMinInterval()
81
+
82
+ let isFirstTimeLaunch = (timerId == 0) && (newInterval > 0)
83
+
84
+ if(timerId > 0)
85
+ {
86
+ clearTimeout(timerId)
87
+ timerId = 0
88
+ }
89
+
90
+ if(newInterval > 0)
91
+ timerId = setTimeout(timerHandler, newInterval*1000)
92
+
93
+ minInterval = newInterval
94
+
95
+ if(isFirstTimeLaunch)
96
+ checkKicks(false)
97
+ }
98
+
99
+ function checkKicks(informObservers=true)
100
+ {
101
+ const s = get(session)
102
+ const appId = s.appId ? s.appId : 'octopus'
103
+ const tid = s.tid ? s.tid : 'octopus/15'
104
+ console.log(s.isActive, appId, tid)
105
+ if(s.isActive && appId && tid)
106
+ {
107
+ reef.fetch(`/dev/kicks?app_id=${appId}&tenant_id=${encodeURIComponent(tid)}&last_check=${lastCheckAt}`).then(res => {
108
+ if(res.ok)
109
+ {
110
+ res.json().then( result =>
111
+ {
112
+ // todo
113
+ //console.log('kicks:', result)
114
+
115
+
116
+ let changedLabels = []
117
+ result.allKicks.forEach(current => {
118
+
119
+ if(lastKicks.has(current.label))
120
+ {
121
+ let storedKick = lastKicks.get(current.label)
122
+ if(storedKick.kick != current.kick)
123
+ {
124
+ lastKicks.set(current.label, {...current})
125
+ changedLabels.push(current.label)
126
+ }
127
+ }
128
+ else
129
+ {
130
+ lastKicks.set(current.label, {...current})
131
+ changedLabels.push(current.label)
132
+ }
133
+ })
134
+
135
+ if(informObservers && changedLabels.length > 0)
136
+ {
137
+ registeredObservers.forEach(ob => {
138
+ const changedLabelsPerObserver = ob.labels.filter(label => changedLabels.includes(label))
139
+ if(changedLabelsPerObserver.length > 0)
140
+ {
141
+ if(ob.callback)
142
+ ob.callback(changedLabelsPerObserver)
143
+ }
144
+ })
145
+ }
146
+ }
147
+ ).catch(err => console.error(err))
148
+ }
149
+ }).catch(err => {
150
+ console.error(err)
151
+ })
152
+ }
153
+
154
+ lastCheckAt = Date.now() / 1000;
155
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@humandialog/forms.svelte",
3
- "version": "1.4.10",
3
+ "version": "1.5.0",
4
4
  "description": "Basic Svelte UI components for Object Reef applications",
5
5
  "devDependencies": {
6
6
  "@playwright/test": "^1.28.1",
@@ -46,7 +46,8 @@
46
46
  "qs": "^6.14.0",
47
47
  "svelte-icons": "^2.1.0",
48
48
  "svelte-share-buttons-component": "^3.0.0",
49
- "svelte-spa-router": "^4.0.1"
49
+ "svelte-spa-router": "^4.0.1",
50
+ "swagger-ui-dist": "^5.27.0"
50
51
  },
51
52
  "keywords": [
52
53
  "svelte",
@@ -158,6 +159,7 @@
158
159
  ".": "./index.js",
159
160
  "./internal/configurable.content.svelte": "./internal/configurable.content.svelte",
160
161
  "./internal/loading.svelte": "./internal/loading.svelte",
162
+ "./kicks": "./kicks.js",
161
163
  "./modal.svelte": "./modal.svelte",
162
164
  "./operations.svelte": "./operations.svelte",
163
165
  "./page.row.svelte": "./page.row.svelte",