@webwriter/deep-learning-model 0.0.1 → 1.0.2

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 (186) hide show
  1. package/.github/workflows/main.yml +8 -0
  2. package/LICENSE +7 -0
  3. package/README.md +290 -0
  4. package/components/dataset-input/dataset-input.styles.ts +20 -0
  5. package/components/dataset-input/dataset-input.ts +196 -0
  6. package/components/inference-fields/class-input.ts +83 -0
  7. package/components/inference-fields/class-output.ts +62 -0
  8. package/components/inference-fields/image-input.ts +182 -0
  9. package/components/inference-fields/image.ts +82 -0
  10. package/components/inference-fields/inference-interfaces.ts +15 -0
  11. package/components/inference-fields/number-input.ts +62 -0
  12. package/components/inference-fields/number-output.ts +56 -0
  13. package/components/model-editor.ts +288 -0
  14. package/components/model-tests/bad-samples.ts +152 -0
  15. package/components/model-tests/loss-distribution.ts +174 -0
  16. package/components/reference-element-select.ts +105 -0
  17. package/custom-elements.json +1470 -0
  18. package/custom.d.ts +180 -0
  19. package/dist/widgets/webwriter-feature-engineering.css +444 -0
  20. package/dist/widgets/webwriter-feature-engineering.js +112763 -0
  21. package/dist/widgets/webwriter-model-designing.css +444 -0
  22. package/dist/widgets/webwriter-model-designing.js +114587 -0
  23. package/dist/widgets/webwriter-model-evaluation.css +444 -0
  24. package/dist/widgets/webwriter-model-evaluation.js +119010 -0
  25. package/dist/widgets/webwriter-model-prediction.css +444 -0
  26. package/dist/widgets/webwriter-model-prediction.js +109251 -0
  27. package/dist/widgets/webwriter-model-training.css +444 -0
  28. package/dist/widgets/webwriter-model-training.js +121465 -0
  29. package/editing-config.json +73 -0
  30. package/icon.svg +1 -0
  31. package/lib/dataset/class.ts +155 -0
  32. package/lib/dataset/dataset.ts +293 -0
  33. package/lib/dataset/feature.ts +110 -0
  34. package/lib/dataset/image.ts +312 -0
  35. package/lib/dataset/linear.ts +120 -0
  36. package/lib/layers/activation.ts +48 -0
  37. package/lib/layers/add.ts +50 -0
  38. package/lib/layers/attention.ts +74 -0
  39. package/lib/layers/concat.ts +50 -0
  40. package/lib/layers/conv.ts +83 -0
  41. package/lib/layers/dropout.ts +44 -0
  42. package/lib/layers/fcl.ts +66 -0
  43. package/lib/layers/flatten.ts +48 -0
  44. package/lib/layers/index.ts +770 -0
  45. package/lib/layers/input.ts +55 -0
  46. package/lib/layers/noise.ts +43 -0
  47. package/lib/layers/output.ts +64 -0
  48. package/lib/layers/reshape.ts +76 -0
  49. package/lib/layers/transposeconv.ts +90 -0
  50. package/lib/tflib.ts +10 -0
  51. package/lit-localize.json +47 -0
  52. package/localization/ar.xlf +553 -0
  53. package/localization/bg.xlf +552 -0
  54. package/localization/cs.xlf +553 -0
  55. package/localization/da.xlf +552 -0
  56. package/localization/de.xlf +552 -0
  57. package/localization/el.xlf +554 -0
  58. package/localization/es.xlf +553 -0
  59. package/localization/et.xlf +553 -0
  60. package/localization/fi.xlf +552 -0
  61. package/localization/fr.xlf +553 -0
  62. package/localization/generated/ar.ts +159 -0
  63. package/localization/generated/bg.ts +158 -0
  64. package/localization/generated/cs.ts +159 -0
  65. package/localization/generated/da.ts +158 -0
  66. package/localization/generated/de.ts +158 -0
  67. package/localization/generated/el.ts +160 -0
  68. package/localization/generated/es.ts +159 -0
  69. package/localization/generated/et.ts +159 -0
  70. package/localization/generated/fi.ts +158 -0
  71. package/localization/generated/fr.ts +159 -0
  72. package/localization/generated/hu.ts +158 -0
  73. package/localization/generated/id.ts +159 -0
  74. package/localization/generated/index.js +3 -0
  75. package/localization/generated/it.ts +159 -0
  76. package/localization/generated/ja.ts +158 -0
  77. package/localization/generated/ko.ts +158 -0
  78. package/localization/generated/locale-codes.js +83 -0
  79. package/localization/generated/lt.ts +158 -0
  80. package/localization/generated/lv.ts +158 -0
  81. package/localization/generated/nb.ts +158 -0
  82. package/localization/generated/nl.ts +158 -0
  83. package/localization/generated/pl.ts +159 -0
  84. package/localization/generated/pt-BR.ts +159 -0
  85. package/localization/generated/pt-PT.ts +159 -0
  86. package/localization/generated/ro.ts +159 -0
  87. package/localization/generated/ru.ts +159 -0
  88. package/localization/generated/sk.ts +159 -0
  89. package/localization/generated/sl.ts +159 -0
  90. package/localization/generated/sv.ts +158 -0
  91. package/localization/generated/tr.ts +158 -0
  92. package/localization/generated/uk.ts +158 -0
  93. package/localization/generated/zh-hans.ts +141 -0
  94. package/localization/generated/zh-hant.ts +141 -0
  95. package/localization/hu.xlf +552 -0
  96. package/localization/id.xlf +553 -0
  97. package/localization/it.xlf +553 -0
  98. package/localization/ja.xlf +552 -0
  99. package/localization/ko.xlf +552 -0
  100. package/localization/lt.xlf +552 -0
  101. package/localization/lv.xlf +552 -0
  102. package/localization/nb.xlf +552 -0
  103. package/localization/nl.xlf +552 -0
  104. package/localization/pkg/ar.xliff +7 -0
  105. package/localization/pkg/bg.xliff +7 -0
  106. package/localization/pkg/cs.xliff +7 -0
  107. package/localization/pkg/da.xliff +7 -0
  108. package/localization/pkg/de.xliff +7 -0
  109. package/localization/pkg/el.xliff +7 -0
  110. package/localization/pkg/es.xliff +7 -0
  111. package/localization/pkg/et.xliff +7 -0
  112. package/localization/pkg/fi.xliff +7 -0
  113. package/localization/pkg/fr.xliff +7 -0
  114. package/localization/pkg/hu.xliff +7 -0
  115. package/localization/pkg/id.xliff +7 -0
  116. package/localization/pkg/it.xliff +7 -0
  117. package/localization/pkg/ja.xliff +7 -0
  118. package/localization/pkg/ko.xliff +7 -0
  119. package/localization/pkg/lt.xliff +7 -0
  120. package/localization/pkg/lv.xliff +7 -0
  121. package/localization/pkg/nb.xliff +7 -0
  122. package/localization/pkg/nl.xliff +7 -0
  123. package/localization/pkg/pl.xliff +7 -0
  124. package/localization/pkg/pt-BR.xliff +7 -0
  125. package/localization/pkg/pt-PT.xliff +7 -0
  126. package/localization/pkg/ro.xliff +7 -0
  127. package/localization/pkg/ru.xliff +7 -0
  128. package/localization/pkg/sk.xliff +7 -0
  129. package/localization/pkg/sl.xliff +7 -0
  130. package/localization/pkg/sv.xliff +7 -0
  131. package/localization/pkg/tr.xliff +7 -0
  132. package/localization/pkg/uk.xliff +7 -0
  133. package/localization/pkg/zh-hans.xliff +7 -0
  134. package/localization/pkg/zh-hant.xliff +7 -0
  135. package/localization/pl.xlf +553 -0
  136. package/localization/pt-BR.xlf +553 -0
  137. package/localization/pt-PT.xlf +553 -0
  138. package/localization/ro.xlf +553 -0
  139. package/localization/ru.xlf +553 -0
  140. package/localization/sk.xlf +553 -0
  141. package/localization/sl.xlf +553 -0
  142. package/localization/snippets/ar.xliff +16 -0
  143. package/localization/snippets/bg.xliff +16 -0
  144. package/localization/snippets/cs.xliff +16 -0
  145. package/localization/snippets/da.xliff +16 -0
  146. package/localization/snippets/de.xliff +16 -0
  147. package/localization/snippets/el.xliff +16 -0
  148. package/localization/snippets/es.xliff +16 -0
  149. package/localization/snippets/et.xliff +16 -0
  150. package/localization/snippets/fi.xliff +16 -0
  151. package/localization/snippets/fr.xliff +16 -0
  152. package/localization/snippets/hu.xliff +16 -0
  153. package/localization/snippets/id.xliff +16 -0
  154. package/localization/snippets/it.xliff +16 -0
  155. package/localization/snippets/ja.xliff +16 -0
  156. package/localization/snippets/ko.xliff +16 -0
  157. package/localization/snippets/lt.xliff +16 -0
  158. package/localization/snippets/lv.xliff +16 -0
  159. package/localization/snippets/nb.xliff +16 -0
  160. package/localization/snippets/nl.xliff +16 -0
  161. package/localization/snippets/pl.xliff +16 -0
  162. package/localization/snippets/pt-BR.xliff +16 -0
  163. package/localization/snippets/pt-PT.xliff +16 -0
  164. package/localization/snippets/ro.xliff +16 -0
  165. package/localization/snippets/ru.xliff +16 -0
  166. package/localization/snippets/sk.xliff +16 -0
  167. package/localization/snippets/sl.xliff +16 -0
  168. package/localization/snippets/sv.xliff +16 -0
  169. package/localization/snippets/tr.xliff +16 -0
  170. package/localization/snippets/uk.xliff +16 -0
  171. package/localization/snippets/zh-hans.xliff +16 -0
  172. package/localization/snippets/zh-hant.xliff +16 -0
  173. package/localization/sv.xlf +552 -0
  174. package/localization/tr.xlf +552 -0
  175. package/localization/uk.xlf +552 -0
  176. package/localization/zh-hans.xlf +552 -0
  177. package/localization/zh-hant.xlf +552 -0
  178. package/package.json +103 -2
  179. package/snippets/MNIST.html +21 -0
  180. package/test.json +63 -0
  181. package/tsconfig.json +8 -0
  182. package/widgets/webwriter-feature-engineering.ts +421 -0
  183. package/widgets/webwriter-model-designing.ts +323 -0
  184. package/widgets/webwriter-model-evaluation.ts +215 -0
  185. package/widgets/webwriter-model-prediction.ts +307 -0
  186. package/widgets/webwriter-model-training.ts +709 -0
