bromcom-ui 2.3.67 → 2.3.71

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 (71) hide show
  1. package/dist/bromcom-ui/bcm-label.entry.js +6 -478
  2. package/dist/bromcom-ui/bcm-select-box.entry.js +3 -0
  3. package/dist/bromcom-ui/bcm-select.entry.js +36 -18
  4. package/dist/bromcom-ui/bromcom-ui.esm.js +1 -1
  5. package/dist/bromcom-ui/{bcm-ad02f9c9.js → string-helper-1d51eff7.js} +23 -2
  6. package/dist/types/components/atoms/icon/icon.d.ts +1 -1
  7. package/dist/types/components/molecules/select/select-box.d.ts +1 -0
  8. package/package.json +1 -1
  9. package/dist/bromcom-ui/bcm-list-2-item.entry.js +0 -36
  10. package/dist/bromcom-ui/bcm-list-2.entry.js +0 -936
  11. package/dist/bromcom-ui/bcm-range.entry.js +0 -160
  12. package/dist/bromcom-ui/bcm-search-2.entry.js +0 -193
  13. package/dist/bromcom-ui/caption-template-2d4ffc88.js +0 -25
  14. package/dist/bromcom-ui/color-helper-19448077.js +0 -35
  15. package/dist/bromcom-ui/element-dragger-2a215f47.js +0 -273
  16. package/dist/bromcom-ui/generate-0a22e8df.js +0 -88
  17. package/dist/bromcom-ui/index-dbc63c66.js +0 -2818
  18. package/dist/bromcom-ui/index-dd5c1283.js +0 -187
  19. package/dist/bromcom-ui/input-template-2c402b1c.js +0 -91
  20. package/dist/bromcom-ui/input-template-3fef2084.js +0 -87
  21. package/dist/bromcom-ui/input-template-5d0fa41c.js +0 -89
  22. package/dist/bromcom-ui/input-template-5d288c2e.js +0 -90
  23. package/dist/bromcom-ui/input-template-63f2d73c.js +0 -83
  24. package/dist/bromcom-ui/input-template-91ff8813.js +0 -90
  25. package/dist/bromcom-ui/input-template-d4438c87.js +0 -86
  26. package/dist/bromcom-ui/input-template-d594af3b.js +0 -86
  27. package/dist/bromcom-ui/input-template-e0e652a9.js +0 -82
  28. package/dist/bromcom-ui/input-template-ece52adc.js +0 -85
  29. package/dist/bromcom-ui/input-template-f669289a.js +0 -93
  30. package/dist/bromcom-ui/json-parse-decarator-223ea680.js +0 -21
  31. package/dist/bromcom-ui/label-template-b0b70fde.js +0 -19
  32. package/dist/bromcom-ui/number-helper-fea1966f.js +0 -13
  33. package/dist/bromcom-ui/popover-placement-31e0e70f.js +0 -96
  34. package/dist/bromcom-ui/property-decorators-21b15487.js +0 -36
  35. package/dist/bromcom-ui/slot-template-5b8e1902.js +0 -9
  36. package/dist/bromcom-ui/snq.es5-946822b8.js +0 -14
  37. package/dist/bromcom-ui/string-helper-414d635d.js +0 -25
  38. package/dist/bromcom-ui/types-6b2a6629.js +0 -172
  39. package/dist/bromcom-ui/utils-333ded7f.js +0 -438
  40. package/dist/types/components/atoms/states/badge.states.d.ts +0 -7
  41. package/dist/types/components/atoms/states/button.states.d.ts +0 -7
  42. package/dist/types/components/molecules/breadcrumb/types.d.ts +0 -10
  43. package/dist/types/components/molecules/input/types.d.ts +0 -13
  44. package/dist/types/components/molecules/progress/types.d.ts +0 -24
  45. package/dist/types/components/molecules/range/range.d.ts +0 -36
  46. package/dist/types/components/molecules/search-2/search-2.d.ts +0 -26
  47. package/dist/types/components/molecules/states/alert.states.d.ts +0 -7
  48. package/dist/types/components/molecules/states/checkbox-group.states.d.ts +0 -53
  49. package/dist/types/components/molecules/states/message.states.d.ts +0 -7
  50. package/dist/types/components/molecules/states/notification.states.d.ts +0 -7
  51. package/dist/types/components/molecules/states/radio-group.states.d.ts +0 -47
  52. package/dist/types/components/molecules/states/result.states.d.ts +0 -7
  53. package/dist/types/components/molecules/states/search.states.d.ts +0 -9
  54. package/dist/types/components/molecules/textarea/types.d.ts +0 -9
  55. package/dist/types/components/organism/list-2/list-2-item.d.ts +0 -11
  56. package/dist/types/components/organism/list-2/list-2.d.ts +0 -104
  57. package/dist/types/components/organism/states/bcm-list2.states.d.ts +0 -19
  58. package/dist/types/decorators/json-parse-decarator.d.ts +0 -4
  59. package/dist/types/decorators/property-decorators.d.ts +0 -6
  60. package/dist/types/helper/number-helper.d.ts +0 -9
  61. package/dist/types/models/states/Atoms/bcm-Atoms-state.d.ts +0 -34
  62. package/dist/types/models/states/molecules/bcm-molecules-state.d.ts +0 -78
  63. package/dist/types/models/states/organisms/bcm-organisms-state.d.ts +0 -69
  64. package/dist/types/templates/button-template.d.ts +0 -16
  65. package/dist/types/templates/checkbox-group-template.d.ts +0 -10
  66. package/dist/types/templates/checkbox-template.d.ts +0 -13
  67. package/dist/types/templates/info-footer-template.d.ts +0 -10
  68. package/dist/types/templates/input-template.d.ts +0 -30
  69. package/dist/types/templates/list-item-template.d.ts +0 -10
  70. package/dist/types/templates/list-template.d.ts +0 -21
  71. package/dist/types/templates/tag-template.d.ts +0 -17
