@3t-transform/threeteeui 0.2.80 → 0.2.82
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/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/tttx-percentage-bar.cjs.entry.js +65 -0
- package/dist/cjs/tttx-tree-view.cjs.entry.js +38 -11
- package/dist/cjs/tttx.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/atoms/tttx-percentage-bar/tttx-percentage-bar.css +11 -0
- package/dist/collection/components/atoms/tttx-percentage-bar/tttx-percentage-bar.js +168 -0
- package/dist/collection/components/atoms/tttx-percentage-bar/tttx-percentage-bar.stories.js +58 -0
- package/dist/collection/components/molecules/tttx-tree-view/tttx-tree-view.css +31 -3
- package/dist/collection/components/molecules/tttx-tree-view/tttx-tree-view.js +39 -11
- package/dist/collection/components/molecules/tttx-tree-view/tttx-tree-view.stories.js +95 -8
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/tttx-percentage-bar.d.ts +11 -0
- package/dist/components/tttx-percentage-bar.js +87 -0
- package/dist/components/tttx-tree-view.js +40 -12
- package/dist/esm/loader.js +1 -1
- package/dist/esm/tttx-percentage-bar.entry.js +61 -0
- package/dist/esm/tttx-tree-view.entry.js +38 -11
- package/dist/esm/tttx.js +1 -1
- package/dist/tttx/p-149f806e.entry.js +1 -0
- package/dist/tttx/p-62115838.entry.js +1 -0
- package/dist/tttx/tttx.esm.js +1 -1
- package/dist/types/components/atoms/tttx-percentage-bar/tttx-percentage-bar.d.ts +22 -0
- package/dist/types/components/atoms/tttx-percentage-bar/tttx-percentage-bar.stories.d.ts +10 -0
- package/dist/types/components/molecules/tttx-tree-view/helper/helper.d.ts +5 -0
- package/dist/types/components/molecules/tttx-tree-view/tttx-tree-view.d.ts +11 -0
- package/dist/types/components/molecules/tttx-tree-view/tttx-tree-view.stories.d.ts +2 -0
- package/dist/types/components.d.ts +24 -0
- package/package.json +2 -2
- package/dist/tttx/p-6e23f980.entry.js +0 -1
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["tttx-multiselect-box.cjs",[[1,"tttx-multiselect-box",{"optionsData":[1,"options-data"],"label":[1],"inline":[4],"placeholder":[1],"searchEnabled":[4,"search-enabled"],"htmlVisibleValue":[4,"html-visible-value"],"visibleValue":[1,"visible-value"],"open":[32],"unsavedSelectedItems":[32],"searchTerm":[32]},[[0,"closeSelectBox","handleCloseSelectBox"],[0,"blur","handleBlur"]]]]],["tttx-dialog-box.cjs",[[1,"tttx-dialog-box",{"data":[1025],"size":[1],"open":[1028],"allowOverflow":[4,"allow-overflow"],"elementSize":[32]},[[9,"resize","handleResize"]]]]],["tttx-select-box.cjs",[[1,"tttx-select-box",{"optionsData":[1,"options-data"],"label":[1],"inline":[4],"placeholder":[1],"searchEnabled":[4,"search-enabled"],"selectedValue":[1,"selected-value"],"open":[32],"selectedItem":[32],"searchTerm":[32]},[[0,"closeSelectBox","handleCloseSelectBox"],[0,"blur","handleBlur"]]]]],["tttx-tree-view.cjs",[[1,"tttx-tree-view",{"data":[1040],"treeData":[32]}]]],["tttx-filter.cjs",[[1,"tttx-filter",{"filterKey":[1,"filter-key"],"filterOptions":[1,"filter-options"],"showSelectAll":[4,"show-select-all"],"showSearchField":[4,"show-search-field"],"showOptionIcons":[4,"show-option-icons"],"filterButtonStyle":[1,"filter-button-style"],"filterHeader":[1,"filter-header"],"defaultFilterOptions":[1,"default-filter-options"],"popoverWidth":[1,"popover-width"],"showPopover":[32],"displayedFilterSettings":[32],"selectedFilters":[32],"filterSearchTerm":[32],"allSelected":[32]},[[0,"closeFilter","handleCloseFilter"]]]]],["tttx-list.cjs",[[1,"tttx-list",{"data":[1025],"name":[1],"_data":[32]}]]],["tttx-sorter.cjs",[[1,"tttx-sorter",{"sorterKey":[1,"sorter-key"],"defaultSortDirection":[1,"default-sort-direction"],"fieldOptionsData":[1,"field-options-data"],"defaultOption":[1,"default-option"],"selectedField":[32],"sortDirection":[32],"dropdownExpand":[32],"dropdownOptions":[32]},[[0,"closeSorter","handleCloseSorter"]]]]],["tttx-tabs.cjs",[[2,"tttx-tabs",{"tabsName":[1,"tabs-name"],"navigation":[4],"wide":[4],"tabs":[1],"_tabs":[32]},[[0,"keydown","handleKeyDown"]]]]],["tttx-form.cjs",[[1,"tttx-form",{"formschema":[1025],"data":[1032],"submit":[64]}]]],["tttx-keyvalue-block.cjs",[[1,"tttx-keyvalue-block",{"keyvalues":[1],"horizontal":[4],"spacedout":[4],"_elements":[32]}]]],["tttx-loading-spinner.cjs",[[1,"tttx-loading-spinner",{"loadingMessage":[1028,"loading-message"],"size":[1025]}]]],["tttx-qrcode.cjs",[[1,"tttx-qrcode",{"link":[1025],"size":[1026]}]]],["tttx-tag.cjs",[[1,"tttx-tag",{"text":[1],"color":[1]}]]],["tttx-textarea.cjs",[[2,"tttx-textarea",{"label":[1],"secondarylabel":[1],"showerrormsg":[4],"showerrorbubble":[4],"errormsg":[1],"rows":[2],"textareaautofocus":[4],"inputkeyhint":[1],"inputindex":[8],"inputtitle":[1],"disabled":[4],"maxlength":[8],"name":[1],"placeholder":[1],"readonly":[8],"required":[4],"value":[1032]}]]],["tttx-toolbar.cjs",[[1,"tttx-toolbar",{"border":[4],"viewSize":[32]},[[9,"resize","handleResize"]]]]],["tttx-icon.cjs",[[1,"tttx-icon",{"icon":[1],"color":[1]}]]],["tttx-standalone-input.cjs",[[2,"tttx-standalone-input",{"label":[1],"secondarylabel":[1],"showerrormsg":[4],"showerrorbubble":[4],"errormsg":[1],"iconleft":[1],"iconleftcolor":[1],"iconright":[1],"iconrightcolor":[1],"inputicon":[1],"inputiconcolor":[1],"inline":[4],"inputautocapitalize":[1],"inputautofocus":[4],"inputkeyhint":[1],"inputindex":[8],"inputtitle":[1],"autocomplete":[1],"checked":[4],"disabled":[4],"max":[8],"maxlength":[8],"min":[8],"minlength":[8],"name":[1],"pattern":[1],"placeholder":[1],"readonly":[8],"required":[4],"step":[8],"type":[1],"value":[1032]}]]],["tttx-button.cjs",[[1,"tttx-button",{"notext":[4],"icon":[1],"iconposition":[1],"iconcolor":[1025],"design":[1]}]]]], options);
|
|
17
|
+
return index.bootstrapLazy([["tttx-multiselect-box.cjs",[[1,"tttx-multiselect-box",{"optionsData":[1,"options-data"],"label":[1],"inline":[4],"placeholder":[1],"searchEnabled":[4,"search-enabled"],"htmlVisibleValue":[4,"html-visible-value"],"visibleValue":[1,"visible-value"],"open":[32],"unsavedSelectedItems":[32],"searchTerm":[32]},[[0,"closeSelectBox","handleCloseSelectBox"],[0,"blur","handleBlur"]]]]],["tttx-dialog-box.cjs",[[1,"tttx-dialog-box",{"data":[1025],"size":[1],"open":[1028],"allowOverflow":[4,"allow-overflow"],"elementSize":[32]},[[9,"resize","handleResize"]]]]],["tttx-select-box.cjs",[[1,"tttx-select-box",{"optionsData":[1,"options-data"],"label":[1],"inline":[4],"placeholder":[1],"searchEnabled":[4,"search-enabled"],"selectedValue":[1,"selected-value"],"open":[32],"selectedItem":[32],"searchTerm":[32]},[[0,"closeSelectBox","handleCloseSelectBox"],[0,"blur","handleBlur"]]]]],["tttx-tree-view.cjs",[[1,"tttx-tree-view",{"data":[1040],"treeData":[32],"selectedId":[32]}]]],["tttx-filter.cjs",[[1,"tttx-filter",{"filterKey":[1,"filter-key"],"filterOptions":[1,"filter-options"],"showSelectAll":[4,"show-select-all"],"showSearchField":[4,"show-search-field"],"showOptionIcons":[4,"show-option-icons"],"filterButtonStyle":[1,"filter-button-style"],"filterHeader":[1,"filter-header"],"defaultFilterOptions":[1,"default-filter-options"],"popoverWidth":[1,"popover-width"],"showPopover":[32],"displayedFilterSettings":[32],"selectedFilters":[32],"filterSearchTerm":[32],"allSelected":[32]},[[0,"closeFilter","handleCloseFilter"]]]]],["tttx-list.cjs",[[1,"tttx-list",{"data":[1025],"name":[1],"_data":[32]}]]],["tttx-sorter.cjs",[[1,"tttx-sorter",{"sorterKey":[1,"sorter-key"],"defaultSortDirection":[1,"default-sort-direction"],"fieldOptionsData":[1,"field-options-data"],"defaultOption":[1,"default-option"],"selectedField":[32],"sortDirection":[32],"dropdownExpand":[32],"dropdownOptions":[32]},[[0,"closeSorter","handleCloseSorter"]]]]],["tttx-tabs.cjs",[[2,"tttx-tabs",{"tabsName":[1,"tabs-name"],"navigation":[4],"wide":[4],"tabs":[1],"_tabs":[32]},[[0,"keydown","handleKeyDown"]]]]],["tttx-form.cjs",[[1,"tttx-form",{"formschema":[1025],"data":[1032],"submit":[64]}]]],["tttx-keyvalue-block.cjs",[[1,"tttx-keyvalue-block",{"keyvalues":[1],"horizontal":[4],"spacedout":[4],"_elements":[32]}]]],["tttx-loading-spinner.cjs",[[1,"tttx-loading-spinner",{"loadingMessage":[1028,"loading-message"],"size":[1025]}]]],["tttx-percentage-bar.cjs",[[2,"tttx-percentage-bar",{"percentage":[8],"thresholds":[1],"color":[1],"min":[1],"labelid":[1],"_percentage":[32],"_ranges":[32],"_min":[32]}]]],["tttx-qrcode.cjs",[[1,"tttx-qrcode",{"link":[1025],"size":[1026]}]]],["tttx-tag.cjs",[[1,"tttx-tag",{"text":[1],"color":[1]}]]],["tttx-textarea.cjs",[[2,"tttx-textarea",{"label":[1],"secondarylabel":[1],"showerrormsg":[4],"showerrorbubble":[4],"errormsg":[1],"rows":[2],"textareaautofocus":[4],"inputkeyhint":[1],"inputindex":[8],"inputtitle":[1],"disabled":[4],"maxlength":[8],"name":[1],"placeholder":[1],"readonly":[8],"required":[4],"value":[1032]}]]],["tttx-toolbar.cjs",[[1,"tttx-toolbar",{"border":[4],"viewSize":[32]},[[9,"resize","handleResize"]]]]],["tttx-icon.cjs",[[1,"tttx-icon",{"icon":[1],"color":[1]}]]],["tttx-standalone-input.cjs",[[2,"tttx-standalone-input",{"label":[1],"secondarylabel":[1],"showerrormsg":[4],"showerrorbubble":[4],"errormsg":[1],"iconleft":[1],"iconleftcolor":[1],"iconright":[1],"iconrightcolor":[1],"inputicon":[1],"inputiconcolor":[1],"inline":[4],"inputautocapitalize":[1],"inputautofocus":[4],"inputkeyhint":[1],"inputindex":[8],"inputtitle":[1],"autocomplete":[1],"checked":[4],"disabled":[4],"max":[8],"maxlength":[8],"min":[8],"minlength":[8],"name":[1],"pattern":[1],"placeholder":[1],"readonly":[8],"required":[4],"step":[8],"type":[1],"value":[1032]}]]],["tttx-button.cjs",[[1,"tttx-button",{"notext":[4],"icon":[1],"iconposition":[1],"iconcolor":[1025],"design":[1]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-4cfa8e25.js');
|
|
6
|
+
|
|
7
|
+
const tttxPercentageBarCss = ".sc-tttx-percentage-bar-h{display:block}.progress.sc-tttx-percentage-bar{width:100%;background-color:#dbdbdb}.progress.sc-tttx-percentage-bar .bar.sc-tttx-percentage-bar{height:20px}";
|
|
8
|
+
|
|
9
|
+
const TttxPercentageBar = class {
|
|
10
|
+
constructor(hostRef) {
|
|
11
|
+
index.registerInstance(this, hostRef);
|
|
12
|
+
this.percentage = undefined;
|
|
13
|
+
this.thresholds = undefined;
|
|
14
|
+
this.color = '#d5d5d5';
|
|
15
|
+
this.min = '1';
|
|
16
|
+
this.labelid = undefined;
|
|
17
|
+
this._percentage = undefined;
|
|
18
|
+
this._ranges = undefined;
|
|
19
|
+
this._min = undefined;
|
|
20
|
+
}
|
|
21
|
+
componentWillRender() {
|
|
22
|
+
if (typeof this.percentage === 'string') {
|
|
23
|
+
this._percentage = parseInt(this.percentage);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
this._percentage = this.percentage;
|
|
27
|
+
}
|
|
28
|
+
let thresholdsArray;
|
|
29
|
+
if (this.thresholds) {
|
|
30
|
+
if (typeof this.thresholds === 'string') {
|
|
31
|
+
thresholdsArray = JSON.parse(this.thresholds);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
thresholdsArray = this.thresholds;
|
|
35
|
+
}
|
|
36
|
+
this._ranges = [{ range: [0], color: thresholdsArray[0].color }];
|
|
37
|
+
for (const [i, thresholdsObj] of thresholdsArray.entries()) {
|
|
38
|
+
this._ranges[this._ranges.length - 1].range.push(thresholdsObj.threshold);
|
|
39
|
+
this._ranges[this._ranges.length - 1].color = thresholdsObj.color;
|
|
40
|
+
if (i < thresholdsArray.length - 1) {
|
|
41
|
+
this._ranges.push({ range: [thresholdsObj.threshold], color: undefined });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
this._min = parseInt(this.min);
|
|
46
|
+
}
|
|
47
|
+
getColour() {
|
|
48
|
+
if (!this._ranges || this._ranges.length === 0) {
|
|
49
|
+
return this.color;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const range = this._ranges.find(r => this._percentage >= r.range[0] && this._percentage <= r.range[1]);
|
|
53
|
+
return range.color;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
getWidth() {
|
|
57
|
+
return Math.min(Math.max(this._percentage, Math.min(this._min, 100)), 100);
|
|
58
|
+
}
|
|
59
|
+
render() {
|
|
60
|
+
return (index.h(index.Host, null, index.h("div", { class: "progress" }, index.h("div", { class: "bar", style: { 'background-color': this.getColour(), 'width': `${this.getWidth()}%` }, role: "progressbar", "aria-valuemin": this._min, "aria-valuemax": "100", "aria-valuenow": this._percentage, "aria-labelledby": this.labelid }))));
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
TttxPercentageBar.style = tttxPercentageBarCss;
|
|
64
|
+
|
|
65
|
+
exports.tttx_percentage_bar = TttxPercentageBar;
|
|
@@ -6,7 +6,7 @@ const index = require('./index-4cfa8e25.js');
|
|
|
6
6
|
const domsanitiser_options = require('./domsanitiser.options-32e670aa.js');
|
|
7
7
|
require('./_commonjsHelpers-537d719a.js');
|
|
8
8
|
|
|
9
|
-
const tttxTreeViewCss = ".material-symbols-rounded{font-variation-settings:\"FILL\" 1, \"wght\" 400, \"GRAD\" 0, \"opsz\" 24}.tree-view-element{margin-left:-50px}.inline-tree-item{display:flex;align-items:center}.element{display:flex;flex-flow:row nowrap;justify-content:flex-start;align-items:center;width:100%}.element-row{min-height:36px;font-family:\"Roboto\", serif;font-size:16px;padding:8px 0px;border-bottom:1px solid #d5d5d5}.
|
|
9
|
+
const tttxTreeViewCss = ".material-symbols-rounded{font-variation-settings:\"FILL\" 1, \"wght\" 400, \"GRAD\" 0, \"opsz\" 24}.tree-view-element{margin-left:-50px}.inline-tree-item{display:flex;align-items:center}.element{display:flex;flex-flow:row nowrap;justify-content:flex-start;align-items:center;width:100%}.element-row{min-height:36px;font-family:\"Roboto\", serif;font-size:16px;padding:8px 0px;position:relative}.element-row::before{content:\"\";position:absolute;left:-50%;right:-50%;bottom:0;border-bottom:1px solid #d5d5d5}.element-row.rowSelected::before{content:\"\";position:absolute;left:-50%;right:-50%;top:0;bottom:0;background-color:rgba(17, 17, 17, 0.1);z-index:-1}li{list-style-type:none}.toggleNode{padding-right:3px}.padding-icon{padding:6px 6px;height:24px;width:24px;display:flex;align-items:center;justify-content:center}.treeNode{font-weight:500}.treeLeaf{font-weight:400}.right-buttons-container{margin-left:auto;display:flex}.borderless:active{outline-style:none}@media (hover: hover){.element-row.rowHover:hover{cursor:pointer}.element-row.rowHover:hover::before{content:\"\";position:absolute;left:-50%;right:-50%;top:0;bottom:0;background-color:rgba(17, 17, 17, 0.05);opacity:0.5;z-index:-1}}";
|
|
10
10
|
|
|
11
11
|
const TttxTreeView = class {
|
|
12
12
|
constructor(hostRef) {
|
|
@@ -14,11 +14,24 @@ const TttxTreeView = class {
|
|
|
14
14
|
this.clickEvent = index.createEvent(this, "clickEvent", 7);
|
|
15
15
|
this.data = undefined;
|
|
16
16
|
this.treeData = undefined;
|
|
17
|
+
this.selectedId = undefined;
|
|
17
18
|
}
|
|
18
19
|
onClickHandler(clickName, event, node) {
|
|
19
20
|
event.stopPropagation();
|
|
20
21
|
const returnJsonObject = JSON.stringify(node);
|
|
21
22
|
this.clickEvent.emit({ eventName: clickName, returnJsonObject });
|
|
23
|
+
if (clickName === 'row') {
|
|
24
|
+
this.selectedElement(event, node);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//for testing as SelectedId is a state
|
|
28
|
+
updateSelectedId(newId) {
|
|
29
|
+
this.selectedId = newId;
|
|
30
|
+
}
|
|
31
|
+
selectedElement(event, node) {
|
|
32
|
+
event.stopPropagation();
|
|
33
|
+
this.selectedId = node.id;
|
|
34
|
+
this.treeData = [...this.treeData];
|
|
22
35
|
}
|
|
23
36
|
toggleNode(node, event) {
|
|
24
37
|
event.stopPropagation();
|
|
@@ -39,7 +52,14 @@ const TttxTreeView = class {
|
|
|
39
52
|
});
|
|
40
53
|
}
|
|
41
54
|
}
|
|
42
|
-
|
|
55
|
+
updateSelected(node) {
|
|
56
|
+
let selected = false;
|
|
57
|
+
if (node.id === this.selectedId) {
|
|
58
|
+
selected = true;
|
|
59
|
+
}
|
|
60
|
+
return selected;
|
|
61
|
+
}
|
|
62
|
+
treeConfigs(node) {
|
|
43
63
|
let checkboxIcon, checkboxColor;
|
|
44
64
|
if (node.checked) {
|
|
45
65
|
checkboxIcon = 'check_box';
|
|
@@ -49,29 +69,36 @@ const TttxTreeView = class {
|
|
|
49
69
|
checkboxIcon = 'check_box_outline_blank';
|
|
50
70
|
checkboxColor = 'grey';
|
|
51
71
|
}
|
|
52
|
-
const rowHoverActive = node.
|
|
72
|
+
const rowHoverActive = node.hasHover ? 'rowHover' : '';
|
|
53
73
|
const expanderIcon = node.isOpen ? 'arrow_drop_down' : 'arrow_right';
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
74
|
+
const selectedActive = node.selectable && node.selected ? 'rowSelected' : '';
|
|
75
|
+
return { checkboxColor, checkboxIcon, rowHoverActive, expanderIcon, selectedActive };
|
|
76
|
+
}
|
|
77
|
+
renderNode(node) {
|
|
78
|
+
if (node.selectable)
|
|
79
|
+
node.selected = this.updateSelected(node);
|
|
80
|
+
const options = this.treeConfigs(node);
|
|
81
|
+
if (node.child) {
|
|
82
|
+
return (index.h("li", null, index.h("div", { class: `inline-tree-item element-row ${options.rowHoverActive} ${options.selectedActive}`, onClick: (event) => {
|
|
83
|
+
if (node.hasHover) {
|
|
57
84
|
event.stopPropagation();
|
|
58
85
|
this.onClickHandler('row', event, node);
|
|
59
86
|
}
|
|
60
|
-
} }, index.h("tttx-button", { class: "toggleNode", design: "borderless-circle", notext: true, icon: expanderIcon, color: "black", onClick: event => this.toggleNode(node, event) }), this.htmlcode('treeNode', node, checkboxIcon, checkboxColor)), node.isOpen ? (index.h("ul", null, index.h("div", { class: "child-node" }, node.child.map(childNode => {
|
|
87
|
+
} }, index.h("tttx-button", { class: "toggleNode", design: "borderless-circle", notext: true, icon: options.expanderIcon, color: "black", onClick: event => this.toggleNode(node, event) }), this.htmlcode('treeNode', node, options.checkboxIcon, options.checkboxColor)), node.isOpen ? (index.h("ul", null, index.h("div", { class: "child-node" }, node.child.map(childNode => {
|
|
61
88
|
return this.renderNode(childNode);
|
|
62
89
|
})))) : null));
|
|
63
90
|
}
|
|
64
91
|
else {
|
|
65
|
-
return (index.h("li", null, index.h("div", { class: `inline-tree-item element-row ${rowHoverActive}`, onClick: (event) => {
|
|
66
|
-
if (node.
|
|
92
|
+
return (index.h("li", null, index.h("div", { class: `inline-tree-item element-row ${options.rowHoverActive} ${options.selectedActive}`, onClick: (event) => {
|
|
93
|
+
if (node.hasHover) {
|
|
67
94
|
event.stopPropagation();
|
|
68
95
|
this.onClickHandler('row', event, node);
|
|
69
96
|
}
|
|
70
|
-
} }, this.htmlcode('treeLeaf', node, checkboxIcon, checkboxColor))));
|
|
97
|
+
} }, this.htmlcode('treeLeaf', node, options.checkboxIcon, options.checkboxColor))));
|
|
71
98
|
}
|
|
72
99
|
}
|
|
73
100
|
htmlcode(type, node, check_box, check_boxColor) {
|
|
74
|
-
const htmlcode = (index.h("div", { class:
|
|
101
|
+
const htmlcode = (index.h("div", { class: "inline-tree-item element" }, node.hasCheckbox && (index.h("tttx-button", { design: "borderless-circle", notext: true, icon: check_box, iconcolor: check_boxColor, class: "padding-icon checkbox", onClick: event => this.handleCheckboxChange(node, event) })), !node.html && node.hasIcon && index.h("tttx-icon", { icon: node.icon, color: node.iconColor, class: "padding-icon" }), !node.html && index.h("div", { class: type }, node.title), node.html && index.h("div", { class: type, innerHTML: domsanitiser_options.purify.sanitize(node.html, domsanitiser_options.domSanitiserOptions) }), (node.menuActive || node.chevronActive) && (index.h("div", { class: "right-buttons-container" }, node.menuActive && (index.h("tttx-button", { design: "borderless-circle", notext: true, icon: "more_vert", color: "black", class: "padding-icon menu-button", onClick: (event) => {
|
|
75
102
|
event.stopPropagation();
|
|
76
103
|
this.onClickHandler('menu', event, node);
|
|
77
104
|
} })), node.chevronActive && (index.h("tttx-icon", { icon: "chevron_right", color: "black", class: "padding-icon chevron-button", onClick: (event) => {
|
package/dist/cjs/tttx.cjs.js
CHANGED
|
@@ -17,7 +17,7 @@ const patchBrowser = () => {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
patchBrowser().then(options => {
|
|
20
|
-
return index.bootstrapLazy([["tttx-multiselect-box.cjs",[[1,"tttx-multiselect-box",{"optionsData":[1,"options-data"],"label":[1],"inline":[4],"placeholder":[1],"searchEnabled":[4,"search-enabled"],"htmlVisibleValue":[4,"html-visible-value"],"visibleValue":[1,"visible-value"],"open":[32],"unsavedSelectedItems":[32],"searchTerm":[32]},[[0,"closeSelectBox","handleCloseSelectBox"],[0,"blur","handleBlur"]]]]],["tttx-dialog-box.cjs",[[1,"tttx-dialog-box",{"data":[1025],"size":[1],"open":[1028],"allowOverflow":[4,"allow-overflow"],"elementSize":[32]},[[9,"resize","handleResize"]]]]],["tttx-select-box.cjs",[[1,"tttx-select-box",{"optionsData":[1,"options-data"],"label":[1],"inline":[4],"placeholder":[1],"searchEnabled":[4,"search-enabled"],"selectedValue":[1,"selected-value"],"open":[32],"selectedItem":[32],"searchTerm":[32]},[[0,"closeSelectBox","handleCloseSelectBox"],[0,"blur","handleBlur"]]]]],["tttx-tree-view.cjs",[[1,"tttx-tree-view",{"data":[1040],"treeData":[32]}]]],["tttx-filter.cjs",[[1,"tttx-filter",{"filterKey":[1,"filter-key"],"filterOptions":[1,"filter-options"],"showSelectAll":[4,"show-select-all"],"showSearchField":[4,"show-search-field"],"showOptionIcons":[4,"show-option-icons"],"filterButtonStyle":[1,"filter-button-style"],"filterHeader":[1,"filter-header"],"defaultFilterOptions":[1,"default-filter-options"],"popoverWidth":[1,"popover-width"],"showPopover":[32],"displayedFilterSettings":[32],"selectedFilters":[32],"filterSearchTerm":[32],"allSelected":[32]},[[0,"closeFilter","handleCloseFilter"]]]]],["tttx-list.cjs",[[1,"tttx-list",{"data":[1025],"name":[1],"_data":[32]}]]],["tttx-sorter.cjs",[[1,"tttx-sorter",{"sorterKey":[1,"sorter-key"],"defaultSortDirection":[1,"default-sort-direction"],"fieldOptionsData":[1,"field-options-data"],"defaultOption":[1,"default-option"],"selectedField":[32],"sortDirection":[32],"dropdownExpand":[32],"dropdownOptions":[32]},[[0,"closeSorter","handleCloseSorter"]]]]],["tttx-tabs.cjs",[[2,"tttx-tabs",{"tabsName":[1,"tabs-name"],"navigation":[4],"wide":[4],"tabs":[1],"_tabs":[32]},[[0,"keydown","handleKeyDown"]]]]],["tttx-form.cjs",[[1,"tttx-form",{"formschema":[1025],"data":[1032],"submit":[64]}]]],["tttx-keyvalue-block.cjs",[[1,"tttx-keyvalue-block",{"keyvalues":[1],"horizontal":[4],"spacedout":[4],"_elements":[32]}]]],["tttx-loading-spinner.cjs",[[1,"tttx-loading-spinner",{"loadingMessage":[1028,"loading-message"],"size":[1025]}]]],["tttx-qrcode.cjs",[[1,"tttx-qrcode",{"link":[1025],"size":[1026]}]]],["tttx-tag.cjs",[[1,"tttx-tag",{"text":[1],"color":[1]}]]],["tttx-textarea.cjs",[[2,"tttx-textarea",{"label":[1],"secondarylabel":[1],"showerrormsg":[4],"showerrorbubble":[4],"errormsg":[1],"rows":[2],"textareaautofocus":[4],"inputkeyhint":[1],"inputindex":[8],"inputtitle":[1],"disabled":[4],"maxlength":[8],"name":[1],"placeholder":[1],"readonly":[8],"required":[4],"value":[1032]}]]],["tttx-toolbar.cjs",[[1,"tttx-toolbar",{"border":[4],"viewSize":[32]},[[9,"resize","handleResize"]]]]],["tttx-icon.cjs",[[1,"tttx-icon",{"icon":[1],"color":[1]}]]],["tttx-standalone-input.cjs",[[2,"tttx-standalone-input",{"label":[1],"secondarylabel":[1],"showerrormsg":[4],"showerrorbubble":[4],"errormsg":[1],"iconleft":[1],"iconleftcolor":[1],"iconright":[1],"iconrightcolor":[1],"inputicon":[1],"inputiconcolor":[1],"inline":[4],"inputautocapitalize":[1],"inputautofocus":[4],"inputkeyhint":[1],"inputindex":[8],"inputtitle":[1],"autocomplete":[1],"checked":[4],"disabled":[4],"max":[8],"maxlength":[8],"min":[8],"minlength":[8],"name":[1],"pattern":[1],"placeholder":[1],"readonly":[8],"required":[4],"step":[8],"type":[1],"value":[1032]}]]],["tttx-button.cjs",[[1,"tttx-button",{"notext":[4],"icon":[1],"iconposition":[1],"iconcolor":[1025],"design":[1]}]]]], options);
|
|
20
|
+
return index.bootstrapLazy([["tttx-multiselect-box.cjs",[[1,"tttx-multiselect-box",{"optionsData":[1,"options-data"],"label":[1],"inline":[4],"placeholder":[1],"searchEnabled":[4,"search-enabled"],"htmlVisibleValue":[4,"html-visible-value"],"visibleValue":[1,"visible-value"],"open":[32],"unsavedSelectedItems":[32],"searchTerm":[32]},[[0,"closeSelectBox","handleCloseSelectBox"],[0,"blur","handleBlur"]]]]],["tttx-dialog-box.cjs",[[1,"tttx-dialog-box",{"data":[1025],"size":[1],"open":[1028],"allowOverflow":[4,"allow-overflow"],"elementSize":[32]},[[9,"resize","handleResize"]]]]],["tttx-select-box.cjs",[[1,"tttx-select-box",{"optionsData":[1,"options-data"],"label":[1],"inline":[4],"placeholder":[1],"searchEnabled":[4,"search-enabled"],"selectedValue":[1,"selected-value"],"open":[32],"selectedItem":[32],"searchTerm":[32]},[[0,"closeSelectBox","handleCloseSelectBox"],[0,"blur","handleBlur"]]]]],["tttx-tree-view.cjs",[[1,"tttx-tree-view",{"data":[1040],"treeData":[32],"selectedId":[32]}]]],["tttx-filter.cjs",[[1,"tttx-filter",{"filterKey":[1,"filter-key"],"filterOptions":[1,"filter-options"],"showSelectAll":[4,"show-select-all"],"showSearchField":[4,"show-search-field"],"showOptionIcons":[4,"show-option-icons"],"filterButtonStyle":[1,"filter-button-style"],"filterHeader":[1,"filter-header"],"defaultFilterOptions":[1,"default-filter-options"],"popoverWidth":[1,"popover-width"],"showPopover":[32],"displayedFilterSettings":[32],"selectedFilters":[32],"filterSearchTerm":[32],"allSelected":[32]},[[0,"closeFilter","handleCloseFilter"]]]]],["tttx-list.cjs",[[1,"tttx-list",{"data":[1025],"name":[1],"_data":[32]}]]],["tttx-sorter.cjs",[[1,"tttx-sorter",{"sorterKey":[1,"sorter-key"],"defaultSortDirection":[1,"default-sort-direction"],"fieldOptionsData":[1,"field-options-data"],"defaultOption":[1,"default-option"],"selectedField":[32],"sortDirection":[32],"dropdownExpand":[32],"dropdownOptions":[32]},[[0,"closeSorter","handleCloseSorter"]]]]],["tttx-tabs.cjs",[[2,"tttx-tabs",{"tabsName":[1,"tabs-name"],"navigation":[4],"wide":[4],"tabs":[1],"_tabs":[32]},[[0,"keydown","handleKeyDown"]]]]],["tttx-form.cjs",[[1,"tttx-form",{"formschema":[1025],"data":[1032],"submit":[64]}]]],["tttx-keyvalue-block.cjs",[[1,"tttx-keyvalue-block",{"keyvalues":[1],"horizontal":[4],"spacedout":[4],"_elements":[32]}]]],["tttx-loading-spinner.cjs",[[1,"tttx-loading-spinner",{"loadingMessage":[1028,"loading-message"],"size":[1025]}]]],["tttx-percentage-bar.cjs",[[2,"tttx-percentage-bar",{"percentage":[8],"thresholds":[1],"color":[1],"min":[1],"labelid":[1],"_percentage":[32],"_ranges":[32],"_min":[32]}]]],["tttx-qrcode.cjs",[[1,"tttx-qrcode",{"link":[1025],"size":[1026]}]]],["tttx-tag.cjs",[[1,"tttx-tag",{"text":[1],"color":[1]}]]],["tttx-textarea.cjs",[[2,"tttx-textarea",{"label":[1],"secondarylabel":[1],"showerrormsg":[4],"showerrorbubble":[4],"errormsg":[1],"rows":[2],"textareaautofocus":[4],"inputkeyhint":[1],"inputindex":[8],"inputtitle":[1],"disabled":[4],"maxlength":[8],"name":[1],"placeholder":[1],"readonly":[8],"required":[4],"value":[1032]}]]],["tttx-toolbar.cjs",[[1,"tttx-toolbar",{"border":[4],"viewSize":[32]},[[9,"resize","handleResize"]]]]],["tttx-icon.cjs",[[1,"tttx-icon",{"icon":[1],"color":[1]}]]],["tttx-standalone-input.cjs",[[2,"tttx-standalone-input",{"label":[1],"secondarylabel":[1],"showerrormsg":[4],"showerrorbubble":[4],"errormsg":[1],"iconleft":[1],"iconleftcolor":[1],"iconright":[1],"iconrightcolor":[1],"inputicon":[1],"inputiconcolor":[1],"inline":[4],"inputautocapitalize":[1],"inputautofocus":[4],"inputkeyhint":[1],"inputindex":[8],"inputtitle":[1],"autocomplete":[1],"checked":[4],"disabled":[4],"max":[8],"maxlength":[8],"min":[8],"minlength":[8],"name":[1],"pattern":[1],"placeholder":[1],"readonly":[8],"required":[4],"step":[8],"type":[1],"value":[1032]}]]],["tttx-button.cjs",[[1,"tttx-button",{"notext":[4],"icon":[1],"iconposition":[1],"iconcolor":[1025],"design":[1]}]]]], options);
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
exports.setNonce = index.setNonce;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"entries": [
|
|
3
3
|
"./components/molecules/tttx-filter/tttx-filter.js",
|
|
4
4
|
"./components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.js",
|
|
5
|
+
"./components/atoms/tttx-percentage-bar/tttx-percentage-bar.js",
|
|
5
6
|
"./components/molecules/tttx-standalone-input/tttx-standalone-input.js",
|
|
6
7
|
"./components/atoms/tttx-button/tttx-button.js",
|
|
7
8
|
"./components/atoms/tttx-icon/tttx-icon.js",
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { Host, h } from '@stencil/core';
|
|
2
|
+
export class TttxPercentageBar {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.percentage = undefined;
|
|
5
|
+
this.thresholds = undefined;
|
|
6
|
+
this.color = '#d5d5d5';
|
|
7
|
+
this.min = '1';
|
|
8
|
+
this.labelid = undefined;
|
|
9
|
+
this._percentage = undefined;
|
|
10
|
+
this._ranges = undefined;
|
|
11
|
+
this._min = undefined;
|
|
12
|
+
}
|
|
13
|
+
componentWillRender() {
|
|
14
|
+
if (typeof this.percentage === 'string') {
|
|
15
|
+
this._percentage = parseInt(this.percentage);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
this._percentage = this.percentage;
|
|
19
|
+
}
|
|
20
|
+
let thresholdsArray;
|
|
21
|
+
if (this.thresholds) {
|
|
22
|
+
if (typeof this.thresholds === 'string') {
|
|
23
|
+
thresholdsArray = JSON.parse(this.thresholds);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
thresholdsArray = this.thresholds;
|
|
27
|
+
}
|
|
28
|
+
this._ranges = [{ range: [0], color: thresholdsArray[0].color }];
|
|
29
|
+
for (const [i, thresholdsObj] of thresholdsArray.entries()) {
|
|
30
|
+
this._ranges[this._ranges.length - 1].range.push(thresholdsObj.threshold);
|
|
31
|
+
this._ranges[this._ranges.length - 1].color = thresholdsObj.color;
|
|
32
|
+
if (i < thresholdsArray.length - 1) {
|
|
33
|
+
this._ranges.push({ range: [thresholdsObj.threshold], color: undefined });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
this._min = parseInt(this.min);
|
|
38
|
+
}
|
|
39
|
+
getColour() {
|
|
40
|
+
if (!this._ranges || this._ranges.length === 0) {
|
|
41
|
+
return this.color;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
const range = this._ranges.find(r => this._percentage >= r.range[0] && this._percentage <= r.range[1]);
|
|
45
|
+
return range.color;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
getWidth() {
|
|
49
|
+
return Math.min(Math.max(this._percentage, Math.min(this._min, 100)), 100);
|
|
50
|
+
}
|
|
51
|
+
render() {
|
|
52
|
+
return (h(Host, null, h("div", { class: "progress" }, h("div", { class: "bar", style: { 'background-color': this.getColour(), 'width': `${this.getWidth()}%` }, role: "progressbar", "aria-valuemin": this._min, "aria-valuemax": "100", "aria-valuenow": this._percentage, "aria-labelledby": this.labelid }))));
|
|
53
|
+
}
|
|
54
|
+
static get is() { return "tttx-percentage-bar"; }
|
|
55
|
+
static get encapsulation() { return "scoped"; }
|
|
56
|
+
static get originalStyleUrls() {
|
|
57
|
+
return {
|
|
58
|
+
"$": ["tttx-percentage-bar.scss"]
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
static get styleUrls() {
|
|
62
|
+
return {
|
|
63
|
+
"$": ["tttx-percentage-bar.css"]
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
static get properties() {
|
|
67
|
+
return {
|
|
68
|
+
"percentage": {
|
|
69
|
+
"type": "any",
|
|
70
|
+
"mutable": false,
|
|
71
|
+
"complexType": {
|
|
72
|
+
"original": "string | number",
|
|
73
|
+
"resolved": "number | string",
|
|
74
|
+
"references": {}
|
|
75
|
+
},
|
|
76
|
+
"required": false,
|
|
77
|
+
"optional": false,
|
|
78
|
+
"docs": {
|
|
79
|
+
"tags": [],
|
|
80
|
+
"text": ""
|
|
81
|
+
},
|
|
82
|
+
"attribute": "percentage",
|
|
83
|
+
"reflect": false
|
|
84
|
+
},
|
|
85
|
+
"thresholds": {
|
|
86
|
+
"type": "string",
|
|
87
|
+
"mutable": false,
|
|
88
|
+
"complexType": {
|
|
89
|
+
"original": "string | Threshold[]",
|
|
90
|
+
"resolved": "Threshold[] | string",
|
|
91
|
+
"references": {
|
|
92
|
+
"Threshold": {
|
|
93
|
+
"location": "local"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"required": false,
|
|
98
|
+
"optional": true,
|
|
99
|
+
"docs": {
|
|
100
|
+
"tags": [],
|
|
101
|
+
"text": ""
|
|
102
|
+
},
|
|
103
|
+
"attribute": "thresholds",
|
|
104
|
+
"reflect": false
|
|
105
|
+
},
|
|
106
|
+
"color": {
|
|
107
|
+
"type": "string",
|
|
108
|
+
"mutable": false,
|
|
109
|
+
"complexType": {
|
|
110
|
+
"original": "string",
|
|
111
|
+
"resolved": "string",
|
|
112
|
+
"references": {}
|
|
113
|
+
},
|
|
114
|
+
"required": false,
|
|
115
|
+
"optional": true,
|
|
116
|
+
"docs": {
|
|
117
|
+
"tags": [],
|
|
118
|
+
"text": ""
|
|
119
|
+
},
|
|
120
|
+
"attribute": "color",
|
|
121
|
+
"reflect": false,
|
|
122
|
+
"defaultValue": "'#d5d5d5'"
|
|
123
|
+
},
|
|
124
|
+
"min": {
|
|
125
|
+
"type": "string",
|
|
126
|
+
"mutable": false,
|
|
127
|
+
"complexType": {
|
|
128
|
+
"original": "string",
|
|
129
|
+
"resolved": "string",
|
|
130
|
+
"references": {}
|
|
131
|
+
},
|
|
132
|
+
"required": false,
|
|
133
|
+
"optional": false,
|
|
134
|
+
"docs": {
|
|
135
|
+
"tags": [],
|
|
136
|
+
"text": ""
|
|
137
|
+
},
|
|
138
|
+
"attribute": "min",
|
|
139
|
+
"reflect": false,
|
|
140
|
+
"defaultValue": "'1'"
|
|
141
|
+
},
|
|
142
|
+
"labelid": {
|
|
143
|
+
"type": "string",
|
|
144
|
+
"mutable": false,
|
|
145
|
+
"complexType": {
|
|
146
|
+
"original": "string",
|
|
147
|
+
"resolved": "string",
|
|
148
|
+
"references": {}
|
|
149
|
+
},
|
|
150
|
+
"required": false,
|
|
151
|
+
"optional": true,
|
|
152
|
+
"docs": {
|
|
153
|
+
"tags": [],
|
|
154
|
+
"text": ""
|
|
155
|
+
},
|
|
156
|
+
"attribute": "labelid",
|
|
157
|
+
"reflect": false
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
static get states() {
|
|
162
|
+
return {
|
|
163
|
+
"_percentage": {},
|
|
164
|
+
"_ranges": {},
|
|
165
|
+
"_min": {}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
title: 'atoms/Percentage Bar',
|
|
3
|
+
component: 'tttx-percentage-bar',
|
|
4
|
+
};
|
|
5
|
+
const TemplatePercentageBar = ({ percentage, thresholds }) => `<tttx-percentage-bar percentage='${percentage}' thresholds='${JSON.stringify(thresholds)}'></tttx-percentage-bar>`;
|
|
6
|
+
export const PercentageBar = TemplatePercentageBar.bind({});
|
|
7
|
+
PercentageBar.args = {
|
|
8
|
+
percentage: 20,
|
|
9
|
+
thresholds: [
|
|
10
|
+
{
|
|
11
|
+
threshold: 50,
|
|
12
|
+
color: '#a20000',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
threshold: 75,
|
|
16
|
+
color: '#fdc500',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
threshold: 100,
|
|
20
|
+
color: '#397a4c',
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
const TemplatePercentageBarWithoutThresholds = ({ percentage, color }) => `<tttx-percentage-bar percentage='${percentage}' color='${color}'></tttx-percentage-bar>`;
|
|
25
|
+
export const PercentageBarWithoutThresholds = TemplatePercentageBarWithoutThresholds.bind({});
|
|
26
|
+
PercentageBarWithoutThresholds.args = {
|
|
27
|
+
percentage: 20,
|
|
28
|
+
color: '#397a4c',
|
|
29
|
+
};
|
|
30
|
+
const TemplatePercentageBarWithoutMinimum = ({ percentage, color, min }) => `<tttx-percentage-bar percentage='${percentage}' color='${color}' min='${min}'></tttx-percentage-bar>`;
|
|
31
|
+
export const PercentageBarWithoutMinimum = TemplatePercentageBarWithoutMinimum.bind({});
|
|
32
|
+
PercentageBarWithoutMinimum.args = {
|
|
33
|
+
percentage: 0,
|
|
34
|
+
color: '#397a4c',
|
|
35
|
+
min: 0,
|
|
36
|
+
};
|
|
37
|
+
const TemplatePercentageBarLabeled = ({ percentage, color, labelid }) => `
|
|
38
|
+
<label id="someLabel">
|
|
39
|
+
${percentage}%
|
|
40
|
+
<tttx-percentage-bar style='width: 100px;' percentage='${percentage}' color='${color}' labelid='${labelid}'></tttx-percentage-bar>
|
|
41
|
+
</label>
|
|
42
|
+
`;
|
|
43
|
+
export const PercentageBarLabeled = TemplatePercentageBarLabeled.bind({});
|
|
44
|
+
PercentageBarLabeled.args = {
|
|
45
|
+
percentage: 69,
|
|
46
|
+
color: '#397a4c',
|
|
47
|
+
labelid: 'someLabel',
|
|
48
|
+
};
|
|
49
|
+
const TemplatePercentageBarLabeledInline = ({ percentage, color, labelid }) => `
|
|
50
|
+
<label id="someLabel" style='display: flex;'>${percentage}% <tttx-percentage-bar style='width: 100px;' percentage='${percentage}' color='${color}' labelid='${labelid}'></tttx-percentage-bar>
|
|
51
|
+
</label>
|
|
52
|
+
`;
|
|
53
|
+
export const PercentageBarLabeledInline = TemplatePercentageBarLabeledInline.bind({});
|
|
54
|
+
PercentageBarLabeledInline.args = {
|
|
55
|
+
percentage: 69,
|
|
56
|
+
color: '#397a4c',
|
|
57
|
+
labelid: 'someLabel',
|
|
58
|
+
};
|
|
@@ -24,11 +24,27 @@
|
|
|
24
24
|
font-family: "Roboto", serif;
|
|
25
25
|
font-size: 16px;
|
|
26
26
|
padding: 8px 0px;
|
|
27
|
+
position: relative;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.element-row::before {
|
|
31
|
+
content: "";
|
|
32
|
+
position: absolute;
|
|
33
|
+
left: -50%;
|
|
34
|
+
right: -50%;
|
|
35
|
+
bottom: 0;
|
|
27
36
|
border-bottom: 1px solid #d5d5d5;
|
|
28
37
|
}
|
|
29
38
|
|
|
30
|
-
.
|
|
31
|
-
|
|
39
|
+
.element-row.rowSelected::before {
|
|
40
|
+
content: "";
|
|
41
|
+
position: absolute;
|
|
42
|
+
left: -50%;
|
|
43
|
+
right: -50%;
|
|
44
|
+
top: 0;
|
|
45
|
+
bottom: 0;
|
|
46
|
+
background-color: rgba(17, 17, 17, 0.1);
|
|
47
|
+
z-index: -1;
|
|
32
48
|
}
|
|
33
49
|
|
|
34
50
|
li {
|
|
@@ -66,7 +82,19 @@ li {
|
|
|
66
82
|
}
|
|
67
83
|
|
|
68
84
|
@media (hover: hover) {
|
|
69
|
-
.rowHover:hover {
|
|
85
|
+
.element-row.rowHover:hover {
|
|
86
|
+
cursor: pointer;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.element-row.rowHover:hover::before {
|
|
90
|
+
content: "";
|
|
91
|
+
position: absolute;
|
|
92
|
+
left: -50%;
|
|
93
|
+
right: -50%;
|
|
94
|
+
top: 0;
|
|
95
|
+
bottom: 0;
|
|
70
96
|
background-color: rgba(17, 17, 17, 0.05);
|
|
97
|
+
opacity: 0.5;
|
|
98
|
+
z-index: -1;
|
|
71
99
|
}
|
|
72
100
|
}
|
|
@@ -6,11 +6,24 @@ export class TttxTreeView {
|
|
|
6
6
|
constructor() {
|
|
7
7
|
this.data = undefined;
|
|
8
8
|
this.treeData = undefined;
|
|
9
|
+
this.selectedId = undefined;
|
|
9
10
|
}
|
|
10
11
|
onClickHandler(clickName, event, node) {
|
|
11
12
|
event.stopPropagation();
|
|
12
13
|
const returnJsonObject = JSON.stringify(node);
|
|
13
14
|
this.clickEvent.emit({ eventName: clickName, returnJsonObject });
|
|
15
|
+
if (clickName === 'row') {
|
|
16
|
+
this.selectedElement(event, node);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//for testing as SelectedId is a state
|
|
20
|
+
updateSelectedId(newId) {
|
|
21
|
+
this.selectedId = newId;
|
|
22
|
+
}
|
|
23
|
+
selectedElement(event, node) {
|
|
24
|
+
event.stopPropagation();
|
|
25
|
+
this.selectedId = node.id;
|
|
26
|
+
this.treeData = [...this.treeData];
|
|
14
27
|
}
|
|
15
28
|
toggleNode(node, event) {
|
|
16
29
|
event.stopPropagation();
|
|
@@ -31,7 +44,14 @@ export class TttxTreeView {
|
|
|
31
44
|
});
|
|
32
45
|
}
|
|
33
46
|
}
|
|
34
|
-
|
|
47
|
+
updateSelected(node) {
|
|
48
|
+
let selected = false;
|
|
49
|
+
if (node.id === this.selectedId) {
|
|
50
|
+
selected = true;
|
|
51
|
+
}
|
|
52
|
+
return selected;
|
|
53
|
+
}
|
|
54
|
+
treeConfigs(node) {
|
|
35
55
|
let checkboxIcon, checkboxColor;
|
|
36
56
|
if (node.checked) {
|
|
37
57
|
checkboxIcon = 'check_box';
|
|
@@ -41,29 +61,36 @@ export class TttxTreeView {
|
|
|
41
61
|
checkboxIcon = 'check_box_outline_blank';
|
|
42
62
|
checkboxColor = 'grey';
|
|
43
63
|
}
|
|
44
|
-
const rowHoverActive = node.
|
|
64
|
+
const rowHoverActive = node.hasHover ? 'rowHover' : '';
|
|
45
65
|
const expanderIcon = node.isOpen ? 'arrow_drop_down' : 'arrow_right';
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
66
|
+
const selectedActive = node.selectable && node.selected ? 'rowSelected' : '';
|
|
67
|
+
return { checkboxColor, checkboxIcon, rowHoverActive, expanderIcon, selectedActive };
|
|
68
|
+
}
|
|
69
|
+
renderNode(node) {
|
|
70
|
+
if (node.selectable)
|
|
71
|
+
node.selected = this.updateSelected(node);
|
|
72
|
+
const options = this.treeConfigs(node);
|
|
73
|
+
if (node.child) {
|
|
74
|
+
return (h("li", null, h("div", { class: `inline-tree-item element-row ${options.rowHoverActive} ${options.selectedActive}`, onClick: (event) => {
|
|
75
|
+
if (node.hasHover) {
|
|
49
76
|
event.stopPropagation();
|
|
50
77
|
this.onClickHandler('row', event, node);
|
|
51
78
|
}
|
|
52
|
-
} }, h("tttx-button", { class: "toggleNode", design: "borderless-circle", notext: true, icon: expanderIcon, color: "black", onClick: event => this.toggleNode(node, event) }), this.htmlcode('treeNode', node, checkboxIcon, checkboxColor)), node.isOpen ? (h("ul", null, h("div", { class: "child-node" }, node.child.map(childNode => {
|
|
79
|
+
} }, h("tttx-button", { class: "toggleNode", design: "borderless-circle", notext: true, icon: options.expanderIcon, color: "black", onClick: event => this.toggleNode(node, event) }), this.htmlcode('treeNode', node, options.checkboxIcon, options.checkboxColor)), node.isOpen ? (h("ul", null, h("div", { class: "child-node" }, node.child.map(childNode => {
|
|
53
80
|
return this.renderNode(childNode);
|
|
54
81
|
})))) : null));
|
|
55
82
|
}
|
|
56
83
|
else {
|
|
57
|
-
return (h("li", null, h("div", { class: `inline-tree-item element-row ${rowHoverActive}`, onClick: (event) => {
|
|
58
|
-
if (node.
|
|
84
|
+
return (h("li", null, h("div", { class: `inline-tree-item element-row ${options.rowHoverActive} ${options.selectedActive}`, onClick: (event) => {
|
|
85
|
+
if (node.hasHover) {
|
|
59
86
|
event.stopPropagation();
|
|
60
87
|
this.onClickHandler('row', event, node);
|
|
61
88
|
}
|
|
62
|
-
} }, this.htmlcode('treeLeaf', node, checkboxIcon, checkboxColor))));
|
|
89
|
+
} }, this.htmlcode('treeLeaf', node, options.checkboxIcon, options.checkboxColor))));
|
|
63
90
|
}
|
|
64
91
|
}
|
|
65
92
|
htmlcode(type, node, check_box, check_boxColor) {
|
|
66
|
-
const htmlcode = (h("div", { class:
|
|
93
|
+
const htmlcode = (h("div", { class: "inline-tree-item element" }, node.hasCheckbox && (h("tttx-button", { design: "borderless-circle", notext: true, icon: check_box, iconcolor: check_boxColor, class: "padding-icon checkbox", onClick: event => this.handleCheckboxChange(node, event) })), !node.html && node.hasIcon && h("tttx-icon", { icon: node.icon, color: node.iconColor, class: "padding-icon" }), !node.html && h("div", { class: type }, node.title), node.html && h("div", { class: type, innerHTML: DOMPurify.sanitize(node.html, domSanitiserOptions) }), (node.menuActive || node.chevronActive) && (h("div", { class: "right-buttons-container" }, node.menuActive && (h("tttx-button", { design: "borderless-circle", notext: true, icon: "more_vert", color: "black", class: "padding-icon menu-button", onClick: (event) => {
|
|
67
94
|
event.stopPropagation();
|
|
68
95
|
this.onClickHandler('menu', event, node);
|
|
69
96
|
} })), node.chevronActive && (h("tttx-icon", { icon: "chevron_right", color: "black", class: "padding-icon chevron-button", onClick: (event) => {
|
|
@@ -116,7 +143,8 @@ export class TttxTreeView {
|
|
|
116
143
|
}
|
|
117
144
|
static get states() {
|
|
118
145
|
return {
|
|
119
|
-
"treeData": {}
|
|
146
|
+
"treeData": {},
|
|
147
|
+
"selectedId": {}
|
|
120
148
|
};
|
|
121
149
|
}
|
|
122
150
|
static get events() {
|