@kestra-io/ui-libs 0.0.1 → 0.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.
@@ -0,0 +1,478 @@
1
+ import JsYaml from "js-yaml";
2
+ import yaml, {Document, YAMLMap, isSeq, isMap, Pair, Scalar, YAMLSeq, LineCounter} from "yaml";
3
+ import _cloneDeep from "lodash/cloneDeep"
4
+ import {SECTIONS} from "./constants";
5
+
6
+ const TOSTRING_OPTIONS = {lineWidth: 0};
7
+
8
+ export default class YamlUtils {
9
+ static stringify(value) {
10
+ if (typeof value === "undefined") {
11
+ return "";
12
+ }
13
+
14
+ if (value.deleted !== undefined) {
15
+ delete value.deleted
16
+ }
17
+
18
+ return JsYaml.dump(YamlUtils._transform(_cloneDeep(value)), {
19
+ lineWidth: -1,
20
+ noCompatMode: true,
21
+ quotingType: "\"",
22
+ });
23
+ }
24
+
25
+ static parse(item) {
26
+ return JsYaml.load(item);
27
+ }
28
+
29
+ static extractTask(source, taskId) {
30
+ const yamlDoc = yaml.parseDocument(source);
31
+ let taskNode = YamlUtils._extractTask(yamlDoc, taskId);
32
+ return taskNode === undefined ? undefined : new yaml.Document(taskNode).toString(TOSTRING_OPTIONS);
33
+ }
34
+
35
+ static _extractTask(yamlDoc, taskId, callback) {
36
+ const find = (element) => {
37
+ if (!element) {
38
+ return;
39
+ }
40
+ if (element instanceof YAMLMap) {
41
+ if (element.get("type") !== undefined && taskId === element.get("id")) {
42
+ return callback ? callback(element) : element;
43
+ }
44
+ }
45
+ if (element.items) {
46
+ for (const [key, item] of element.items.entries()) {
47
+ let result;
48
+
49
+ if (item instanceof YAMLMap) {
50
+ result = find(item);
51
+ } else {
52
+ result = find(item.value);
53
+ }
54
+
55
+ if (result) {
56
+ if (callback) {
57
+ if (element instanceof YAMLMap) {
58
+ element.set(item.key.value, result);
59
+ } else {
60
+ element.items[key] = result;
61
+ }
62
+ }
63
+
64
+ if (!callback && result) {
65
+ return result
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+ let result = find(yamlDoc.contents)
72
+
73
+ if (result === undefined) {
74
+ return undefined;
75
+ }
76
+
77
+ if (callback) {
78
+ return new Document(result)
79
+ } else {
80
+ return new Document(result);
81
+ }
82
+ }
83
+
84
+ static replaceTaskInDocument(source, taskId, newContent) {
85
+ const yamlDoc = yaml.parseDocument(source);
86
+ const newItem = yamlDoc.createNode(yaml.parseDocument(newContent))
87
+
88
+ YamlUtils._extractTask(yamlDoc, taskId, (oldValue) => {
89
+ YamlUtils.replaceCommentInTask(oldValue, newItem)
90
+
91
+ return newItem;
92
+ })
93
+
94
+ return yamlDoc.toString(TOSTRING_OPTIONS);
95
+ }
96
+
97
+ static replaceCommentInTask(oldTask, newTask) {
98
+ for (const oldProp of oldTask.items) {
99
+ for (const newProp of newTask.items) {
100
+ if (oldProp.key.value === newProp.key.value && newProp.value.comment === undefined) {
101
+ newProp.value.comment = oldProp.value.comment
102
+ break;
103
+ }
104
+ }
105
+ }
106
+ }
107
+
108
+ static _transform(value) {
109
+ if (value instanceof Array) {
110
+ return value.map(r => {
111
+ return YamlUtils._transform(r);
112
+ })
113
+ } else if (typeof (value) === "string" || value instanceof String) {
114
+ // value = value
115
+ // .replaceAll(/\u00A0/g, " ");
116
+ //
117
+ // if (value.indexOf("\\n") >= 0) {
118
+ // return value.replaceAll("\\n", "\n") + "\n";
119
+ // }
120
+
121
+ return value;
122
+ } else if (value instanceof Object) {
123
+ return YamlUtils.sort(value)
124
+ .reduce((accumulator, r) => {
125
+ if (value[r] !== undefined) {
126
+ accumulator[r] = YamlUtils._transform(value[r])
127
+ }
128
+
129
+ return accumulator;
130
+ }, Object.create({}))
131
+ }
132
+
133
+ return value;
134
+ }
135
+
136
+ static sort(value) {
137
+ const SORT_FIELDS = [
138
+ "id",
139
+ "type",
140
+ "namespace",
141
+ "description",
142
+ "revision",
143
+ "inputs",
144
+ "variables",
145
+ "tasks",
146
+ "errors",
147
+ "triggers",
148
+ "listeners",
149
+ ];
150
+
151
+ return Object.keys(value)
152
+ .sort()
153
+ .sort((a, b) => {
154
+ return YamlUtils.index(SORT_FIELDS, a) - YamlUtils.index(SORT_FIELDS, b);
155
+ });
156
+ }
157
+
158
+ static index(based, value) {
159
+ const index = based.indexOf(value);
160
+
161
+ return index === -1 ? Number.MAX_SAFE_INTEGER : index;
162
+ }
163
+
164
+ static extractAllTypes(source) {
165
+ const yamlDoc = yaml.parseDocument(source);
166
+ const types = [];
167
+ if (yamlDoc.contents && yamlDoc.contents.items && yamlDoc.contents.items.find(e => ["tasks", "triggers", "errors"].includes(e.key.value))) {
168
+ yaml.visit(yamlDoc, {
169
+ Map(_, map) {
170
+ if (map.items) {
171
+ for (const item of map.items) {
172
+ if (item.key.value === "type") {
173
+ const type = item.value?.value;
174
+ types.push({type, range: map.range});
175
+ }
176
+ }
177
+ }
178
+ }
179
+ })
180
+ }
181
+ return types;
182
+ }
183
+
184
+ static getTaskType(source, position) {
185
+ const types = this.extractAllTypes(source)
186
+
187
+ const lineCounter = new LineCounter();
188
+ yaml.parseDocument(source, {lineCounter});
189
+ const cursorIndex = lineCounter.lineStarts[position.lineNumber - 1] + position.column;
190
+
191
+ for(const type of types.reverse()) {
192
+ if (cursorIndex > type.range[1]) {
193
+ return type.type;
194
+ }
195
+ if (cursorIndex >= type.range[0] && cursorIndex <= type.range[1]) {
196
+ return type.type;
197
+ }
198
+ }
199
+ return null;
200
+ }
201
+
202
+ static swapTasks(source, taskId1, taskId2) {
203
+ const yamlDoc = yaml.parseDocument(source);
204
+
205
+ const task1 = YamlUtils._extractTask(yamlDoc, taskId1);
206
+ const task2 = YamlUtils._extractTask(yamlDoc, taskId2);
207
+
208
+ yaml.visit(yamlDoc, {
209
+ Pair(_, pair) {
210
+ if (pair.key.value === "dependsOn" && pair.value.items.map(e => e.value).includes(taskId2)) {
211
+ throw {
212
+ message: "dependency task",
213
+ messageOptions: {taskId: taskId2}
214
+ };
215
+ }
216
+ }
217
+ });
218
+
219
+ YamlUtils._extractTask(yamlDoc, taskId1, () => task2);
220
+ YamlUtils._extractTask(yamlDoc, taskId2, () => task1);
221
+
222
+ return yamlDoc.toString(TOSTRING_OPTIONS);
223
+ }
224
+
225
+ static insertTask(source, taskId, newTask, insertPosition) {
226
+ const yamlDoc = yaml.parseDocument(source);
227
+ const newTaskNode = yamlDoc.createNode(yaml.parseDocument(newTask))
228
+ const tasksNode = yamlDoc.contents.items.find(e => e.key.value === "tasks");
229
+ if (!tasksNode || !tasksNode?.value.value === null) {
230
+ if (tasksNode) {
231
+ yamlDoc.contents.items.splice(yamlDoc.contents.items.indexOf(tasksNode), 1)
232
+ }
233
+ const taskList = new YAMLSeq()
234
+ taskList.items.push(newTaskNode)
235
+ const tasks = new Pair(new Scalar("tasks"), taskList)
236
+ yamlDoc.contents.items.push(tasks)
237
+ return yamlDoc.toString(TOSTRING_OPTIONS);
238
+ }
239
+ let added = false;
240
+ yaml.visit(yamlDoc, {
241
+ Seq(_, seq) {
242
+ for (const map of seq.items) {
243
+ if (isMap(map)) {
244
+ if (added) {
245
+ return yaml.visit.BREAK;
246
+ }
247
+ if (map.get("id") === taskId) {
248
+ const index = seq.items.indexOf(map);
249
+ if (insertPosition === "before") {
250
+ if (index === 0) {
251
+ seq.items.unshift(newTaskNode)
252
+ } else {
253
+ seq.items.splice(index, 0, newTaskNode)
254
+ }
255
+ } else {
256
+ if (index === seq.items.length - 1) {
257
+ seq.items.push(newTaskNode)
258
+ } else {
259
+ seq.items.splice(index + 1, 0, newTaskNode)
260
+ }
261
+ }
262
+ added = true;
263
+ return seq
264
+ }
265
+ }
266
+ }
267
+ }
268
+ })
269
+ return yamlDoc.toString(TOSTRING_OPTIONS);
270
+ }
271
+
272
+ static insertTrigger(source, triggerTask) {
273
+ const yamlDoc = yaml.parseDocument(source);
274
+ const newTriggerNode = yamlDoc.createNode(yaml.parseDocument(triggerTask));
275
+ let added = false;
276
+ const triggers = yamlDoc.contents.items.find(item => item.key.value === "triggers");
277
+ if (triggers && triggers.value.items) {
278
+ yaml.visit(yamlDoc, {
279
+ Pair(_, pair) {
280
+ if (added) {
281
+ return yaml.visit.BREAK;
282
+ }
283
+ if (pair.key.value === "triggers") {
284
+ pair.value.items.push(newTriggerNode);
285
+ added = true;
286
+ return pair;
287
+ }
288
+ }
289
+ })
290
+ } else {
291
+ if (triggers) {
292
+ yamlDoc.contents.items.splice(yamlDoc.contents.items.indexOf(triggers), 1)
293
+ }
294
+ const triggersSeq = new yaml.YAMLSeq();
295
+ triggersSeq.items.push(newTriggerNode);
296
+ const newTriggers = new yaml.Pair(new yaml.Scalar("triggers"), triggersSeq);
297
+ yamlDoc.contents.items.push(newTriggers);
298
+ }
299
+ return YamlUtils.cleanMetadata(yamlDoc.toString(TOSTRING_OPTIONS));
300
+ }
301
+
302
+ static insertError(source, errorTask) {
303
+ const yamlDoc = yaml.parseDocument(source);
304
+ const newErrorNode = yamlDoc.createNode(yaml.parseDocument(errorTask));
305
+ const errors = yamlDoc.contents.items.find(item => item.key.value === "errors");
306
+ if (errors && errors.value.items) {
307
+ yamlDoc.contents.items[yamlDoc.contents.items.indexOf(errors)].value.items.push(newErrorNode);
308
+ } else {
309
+ if (errors) {
310
+ yamlDoc.contents.items.splice(yamlDoc.contents.items.indexOf(errors), 1)
311
+ }
312
+ const errorsSeq = new yaml.YAMLSeq();
313
+ errorsSeq.items.push(newErrorNode);
314
+ const newErrors = new yaml.Pair(new yaml.Scalar("errors"), errorsSeq);
315
+ yamlDoc.contents.items.push(newErrors);
316
+ }
317
+ return YamlUtils.cleanMetadata(yamlDoc.toString(TOSTRING_OPTIONS));
318
+ }
319
+
320
+ static insertErrorInFlowable(source, errorTask, flowableTask) {
321
+ const yamlDoc = yaml.parseDocument(source);
322
+ const newErrorNode = yamlDoc.createNode(yaml.parseDocument(errorTask));
323
+ let added = false;
324
+ yaml.visit(yamlDoc, {
325
+ Map(_, map) {
326
+ if (added) {
327
+ return yaml.visit.BREAK;
328
+ }
329
+ if (map.get("id") === flowableTask) {
330
+ if (map.items.find(item => item.key.value === "errors")) {
331
+ map.items.find(item => item.key.value === "errors").value.items.push(newErrorNode);
332
+ } else {
333
+ const errorsSeq = new yaml.YAMLSeq();
334
+ errorsSeq.items.push(newErrorNode);
335
+ const errors = new yaml.Pair(new yaml.Scalar("errors"), errorsSeq);
336
+ map.items.push(errors);
337
+ }
338
+ added = true;
339
+ return map;
340
+ }
341
+ }
342
+ })
343
+ return yamlDoc.toString(TOSTRING_OPTIONS);
344
+ }
345
+
346
+ static deleteTask(source, taskId, section) {
347
+ const inSection = section === SECTIONS.TASKS ? ["tasks", "errors"] : ["triggers"];
348
+ const yamlDoc = yaml.parseDocument(source);
349
+ yaml.visit(yamlDoc, {
350
+ Pair(_, pair) {
351
+ if (inSection.includes(pair.key.value)) {
352
+ yaml.visit(pair.value, {
353
+ Map(_, map) {
354
+ if (map.get("id") === taskId) {
355
+ return yaml.visit.REMOVE;
356
+ }
357
+ }
358
+ })
359
+ }
360
+ }
361
+ })
362
+ // delete empty sections
363
+ yaml.visit(yamlDoc, {
364
+ Pair(_, pair) {
365
+ if (isSeq(pair.value) && pair.value.items.length === 0) {
366
+ return yaml.visit.REMOVE;
367
+ }
368
+ }
369
+ })
370
+ return yamlDoc.toString(TOSTRING_OPTIONS);
371
+ }
372
+
373
+ static getFirstTask(source) {
374
+ let parse = YamlUtils.parse(source);
375
+
376
+ return parse && parse.tasks && parse.tasks[0].id;
377
+ }
378
+
379
+ static checkTaskAlreadyExist(source, taskYaml) {
380
+ const yamlDoc = yaml.parseDocument(source);
381
+ const parsedTask = YamlUtils.parse(taskYaml);
382
+ let taskExist = false;
383
+ yaml.visit(yamlDoc, {
384
+ Pair(_, pair) {
385
+ if (pair.key.value === "tasks") {
386
+ yaml.visit(pair, {
387
+ Map(_, map) {
388
+ if (map.get("id") === parsedTask.id) {
389
+ taskExist = true;
390
+ return yaml.visit.BREAK;
391
+ }
392
+ }
393
+ })
394
+ }
395
+ }
396
+ })
397
+ return taskExist ? parsedTask.id : null;
398
+ }
399
+
400
+ static isParentChildrenRelation(source, task1, task2) {
401
+ return YamlUtils.isChildrenOf(source, task2, task1) || YamlUtils.isChildrenOf(source, task1, task2);
402
+ }
403
+
404
+ static isChildrenOf(source, parentTask, childTask) {
405
+ const yamlDoc = yaml.parseDocument(YamlUtils.extractTask(source, parentTask));
406
+ let isChildrenOf = false;
407
+ yaml.visit(yamlDoc, {
408
+ Map(_, map) {
409
+ if (map.get("id") === childTask) {
410
+ isChildrenOf = true;
411
+ return yaml.visit.BREAK;
412
+ }
413
+ }
414
+ })
415
+ return isChildrenOf;
416
+ }
417
+
418
+ static getChildrenTasks(source, taskId) {
419
+ const yamlDoc = yaml.parseDocument(YamlUtils.extractTask(source, taskId));
420
+ const children = [];
421
+ yaml.visit(yamlDoc, {
422
+ Map(_, map) {
423
+ if (map.get("id") !== taskId) {
424
+ children.push(map.get("id"));
425
+ }
426
+ }
427
+ })
428
+ return children;
429
+ }
430
+
431
+ static replaceIdAndNamespace(source, id, namespace) {
432
+ return source.replace(/^(id\s*:\s*(["']?))\S*/m, "$1"+id+"$2").replace(/^(namespace\s*:\s*(["']?))\S*/m, "$1"+namespace+"$2")
433
+ }
434
+
435
+ static updateMetadata(source, metadata) {
436
+ // TODO: check how to keep comments
437
+ const yamlDoc = yaml.parseDocument(source);
438
+ for (const property in metadata) {
439
+ if (yamlDoc.contents.items.find(item => item.key.value === property)) {
440
+ yamlDoc.contents.items.find(item => item.key.value === property).value = metadata[property];
441
+ } else {
442
+ yamlDoc.contents.items.push(new yaml.Pair(new yaml.Scalar(property), metadata[property]));
443
+ }
444
+ }
445
+ return YamlUtils.cleanMetadata(yamlDoc.toString(TOSTRING_OPTIONS));
446
+ }
447
+
448
+ static cleanMetadata(source) {
449
+ // Reorder and remove empty metadata
450
+ const yamlDoc = yaml.parseDocument(source);
451
+ const order = ["id", "namespace", "description", "labels", "inputs", "variables", "tasks", "triggers", "errors", "taskDefaults"];
452
+ const updatedItems = [];
453
+ for (const prop of order) {
454
+ const item = yamlDoc.contents.items.find(e => e.key.value === prop);
455
+ if (item && (((isSeq(item.value) || isMap(item.value)) && item.value.items.length > 0) || item.value.value)) {
456
+ updatedItems.push(item);
457
+ }
458
+ }
459
+ yamlDoc.contents.items = updatedItems;
460
+ return yamlDoc.toString(TOSTRING_OPTIONS);
461
+ }
462
+
463
+ static getMetadata(source) {
464
+ const yamlDoc = yaml.parseDocument(source);
465
+ const metadata = {};
466
+ for (const item of yamlDoc.contents.items) {
467
+ if (item.key.value !== "tasks" && item.key.value !== "triggers" && item.key.value !== "errors") {
468
+ metadata[item.key.value] = isMap(item.value) || isSeq(item.value) ? item.value.toJSON() : item.value.value;
469
+ }
470
+ }
471
+ return metadata;
472
+ }
473
+
474
+ static flowHaveTasks(source) {
475
+ const tasks = yaml.parseDocument(source).contents.items.find(item => item.key.value === "tasks");
476
+ return tasks && tasks.value.items && tasks.value.items.length >= 1;
477
+ }
478
+ }
@@ -0,0 +1,19 @@
1
+ export const SECTIONS = {
2
+ TASKS: "TASKS",
3
+ TRIGGERS: "TRIGGERS",
4
+ }
5
+
6
+ export const EVENTS = {
7
+ "EDIT": "edit",
8
+ "DELETE": "delete",
9
+ "SHOW_DESCRIPTION": "showDescription",
10
+ "COLLAPSE": "collapse",
11
+ "EXPAND": "expand",
12
+ "OPEN_LINK": "openLink",
13
+ "ADD_TASK": "addTask",
14
+ "SHOW_LOGS": "showLogs",
15
+ "MOUSE_OVER": "mouseover",
16
+ "MOUSE_LEAVE": "mouseleave",
17
+ "ADD_ERROR": "addError",
18
+ "EXPAND_DEPENDENCIES": "expandDependencies",
19
+ }
@@ -0,0 +1,23 @@
1
+ String.prototype.capitalize = function () {
2
+ return this.charAt(0).toUpperCase() + this.slice(1)
3
+ }
4
+
5
+ String.prototype.hashCode = function () {
6
+ var hash = 0;
7
+ if (this.length === 0) {
8
+ return hash;
9
+ }
10
+ for (var i = 0; i < this.length; i++) {
11
+ var char = this.charCodeAt(i);
12
+ hash = ((hash << 5) - hash) + char;
13
+ hash = hash & hash; // Convert to 32bit integer
14
+ }
15
+ return hash + "";
16
+ }
17
+
18
+ const root = document.querySelector(":root");
19
+ const rootStyle = getComputedStyle(root);
20
+
21
+ export const cssVariable = (name) => {
22
+ return rootStyle.getPropertyValue(name);
23
+ }
@@ -0,0 +1,165 @@
1
+ import _mapValues from "lodash/mapValues";
2
+ import PauseCircle from "vue-material-design-icons/PauseCircle.vue";
3
+ import CheckCircle from "vue-material-design-icons/CheckCircle.vue";
4
+ import PlayCircle from "vue-material-design-icons/PlayCircle.vue";
5
+ import CloseCircle from "vue-material-design-icons/CloseCircle.vue";
6
+ import StopCircle from "vue-material-design-icons/StopCircle.vue";
7
+ import SkipPreviousCircle from "vue-material-design-icons/SkipPreviousCircle.vue";
8
+ import AlertCircle from "vue-material-design-icons/AlertCircle.vue";
9
+ import DotsVerticalCircle from "vue-material-design-icons/DotsVerticalCircle.vue";
10
+ import {cssVariable} from "./global"
11
+
12
+ const STATE = Object.freeze({
13
+ CREATED: {
14
+ name: "CREATED",
15
+ colorClass: "cyan",
16
+ icon: DotsVerticalCircle,
17
+ isRunning: true,
18
+ isKillable: true,
19
+ isFailed: false,
20
+ },
21
+ RESTARTED: {
22
+ name: "RESTARTED",
23
+ colorClass: "cyan",
24
+ icon: SkipPreviousCircle,
25
+ isRunning: false,
26
+ isKillable: true,
27
+ isFailed: false,
28
+ },
29
+ SUCCESS: {
30
+ name: "SUCCESS",
31
+ colorClass: "green",
32
+ icon: CheckCircle,
33
+ isRunning: false,
34
+ isKillable: false,
35
+ isFailed: false,
36
+ },
37
+ RUNNING: {
38
+ name: "RUNNING",
39
+ colorClass: "purple",
40
+ icon: PlayCircle,
41
+ isRunning: true,
42
+ isKillable: true,
43
+ isFailed: false,
44
+ },
45
+ KILLING: {
46
+ name: "KILLING",
47
+ colorClass: "yellow",
48
+ icon: CloseCircle,
49
+ isRunning: true,
50
+ isKillable: true,
51
+ isFailed: true,
52
+ },
53
+ KILLED: {
54
+ name: "KILLED",
55
+ colorClass: "yellow",
56
+ icon: StopCircle,
57
+ isRunning: false,
58
+ isKillable: false,
59
+ isFailed: true,
60
+ },
61
+ WARNING: {
62
+ name: "WARNING",
63
+ colorClass: "orange",
64
+ icon: AlertCircle,
65
+ isRunning: false,
66
+ isKillable: false,
67
+ isFailed: true,
68
+ },
69
+ FAILED: {
70
+ name: "FAILED",
71
+ colorClass: "red",
72
+ icon: CloseCircle,
73
+ isRunning: false,
74
+ isKillable: false,
75
+ isFailed: true,
76
+ },
77
+ PAUSED: {
78
+ name: "PAUSED",
79
+ colorClass: "indigo",
80
+ icon: PauseCircle,
81
+ isRunning: true,
82
+ isKillable: true,
83
+ isFailed: false,
84
+ }
85
+ });
86
+
87
+ export default class State {
88
+ static get CREATED() {
89
+ return STATE.CREATED.name;
90
+ }
91
+
92
+ static get RESTARTED() {
93
+ return STATE.RESTARTED.name;
94
+ }
95
+
96
+ static get SUCCESS() {
97
+ return STATE.SUCCESS.name;
98
+ }
99
+
100
+ static get RUNNING() {
101
+ return STATE.RUNNING.name;
102
+ }
103
+
104
+ static get KILLING() {
105
+ return STATE.KILLING.name;
106
+ }
107
+
108
+ static get KILLED() {
109
+ return STATE.KILLED.name;
110
+ }
111
+
112
+ static get FAILED() {
113
+ return STATE.FAILED.name;
114
+ }
115
+
116
+ static get WARNING() {
117
+ return STATE.WARNING.name;
118
+ }
119
+
120
+ static get PAUSED() {
121
+ return STATE.PAUSED.name;
122
+ }
123
+
124
+ static isRunning(state) {
125
+ return STATE[state] && STATE[state].isRunning;
126
+ }
127
+
128
+ static isKillable(state) {
129
+ return STATE[state] && STATE[state].isKillable;
130
+ }
131
+
132
+ static isPaused(state) {
133
+ return STATE[state] && STATE[state] === STATE.PAUSED;
134
+ }
135
+
136
+ static isFailed(state) {
137
+ return STATE[state] && STATE[state].isFailed;
138
+ }
139
+
140
+ static allStates() {
141
+ return _mapValues(STATE, state => {
142
+ return {
143
+ key: state.name,
144
+ icon: state.icon,
145
+ color: cssVariable("--bs-" + state.colorClass)
146
+ }
147
+ });
148
+ }
149
+
150
+ static arrayAllStates() {
151
+ return Object.values(STATE);
152
+ }
153
+
154
+ static colorClass() {
155
+ return _mapValues(STATE, state => state.colorClass);
156
+ }
157
+
158
+ static color() {
159
+ return _mapValues(STATE, state => cssVariable("--bs-" + state.colorClass));
160
+ }
161
+
162
+ static icon() {
163
+ return _mapValues(STATE, state => state.icon);
164
+ }
165
+ }