@@ -1,193 +0,0 @@
1
- import { r as registerInstance, e as createEvent, h, f as Host, g as getElement } from './index-dbc63c66.js';
2
- import { G as Generate } from './generate-0a22e8df.js';
3
- import './index-43956e3c.js';
4
- import { c as createStore } from './index-dd5c1283.js';
5
- import { s as snq } from './snq.es5-946822b8.js';
6
- import './bcm-ad02f9c9.js';
7
- import { J as JsonParse } from './json-parse-decarator-223ea680.js';
8
- import { I as InputTemplate } from './input-template-5d288c2e.js';
9
-
10
- const { state } = createStore({
11
- value: new Map(),
12
- });
13
- const setValue = (val) => {
14
- const { id, dataSource } = val;
15
- const data = {
16
- id: snq(() => id, Generate.UID),
17
- dataSource: recursive(dataSource)
18
- };
19
- state.value.set(data.id, data);
20
- };
21
- const recursive = (data, parentId) => {
22
- const recData = data.map((item) => (Object.assign(Object.assign(Object.assign({}, item), { parentId: parentId || null }), (item.items && { items: snq(() => recursive(item.items, item.id), []) }))));
23
- return recData;
24
- };
25
- const removeValue = (_id) => {
26
- state.value.delete(_id);
27
- };
28
- const getValue = (id) => snq(() => state.value.get(id), {});
29
- const getDataPagination = (id, limit = 3) => {
30
- let data = [];
31
- const value = getValue(id);
32
- if (value) {
33
- const { dataSource } = value;
34
- data = dataSource.slice(0, limit);
35
- }
36
- return data;
37
- };
38
- // //search treeview data by text
39
- // const searchData = (id, search, items?) => {
40
- // let dataSource
41
- // if (items && items.length > 0) {
42
- // dataSource = items
43
- // } else {
44
- // const value = getValue(id);
45
- // dataSource = value.dataSource;
46
- // }
47
- // let result = []
48
- // if (dataSource) {
49
- // dataSource.forEach(child => {
50
- // if (child.text.toLowerCase().includes(search.toLowerCase())) {
51
- // result.push(child)
52
- // }
53
- // result = result.concat(searchData(id, search, child.items))
54
- // })
55
- // };
56
- // return result
57
- // };
58
- //nested search
59
- const searchData = (id, searchText, items) => {
60
- let dataSource;
61
- if (items && items.length > 0) {
62
- dataSource = items;
63
- }
64
- else {
65
- const value = getValue(id);
66
- dataSource = value.dataSource;
67
- }
68
- let results = [];
69
- if (dataSource) {
70
- results = nestedSearch(dataSource, searchText);
71
- //return with their parents
72
- // dataSource.forEach(child => {
73
- // if (child.text.toLowerCase().includes(searchText.toLowerCase())) {
74
- // results.push(child)
75
- // } else if (child.items && child.items.length > 0) {
76
- // child.items = nestedSearch(child.items, searchText)
77
- // if (child.items.length > 0) {
78
- // results.push(child)
79
- // }
80
- // }
81
- // })
82
- }
83
- return Generate.flatArray(results);
84
- };
85
- const nestedSearch = (items, searchText) => {
86
- let result = [];
87
- if (items && items.length > 0) {
88
- items.forEach(child => {
89
- if (child.text.toLowerCase().includes(searchText.toLowerCase())) {
90
- result.push(child.id);
91
- if (child.items && child.items.length > 0) {
92
- child.items.forEach(chi => {
93
- result.push(chi.id);
94
- });
95
- }
96
- }
97
- else if (child.items && child.items.length > 0) {
98
- const found = nestedSearch(child.items, searchText);
99
- if (found.length > 0) {
100
- found.forEach(chi => {
101
- result.push(chi);
102
- });
103
- result.push(child.id);
104
- }
105
- }
106
- });
107
- }
108
- ;
109
- return result;
110
- };
111
- const searchState = {
112
- setValue,
113
- removeValue,
114
- getValue,
115
- getDataPagination,
116
- searchData
117
- };
118
-
119
- var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
120
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
121
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
122
- r = Reflect.decorate(decorators, target, key, desc);
123
- else
124
- for (var i = decorators.length - 1; i >= 0; i--)
125
- if (d = decorators[i])
126
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
127
- return c > 3 && r && Object.defineProperty(target, key, r), r;
128
- };
129
- const BcmSearch2 = class {
130
- constructor(hostRef) {
131
- registerInstance(this, hostRef);
132
- this.bcmOnSearch = createEvent(this, "bcm-on-search", 7);
133
- this._id = Generate.UID();
134
- this.placeholder = "Search";
135
- this.disabled = false;
136
- this.readonly = false;
137
- this.clearable = true;
138
- this.limit = 10;
139
- this.data = [];
140
- this.tick = {};
141
- this.debounceHandler = Generate.debounceInput((event) => this.onSearchValue(event, this), 500, false);
142
- }
143
- async componentDidLoad() {
144
- await this.initState();
145
- }
146
- async dataChanged(newValue, oldValue) {
147
- // console.log('data changed', newValue, oldValue)
148
- if (newValue !== oldValue) {
149
- await this.initState();
150
- }
151
- }
152
- async initState() {
153
- await searchState.setValue({
154
- id: this._id,
155
- dataSource: this.data,
156
- });
157
- await this.markForCheck();
158
- }
159
- markForCheck() {
160
- this.tick = Generate.UID();
161
- }
162
- handleInput() {
163
- console.log("aheyya");
164
- }
165
- handleFocus() { }
166
- handleBlur() { }
167
- handleChange() { }
168
- handleClear() {
169
- this.inputElement.value = '';
170
- const { value, id } = this.inputElement;
171
- searchState.searchData(id, value);
172
- this.bcmOnSearch.emit(null);
173
- }
174
- onSearchValue(event, instance) {
175
- const { value, id } = event.target;
176
- const searchResult = value.length > 0 ? searchState.searchData(id, value) : null;
177
- const { bcmOnSearch } = instance;
178
- bcmOnSearch.emit(searchResult);
179
- }
180
- render() {
181
- const { _id, placeholder, disabled, readonly, clearable } = this;
182
- return h(Host, null, h(InputTemplate, { size: "medium", id: _id, type: "text", placeholder: placeholder, disabled: disabled, readonly: readonly, clearable: clearable, handleFocus: () => this.handleFocus(), handleBlur: () => this.handleBlur(), handleChange: () => this.handleChange(), handleClear: () => this.handleClear(), handleInput: this.debounceHandler, ref: (el) => this.inputElement = el }));
183
- }
184
- get el() { return getElement(this); }
185
- static get watchers() { return {
186
- "data": ["dataChanged"]
187
- }; }
188
- };
189
- __decorate([
190
- JsonParse('data')
191
- ], BcmSearch2.prototype, "data", void 0);
192
-
193
- export { BcmSearch2 as bcm_search_2 };
@@ -1,25 +0,0 @@
1
- import { h } from './index-dbc63c66.js';
2
-
3
- const CaptionTemplate = ({ noCaption, captionType, captionClasses, caption, captionError,
4
- //textarea props
5
- maxLength, value }) => {
6
- const classes = `size-1 bcm-caption-area__text`;
7
- const captionTextClass = `${classes} ${captionType} ${captionClasses}`;
8
- const countClasses = `${classes} default ${captionClasses}`;
9
- return ((noCaption == false || maxLength) && (h("div", { class: "bcm-caption-area" },
10
- h("span", { class: captionTextClass }, captionType == "error"
11
- ? h("span", null,
12
- " ",
13
- captionError,
14
- " ")
15
- : caption && h("span", null,
16
- " ",
17
- caption,
18
- " ")),
19
- maxLength && h("span", { class: countClasses },
20
- " ",
21
- `${value === null || value === void 0 ? void 0 : value.length}/${maxLength}`,
22
- " "))));
23
- };
24
-
25
- export { CaptionTemplate as C };
@@ -1,35 +0,0 @@
1
- import { f as extractColor, C as ColorPalette } from './utils-333ded7f.js';
2
-
3
- class ColorHelper {
4
- }
5
- ColorHelper.isHex = (str) => /^[A-F0-9]+$/i.test(str);
6
- ColorHelper.isRgb = (str) => /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.test(str);
7
- ColorHelper.isRgba = (str) => /^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.test(str);
8
- ColorHelper.isHsl = (str) => /^hsl\((\d{1,3}),\s*(\d{1,3}%),\s*(\d{1,3}%)\)$/.test(str);
9
- ColorHelper.isHsla = (str) => /^hsla\((\d{1,3}),\s*(\d{1,3}%),\s*(\d{1,3}%),\s*(\d{1,3})\)$/.test(str);
10
- ColorHelper.convertColorToHex = (color) => {
11
- if (color) {
12
- if (ColorHelper.isHex(color)) {
13
- return color;
14
- }
15
- if (ColorHelper.isRgb(color)) {
16
- const rgb = color.match(/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/);
17
- return `#${(0x1000000 + (parseInt(rgb[1]) * 0x10000) + (parseInt(rgb[2]) * 0x100) + parseInt(rgb[3])).toString(16).substring(1)}`;
18
- }
19
- if (extractColor(ColorPalette, color)) {
20
- return extractColor(ColorPalette, color);
21
- }
22
- }
23
- };
24
- ColorHelper.reverseColor = (color) => {
25
- const hexColor = ColorHelper.convertColorToHex(color);
26
- if (hexColor) {
27
- const r = parseInt(hexColor.substring(1, 3), 16);
28
- const g = parseInt(hexColor.substring(3, 5), 16);
29
- const b = parseInt(hexColor.substring(5, 7), 16);
30
- const yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000;
31
- return (yiq >= 200) ? '#000000' : '#FFFFFF';
32
- }
33
- };
34
-
35
- export { ColorHelper as C };
@@ -1,273 +0,0 @@
1
- import { a as getTransform } from './utils-333ded7f.js';
2
-
3
- /**
4
- * Enums
5
- */
6
- var DragDirections;
7
- (function (DragDirections) {
8
- DragDirections["x"] = "x";
9
- DragDirections["y"] = "y";
10
- DragDirections["both"] = "both";
11
- })(DragDirections || (DragDirections = {}));
12
- /**
13
- * @Class BcmDragger
14
- * @desc -
15
- */
16
- class ElementDragger {
17
- constructor({ target, trigger, limit, center, direction = DragDirections.both, snapOnMouseDown = false, useTransform = false }) {
18
- this.drag = {
19
- x: 0,
20
- y: 0
21
- };
22
- this.offset = {
23
- left: 0,
24
- top: 0
25
- };
26
- this.events = {
27
- end: [],
28
- drag: []
29
- };
30
- this.active = false;
31
- this.anim = false;
32
- this.busy = false;
33
- this.target = target;
34
- this.trigger = trigger || target;
35
- this.direction = direction;
36
- this.limit = limit;
37
- this.useTransform = useTransform;
38
- this.snapOnMouseDown = snapOnMouseDown;
39
- this.center = center;
40
- this.container = this.findRelativeContainer();
41
- // Get trigger offset initially
42
- // #
43
- this.offset = {
44
- top: this.useTransform
45
- ? getTransform(target).y
46
- : target.offsetTop,
47
- left: this.useTransform
48
- ? getTransform(target).x
49
- : target.offsetLeft
50
- };
51
- this.attachEvents();
52
- }
53
- /**
54
- * @desc
55
- */
56
- attachEvents() {
57
- /**
58
- * Mouse Event: move -> [window]
59
- */
60
- window.addEventListener('mousemove', (_event) => this.windowMove(_event));
61
- /**
62
- * Mouse Event: move -> [window]
63
- */
64
- window.addEventListener('mouseup', (_event) => this.windowUp());
65
- /**
66
- * Mouse Event: down -> [BcmDragger.trigger]
67
- */
68
- this.trigger.addEventListener('mousedown', (_event) => this.triggerDown(_event));
69
- }
70
- /**
71
- * @desc
72
- * @param element
73
- * @param property
74
- */
75
- computedStyle(element, property) {
76
- return window.getComputedStyle(element, null).getPropertyValue(property);
77
- }
78
- /**
79
- * @desc
80
- * -
81
- */
82
- findRelativeContainer() {
83
- const { target } = this;
84
- const elementNode = Node.ELEMENT_NODE;
85
- let currentParent = target.parentNode;
86
- while (currentParent && currentParent.nodeType === elementNode) {
87
- const match = ['absolute', 'relative'].includes(this.computedStyle(currentParent, 'position'));
88
- if (match)
89
- return currentParent;
90
- currentParent = currentParent.parentNode;
91
- }
92
- return null;
93
- }
94
- /**
95
- * @desc
96
- * @param event
97
- */
98
- windowMove(event) {
99
- if (!this.active)
100
- return;
101
- const { limit } = this;
102
- const { center: { x: centerX, y: centerY } = { x: 0, y: 0 }, } = this;
103
- let x = event.pageX - this.drag.x - centerX;
104
- let y = event.pageY - this.drag.y - centerY;
105
- this.busy = true;
106
- // Check limit boundaries
107
- // #
108
- const [xMax, xMin, yMax, yMin] = [
109
- limit && limit.x && limit.x.max - centerX,
110
- limit && limit.x && limit.x.min - centerX,
111
- limit && limit.y && limit.y.max - centerY,
112
- limit && limit.y && limit.y.min - centerY
113
- ];
114
- if ((xMax || xMax === 0) && x > xMax) {
115
- x = xMax;
116
- }
117
- if ((xMin || xMin === 0) && x < xMin) {
118
- x = xMin;
119
- }
120
- if ((yMax || yMax === 0) && y > yMax) {
121
- y = yMax;
122
- }
123
- if ((yMin || yMin === 0) && y < yMin) {
124
- y = yMin;
125
- }
126
- this.offset = {
127
- top: y,
128
- left: x
129
- };
130
- this.removeTransition();
131
- this.move();
132
- }
133
- /**
134
- * @desc
135
- */
136
- windowUp() {
137
- if (!this.active)
138
- return;
139
- this.triggerEvent('end', this.getCurrentPosition());
140
- this.animTimeout = setTimeout(() => {
141
- clearTimeout(this.animTimeout);
142
- this.busy = false;
143
- }, 210);
144
- this.active = false;
145
- }
146
- /**
147
- * @desc
148
- * @param event
149
- */
150
- triggerDown(event) {
151
- this.active = true;
152
- if (this.snapOnMouseDown) {
153
- this.offset.left = event.offsetX;
154
- this.offset.top = event.offsetY;
155
- this.move();
156
- }
157
- this.drag.x = event.pageX - this.offset.left;
158
- this.drag.y = event.pageY - this.offset.top;
159
- }
160
- /**
161
- * @desc
162
- */
163
- move(triggerDrag = true) {
164
- const { direction, useTransform, target, offset: { top, left } } = this;
165
- if (direction === DragDirections.both) {
166
- useTransform
167
- ? target.style.transform = `translate(${left}px, ${top}px)`
168
- : (target.style.top = `${top}px`) && (target.style.left = `${left}px`);
169
- }
170
- else if (direction === DragDirections.x) {
171
- useTransform
172
- ? target.style.transform = `translateX(${left}px)`
173
- : target.style.left = `${left}px`;
174
- }
175
- else if (direction === DragDirections.y) {
176
- useTransform
177
- ? target.style.transform = `translateY(${top}px)`
178
- : target.style.top = `${top}px`;
179
- }
180
- if (triggerDrag)
181
- this.triggerEvent('drag', this.getCurrentPosition());
182
- }
183
- /**
184
- * @desc
185
- * -
186
- */
187
- calculateOffset() {
188
- const { target, container } = this;
189
- let { left, top } = target.style;
190
- if (!container) {
191
- return { left, top };
192
- }
193
- const [rectTarget, rectContainer] = [
194
- target.getBoundingClientRect(),
195
- container.getBoundingClientRect()
196
- ];
197
- left = rectTarget.left - rectContainer.left,
198
- top = rectTarget.top - rectContainer.top;
199
- return { left, top };
200
- }
201
- /**
202
- * @desc
203
- */
204
- getCurrentPosition() {
205
- const { target } = this;
206
- const { center: { x: centerX, y: centerY } = { x: 0, y: 0 } } = this;
207
- let { left: x, top: y } = this.calculateOffset();
208
- // 'offsetLeft' and 'offsetTop' properties are giving 'long integer' values
209
- // in this case, this is not useful, we are using subpixel values.
210
- return {
211
- x: this.useTransform
212
- ? getTransform(target).x + centerX
213
- : /* this.target.offsetLeft */ parseFloat(x) + centerX,
214
- y: this.useTransform
215
- ? getTransform(target).y + centerY
216
- : /* this.target.offsetTop */ parseFloat(y) + centerY
217
- };
218
- }
219
- /**
220
- * @desc
221
- * @param x
222
- * @param y
223
- */
224
- setPosition({ x, y, anim }) {
225
- const { center: { x: centerX, y: centerY } = { x: 0, y: 0 }, } = this;
226
- if (x || x === 0) {
227
- this.offset.left = x - centerX;
228
- }
229
- if (y || y === 0) {
230
- this.offset.top = y - centerY;
231
- }
232
- anim && this.applyTransition();
233
- this.move(false);
234
- }
235
- /**
236
- * @desc
237
- */
238
- applyTransition() {
239
- this.anim = true;
240
- this.target.style.transition = 'transform 0.2s ease';
241
- }
242
- /**
243
- * @desc
244
- */
245
- removeTransition() {
246
- this.anim = false;
247
- this.target.style.transition = '';
248
- }
249
- /**
250
- * @desc
251
- * @returns
252
- */
253
- getOffset() {
254
- return this.offset;
255
- }
256
- /**
257
- * @desc
258
- * @param event
259
- * @param fn
260
- */
261
- on(event, fn) {
262
- this.events[event].push(fn);
263
- }
264
- /**
265
- * @desc
266
- * @param event
267
- */
268
- triggerEvent(event, ...params) {
269
- this.events[event].forEach((fn) => fn(params[0]));
270
- }
271
- }
272
-
273
- export { DragDirections as D, ElementDragger as E };
@@ -1,88 +0,0 @@
1
- /**
2
- * 'status' prop predefined values
3
- */
4
- var StatusProps;
5
- (function (StatusProps) {
6
- StatusProps["info"] = "info";
7
- StatusProps["error"] = "error";
8
- StatusProps["warning"] = "warning";
9
- StatusProps["success"] = "success";
10
- StatusProps["default"] = "default";
11
- })(StatusProps || (StatusProps = {}));
12
- /**
13
- * 'type' prop predefined values
14
- */
15
- var TypeProps;
16
- (function (TypeProps) {
17
- TypeProps["banner"] = "banner";
18
- TypeProps["basic"] = "basic";
19
- })(TypeProps || (TypeProps = {}));
20
-
21
- class Generate {
22
- }
23
- Generate.UID = () => Math.random().toString(36).substr(2, 9);
24
- Generate.getIconAttrWithStatusType = (status, loading = false) => {
25
- if (loading)
26
- return { icon: 'loading', color: 'blue-6' };
27
- switch (status) {
28
- case StatusProps.info:
29
- return { color: 'blue-6', icon: 'info-circle' };
30
- case StatusProps.error:
31
- return { color: 'red-6', icon: 'close-circle' };
32
- case StatusProps.warning:
33
- return { color: 'warmyellow-6', icon: 'exclamation-circle' };
34
- case StatusProps.success:
35
- return { color: 'green-6', icon: 'check-circle' };
36
- }
37
- };
38
- Generate.createComponent = (element, props) => {
39
- let container = document.getElementById('append-area');
40
- if (!container) {
41
- container = document.createElement('div');
42
- container.id = 'append-area';
43
- document.body.appendChild(container);
44
- }
45
- let box = document.createElement(element);
46
- Object.keys(props).forEach(key => {
47
- box[key] = props[key];
48
- });
49
- container.appendChild(box);
50
- return box;
51
- };
52
- Generate.debounceInput = (func, wait, immediate) => {
53
- let timeout;
54
- return function () {
55
- let context = this, args = arguments;
56
- let later = function () {
57
- timeout = null;
58
- if (!immediate)
59
- func.apply(context, args);
60
- };
61
- let callNow = immediate && !timeout;
62
- clearTimeout(timeout);
63
- timeout = setTimeout(later, wait);
64
- if (callNow)
65
- func.apply(context, args);
66
- };
67
- };
68
- Generate.flatArray = (arr) => {
69
- return arr.reduce((acc, val) => {
70
- return acc.concat(Array.isArray(val) ? Generate.flatArray(val) : val);
71
- }, []);
72
- };
73
- Generate.reverseNodeList = (node_list) => {
74
- let arr = [];
75
- for (let i = node_list.length - 1; i >= 0; i--) {
76
- arr.push(node_list[i]);
77
- }
78
- return arr;
79
- };
80
- Generate.findEventPath = (event, find, items) => {
81
- items = Array.isArray(items) ? items : [items];
82
- let path = event.path || (event.composedPath && event.composedPath());
83
- if (path) {
84
- return path.filter((element) => items.includes(element[find]))[0] !== undefined;
85
- }
86
- };
87
-
88
- export { Generate as G, StatusProps as S, TypeProps as T };