@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
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
A Vue Directive to call a callback when a supported event type occurs *outside* of the element
|
|
2
|
-
the directive is bound to. Any events on the element or any descendant elements are ignored.
|
|
3
|
-
The directive supports the event types `click` and `focusin` and can be configured in several ways.
|
|
4
|
-
If no event type is set, `click` is the default.
|
|
5
|
-
|
|
6
|
-
## Usage
|
|
7
|
-
|
|
8
|
-
### Default
|
|
9
|
-
|
|
10
|
-
The following example listens for click events outside the specified element:
|
|
11
|
-
|
|
12
|
-
```html
|
|
13
|
-
<script>
|
|
14
|
-
import { GlOutsideDirective as Outside } from '@gitlab/ui';
|
|
15
|
-
|
|
16
|
-
export default {
|
|
17
|
-
directives: { Outside },
|
|
18
|
-
methods: {
|
|
19
|
-
onClick(event) {
|
|
20
|
-
console.log('User clicked somewhere outside of this component', event);
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
</script>
|
|
25
|
-
|
|
26
|
-
<template>
|
|
27
|
-
<div v-outside="onClick">Click anywhere but here</div>
|
|
28
|
-
</template>
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### When binding another event type than `click`
|
|
32
|
-
|
|
33
|
-
You can specify event types as modifiers. The following example listens for `focusin` events,
|
|
34
|
-
but not for `click`. With this implementation:
|
|
35
|
-
|
|
36
|
-
```html
|
|
37
|
-
<script>
|
|
38
|
-
export default {
|
|
39
|
-
methods: {
|
|
40
|
-
onFocusin(event) {
|
|
41
|
-
console.log('User set the focus somewhere outside of this component', event);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
</script>
|
|
46
|
-
|
|
47
|
-
<template>
|
|
48
|
-
<div v-outside.focusin="onFocusin">...</div>
|
|
49
|
-
</template>
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### When binding multiple event types
|
|
53
|
-
|
|
54
|
-
You can specify multiple event types by providing multiple modifiers. The following example
|
|
55
|
-
listens for `click` and `focusin` events:
|
|
56
|
-
|
|
57
|
-
```html
|
|
58
|
-
<script>
|
|
59
|
-
export default {
|
|
60
|
-
methods: {
|
|
61
|
-
onEvent(event) {
|
|
62
|
-
console.log('Event occurred outside the element:', event);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
</script>
|
|
67
|
-
|
|
68
|
-
<template>
|
|
69
|
-
<div v-outside.click.focusin="onEvent">...</div>
|
|
70
|
-
</template>
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
💡 The callback function receives the `event` as a parameter. You can use the `event.type`
|
|
74
|
-
property to execute different code paths depending on which event triggered the callback.
|
|
75
|
-
|
|
76
|
-
### When handler expects arguments
|
|
77
|
-
|
|
78
|
-
In case a click handler expects an arument to be passed, simple `v-outside="onClick('foo')"` will
|
|
79
|
-
invoke the handler instantly when mounting the component and the directive won't be active. The
|
|
80
|
-
simplest solution to pass the arguments to the directive is to wrap the handler into an anonumous
|
|
81
|
-
function.
|
|
82
|
-
|
|
83
|
-
```html
|
|
84
|
-
<script>
|
|
85
|
-
import { GlOutsideDirective as Outside } from '@gitlab/ui';
|
|
86
|
-
|
|
87
|
-
export default {
|
|
88
|
-
directives: { Outside },
|
|
89
|
-
methods: {
|
|
90
|
-
onClick(event, foo) {
|
|
91
|
-
console.log('Event occurred outside the element:', event);
|
|
92
|
-
console.log('An argument was passed along:', foo);
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
};
|
|
96
|
-
</script>
|
|
97
|
-
|
|
98
|
-
<template>
|
|
99
|
-
<div v-outside="(event) => onClick(event, 'foo')">Click anywhere but here</div>
|
|
100
|
-
</template>
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
## Caveats
|
|
104
|
-
|
|
105
|
-
* Clicks cannot be detected across document boundaries (e.g., across an
|
|
106
|
-
`iframe` boundary), in either direction.
|
|
107
|
-
* Clicks on focusable elements, such as buttons or input fields, will fire both
|
|
108
|
-
`click` and `focusin` events. When both event types are registered,
|
|
109
|
-
the callback will be executed twice. To prevent executing the same code twice
|
|
110
|
-
after only one user interaction, use a flag in the callback to stop its
|
|
111
|
-
execution. Example:
|
|
112
|
-
|
|
113
|
-
```html
|
|
114
|
-
<script>
|
|
115
|
-
export default {
|
|
116
|
-
data: () => ({
|
|
117
|
-
isOpen: false,
|
|
118
|
-
}),
|
|
119
|
-
methods: {
|
|
120
|
-
openDropdown() {
|
|
121
|
-
this.isOpen = true;
|
|
122
|
-
},
|
|
123
|
-
closeDropdown() {
|
|
124
|
-
if(!this.isOpen) {
|
|
125
|
-
return
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// more code
|
|
129
|
-
|
|
130
|
-
this.isOpen = false;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
</script>
|
|
135
|
-
|
|
136
|
-
<template>
|
|
137
|
-
<button type="button" @click="openDropdown">Open</button>
|
|
138
|
-
<div v-outside.click.focusin="closeDropdown">...</div>
|
|
139
|
-
</template>
|
|
140
|
-
```
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
This directive can be used to get notified whenever a given element's size (width or height) changes
|
|
2
|
-
and to retrieve the updated dimensions.
|
|
3
|
-
|
|
4
|
-
Under the hood, it leverages the [Resize Observer API](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver).
|
|
5
|
-
If you use GitLab UI in an older browser which doesn't support the Resize Observer API,
|
|
6
|
-
you can use a [polyfill](https://github.com/que-etc/resize-observer-polyfill).
|
|
7
|
-
|
|
8
|
-
The directive accepts a callback as a value and passes on the received
|
|
9
|
-
[contentRect](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry/contentRect)
|
|
10
|
-
and the target element whenever a resize event gets triggered.
|
|
11
|
-
|
|
12
|
-
```html
|
|
13
|
-
<script>
|
|
14
|
-
export default {
|
|
15
|
-
data() {
|
|
16
|
-
return {
|
|
17
|
-
width: 0,
|
|
18
|
-
height: 0,
|
|
19
|
-
};
|
|
20
|
-
},
|
|
21
|
-
methods: {
|
|
22
|
-
handleResize({ contentRect: { width, height } }) {
|
|
23
|
-
this.width = width;
|
|
24
|
-
this.height = height;
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
</script>
|
|
29
|
-
<template>
|
|
30
|
-
<div v-gl-resize-observer-directive="handleResize">
|
|
31
|
-
<p>{{ width }} x {{ height }}</p>
|
|
32
|
-
</div>
|
|
33
|
-
</template>
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
The observer can be toggled on or off by passing a boolean argument to the directive:
|
|
37
|
-
|
|
38
|
-
```html
|
|
39
|
-
<script>
|
|
40
|
-
export default {
|
|
41
|
-
data() {
|
|
42
|
-
return {
|
|
43
|
-
shouldObserve: true,
|
|
44
|
-
};
|
|
45
|
-
},
|
|
46
|
-
methods: {
|
|
47
|
-
handleResize() {},
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
</script>
|
|
51
|
-
<template>
|
|
52
|
-
<div v-gl-resize-observer-directive[shouldObserve]="handleResize"></div>
|
|
53
|
-
</template>
|
|
54
|
-
```
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
A Vue Directive to sanitize HTML to avoid any XSS vulnerabilities.
|
|
2
|
-
|
|
3
|
-
## Usage
|
|
4
|
-
|
|
5
|
-
This directive can be used to sanitize HTML code which may contain user input, to prevent cross-site
|
|
6
|
-
scripting (XSS) vulnerabilities.
|
|
7
|
-
|
|
8
|
-
Under the hood, it uses [DOMPurify](https://github.com/cure53/DOMPurify) to sanitize the provided HTML.
|
|
9
|
-
|
|
10
|
-
DOMPurify will strip out dangerous HTML and will keep the safe HTML. You can refer complete list of
|
|
11
|
-
[tags][1] and [attributes][2] allowed by DOMPurify.
|
|
12
|
-
|
|
13
|
-
[1]: https://github.com/cure53/DOMPurify/blob/main/src/tags.js
|
|
14
|
-
[2]: https://github.com/cure53/DOMPurify/blob/main/src/attrs.js
|
|
15
|
-
|
|
16
|
-
## Example
|
|
17
|
-
|
|
18
|
-
```html
|
|
19
|
-
<script>
|
|
20
|
-
import { GlSafeHtmlDirective as SafeHtml } from '@gitlab/ui';
|
|
21
|
-
|
|
22
|
-
export default {
|
|
23
|
-
directives: {
|
|
24
|
-
SafeHtml,
|
|
25
|
-
},
|
|
26
|
-
data() {
|
|
27
|
-
return {
|
|
28
|
-
rawHtml: "Hello! <script>alert('XSS')</script>",
|
|
29
|
-
};
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
</script>
|
|
33
|
-
|
|
34
|
-
<template>
|
|
35
|
-
<div v-safe-html="rawHtml"></div>
|
|
36
|
-
</template>
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Advanced configuration
|
|
40
|
-
|
|
41
|
-
```js
|
|
42
|
-
// It allows only <b> tags
|
|
43
|
-
const config = { ALLOWED_TAGS: ['b'] };
|
|
44
|
-
|
|
45
|
-
// It doesn't allow any html tags
|
|
46
|
-
const config = { ALLOWED_TAGS: [] };
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
```html
|
|
50
|
-
<div v-safe-html:[config]="rawHtml"></div>
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
For advanced configuration options, please refer to [DOMPurify's documentation](https://github.com/cure53/DOMPurify#can-i-configure-dompurify).
|
|
54
|
-
|
|
55
|
-
### Notes
|
|
56
|
-
|
|
57
|
-
1. `target` attribute is not allowed by default - See <https://gitlab.com/gitlab-org/gitlab-ui/-/issues/1427>.
|
|
58
|
-
1. To know more about other tips & caveats - See <https://gitlab.com/groups/gitlab-org/-/epics/4273#caveats>.
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
A Vue directive to make the hyperlinks secure by default.
|
|
2
|
-
|
|
3
|
-
## Security measures
|
|
4
|
-
|
|
5
|
-
### rel
|
|
6
|
-
|
|
7
|
-
When setting target to `_blank`, the rel attribute gets set automatically to `noopener noreferrer`,
|
|
8
|
-
this is done to avoid the `window.opener` [API exploit]. If you set the `rel` attribute manually,
|
|
9
|
-
this will overwrite the aforementioned logic.
|
|
10
|
-
|
|
11
|
-
### href
|
|
12
|
-
|
|
13
|
-
This directive enforces "safe" URLs. What this means is that, if the provided `href`
|
|
14
|
-
doesn't point to a safe protocol (one of `http:`, `https:`, `mailto:` or `ftp:`), then it is
|
|
15
|
-
replaced with `about:blank` to prevent [URL injections].
|
|
16
|
-
|
|
17
|
-
```html
|
|
18
|
-
<script>
|
|
19
|
-
import { GlSafeLinkDirective as SafeLink } from '@gitlab/ui';
|
|
20
|
-
|
|
21
|
-
export default {
|
|
22
|
-
data() {
|
|
23
|
-
return {
|
|
24
|
-
url: 'javascript:alert(1)',
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
directives: { SafeLink },
|
|
28
|
-
};
|
|
29
|
-
</script>
|
|
30
|
-
<template>
|
|
31
|
-
<a v-safe-link href="url" target="_blank">Click</a>
|
|
32
|
-
<!-- Renders to: <a href="about:blank" target="_blank">Click</a> -->
|
|
33
|
-
</template>
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
[API exploit]: https://www.jitbit.com/alexblog/256-targetblank---the-most-underestimated-vulnerability-ever/
|
|
37
|
-
[URL injections]: https://vuejs.org/v2/guide/security.html#Injecting-URLs
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
## Usage
|
|
2
|
-
|
|
3
|
-
`GlColorContrast` is an **internal** component to display color contrast
|
|
4
|
-
scores and levels for design token stories.
|
|
5
|
-
|
|
6
|
-
`GlColorContrast` accepts `foreground` and `background` color props to
|
|
7
|
-
calculate a contrast score (e.g. `4.5`) and level (e.g. `AA`) consistent
|
|
8
|
-
with [WCAG 2.1 1.4.3: Contrast (Minimum) level](https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html).
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { HEX_REGEX } from '../../utils/constants';
|
|
3
|
-
import { getColorContrast } from '../../utils/utils';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
name: 'GlColorContrast',
|
|
7
|
-
props: {
|
|
8
|
-
foreground: {
|
|
9
|
-
type: String,
|
|
10
|
-
required: true,
|
|
11
|
-
validator: (value) => HEX_REGEX.test(value),
|
|
12
|
-
},
|
|
13
|
-
background: {
|
|
14
|
-
type: String,
|
|
15
|
-
required: true,
|
|
16
|
-
validator: (value) => HEX_REGEX.test(value),
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
computed: {
|
|
20
|
-
isValidColorCombination() {
|
|
21
|
-
return HEX_REGEX.test(this.foreground) && HEX_REGEX.test(this.background);
|
|
22
|
-
},
|
|
23
|
-
classes() {
|
|
24
|
-
if (!this.isValidColorCombination) return 'gl-text-neutral-950';
|
|
25
|
-
const { grade } = this.contrast.level;
|
|
26
|
-
const isFail = grade === 'F';
|
|
27
|
-
const contrastScore = getColorContrast('#fff', this.background).score > 4.5;
|
|
28
|
-
const textClass = contrastScore ? 'gl-text-neutral-0' : 'gl-text-neutral-950';
|
|
29
|
-
const failClasses = contrastScore
|
|
30
|
-
? 'gl-shadow-inner-1-red-300 gl-text-red-300'
|
|
31
|
-
: 'gl-shadow-inner-1-red-500 gl-text-red-500';
|
|
32
|
-
return [isFail ? failClasses : textClass];
|
|
33
|
-
},
|
|
34
|
-
contrast() {
|
|
35
|
-
return getColorContrast(this.foreground, this.background);
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
</script>
|
|
40
|
-
|
|
41
|
-
<template>
|
|
42
|
-
<code
|
|
43
|
-
class="gl-w-10 gl-rounded-base gl-p-2 gl-text-center gl-text-xs"
|
|
44
|
-
:class="classes"
|
|
45
|
-
:style="{ backgroundColor: background }"
|
|
46
|
-
>
|
|
47
|
-
<template v-if="isValidColorCombination">
|
|
48
|
-
{{ contrast.level.grade }} {{ contrast.score }}
|
|
49
|
-
</template>
|
|
50
|
-
<template v-else>???</template>
|
|
51
|
-
</code>
|
|
52
|
-
</template>
|