@@ -0,0 +1,152 @@
1
+ import { msg } from "@lit/localize";
2
+ import { SlButton, SlButtonGroup, SlIcon, SlIconButton, SlInput, SlOption, SlSelect } from "@shoelace-style/shoelace";
3
+ import { LitElementWw } from "@webwriter/lit";
4
+ import { css, html, TemplateResult } from "lit";
5
+ import { until } from 'lit-html/directives/until.js';
6
+ import { property } from "lit/decorators.js";
7
+ import { Dataset, TransformedDataset } from "../../lib/dataset/dataset";
8
+
9
+ import type * as TF from "@tensorflow/tfjs";
10
+ import getTF from "../../lib/tflib";
11
+ let tf: typeof TF;
12
+ (async () => {tf = await getTF()})()
13
+
14
+ async function waitFor(condition: Function, interval = 10) {
15
+ if (condition())
16
+ return;
17
+ return new Promise(async function(res, rej) {
18
+ let inter = setInterval(function() {
19
+ if (condition()) {
20
+ clearInterval(inter)
21
+ res(null);
22
+ }
23
+ }, interval)
24
+ });
25
+ }
26
+
27
+ export class BadSamples extends LitElementWw {
28
+ static scopedElements = {
29
+ "sl-button": SlButton,
30
+ "sl-button-group": SlButtonGroup,
31
+ "sl-option": SlOption,
32
+ "sl-select": SlSelect,
33
+ "sl-input":SlInput,
34
+ "sl-icon": SlIcon,
35
+ "sl-icon-button": SlIconButton,
36
+ }
37
+
38
+ static styles = css`
39
+ #container {
40
+ display: flex;
41
+ flex-direction: row;
42
+ flex-wrap: wrap;
43
+ align-content: flex-start;
44
+ justify-content: center;
45
+ align-items: flex-start;
46
+ gap: 5px;
47
+ }
48
+ #container * {
49
+ flex-grow: 1;
50
+ }
51
+ #top {
52
+ width: 100%;
53
+ display: flex;
54
+ }
55
+ .input, .output {
56
+ padding: 5px 10px;
57
+ position: relative;
58
+ border: 1px solid lightgrey;
59
+ border-radius: 5px;
60
+ }
61
+ .input > *, .output > * {
62
+ width: 100%;
63
+ }
64
+ .input > p, .output > p {
65
+ margin: 0px;
66
+ font-size: 16px;
67
+ }
68
+ table {
69
+ width:100%;
70
+ }
71
+ table td {
72
+ padding: 0px 10px;
73
+ }
74
+ `
75
+
76
+ @property()
77
+ accessor model:TF.LayersModel;
78
+
79
+ @property()
80
+ accessor rawDataset: Dataset;
81
+
82
+ @property()
83
+ accessor tensorDataset: TransformedDataset;
84
+
85
+ constructor() {
86
+ super();
87
+ let that = this;
88
+ setTimeout(function() {
89
+ that.requestUpdate();
90
+ }, 1000)
91
+ }
92
+
93
+ async getBadSamples() {
94
+ let model = this.model;
95
+ let errors = [];
96
+
97
+ for (let i = this.rawDataset.validationEnd; i < this.rawDataset.length(); i++) {
98
+ let sample = await this.tensorDataset.getSample(i);
99
+ tf.tidy(() => {
100
+ let inputs = Object.entries(sample).filter(([s,v]) => model.inputNames.indexOf("in_" + s) != -1).map(([s,v]) => v)
101
+ inputs = inputs.map(i => i.reshape([1 , ...i.shape]))
102
+ let out = model.predict(inputs, {batchSize:1});
103
+ let err;
104
+ if (out instanceof Array) {
105
+
106
+ } else {
107
+ out = out.squeeze();
108
+ tf.keep(out);
109
+ let diff = sample[model.outputNames[0].replace("out_","")].sub(out);
110
+ err = diff.abs().sum();
111
+ }
112
+ errors.push({sample: i, loss:err.arraySync(), pred:out})
113
+ })
114
+ Object.values(sample).forEach(t => t.dispose());
115
+ }
116
+
117
+ let sorted = errors.sort((e1 , e2) => e2.loss - e1.loss).slice(0,6);
118
+ let that = this;
119
+ let output = [];
120
+ for (let err of sorted) {
121
+ let tData = []
122
+ for (let inName of model.inputNames) {
123
+ let featureName = inName.replace("in_","");
124
+ let sample = that.rawDataset.getSample(err.sample)
125
+ let features = that.tensorDataset.featureMaps;
126
+ let featureElement = features[featureName].renderTransformedValue(sample[featureName]);
127
+ tData.push(html`<td>${featureElement}</td>`)
128
+ }
129
+ for (let outName of model.outputNames) {
130
+ let featureName = outName.replace("out_","");
131
+ let sample = that.rawDataset.getSample(err.sample)
132
+ let features = that.tensorDataset.featureMaps;
133
+ let label = await features[featureName].transform(sample[featureName]);
134
+ let featureElement = features[featureName].renderPredictionDifference(err.pred, label);
135
+ //label.dispose();
136
+ tData.push(html`<td>${featureElement}</td>`)
137
+ }
138
+
139
+ output.push(html`<tr>${tData}<td>${err.loss.toFixed(3)}</td></tr>`);
140
+ };
141
+ let names = [...model.inputNames.map(name => name.replace("in_","")), ...model.outputNames.map(name => name.replace("out_","")), "Absolute Difference"]
142
+
143
+ return html`<table><thead><tr>${names.map(n => html`<td>${n}</td>`)}</tr></thead><tbody>${output}</tbody></table>`
144
+ }
145
+
146
+ public render(): TemplateResult {
147
+ if (this.model == null)
148
+ return html`<p>${msg("Loading model...")}</p>`
149
+
150
+ return html`${until(this.getBadSamples(), html`<p>${msg("Calculating Loss For Samples...")}</p>`)}`
151
+ }
152
+ }
@@ -0,0 +1,174 @@
1
+ import { msg } from "@lit/localize";
2
+ import { SlButton, SlButtonGroup, SlIcon, SlIconButton, SlInput, SlOption, SlSelect } from "@shoelace-style/shoelace";
3
+ import { LitElementWw } from "@webwriter/lit";
4
+ import ApexCharts from "apexcharts";
5
+ import { css, html, TemplateResult } from "lit";
6
+ import { until } from 'lit-html/directives/until.js';
7
+ import { property } from "lit/decorators.js";
8
+ import { Dataset, TransformedDataset } from "../../lib/dataset/dataset";
9
+
10
+ import type * as TF from "@tensorflow/tfjs";
11
+ import getTF from "../../lib/tflib";
12
+ let tf: typeof TF;
13
+ (async () => {tf = await getTF()})()
14
+
15
+ async function waitFor(condition: Function, interval = 10) {
16
+ if (condition())
17
+ return;
18
+ return new Promise(async function(res, rej) {
19
+ let inter = setInterval(function() {
20
+ if (condition()) {
21
+ clearInterval(inter)
22
+ res(null);
23
+ }
24
+ }, interval)
25
+ });
26
+ }
27
+
28
+ export class LossDistribution extends LitElementWw {
29
+ static scopedElements = {
30
+ "sl-button": SlButton,
31
+ "sl-button-group": SlButtonGroup,
32
+ "sl-option": SlOption,
33
+ "sl-select": SlSelect,
34
+ "sl-input":SlInput,
35
+ "sl-icon": SlIcon,
36
+ "sl-icon-button": SlIconButton,
37
+ }
38
+
39
+ static styles = css`
40
+ #container {
41
+ display: flex;
42
+ flex-direction: row;
43
+ flex-wrap: wrap;
44
+ align-content: flex-start;
45
+ justify-content: center;
46
+ align-items: flex-start;
47
+ gap: 5px;
48
+ }
49
+ #container * {
50
+ flex-grow: 1;
51
+ }
52
+ #top {
53
+ width: 100%;
54
+ display: flex;
55
+ }
56
+ .input, .output {
57
+ padding: 5px 10px;
58
+ position: relative;
59
+ border: 1px solid lightgrey;
60
+ border-radius: 5px;
61
+ }
62
+ .input > *, .output > * {
63
+ width: 100%;
64
+ }
65
+ .input > p, .output > p {
66
+ margin: 0px;
67
+ font-size: 16px;
68
+ }
69
+ `
70
+
71
+ @property()
72
+ accessor model:TF.LayersModel;
73
+
74
+ @property()
75
+ accessor rawDataset: Dataset;
76
+
77
+ @property()
78
+ accessor tensorDataset: TransformedDataset;
79
+
80
+ constructor() {
81
+ super();
82
+ let that = this;
83
+ setTimeout(function() {
84
+ that.requestUpdate();
85
+ }, 1000)
86
+ }
87
+
88
+ async getDiagram() {
89
+ let model = this.model;
90
+ let errors = [];
91
+
92
+ for (let i = this.rawDataset.validationEnd; i < this.rawDataset.length(); i++) {
93
+ let sample = await this.tensorDataset.getSample(i);
94
+ tf.tidy(() => {
95
+ let inputs = Object.entries(sample).filter(([s,v]) => model.inputNames.indexOf("in_" + s) != -1).map(([s,v]) => v)
96
+ inputs = inputs.map(i => i.reshape([1 , ...i.shape]))
97
+ let out = model.predict(inputs, {batchSize:1}) as TF.Tensor;
98
+ let diff = sample[model.outputNames[0].replace("out_","")].sub(out);
99
+ let err = diff.abs().sum();
100
+ errors.push(err.arraySync())
101
+ })
102
+ Object.values(sample).forEach(t => t.dispose());
103
+ }
104
+ //errors = errors.filter(v => v < 0.1)
105
+
106
+ let min = Math.min(...errors)
107
+ let max = Math.max(...errors)
108
+ let bins = new Array<number>(5);
109
+ let titles = []
110
+ bins.fill(0);
111
+ for (let e of errors) {
112
+ let p = (e - min) / (max - min)
113
+ bins[Math.floor(p * bins.length)] += 1;
114
+ }
115
+ bins.pop(); // Because we always round down the bins
116
+ for (let b = 0; b < bins.length; b++) {
117
+ let p = b / bins.length;
118
+ titles[b] = (p * (max - min) + min).toPrecision(3) + " - " + ((p + 1 / bins.length) * (max - min) + min).toPrecision(3);
119
+ }
120
+ let chartDiv = document.createElement("div");
121
+ let chart = new ApexCharts(chartDiv, {
122
+ series: [{
123
+ name: 'Frequency',
124
+ data: bins
125
+ }],
126
+ chart: {
127
+ id: 'realtime',
128
+ height: 200,
129
+ type: 'bar',
130
+ animations: {
131
+ enabled: false
132
+ },
133
+ toolbar: {
134
+ show: false
135
+ },
136
+ zoom: {
137
+ enabled: false
138
+ }
139
+ },
140
+ dataLabels: {
141
+ enabled: false
142
+ },
143
+ title: {
144
+ text: 'Training Loss Spread',
145
+ align: 'left'
146
+ },
147
+ markers: {
148
+ size: 0
149
+ },
150
+ xaxis: {
151
+ type: 'number',
152
+ categories: titles,
153
+ },
154
+ yaxis: {
155
+ min: 0
156
+ },
157
+ legend: {
158
+ show: false
159
+ },
160
+ });
161
+ setTimeout(function() {
162
+ chart.render();
163
+ }, 10)
164
+
165
+ return html`${chartDiv}`
166
+ }
167
+
168
+ public render(): TemplateResult {
169
+ if (this.model == null)
170
+ return html`<p>${msg("Loading model...")}</p>`
171
+
172
+ return html`${until(this.getDiagram(), html`<p>${msg("Calculating Loss Distribution...")}</p>`)}`
173
+ }
174
+ }
@@ -0,0 +1,105 @@
1
+ import { msg } from "@lit/localize";
2
+ import SlButton from "@shoelace-style/shoelace/dist/components/button/button.component.js";
3
+ import SlOption from "@shoelace-style/shoelace/dist/components/option/option.component.js";
4
+ import SlSelect from "@shoelace-style/shoelace/dist/components/select/select.component.js";
5
+ import "@shoelace-style/shoelace/dist/themes/light.css";
6
+ import { LitElementWw, OptionDeclaration } from "@webwriter/lit";
7
+ import { css, html, TemplateResult } from "lit";
8
+ import { property } from "lit/decorators.js";
9
+
10
+ export class AiWidgetsReferenceSelect extends LitElementWw {
11
+ static scopedElements = {
12
+ "sl-select": SlSelect,
13
+ "sl-option": SlOption,
14
+ "sl-button": SlButton
15
+ }
16
+
17
+ static styles = css`
18
+ :host {
19
+ display:block;
20
+ }
21
+ `
22
+
23
+ constructor() {
24
+ super();
25
+ let that = this;
26
+ setInterval(function () {
27
+ that.requestUpdate();
28
+ }, 1000);
29
+ }
30
+
31
+ public options: Record<string, OptionDeclaration> = {}
32
+
33
+ @property({ type: String, attribute: true })
34
+ accessor elemId: string;
35
+
36
+ @property({ type: String, attribute: true })
37
+ accessor elementType: string;
38
+
39
+ @property({ type: String, attribute: true })
40
+ accessor typeName: string;
41
+
42
+ @property({ type: String }) ownerId;
43
+
44
+ private lastRef:HTMLElement;
45
+
46
+ firstUpdated() {
47
+ if (this.elemId == "" || this.elemId == null) {
48
+ let testSibblingForElementType = document.getElementById(this.ownerId);
49
+ console.log(testSibblingForElementType, this.elementType);
50
+ while (testSibblingForElementType != null && testSibblingForElementType.tagName.toLowerCase() != this.elementType) {
51
+ testSibblingForElementType = testSibblingForElementType.previousElementSibling as HTMLElement;
52
+ console.log(testSibblingForElementType);
53
+ }
54
+ this.elemId = testSibblingForElementType.id;
55
+ }
56
+ this.dispatchEvent(new CustomEvent('refchange', {
57
+ detail: {
58
+ id: this.elemId
59
+ }
60
+ }));
61
+ }
62
+
63
+ public render(): TemplateResult {
64
+ let that = this;
65
+ let elements = document.querySelectorAll(this.elementType)
66
+ let options = [];
67
+ let index = 1;
68
+ elements.forEach(function (elem: LitElementWw) {
69
+ let option = document.createElement("sl-option")
70
+ option.innerText = that.typeName + " " + index;
71
+ option.value = elem.id;
72
+ options.push(option)
73
+ index++;
74
+ })
75
+ function changeElem(e: Event) {
76
+ this.elemId = (e.target as SlSelect).value as string;
77
+ highlight();
78
+ this.dispatchEvent(new CustomEvent('refchange', {
79
+ detail: {
80
+ id: that.elemId,
81
+ lastRef: this.lastRef
82
+ }
83
+ }));
84
+ this.lastRef = this.getRefElement();
85
+ }
86
+ function highlight() {
87
+ if (that.elemId == "")
88
+ return;
89
+ let elem = that.getRefElement();
90
+ elem.style.boxShadow = "0px 0px 5px 5px orange";
91
+ setTimeout(function () {
92
+ elem.style.boxShadow = "";
93
+ }, 1000);
94
+ }
95
+ return html`<sl-select id="elemselect" value=${this.elemId} placeholder=${msg("Select Source Element")} @sl-focus=${highlight} @sl-change=${changeElem}>
96
+ ${options}
97
+ </sl-select>
98
+ <sl-button @click=${highlight} id="btn">${msg("Show selection")}</sl-button>
99
+ `
100
+ }
101
+
102
+ public getRefElement() {
103
+ return document.querySelector("#" + this.elemId) as HTMLElement
104
+ }
105
+ }