@gitlab/ui 115.11.0 → 116.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 -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 -1
- package/src/tokens/common_story_options.js +1 -9
- package/src/tokens/tokens_story.vue +2 -22
- 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_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/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,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>
|