@gitlab/ui 127.1.1 → 128.1.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/form/form_checkbox/form_checkbox.js +0 -3
- package/dist/components/base/form/form_checkbox/form_checkbox_group.js +132 -3
- package/dist/components/base/form/form_group/form_group.js +3 -0
- package/dist/components/base/new_dropdowns/base_dropdown/base_dropdown.js +95 -20
- package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown.js +1 -1
- package/dist/components/base/new_dropdowns/listbox/listbox.js +47 -10
- 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/build/js/tokens.dark.js +127 -127
- package/dist/tokens/build/js/tokens.js +110 -110
- package/dist/vendor/bootstrap-vue/src/constants/components.js +1 -3
- package/dist/vendor/bootstrap-vue/src/mixins/form-radio-check-group.js +1 -2
- package/package.json +1 -1
- package/src/components/base/form/form_checkbox/form_checkbox.vue +0 -3
- package/src/components/base/form/form_checkbox/form_checkbox_group.vue +148 -21
- package/src/components/base/form/form_group/form_group.vue +3 -0
- package/src/components/base/new_dropdowns/base_dropdown/base_dropdown.vue +101 -22
- package/src/components/base/new_dropdowns/disclosure/disclosure_dropdown.vue +3 -2
- package/src/components/base/new_dropdowns/listbox/listbox.vue +52 -9
- package/src/scss/bootstrap_vue.scss +0 -1
- package/src/tokens/build/css/tokens.css +24 -24
- package/src/tokens/build/css/tokens.dark.css +26 -26
- package/src/tokens/build/docs/tokens-tailwind-docs.dark.json +82 -82
- package/src/tokens/build/docs/tokens-tailwind-docs.json +81 -81
- package/src/tokens/build/figma/constants.tokens.json +2245 -226
- package/src/tokens/build/figma/contextual.tokens.json +753 -77
- package/src/tokens/build/figma/deprecated.tokens.json +4151 -420
- package/src/tokens/build/figma/semantic.tokens.json +171 -19
- package/src/tokens/build/js/tokens.dark.js +130 -127
- package/src/tokens/build/js/tokens.js +113 -110
- package/src/tokens/build/json/tokens.dark.json +161 -161
- package/src/tokens/build/json/tokens.json +142 -142
- package/src/tokens/build/scss/_tokens.dark.scss +26 -26
- package/src/tokens/build/scss/_tokens.scss +24 -24
- package/src/tokens/constant/color.alpha.tokens.json +135 -15
- package/src/tokens/constant/color.tokens.json +2110 -211
- package/src/tokens/contextual/avatar.tokens.json +54 -6
- package/src/tokens/contextual/button.tokens.json +90 -10
- package/src/tokens/contextual/chart.tokens.json +9 -1
- package/src/tokens/contextual/illustration.tokens.json +600 -60
- package/src/tokens/deprecated/deprecated.color.data_viz.tokens.json +1100 -110
- package/src/tokens/deprecated/deprecated.color.theme.tokens.json +1440 -144
- package/src/tokens/deprecated/deprecated.color.tokens.json +1490 -149
- package/src/tokens/deprecated/deprecated.color.transparency.tokens.json +147 -43
- package/src/tokens/semantic/action.tokens.json +162 -18
- package/src/tokens/semantic/background.tokens.json +9 -1
- package/src/vendor/bootstrap-vue/src/constants/components.js +0 -2
- package/src/vendor/bootstrap-vue/src/mixins/form-radio-check-group.js +1 -2
- package/dist/vendor/bootstrap-vue/src/components/form-checkbox/form-checkbox-group.js +0 -37
- package/dist/vendor/bootstrap-vue/src/components/form-checkbox/form-checkbox.js +0 -134
- package/dist/vendor/bootstrap-vue/src/components/form-checkbox/index.js +0 -2
- package/src/vendor/bootstrap-vue/src/components/form-checkbox/_form-checkbox-group.scss +0 -1
- package/src/vendor/bootstrap-vue/src/components/form-checkbox/_form-checkbox.scss +0 -125
- package/src/vendor/bootstrap-vue/src/components/form-checkbox/form-checkbox-group.js +0 -42
- package/src/vendor/bootstrap-vue/src/components/form-checkbox/form-checkbox.js +0 -132
- package/src/vendor/bootstrap-vue/src/components/form-checkbox/index.js +0 -4
- package/src/vendor/bootstrap-vue/src/components/form-checkbox/index.scss +0 -2
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { extend } from '../../vue';
|
|
2
|
-
import { NAME_FORM_CHECKBOX } from '../../constants/components';
|
|
3
|
-
import { EVENT_NAME_CHANGE, MODEL_EVENT_NAME_PREFIX } from '../../constants/events';
|
|
4
|
-
import { PROP_TYPE_BOOLEAN, PROP_TYPE_ANY } from '../../constants/props';
|
|
5
|
-
import { isArray } from '../../utils/inspect';
|
|
6
|
-
import { looseEqual } from '../../utils/loose-equal';
|
|
7
|
-
import { looseIndexOf } from '../../utils/loose-index-of';
|
|
8
|
-
import { sortKeys } from '../../utils/object';
|
|
9
|
-
import { makePropsConfigurable, makeProp } from '../../utils/props';
|
|
10
|
-
import { props as props$1, formRadioCheckMixin, MODEL_EVENT_NAME } from '../../mixins/form-radio-check';
|
|
11
|
-
|
|
12
|
-
// --- Constants ---
|
|
13
|
-
|
|
14
|
-
const MODEL_PROP_NAME_INDETERMINATE = 'indeterminate';
|
|
15
|
-
const MODEL_EVENT_NAME_INDETERMINATE = MODEL_EVENT_NAME_PREFIX + MODEL_PROP_NAME_INDETERMINATE;
|
|
16
|
-
|
|
17
|
-
// --- Props ---
|
|
18
|
-
|
|
19
|
-
const props = makePropsConfigurable(sortKeys({
|
|
20
|
-
...props$1,
|
|
21
|
-
// Not applicable in multi-check mode
|
|
22
|
-
[MODEL_PROP_NAME_INDETERMINATE]: makeProp(PROP_TYPE_BOOLEAN, false),
|
|
23
|
-
// Custom switch styling
|
|
24
|
-
switch: makeProp(PROP_TYPE_BOOLEAN, false),
|
|
25
|
-
// Not applicable in multi-check mode
|
|
26
|
-
uncheckedValue: makeProp(PROP_TYPE_ANY, false),
|
|
27
|
-
value: makeProp(PROP_TYPE_ANY, true)
|
|
28
|
-
}), NAME_FORM_CHECKBOX);
|
|
29
|
-
|
|
30
|
-
// --- Main component ---
|
|
31
|
-
|
|
32
|
-
// @vue/component
|
|
33
|
-
const BFormCheckbox = /*#__PURE__*/extend({
|
|
34
|
-
name: NAME_FORM_CHECKBOX,
|
|
35
|
-
mixins: [formRadioCheckMixin],
|
|
36
|
-
inject: {
|
|
37
|
-
getBvGroup: {
|
|
38
|
-
from: 'getBvCheckGroup',
|
|
39
|
-
default: () => () => null
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
props,
|
|
43
|
-
computed: {
|
|
44
|
-
bvGroup() {
|
|
45
|
-
return this.getBvGroup();
|
|
46
|
-
},
|
|
47
|
-
isChecked() {
|
|
48
|
-
const {
|
|
49
|
-
value,
|
|
50
|
-
computedLocalChecked: checked
|
|
51
|
-
} = this;
|
|
52
|
-
return isArray(checked) ? looseIndexOf(checked, value) > -1 : looseEqual(checked, value);
|
|
53
|
-
},
|
|
54
|
-
isRadio() {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
watch: {
|
|
59
|
-
[MODEL_PROP_NAME_INDETERMINATE](newValue, oldValue) {
|
|
60
|
-
if (!looseEqual(newValue, oldValue)) {
|
|
61
|
-
this.setIndeterminate(newValue);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
mounted() {
|
|
66
|
-
// Set initial indeterminate state
|
|
67
|
-
this.setIndeterminate(this[MODEL_PROP_NAME_INDETERMINATE]);
|
|
68
|
-
},
|
|
69
|
-
methods: {
|
|
70
|
-
computedLocalCheckedWatcher(newValue, oldValue) {
|
|
71
|
-
if (!looseEqual(newValue, oldValue)) {
|
|
72
|
-
this.$emit(MODEL_EVENT_NAME, newValue);
|
|
73
|
-
const $input = this.$refs.input;
|
|
74
|
-
if ($input) {
|
|
75
|
-
this.$emit(MODEL_EVENT_NAME_INDETERMINATE, $input.indeterminate);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
handleChange(_ref) {
|
|
80
|
-
let {
|
|
81
|
-
target: {
|
|
82
|
-
checked,
|
|
83
|
-
indeterminate
|
|
84
|
-
}
|
|
85
|
-
} = _ref;
|
|
86
|
-
const {
|
|
87
|
-
value,
|
|
88
|
-
uncheckedValue
|
|
89
|
-
} = this;
|
|
90
|
-
|
|
91
|
-
// Update `computedLocalChecked`
|
|
92
|
-
let localChecked = this.computedLocalChecked;
|
|
93
|
-
if (isArray(localChecked)) {
|
|
94
|
-
const index = looseIndexOf(localChecked, value);
|
|
95
|
-
if (checked && index < 0) {
|
|
96
|
-
// Add value to array
|
|
97
|
-
localChecked = localChecked.concat(value);
|
|
98
|
-
} else if (!checked && index > -1) {
|
|
99
|
-
// Remove value from array
|
|
100
|
-
localChecked = localChecked.slice(0, index).concat(localChecked.slice(index + 1));
|
|
101
|
-
}
|
|
102
|
-
} else {
|
|
103
|
-
localChecked = checked ? value : uncheckedValue;
|
|
104
|
-
}
|
|
105
|
-
this.computedLocalChecked = localChecked;
|
|
106
|
-
|
|
107
|
-
// Fire events in a `$nextTick()` to ensure the `v-model` is updated
|
|
108
|
-
this.$nextTick(() => {
|
|
109
|
-
// Change is only emitted on user interaction
|
|
110
|
-
this.$emit(EVENT_NAME_CHANGE, localChecked);
|
|
111
|
-
|
|
112
|
-
// If this is a child of a group, we emit a change event on it as well
|
|
113
|
-
if (this.isGroup) {
|
|
114
|
-
this.bvGroup.$emit(EVENT_NAME_CHANGE, localChecked);
|
|
115
|
-
}
|
|
116
|
-
this.$emit(MODEL_EVENT_NAME_INDETERMINATE, indeterminate);
|
|
117
|
-
});
|
|
118
|
-
},
|
|
119
|
-
setIndeterminate(state) {
|
|
120
|
-
// Indeterminate only supported in single checkbox mode
|
|
121
|
-
if (isArray(this.computedLocalChecked)) {
|
|
122
|
-
state = false;
|
|
123
|
-
}
|
|
124
|
-
const $input = this.$refs.input;
|
|
125
|
-
if ($input) {
|
|
126
|
-
$input.indeterminate = state;
|
|
127
|
-
// Emit update event to prop
|
|
128
|
-
this.$emit(MODEL_EVENT_NAME_INDETERMINATE, state);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
export { BFormCheckbox, props };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import "../../utilities";
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
// Adds control sizing to Bootstrap custom checkbox/switch inputs
|
|
2
|
-
|
|
3
|
-
.custom-checkbox.b-custom-control-lg,
|
|
4
|
-
.input-group-lg .custom-checkbox {
|
|
5
|
-
font-size: $font-size-lg;
|
|
6
|
-
line-height: $line-height-lg;
|
|
7
|
-
padding-left: $b-custom-control-gutter-lg + $b-custom-control-indicator-size-lg;
|
|
8
|
-
|
|
9
|
-
.custom-control-label::before {
|
|
10
|
-
top: ($font-size-lg * $line-height-lg - $b-custom-control-indicator-size-lg) * 0.5;
|
|
11
|
-
left: -($b-custom-control-gutter-lg + $b-custom-control-indicator-size-lg);
|
|
12
|
-
width: $b-custom-control-indicator-size-lg;
|
|
13
|
-
height: $b-custom-control-indicator-size-lg;
|
|
14
|
-
@include border-radius($b-custom-checkbox-indicator-border-radius-lg);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.custom-control-label::after {
|
|
18
|
-
top: ($font-size-lg * $line-height-lg - $b-custom-control-indicator-size-lg) * 0.5;
|
|
19
|
-
left: -($b-custom-control-gutter-lg + $b-custom-control-indicator-size-lg);
|
|
20
|
-
width: $b-custom-control-indicator-size-lg;
|
|
21
|
-
height: $b-custom-control-indicator-size-lg;
|
|
22
|
-
background-size: $b-custom-control-indicator-bg-size-lg;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.custom-checkbox.b-custom-control-sm,
|
|
27
|
-
.input-group-sm .custom-checkbox {
|
|
28
|
-
font-size: $font-size-sm;
|
|
29
|
-
line-height: $line-height-sm;
|
|
30
|
-
padding-left: $b-custom-control-gutter-sm + $b-custom-control-indicator-size-sm;
|
|
31
|
-
|
|
32
|
-
.custom-control-label::before {
|
|
33
|
-
top: ($font-size-sm * $line-height-sm - $b-custom-control-indicator-size-sm) * 0.5;
|
|
34
|
-
left: -($b-custom-control-gutter-sm + $b-custom-control-indicator-size-sm);
|
|
35
|
-
width: $b-custom-control-indicator-size-sm;
|
|
36
|
-
height: $b-custom-control-indicator-size-sm;
|
|
37
|
-
@include border-radius($b-custom-checkbox-indicator-border-radius-sm);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.custom-control-label::after {
|
|
41
|
-
top: ($font-size-sm * $line-height-sm - $b-custom-control-indicator-size-sm) * 0.5;
|
|
42
|
-
left: -($b-custom-control-gutter-sm + $b-custom-control-indicator-size-sm);
|
|
43
|
-
width: $b-custom-control-indicator-size-sm;
|
|
44
|
-
height: $b-custom-control-indicator-size-sm;
|
|
45
|
-
background-size: $b-custom-control-indicator-bg-size-sm;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.custom-switch.b-custom-control-lg,
|
|
50
|
-
.input-group-lg .custom-switch {
|
|
51
|
-
padding-left: $b-custom-switch-width-lg + $b-custom-control-gutter-lg;
|
|
52
|
-
|
|
53
|
-
.custom-control-label {
|
|
54
|
-
font-size: $font-size-lg;
|
|
55
|
-
line-height: $line-height-lg;
|
|
56
|
-
|
|
57
|
-
&::before {
|
|
58
|
-
top: ($font-size-lg * $line-height-lg - $b-custom-control-indicator-size-lg) * 0.5;
|
|
59
|
-
height: $b-custom-control-indicator-size-lg;
|
|
60
|
-
left: -($b-custom-switch-width-lg + $b-custom-control-gutter-lg);
|
|
61
|
-
width: $b-custom-switch-width-lg;
|
|
62
|
-
border-radius: $b-custom-switch-indicator-border-radius-lg;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
&::after {
|
|
66
|
-
top: calc(
|
|
67
|
-
#{(($font-size-lg * $line-height-lg - $b-custom-control-indicator-size-lg) * 0.5)} + #{$custom-control-indicator-border-width *
|
|
68
|
-
2}
|
|
69
|
-
);
|
|
70
|
-
left: calc(
|
|
71
|
-
#{- ($b-custom-switch-width-lg + $b-custom-control-gutter-lg)} + #{$custom-control-indicator-border-width *
|
|
72
|
-
2}
|
|
73
|
-
);
|
|
74
|
-
width: $b-custom-switch-indicator-size-lg;
|
|
75
|
-
height: $b-custom-switch-indicator-size-lg;
|
|
76
|
-
border-radius: $b-custom-switch-indicator-border-radius-lg;
|
|
77
|
-
background-size: $b-custom-control-indicator-bg-size-lg;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.custom-control-input:checked ~ .custom-control-label {
|
|
82
|
-
&::after {
|
|
83
|
-
transform: translateX($b-custom-switch-width-lg - $b-custom-control-indicator-size-lg);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.custom-switch.b-custom-control-sm,
|
|
89
|
-
.input-group-sm .custom-switch {
|
|
90
|
-
padding-left: $b-custom-switch-width-sm + $b-custom-control-gutter-sm;
|
|
91
|
-
|
|
92
|
-
.custom-control-label {
|
|
93
|
-
font-size: $font-size-sm;
|
|
94
|
-
line-height: $line-height-sm;
|
|
95
|
-
|
|
96
|
-
&::before {
|
|
97
|
-
top: ($font-size-sm * $line-height-sm - $b-custom-control-indicator-size-sm) * 0.5;
|
|
98
|
-
left: -($b-custom-switch-width-sm + $b-custom-control-gutter-sm);
|
|
99
|
-
width: $b-custom-switch-width-sm;
|
|
100
|
-
height: $b-custom-control-indicator-size-sm;
|
|
101
|
-
border-radius: $b-custom-switch-indicator-border-radius-sm;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
&::after {
|
|
105
|
-
top: calc(
|
|
106
|
-
#{(($font-size-sm * $line-height-sm - $b-custom-control-indicator-size-sm) * 0.5)} + #{$custom-control-indicator-border-width *
|
|
107
|
-
2}
|
|
108
|
-
);
|
|
109
|
-
left: calc(
|
|
110
|
-
#{- ($b-custom-switch-width-sm + $b-custom-control-gutter-sm)} + #{$custom-control-indicator-border-width *
|
|
111
|
-
2}
|
|
112
|
-
);
|
|
113
|
-
width: $b-custom-switch-indicator-size-sm;
|
|
114
|
-
height: $b-custom-switch-indicator-size-sm;
|
|
115
|
-
border-radius: $b-custom-switch-indicator-border-radius-sm;
|
|
116
|
-
background-size: $b-custom-control-indicator-bg-size-sm;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
.custom-control-input:checked ~ .custom-control-label {
|
|
121
|
-
&::after {
|
|
122
|
-
transform: translateX($b-custom-switch-width-sm - $b-custom-control-indicator-size-sm);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { extend } from '../../vue'
|
|
2
|
-
import { NAME_FORM_CHECKBOX_GROUP } from '../../constants/components'
|
|
3
|
-
import { PROP_TYPE_ARRAY, PROP_TYPE_BOOLEAN } from '../../constants/props'
|
|
4
|
-
import { sortKeys } from '../../utils/object'
|
|
5
|
-
import { makeProp, makePropsConfigurable } from '../../utils/props'
|
|
6
|
-
import {
|
|
7
|
-
MODEL_PROP_NAME,
|
|
8
|
-
formRadioCheckGroupMixin,
|
|
9
|
-
props as formRadioCheckGroupProps
|
|
10
|
-
} from '../../mixins/form-radio-check-group'
|
|
11
|
-
|
|
12
|
-
// --- Props ---
|
|
13
|
-
|
|
14
|
-
export const props = makePropsConfigurable(
|
|
15
|
-
sortKeys({
|
|
16
|
-
...formRadioCheckGroupProps,
|
|
17
|
-
[MODEL_PROP_NAME]: makeProp(PROP_TYPE_ARRAY, []),
|
|
18
|
-
// Custom switch styling
|
|
19
|
-
switches: makeProp(PROP_TYPE_BOOLEAN, false)
|
|
20
|
-
}),
|
|
21
|
-
NAME_FORM_CHECKBOX_GROUP
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
// --- Main component ---
|
|
25
|
-
|
|
26
|
-
// @vue/component
|
|
27
|
-
export const BFormCheckboxGroup = /*#__PURE__*/ extend({
|
|
28
|
-
name: NAME_FORM_CHECKBOX_GROUP,
|
|
29
|
-
// Includes render function
|
|
30
|
-
mixins: [formRadioCheckGroupMixin],
|
|
31
|
-
provide() {
|
|
32
|
-
return {
|
|
33
|
-
getBvCheckGroup: () => this
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
props,
|
|
37
|
-
computed: {
|
|
38
|
-
isRadioGroup() {
|
|
39
|
-
return false
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
})
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { extend } from '../../vue'
|
|
2
|
-
import { NAME_FORM_CHECKBOX } from '../../constants/components'
|
|
3
|
-
import { EVENT_NAME_CHANGE, MODEL_EVENT_NAME_PREFIX } from '../../constants/events'
|
|
4
|
-
import { PROP_TYPE_ANY, PROP_TYPE_BOOLEAN } from '../../constants/props'
|
|
5
|
-
import { isArray } from '../../utils/inspect'
|
|
6
|
-
import { looseEqual } from '../../utils/loose-equal'
|
|
7
|
-
import { looseIndexOf } from '../../utils/loose-index-of'
|
|
8
|
-
import { sortKeys } from '../../utils/object'
|
|
9
|
-
import { makeProp, makePropsConfigurable } from '../../utils/props'
|
|
10
|
-
import {
|
|
11
|
-
MODEL_EVENT_NAME,
|
|
12
|
-
formRadioCheckMixin,
|
|
13
|
-
props as formRadioCheckProps
|
|
14
|
-
} from '../../mixins/form-radio-check'
|
|
15
|
-
|
|
16
|
-
// --- Constants ---
|
|
17
|
-
|
|
18
|
-
const MODEL_PROP_NAME_INDETERMINATE = 'indeterminate'
|
|
19
|
-
const MODEL_EVENT_NAME_INDETERMINATE = MODEL_EVENT_NAME_PREFIX + MODEL_PROP_NAME_INDETERMINATE
|
|
20
|
-
|
|
21
|
-
// --- Props ---
|
|
22
|
-
|
|
23
|
-
export const props = makePropsConfigurable(
|
|
24
|
-
sortKeys({
|
|
25
|
-
...formRadioCheckProps,
|
|
26
|
-
// Not applicable in multi-check mode
|
|
27
|
-
[MODEL_PROP_NAME_INDETERMINATE]: makeProp(PROP_TYPE_BOOLEAN, false),
|
|
28
|
-
// Custom switch styling
|
|
29
|
-
switch: makeProp(PROP_TYPE_BOOLEAN, false),
|
|
30
|
-
// Not applicable in multi-check mode
|
|
31
|
-
uncheckedValue: makeProp(PROP_TYPE_ANY, false),
|
|
32
|
-
value: makeProp(PROP_TYPE_ANY, true)
|
|
33
|
-
}),
|
|
34
|
-
NAME_FORM_CHECKBOX
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
// --- Main component ---
|
|
38
|
-
|
|
39
|
-
// @vue/component
|
|
40
|
-
export const BFormCheckbox = /*#__PURE__*/ extend({
|
|
41
|
-
name: NAME_FORM_CHECKBOX,
|
|
42
|
-
mixins: [formRadioCheckMixin],
|
|
43
|
-
inject: {
|
|
44
|
-
getBvGroup: {
|
|
45
|
-
from: 'getBvCheckGroup',
|
|
46
|
-
default: () => () => null
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
props,
|
|
50
|
-
computed: {
|
|
51
|
-
bvGroup() {
|
|
52
|
-
return this.getBvGroup()
|
|
53
|
-
},
|
|
54
|
-
isChecked() {
|
|
55
|
-
const { value, computedLocalChecked: checked } = this
|
|
56
|
-
return isArray(checked) ? looseIndexOf(checked, value) > -1 : looseEqual(checked, value)
|
|
57
|
-
},
|
|
58
|
-
isRadio() {
|
|
59
|
-
return false
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
watch: {
|
|
63
|
-
[MODEL_PROP_NAME_INDETERMINATE](newValue, oldValue) {
|
|
64
|
-
if (!looseEqual(newValue, oldValue)) {
|
|
65
|
-
this.setIndeterminate(newValue)
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
mounted() {
|
|
70
|
-
// Set initial indeterminate state
|
|
71
|
-
this.setIndeterminate(this[MODEL_PROP_NAME_INDETERMINATE])
|
|
72
|
-
},
|
|
73
|
-
methods: {
|
|
74
|
-
computedLocalCheckedWatcher(newValue, oldValue) {
|
|
75
|
-
if (!looseEqual(newValue, oldValue)) {
|
|
76
|
-
this.$emit(MODEL_EVENT_NAME, newValue)
|
|
77
|
-
|
|
78
|
-
const $input = this.$refs.input
|
|
79
|
-
if ($input) {
|
|
80
|
-
this.$emit(MODEL_EVENT_NAME_INDETERMINATE, $input.indeterminate)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
handleChange({ target: { checked, indeterminate } }) {
|
|
86
|
-
const { value, uncheckedValue } = this
|
|
87
|
-
|
|
88
|
-
// Update `computedLocalChecked`
|
|
89
|
-
let localChecked = this.computedLocalChecked
|
|
90
|
-
if (isArray(localChecked)) {
|
|
91
|
-
const index = looseIndexOf(localChecked, value)
|
|
92
|
-
if (checked && index < 0) {
|
|
93
|
-
// Add value to array
|
|
94
|
-
localChecked = localChecked.concat(value)
|
|
95
|
-
} else if (!checked && index > -1) {
|
|
96
|
-
// Remove value from array
|
|
97
|
-
localChecked = localChecked.slice(0, index).concat(localChecked.slice(index + 1))
|
|
98
|
-
}
|
|
99
|
-
} else {
|
|
100
|
-
localChecked = checked ? value : uncheckedValue
|
|
101
|
-
}
|
|
102
|
-
this.computedLocalChecked = localChecked
|
|
103
|
-
|
|
104
|
-
// Fire events in a `$nextTick()` to ensure the `v-model` is updated
|
|
105
|
-
this.$nextTick(() => {
|
|
106
|
-
// Change is only emitted on user interaction
|
|
107
|
-
this.$emit(EVENT_NAME_CHANGE, localChecked)
|
|
108
|
-
|
|
109
|
-
// If this is a child of a group, we emit a change event on it as well
|
|
110
|
-
if (this.isGroup) {
|
|
111
|
-
this.bvGroup.$emit(EVENT_NAME_CHANGE, localChecked)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
this.$emit(MODEL_EVENT_NAME_INDETERMINATE, indeterminate)
|
|
115
|
-
})
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
setIndeterminate(state) {
|
|
119
|
-
// Indeterminate only supported in single checkbox mode
|
|
120
|
-
if (isArray(this.computedLocalChecked)) {
|
|
121
|
-
state = false
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const $input = this.$refs.input
|
|
125
|
-
if ($input) {
|
|
126
|
-
$input.indeterminate = state
|
|
127
|
-
// Emit update event to prop
|
|
128
|
-
this.$emit(MODEL_EVENT_NAME_INDETERMINATE, state)
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
})
|