@gitlab/ui 115.11.0 → 117.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/base/filtered_search/filtered_search_suggestion.js +11 -5
- package/dist/components/dashboards/dashboard_layout/grid_layout/grid_layout.js +2 -2
- package/dist/components/dashboards/dashboard_panel/dashboard_panel.js +45 -3
- package/dist/components/index.js +1 -4
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/tailwind.css +1 -1
- package/dist/tailwind.css.map +1 -1
- package/dist/tokens/common_story_options.js +1 -6
- package/dist/tokens/tokens_story.js +3 -16
- package/package.json +5 -5
- package/src/components/base/filtered_search/filtered_search_suggestion.vue +32 -14
- package/src/components/dashboards/dashboard_layout/grid_layout/grid_layout.vue +2 -2
- package/src/components/dashboards/dashboard_panel/dashboard_panel.md +61 -13
- package/src/components/dashboards/dashboard_panel/dashboard_panel.vue +46 -3
- package/src/components/index.js +1 -4
- package/src/scss/components.scss +0 -1
- package/src/tokens/common_story_options.js +1 -9
- package/src/tokens/tokens_story.vue +2 -22
- package/dist/components/base/form/form_checkbox_tree/checkbox_tree_node.js +0 -79
- package/dist/components/base/form/form_checkbox_tree/form_checkbox_tree.js +0 -138
- package/dist/components/base/form/form_checkbox_tree/models/constants.js +0 -12
- package/dist/components/base/form/form_checkbox_tree/models/node.js +0 -51
- package/dist/components/base/form/form_checkbox_tree/models/tree.js +0 -200
- package/dist/components/base/nav/nav.js +0 -132
- package/dist/components/base/nav/nav_item.js +0 -125
- package/src/components/base/form/form.md +0 -2
- package/src/components/base/form/form_character_count/form_character_count.md +0 -53
- package/src/components/base/form/form_checkbox_tree/checkbox_tree_node.vue +0 -58
- package/src/components/base/form/form_checkbox_tree/form_checkbox_tree.md +0 -73
- package/src/components/base/form/form_checkbox_tree/form_checkbox_tree.vue +0 -116
- package/src/components/base/form/form_checkbox_tree/models/constants.js +0 -12
- package/src/components/base/form/form_checkbox_tree/models/node.js +0 -48
- package/src/components/base/form/form_checkbox_tree/models/tree.js +0 -186
- package/src/components/base/form/form_combobox/form_combobox.md +0 -52
- package/src/components/base/form/form_date/form_date.md +0 -26
- package/src/components/base/form/form_fields/form_fields.md +0 -41
- package/src/components/base/form/form_group/form_group.md +0 -1
- package/src/components/base/form/form_input_group/form_input_group.md +0 -67
- package/src/components/base/form/input_group_text/input_group_text.md +0 -1
- package/src/components/base/nav/nav.md +0 -184
- package/src/components/base/nav/nav.scss +0 -7
- package/src/components/base/nav/nav.vue +0 -70
- package/src/components/base/nav/nav_item.vue +0 -109
- package/src/components/base/token_selector/token_selector.md +0 -78
- package/src/components/charts/bar/bar.md +0 -3
- package/src/components/charts/chart/chart.md +0 -19
- package/src/components/charts/gauge/gauge.md +0 -8
- package/src/components/charts/heatmap/heatmap.md +0 -7
- package/src/components/charts/legend/legend.md +0 -16
- package/src/components/charts/line/line.md +0 -7
- package/src/components/charts/series_label/series_label.md +0 -1
- package/src/components/charts/shared/tooltip/tooltip.md +0 -3
- package/src/components/charts/single_stat/single_stat.md +0 -8
- package/src/components/charts/sparkline/sparkline.md +0 -8
- package/src/components/charts/stacked_column/stacked_column.md +0 -10
- package/src/components/regions/empty_state/empty_state.md +0 -4
- package/src/components/utilities/animated_number/animated_number.md +0 -6
- package/src/components/utilities/friendly_wrap/friendly_wrap.md +0 -66
- package/src/components/utilities/intersection_observer/intersection_observer.md +0 -16
- package/src/components/utilities/intersperse/intersperse.md +0 -90
- package/src/components/utilities/sprintf/sprintf.md +0 -243
- package/src/components/utilities/truncate/truncate.md +0 -14
- package/src/components/utilities/truncate_text/truncate_text.md +0 -26
- package/src/directives/hover_load/hover_load.md +0 -22
- package/src/directives/outside/outside.md +0 -140
- package/src/directives/resize_observer/resize_observer.md +0 -54
- package/src/directives/safe_html/safe_html.md +0 -58
- package/src/directives/safe_link/safe_link.md +0 -37
- package/src/internal/color_contrast/color_contrast.md +0 -8
- package/src/internal/color_contrast/color_contrast.vue +0 -52
|
@@ -2,18 +2,16 @@
|
|
|
2
2
|
import { colorFromBackground } from '../utils/utils';
|
|
3
3
|
import { GlTooltipDirective } from '../directives/tooltip/tooltip';
|
|
4
4
|
import GlBadge from '../components/base/badge/badge.vue';
|
|
5
|
-
import GlColorContrast from '../internal/color_contrast/color_contrast.vue';
|
|
6
5
|
|
|
7
6
|
export default {
|
|
8
7
|
name: 'TokensStory',
|
|
9
8
|
components: {
|
|
10
9
|
GlBadge,
|
|
11
|
-
GlColorContrast,
|
|
12
10
|
},
|
|
13
11
|
directives: {
|
|
14
12
|
GlTooltip: GlTooltipDirective,
|
|
15
13
|
},
|
|
16
|
-
inject: ['
|
|
14
|
+
inject: ['containerClass'],
|
|
17
15
|
props: {
|
|
18
16
|
tokens: {
|
|
19
17
|
type: Object,
|
|
@@ -30,7 +28,6 @@ export default {
|
|
|
30
28
|
},
|
|
31
29
|
getClasses(value) {
|
|
32
30
|
if (!this.isHex(value)) return '';
|
|
33
|
-
if (!this.isBackgroundColorStory) return '';
|
|
34
31
|
|
|
35
32
|
const textColorVariant = colorFromBackground(value, 4.5);
|
|
36
33
|
return {
|
|
@@ -38,13 +35,6 @@ export default {
|
|
|
38
35
|
'gl-text-neutral-0': textColorVariant === 'light',
|
|
39
36
|
};
|
|
40
37
|
},
|
|
41
|
-
getStyle(value) {
|
|
42
|
-
if (this.isBackgroundColorStory) {
|
|
43
|
-
return { backgroundColor: value };
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return { color: value };
|
|
47
|
-
},
|
|
48
38
|
},
|
|
49
39
|
};
|
|
50
40
|
</script>
|
|
@@ -57,7 +47,7 @@ export default {
|
|
|
57
47
|
:key="token.name"
|
|
58
48
|
class="gl-flex gl-flex-wrap gl-items-center gl-justify-between gl-gap-3 gl-p-3"
|
|
59
49
|
:class="getClasses(token.$value)"
|
|
60
|
-
:style="
|
|
50
|
+
:style="{ backgroundColor: token.$value }"
|
|
61
51
|
>
|
|
62
52
|
<code v-gl-tooltip :title="token.comment" class="gl-text-inherit">
|
|
63
53
|
{{ getTokenName(token) }}
|
|
@@ -67,16 +57,6 @@ export default {
|
|
|
67
57
|
Deprecated
|
|
68
58
|
</gl-badge>
|
|
69
59
|
<code class="gl-text-inherit">{{ token.$value }}</code>
|
|
70
|
-
<gl-color-contrast
|
|
71
|
-
v-if="isHex(token.$value)"
|
|
72
|
-
:foreground="token.$value"
|
|
73
|
-
:background="darkBackground"
|
|
74
|
-
/>
|
|
75
|
-
<gl-color-contrast
|
|
76
|
-
v-if="isHex(token.$value)"
|
|
77
|
-
:foreground="token.$value"
|
|
78
|
-
:background="lightBackground"
|
|
79
|
-
/>
|
|
80
60
|
</div>
|
|
81
61
|
</li>
|
|
82
62
|
</ul>
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import GlFormCheckbox from '../form_checkbox/form_checkbox';
|
|
2
|
-
import { QA_PREFIX } from './models/constants';
|
|
3
|
-
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
4
|
-
|
|
5
|
-
var script = {
|
|
6
|
-
name: 'GlFormCheckboxTreeNode',
|
|
7
|
-
qaPrefix: QA_PREFIX,
|
|
8
|
-
components: {
|
|
9
|
-
GlFormCheckbox
|
|
10
|
-
},
|
|
11
|
-
inject: ['tree'],
|
|
12
|
-
props: {
|
|
13
|
-
option: {
|
|
14
|
-
type: Object,
|
|
15
|
-
required: true
|
|
16
|
-
},
|
|
17
|
-
isNested: {
|
|
18
|
-
type: Boolean,
|
|
19
|
-
required: false,
|
|
20
|
-
default: false
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
computed: {
|
|
24
|
-
node() {
|
|
25
|
-
return this.tree.getNode(this.option.value);
|
|
26
|
-
},
|
|
27
|
-
label() {
|
|
28
|
-
return this.node.label || this.node.value;
|
|
29
|
-
},
|
|
30
|
-
rootClass() {
|
|
31
|
-
return this.isNested ? 'gl-ml-6' : null;
|
|
32
|
-
},
|
|
33
|
-
checkboxClass() {
|
|
34
|
-
const {
|
|
35
|
-
isChecked,
|
|
36
|
-
isIndeterminate
|
|
37
|
-
} = this.node;
|
|
38
|
-
return [isChecked && 'js-is-checked', isIndeterminate && 'js-is-indeterminate'];
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
/* script */
|
|
44
|
-
const __vue_script__ = script;
|
|
45
|
-
|
|
46
|
-
/* template */
|
|
47
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{class:_vm.rootClass,attrs:{"data-testid":("" + (_vm.$options.qaPrefix) + (_vm.option.value))}},[_c('gl-form-checkbox',{class:_vm.checkboxClass,attrs:{"checked":_vm.node.isChecked,"indeterminate":_vm.node.isIndeterminate},on:{"change":function($event){return _vm.tree.toggleOption(_vm.option, $event)}}},[_vm._v("\n "+_vm._s(_vm.label)+"\n ")]),_vm._v(" "),_vm._l((_vm.option.children),function(child){return _c('gl-form-checkbox-tree-node',{key:child.value,attrs:{"option":child,"is-nested":""}})})],2)};
|
|
48
|
-
var __vue_staticRenderFns__ = [];
|
|
49
|
-
|
|
50
|
-
/* style */
|
|
51
|
-
const __vue_inject_styles__ = undefined;
|
|
52
|
-
/* scoped */
|
|
53
|
-
const __vue_scope_id__ = undefined;
|
|
54
|
-
/* module identifier */
|
|
55
|
-
const __vue_module_identifier__ = undefined;
|
|
56
|
-
/* functional template */
|
|
57
|
-
const __vue_is_functional_template__ = false;
|
|
58
|
-
/* style inject */
|
|
59
|
-
|
|
60
|
-
/* style inject SSR */
|
|
61
|
-
|
|
62
|
-
/* style inject shadow dom */
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const __vue_component__ = /*#__PURE__*/__vue_normalize__(
|
|
67
|
-
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
68
|
-
__vue_inject_styles__,
|
|
69
|
-
__vue_script__,
|
|
70
|
-
__vue_scope_id__,
|
|
71
|
-
__vue_is_functional_template__,
|
|
72
|
-
__vue_module_identifier__,
|
|
73
|
-
false,
|
|
74
|
-
undefined,
|
|
75
|
-
undefined,
|
|
76
|
-
undefined
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
export { __vue_component__ as default };
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import GlFormCheckbox from '../form_checkbox/form_checkbox';
|
|
2
|
-
import GlFormGroup from '../form_group/form_group';
|
|
3
|
-
import GlFormCheckboxTreeNode from './checkbox_tree_node';
|
|
4
|
-
import { V_MODEL } from './models/constants';
|
|
5
|
-
import { Tree } from './models/tree';
|
|
6
|
-
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
7
|
-
|
|
8
|
-
var script = {
|
|
9
|
-
name: 'GlFormCheckboxTree',
|
|
10
|
-
components: {
|
|
11
|
-
GlFormGroup,
|
|
12
|
-
GlFormCheckbox,
|
|
13
|
-
GlFormCheckboxTreeNode
|
|
14
|
-
},
|
|
15
|
-
provide() {
|
|
16
|
-
return {
|
|
17
|
-
tree: this.tree
|
|
18
|
-
};
|
|
19
|
-
},
|
|
20
|
-
model: {
|
|
21
|
-
prop: V_MODEL.PROP,
|
|
22
|
-
event: V_MODEL.EVENT
|
|
23
|
-
},
|
|
24
|
-
props: {
|
|
25
|
-
/**
|
|
26
|
-
* Options tree where each option is in the form:
|
|
27
|
-
* {
|
|
28
|
-
* value: String|Number,
|
|
29
|
-
* label: String,
|
|
30
|
-
* children: Array,
|
|
31
|
-
* }
|
|
32
|
-
*/
|
|
33
|
-
options: {
|
|
34
|
-
type: Array,
|
|
35
|
-
required: true
|
|
36
|
-
},
|
|
37
|
-
/**
|
|
38
|
-
* The selected options as an array of values
|
|
39
|
-
*/
|
|
40
|
-
value: {
|
|
41
|
-
type: Array,
|
|
42
|
-
required: false,
|
|
43
|
-
default: () => []
|
|
44
|
-
},
|
|
45
|
-
/**
|
|
46
|
-
* Set to true to hide the "Select/unselect all" checkbox
|
|
47
|
-
*/
|
|
48
|
-
hideToggleAll: {
|
|
49
|
-
type: Boolean,
|
|
50
|
-
required: false,
|
|
51
|
-
default: false
|
|
52
|
-
},
|
|
53
|
-
/**
|
|
54
|
-
* Label for the toggle all checkbox when some or all options are unchecked
|
|
55
|
-
*/
|
|
56
|
-
selectAllLabel: {
|
|
57
|
-
type: String,
|
|
58
|
-
required: false,
|
|
59
|
-
default: 'Select all'
|
|
60
|
-
},
|
|
61
|
-
/**
|
|
62
|
-
* Label for the toggle all checkbox when all options are checked
|
|
63
|
-
*/
|
|
64
|
-
unselectAllLabel: {
|
|
65
|
-
type: String,
|
|
66
|
-
required: false,
|
|
67
|
-
default: 'Unselect all'
|
|
68
|
-
},
|
|
69
|
-
label: {
|
|
70
|
-
type: String,
|
|
71
|
-
required: false,
|
|
72
|
-
default: 'Checkbox tree'
|
|
73
|
-
},
|
|
74
|
-
labelSrOnly: {
|
|
75
|
-
type: Boolean,
|
|
76
|
-
required: false,
|
|
77
|
-
default: true
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
data() {
|
|
81
|
-
return {
|
|
82
|
-
tree: new Tree(this.options, this.value)
|
|
83
|
-
};
|
|
84
|
-
},
|
|
85
|
-
computed: {
|
|
86
|
-
toggleAllLabel() {
|
|
87
|
-
return this.tree.allOptionsChecked ? this.unselectAllLabel : this.selectAllLabel;
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
watch: {
|
|
91
|
-
'tree.selected': {
|
|
92
|
-
handler(selected) {
|
|
93
|
-
/**
|
|
94
|
-
* Emitted when the selection changes.
|
|
95
|
-
*/
|
|
96
|
-
this.$emit(V_MODEL.EVENT, selected);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
/* script */
|
|
103
|
-
const __vue_script__ = script;
|
|
104
|
-
|
|
105
|
-
/* template */
|
|
106
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-form-group',{attrs:{"label":_vm.label,"label-sr-only":_vm.labelSrOnly}},[(!_vm.hideToggleAll)?_c('gl-form-checkbox',{staticClass:"gl-form-checkbox-tree-toggle-all",attrs:{"checked":_vm.tree.allOptionsChecked,"indeterminate":_vm.tree.someOptionsChecked},on:{"change":function($event){return _vm.tree.toggleAllOptions($event)}}},[_vm._v("\n "+_vm._s(_vm.toggleAllLabel)+"\n ")]):_vm._e(),_vm._v(" "),_vm._l((_vm.options),function(option){return _c('gl-form-checkbox-tree-node',{key:option.value,attrs:{"option":option}})})],2)};
|
|
107
|
-
var __vue_staticRenderFns__ = [];
|
|
108
|
-
|
|
109
|
-
/* style */
|
|
110
|
-
const __vue_inject_styles__ = undefined;
|
|
111
|
-
/* scoped */
|
|
112
|
-
const __vue_scope_id__ = undefined;
|
|
113
|
-
/* module identifier */
|
|
114
|
-
const __vue_module_identifier__ = undefined;
|
|
115
|
-
/* functional template */
|
|
116
|
-
const __vue_is_functional_template__ = false;
|
|
117
|
-
/* style inject */
|
|
118
|
-
|
|
119
|
-
/* style inject SSR */
|
|
120
|
-
|
|
121
|
-
/* style inject shadow dom */
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const __vue_component__ = /*#__PURE__*/__vue_normalize__(
|
|
126
|
-
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
127
|
-
__vue_inject_styles__,
|
|
128
|
-
__vue_script__,
|
|
129
|
-
__vue_scope_id__,
|
|
130
|
-
__vue_is_functional_template__,
|
|
131
|
-
__vue_module_identifier__,
|
|
132
|
-
false,
|
|
133
|
-
undefined,
|
|
134
|
-
undefined,
|
|
135
|
-
undefined
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
export { __vue_component__ as default };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { CHECKED_STATE } from './constants';
|
|
2
|
-
|
|
3
|
-
class Node {
|
|
4
|
-
constructor(_ref) {
|
|
5
|
-
let {
|
|
6
|
-
value,
|
|
7
|
-
label,
|
|
8
|
-
parent = null,
|
|
9
|
-
children = [],
|
|
10
|
-
depth,
|
|
11
|
-
isChecked
|
|
12
|
-
} = _ref;
|
|
13
|
-
this.value = value;
|
|
14
|
-
this.label = label;
|
|
15
|
-
this.parent = parent;
|
|
16
|
-
this.children = children;
|
|
17
|
-
this.depth = depth;
|
|
18
|
-
this.checkedState = isChecked ? CHECKED_STATE.CHECKED : CHECKED_STATE.UNCHECKED;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Sets the node's checked state
|
|
23
|
-
* @param {number} checkedState
|
|
24
|
-
*/
|
|
25
|
-
setCheckedState(checkedState) {
|
|
26
|
-
this.checkedState = checkedState;
|
|
27
|
-
}
|
|
28
|
-
get isChild() {
|
|
29
|
-
return this.parent !== null;
|
|
30
|
-
}
|
|
31
|
-
get isParent() {
|
|
32
|
-
return this.children.length > 0;
|
|
33
|
-
}
|
|
34
|
-
get isLeaf() {
|
|
35
|
-
return !this.isParent;
|
|
36
|
-
}
|
|
37
|
-
get isUnchecked() {
|
|
38
|
-
return this.checkedState === CHECKED_STATE.UNCHECKED;
|
|
39
|
-
}
|
|
40
|
-
get isIndeterminate() {
|
|
41
|
-
return this.checkedState === CHECKED_STATE.INDETERMINATE;
|
|
42
|
-
}
|
|
43
|
-
get isChecked() {
|
|
44
|
-
return this.checkedState === CHECKED_STATE.CHECKED;
|
|
45
|
-
}
|
|
46
|
-
get isCheckedOrIndeterminate() {
|
|
47
|
-
return this.isChecked || this.isIndeterminate;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export { Node };
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { CHECKED_STATE } from './constants';
|
|
2
|
-
import { Node } from './node';
|
|
3
|
-
|
|
4
|
-
class Tree {
|
|
5
|
-
constructor(options, selected) {
|
|
6
|
-
this.treeDepth = 0;
|
|
7
|
-
this.nodes = {};
|
|
8
|
-
this.initNodes(options, selected);
|
|
9
|
-
this.initIndeterminateStates();
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @returns {[Node]} The tree as an array of Node instances
|
|
14
|
-
*/
|
|
15
|
-
get nodesList() {
|
|
16
|
-
return Object.values(this.nodes);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @returns {array} The values currently selected
|
|
21
|
-
*/
|
|
22
|
-
get selected() {
|
|
23
|
-
return this.nodesList.filter(node => node.isChecked).map(node => node.value);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @returns {boolean} Whether all options are checked
|
|
28
|
-
*/
|
|
29
|
-
get allOptionsChecked() {
|
|
30
|
-
return this.selected.length === this.nodesList.length;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @returns {boolean} Whether some, but not all options are checked
|
|
35
|
-
*/
|
|
36
|
-
get someOptionsChecked() {
|
|
37
|
-
return this.selected.length > 0 && !this.allOptionsChecked;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Creates a flat tree of Node instances.
|
|
42
|
-
* @param {array} options The options list
|
|
43
|
-
* @param {array} selected Pre-selected option values
|
|
44
|
-
* @param {object} parent The options' parent
|
|
45
|
-
* @param {number} depth The current depth-level in the tree
|
|
46
|
-
*/
|
|
47
|
-
// eslint-disable-next-line max-params
|
|
48
|
-
initNodes() {
|
|
49
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
50
|
-
let selected = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
51
|
-
let parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
52
|
-
let depth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
53
|
-
if (!options.length) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
this.treeDepth = depth > this.treeDepth ? depth : this.treeDepth;
|
|
57
|
-
options.forEach(option => {
|
|
58
|
-
const isChecked = selected.includes(option.value);
|
|
59
|
-
this.nodes[option.value] = new Node({
|
|
60
|
-
...option,
|
|
61
|
-
parent,
|
|
62
|
-
isChecked,
|
|
63
|
-
depth
|
|
64
|
-
});
|
|
65
|
-
this.initNodes(option.children, selected, option, depth + 1);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Looks for UNCHECKED nodes and sets their checked state to INDETERMINATE if needed. We start
|
|
71
|
-
* with the deepest leaves and we go up level by level to propagate the correct INDETERMINATE
|
|
72
|
-
* states to each parent node.
|
|
73
|
-
*/
|
|
74
|
-
initIndeterminateStates() {
|
|
75
|
-
const nodes = [...this.nodesList];
|
|
76
|
-
for (let i = this.treeDepth; i >= 0; i -= 1) {
|
|
77
|
-
const removeIndices = [];
|
|
78
|
-
nodes.forEach((node, nodeIndex) => {
|
|
79
|
-
if (node.depth === i && node.isUnchecked) {
|
|
80
|
-
node.setCheckedState(this.optionHasSomeChildrenChecked(node) ? CHECKED_STATE.INDETERMINATE : node.checkedState);
|
|
81
|
-
removeIndices.push(nodeIndex);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
removeIndices.reverse().forEach(index => {
|
|
85
|
-
nodes.splice(index, 1);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Returns true if all of the option's children are checked, false otherwise.
|
|
92
|
-
* @param {object} option
|
|
93
|
-
* @returns {boolean}
|
|
94
|
-
*/
|
|
95
|
-
optionHasAllChildrenChecked(option) {
|
|
96
|
-
return this.getOptionChildren(option).every(child => child.isChecked);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Returns true if at least one of the option's children is in a checked or indeterminate state,
|
|
101
|
-
* returns false otherwise.
|
|
102
|
-
* We consider the INDETERMINATE state as a checked state so we can propagate INDETERMINATE states
|
|
103
|
-
* to the option's parents.
|
|
104
|
-
* @param {object} option
|
|
105
|
-
* @returns {boolean}
|
|
106
|
-
*/
|
|
107
|
-
optionHasSomeChildrenChecked(option) {
|
|
108
|
-
return this.getOptionChildren(option).some(child => child.isCheckedOrIndeterminate);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Returns the Node instance for a given option's value.
|
|
113
|
-
* @param {number|string} value The option's value
|
|
114
|
-
* @returns {Node}
|
|
115
|
-
*/
|
|
116
|
-
getNode(value) {
|
|
117
|
-
return this.nodes[value];
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Returns the option's children as Node instances.
|
|
122
|
-
* @param {object} option
|
|
123
|
-
* @returns {[Node]}
|
|
124
|
-
*/
|
|
125
|
-
getOptionChildren(option) {
|
|
126
|
-
return option.children.map(_ref => {
|
|
127
|
-
let {
|
|
128
|
-
value
|
|
129
|
-
} = _ref;
|
|
130
|
-
return this.getNode(value);
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Sets a node's state based on whether it got checked or unchecked
|
|
136
|
-
* @param {Node} node The node to be toggled
|
|
137
|
-
* @param {boolean} checked Whether the node should be checked
|
|
138
|
-
*/
|
|
139
|
-
static toggleNodeState(node, checked) {
|
|
140
|
-
node.setCheckedState(checked ? CHECKED_STATE.CHECKED : CHECKED_STATE.UNCHECKED);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Toggles all options.
|
|
145
|
-
* @param {boolean} checked Whether the options should be checked or unchecked
|
|
146
|
-
*/
|
|
147
|
-
toggleAllOptions(checked) {
|
|
148
|
-
this.nodesList.forEach(node => {
|
|
149
|
-
Tree.toggleNodeState(node, checked);
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Toggles an option's checked state and propagates the state change to the
|
|
155
|
-
* option's parents and children.
|
|
156
|
-
* @param {object} param0 The option to be toggled
|
|
157
|
-
* @param {boolean} checked Whether the option is checked
|
|
158
|
-
* @param {boolean} propagateToParent Whether the state should be propagated to the parents
|
|
159
|
-
*/
|
|
160
|
-
toggleOption(_ref2, checked) {
|
|
161
|
-
let {
|
|
162
|
-
value
|
|
163
|
-
} = _ref2;
|
|
164
|
-
let propagateToParent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
165
|
-
const node = this.getNode(value);
|
|
166
|
-
Tree.toggleNodeState(node, checked);
|
|
167
|
-
if (node.isChild && propagateToParent) {
|
|
168
|
-
this.toggleParentOption(node.parent);
|
|
169
|
-
}
|
|
170
|
-
if (node.isParent) {
|
|
171
|
-
node.children.forEach(child => this.toggleOption(child, checked, false));
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Toggles a parent option's checked state. This is called as a result of a child option being
|
|
177
|
-
* toggled by the user and the change being propagated to that option's parents. This method
|
|
178
|
-
* recursively propagates the state changes to all the ancestors chain until we have reached the
|
|
179
|
-
* tree's trunk.
|
|
180
|
-
* @param {object} param0 The option to be toggled
|
|
181
|
-
*/
|
|
182
|
-
toggleParentOption(_ref3) {
|
|
183
|
-
let {
|
|
184
|
-
value
|
|
185
|
-
} = _ref3;
|
|
186
|
-
const node = this.getNode(value);
|
|
187
|
-
if (this.optionHasAllChildrenChecked(node)) {
|
|
188
|
-
node.checkedState = CHECKED_STATE.CHECKED;
|
|
189
|
-
} else if (this.optionHasSomeChildrenChecked(node)) {
|
|
190
|
-
node.checkedState = CHECKED_STATE.INDETERMINATE;
|
|
191
|
-
} else {
|
|
192
|
-
node.checkedState = CHECKED_STATE.UNCHECKED;
|
|
193
|
-
}
|
|
194
|
-
if (node.isChild) {
|
|
195
|
-
this.toggleParentOption(node.parent);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export { Tree };
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
2
|
-
|
|
3
|
-
var script = {
|
|
4
|
-
name: 'GlNav',
|
|
5
|
-
props: {
|
|
6
|
-
/**
|
|
7
|
-
* Align the nav items in the nav: 'start' (or 'left'), 'center', 'end' (or 'right')
|
|
8
|
-
*/
|
|
9
|
-
align: {
|
|
10
|
-
type: String,
|
|
11
|
-
required: false,
|
|
12
|
-
default: ''
|
|
13
|
-
},
|
|
14
|
-
/**
|
|
15
|
-
* Set this prop when the nav is placed inside a card header
|
|
16
|
-
*/
|
|
17
|
-
cardHeader: {
|
|
18
|
-
type: Boolean,
|
|
19
|
-
required: false,
|
|
20
|
-
default: false
|
|
21
|
-
},
|
|
22
|
-
/**
|
|
23
|
-
* Proportionately fills all horizontal space with nav items.
|
|
24
|
-
* All horizontal space is occupied, but not every nav item has the same width
|
|
25
|
-
*/
|
|
26
|
-
fill: {
|
|
27
|
-
type: Boolean,
|
|
28
|
-
required: false,
|
|
29
|
-
default: false
|
|
30
|
-
},
|
|
31
|
-
/**
|
|
32
|
-
* Fills all horizontal space with nav items, but unlike 'fill', every nav item will be the same width
|
|
33
|
-
*/
|
|
34
|
-
justified: {
|
|
35
|
-
type: Boolean,
|
|
36
|
-
required: false,
|
|
37
|
-
default: false
|
|
38
|
-
},
|
|
39
|
-
/**
|
|
40
|
-
* Renders the nav items with the appearance of pill buttons
|
|
41
|
-
*/
|
|
42
|
-
pills: {
|
|
43
|
-
type: Boolean,
|
|
44
|
-
required: false,
|
|
45
|
-
default: false
|
|
46
|
-
},
|
|
47
|
-
/**
|
|
48
|
-
* Makes the nav smaller
|
|
49
|
-
*/
|
|
50
|
-
small: {
|
|
51
|
-
type: Boolean,
|
|
52
|
-
required: false,
|
|
53
|
-
default: false
|
|
54
|
-
},
|
|
55
|
-
/**
|
|
56
|
-
* Renders the nav items with the appearance of tabs
|
|
57
|
-
*/
|
|
58
|
-
tabs: {
|
|
59
|
-
type: Boolean,
|
|
60
|
-
required: false,
|
|
61
|
-
default: false
|
|
62
|
-
},
|
|
63
|
-
/**
|
|
64
|
-
* Specify the HTML tag to render instead of the default tag
|
|
65
|
-
*/
|
|
66
|
-
tag: {
|
|
67
|
-
type: String,
|
|
68
|
-
required: false,
|
|
69
|
-
default: 'ul'
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
computed: {
|
|
73
|
-
justifyContent() {
|
|
74
|
-
if (!this.align) return '';
|
|
75
|
-
const alignMapping = {
|
|
76
|
-
left: 'start',
|
|
77
|
-
right: 'end'
|
|
78
|
-
};
|
|
79
|
-
return `justify-content-${alignMapping[this.align] || this.align}`;
|
|
80
|
-
},
|
|
81
|
-
classes() {
|
|
82
|
-
return {
|
|
83
|
-
'nav-tabs': this.tabs,
|
|
84
|
-
'nav-pills': this.pills && !this.tabs,
|
|
85
|
-
'card-header-tabs': this.cardHeader && this.tabs,
|
|
86
|
-
'card-header-pills': this.cardHeader && this.pills && !this.tabs,
|
|
87
|
-
'nav-fill': this.fill,
|
|
88
|
-
'nav-justified': this.justified,
|
|
89
|
-
[this.justifyContent]: this.align,
|
|
90
|
-
small: this.small
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
/* script */
|
|
97
|
-
const __vue_script__ = script;
|
|
98
|
-
|
|
99
|
-
/* template */
|
|
100
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c(_vm.tag,_vm._g({tag:"component",staticClass:"nav",class:_vm.classes},_vm.$listeners),[_vm._t("default")],2)};
|
|
101
|
-
var __vue_staticRenderFns__ = [];
|
|
102
|
-
|
|
103
|
-
/* style */
|
|
104
|
-
const __vue_inject_styles__ = undefined;
|
|
105
|
-
/* scoped */
|
|
106
|
-
const __vue_scope_id__ = undefined;
|
|
107
|
-
/* module identifier */
|
|
108
|
-
const __vue_module_identifier__ = undefined;
|
|
109
|
-
/* functional template */
|
|
110
|
-
const __vue_is_functional_template__ = false;
|
|
111
|
-
/* style inject */
|
|
112
|
-
|
|
113
|
-
/* style inject SSR */
|
|
114
|
-
|
|
115
|
-
/* style inject shadow dom */
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const __vue_component__ = /*#__PURE__*/__vue_normalize__(
|
|
120
|
-
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
121
|
-
__vue_inject_styles__,
|
|
122
|
-
__vue_script__,
|
|
123
|
-
__vue_scope_id__,
|
|
124
|
-
__vue_is_functional_template__,
|
|
125
|
-
__vue_module_identifier__,
|
|
126
|
-
false,
|
|
127
|
-
undefined,
|
|
128
|
-
undefined,
|
|
129
|
-
undefined
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
export { __vue_component__ as default };
|