@gitlab/ui 37.2.0 → 37.4.1

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.
Files changed (68) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/components/base/form/form_group/form_group.documentation.js +2 -6
  3. package/dist/components/base/search_box_by_click/search_box_by_click.documentation.js +2 -80
  4. package/dist/components/base/search_box_by_click/search_box_by_click.js +60 -1
  5. package/dist/components/base/search_box_by_type/search_box_by_type.documentation.js +2 -20
  6. package/dist/components/base/search_box_by_type/search_box_by_type.js +19 -5
  7. package/dist/directives/hover_load/hover_load.documentation.js +1 -1
  8. package/dist/directives/resize_observer/resize_observer.documentation.js +2 -5
  9. package/dist/directives/safe_html/safe_html.documentation.js +1 -1
  10. package/dist/directives/safe_link/safe_link.documentation.js +2 -3
  11. package/dist/index.css +1 -1
  12. package/dist/index.css.map +1 -1
  13. package/dist/utility_classes.css +1 -1
  14. package/dist/utility_classes.css.map +1 -1
  15. package/documentation/documented_stories.js +7 -0
  16. package/package.json +1 -1
  17. package/src/components/base/button/button.scss +5 -9
  18. package/src/components/base/form/form_group/form_group.documentation.js +0 -3
  19. package/src/components/base/form/form_group/form_group.md +0 -2
  20. package/src/components/base/form/form_group/form_group.stories.js +106 -145
  21. package/src/components/base/search_box_by_click/search_box_by_click.documentation.js +0 -90
  22. package/src/components/base/search_box_by_click/search_box_by_click.md +0 -2
  23. package/src/components/base/search_box_by_click/search_box_by_click.stories.js +91 -48
  24. package/src/components/base/search_box_by_click/search_box_by_click.vue +50 -1
  25. package/src/components/base/search_box_by_type/search_box_by_type.documentation.js +0 -18
  26. package/src/components/base/search_box_by_type/search_box_by_type.md +0 -2
  27. package/src/components/base/search_box_by_type/search_box_by_type.stories.js +49 -43
  28. package/src/components/base/search_box_by_type/search_box_by_type.vue +16 -6
  29. package/src/directives/hover_load/hover_load.md +0 -2
  30. package/src/directives/hover_load/hover_load.stories.js +39 -34
  31. package/src/directives/resize_observer/resize_observer.documentation.js +0 -2
  32. package/src/directives/resize_observer/resize_observer.md +0 -6
  33. package/src/directives/resize_observer/resize_observer.stories.js +70 -51
  34. package/src/directives/safe_html/safe_html.md +0 -4
  35. package/src/directives/safe_html/safe_html.stories.js +53 -44
  36. package/src/directives/safe_link/safe_link.documentation.js +0 -1
  37. package/src/directives/safe_link/safe_link.md +0 -4
  38. package/src/directives/safe_link/safe_link.stories.js +31 -30
  39. package/src/scss/utilities.scss +8 -0
  40. package/src/scss/utility-mixins/background.scss +4 -0
  41. package/dist/components/base/form/form_group/examples/form_group/form_group.basic.example.js +0 -38
  42. package/dist/components/base/form/form_group/examples/form_group/form_group.disabled.example.js +0 -48
  43. package/dist/components/base/form/form_group/examples/form_group/form_group.textarea.example.js +0 -48
  44. package/dist/components/base/form/form_group/examples/form_group/form_group.validation.example.js +0 -66
  45. package/dist/components/base/form/form_group/examples/form_group/index.js +0 -27
  46. package/dist/components/base/search_box_by_click/examples/index.js +0 -22
  47. package/dist/components/base/search_box_by_click/examples/search_box_by_click.default.example.js +0 -48
  48. package/dist/components/base/search_box_by_click/examples/search_box_by_click.history.example.js +0 -51
  49. package/dist/components/base/search_box_by_click/examples/search_box_by_click.v_model.example.js +0 -54
  50. package/dist/components/base/search_box_by_type/examples/index.js +0 -17
  51. package/dist/components/base/search_box_by_type/examples/search_box_by_type.default.example.js +0 -48
  52. package/dist/components/base/search_box_by_type/examples/search_box_by_type.loading.example.js +0 -65
  53. package/dist/directives/resize_observer/examples/index.js +0 -12
  54. package/dist/directives/resize_observer/examples/resize_observer.basic.example.js +0 -62
  55. package/src/components/base/form/form_group/examples/form_group/form_group.basic.example.vue +0 -11
  56. package/src/components/base/form/form_group/examples/form_group/form_group.disabled.example.vue +0 -21
  57. package/src/components/base/form/form_group/examples/form_group/form_group.textarea.example.vue +0 -15
  58. package/src/components/base/form/form_group/examples/form_group/form_group.validation.example.vue +0 -36
  59. package/src/components/base/form/form_group/examples/form_group/index.js +0 -32
  60. package/src/components/base/search_box_by_click/examples/index.js +0 -26
  61. package/src/components/base/search_box_by_click/examples/search_box_by_click.default.example.vue +0 -14
  62. package/src/components/base/search_box_by_click/examples/search_box_by_click.history.example.vue +0 -23
  63. package/src/components/base/search_box_by_click/examples/search_box_by_click.v_model.example.vue +0 -23
  64. package/src/components/base/search_box_by_type/examples/index.js +0 -20
  65. package/src/components/base/search_box_by_type/examples/search_box_by_type.default.example.vue +0 -14
  66. package/src/components/base/search_box_by_type/examples/search_box_by_type.loading.example.vue +0 -34
  67. package/src/directives/resize_observer/examples/index.js +0 -14
  68. package/src/directives/resize_observer/examples/resize_observer.basic.example.vue +0 -21
@@ -26,6 +26,9 @@ export default {
26
26
  GlTooltip: GlTooltipDirective,
27
27
  },
28
28
  props: {
29
+ /**
30
+ * If provided, used as value of search input
31
+ */
29
32
  value: {
30
33
  required: false,
31
34
  default: '',
@@ -33,11 +36,17 @@ export default {
33
36
  // so we should not force any specific type for value here
34
37
  validator: () => true,
35
38
  },
39
+ /**
40
+ * If provided, used as history items for this component
41
+ */
36
42
  historyItems: {
37
43
  type: Array,
38
44
  required: false,
39
45
  default: null,
40
46
  },
47
+ /**
48
+ * If provided, used as a placeholder for this component
49
+ */
41
50
  placeholder: {
42
51
  type: String,
43
52
  required: false,
@@ -48,26 +57,41 @@ export default {
48
57
  required: false,
49
58
  default: true,
50
59
  },
60
+ /**
61
+ * If provided and true, disables the input and controls
62
+ */
51
63
  disabled: {
52
64
  type: Boolean,
53
65
  required: false,
54
66
  default: false,
55
67
  },
68
+ /**
69
+ * i18n for recent searches title within history dropdown
70
+ */
56
71
  recentSearchesHeader: {
57
72
  type: String,
58
73
  required: false,
59
74
  default: 'Recent searches',
60
75
  },
76
+ /**
77
+ * i18n for clear button title
78
+ */
61
79
  clearButtonTitle: {
62
80
  type: String,
63
81
  required: false,
64
82
  default: 'Clear',
65
83
  },
84
+ /**
85
+ * i18n for close button title within history dropdown
86
+ */
66
87
  closeButtonTitle: {
67
88
  type: String,
68
89
  required: false,
69
90
  default: 'Close',
70
91
  },
92
+ /**
93
+ * i18n for recent searches clear text
94
+ */
71
95
  clearRecentSearchesText: {
72
96
  type: String,
73
97
  required: false,
@@ -78,12 +102,18 @@ export default {
78
102
  required: false,
79
103
  default: "You don't have any recent searches",
80
104
  },
105
+ /**
106
+ * Container for tooltip. Valid values: DOM node, selector string or `false` for default
107
+ */
81
108
  tooltipContainer: {
82
109
  required: false,
83
110
  default: false,
84
111
  validator: (value) =>
85
112
  value === false || typeof value === 'string' || value instanceof HTMLElement,
86
113
  },
114
+ /**
115
+ * HTML attributes to add to the search button
116
+ */
87
117
  searchButtonAttributes: {
88
118
  type: Object,
89
119
  required: false,
@@ -130,10 +160,19 @@ export default {
130
160
  this.$refs.historyDropdown.hide();
131
161
  },
132
162
  search(value) {
163
+ /**
164
+ * Emitted when search is submitted
165
+ * @property {*} value Search value
166
+ */
133
167
  this.$emit('submit', value);
134
168
  },
135
169
  selectHistoryItem(item) {
136
170
  this.currentValue = item;
171
+
172
+ /**
173
+ * Emitted when item from history is selected
174
+ * @property {*} item History item
175
+ */
137
176
  this.$emit('history-item-selected', item);
138
177
  setTimeout(() => {
139
178
  document.activeElement.blur();
@@ -141,11 +180,20 @@ export default {
141
180
  },
142
181
  clearInput() {
143
182
  this.currentValue = '';
183
+ /**
184
+ * Emitted when search is cleared
185
+ */
144
186
  this.$emit('clear');
145
187
  if (this.$refs.input) {
146
188
  this.$refs.input.$el.focus();
147
189
  }
148
190
  },
191
+ emitClearHistory() {
192
+ /**
193
+ * Emitted when clear history button is clicked
194
+ */
195
+ this.$emit('clear-history');
196
+ },
149
197
  },
150
198
  };
151
199
  </script>
@@ -187,10 +235,11 @@ export default {
187
235
  class="gl-search-box-by-click-history-item"
188
236
  @click="selectHistoryItem(item)"
189
237
  >
238
+ <!-- @slot Slot to customize history item in history dropdown. Used only with history-items prop -->
190
239
  <slot name="history-item" :historyItem="item">{{ item }}</slot>
191
240
  </gl-dropdown-item>
192
241
  <gl-dropdown-divider />
193
- <gl-dropdown-item ref="clearHistory" @click="$emit('clear-history')">{{
242
+ <gl-dropdown-item ref="clearHistory" @click="emitClearHistory">{{
194
243
  clearRecentSearchesText
195
244
  }}</gl-dropdown-item>
196
245
  </template>
@@ -1,24 +1,6 @@
1
- import examples from './examples';
2
1
  import description from './search_box_by_type.md';
3
2
 
4
3
  export default {
5
4
  followsDesignSystem: true,
6
5
  description,
7
- propsInfo: {
8
- value: {
9
- additionalInfo: 'If provided, used as value of search input',
10
- },
11
- disabled: {
12
- additionalInfo: 'If provided and true, disables the input and controls',
13
- },
14
- isLoading: {
15
- additionalInfo: 'Puts search box into loading state, rendering spinner',
16
- },
17
- tooltipContainer: {
18
- additionalInfo:
19
- 'Container for tooltip. Valid values: DOM node, selector string or `false` for default',
20
- },
21
- },
22
- examples,
23
- bootstrapComponent: 'b-form-input',
24
6
  };
@@ -1,3 +1 @@
1
- # Search Box By Type
2
-
3
1
  Provides a clearable text input with loading state to be used for [search](https://design.gitlab.com/components/search).
@@ -1,49 +1,55 @@
1
- import { withKnobs, boolean, text } from '@storybook/addon-knobs';
2
- import { documentedStoriesOf } from '../../../../documentation/documented_stories';
3
1
  import { GlSearchBoxByType } from '../../../index';
2
+ import { disableControls } from '../../../utils/stories_utils';
4
3
  import readme from './search_box_by_type.md';
5
4
 
6
- const components = {
7
- GlSearchBoxByType,
8
- };
5
+ const template = `
6
+ <gl-search-box-by-type
7
+ v-model="searchQuery"
8
+ :clear-button-title="clearButtonTitle"
9
+ :disabled="disabled"
10
+ :is-loading="isLoading"
11
+ :placeholder="placeholder"
12
+ />
13
+ `;
14
+
15
+ const defaultValue = (prop) => GlSearchBoxByType.props[prop].default;
9
16
 
10
- function generateProps({
11
- disabled = false,
12
- value = '',
17
+ const generateProps = ({
18
+ clearButtonTitle = defaultValue('clearButtonTitle'),
19
+ disabled = defaultValue('disabled'),
13
20
  placeholder = 'Search',
14
- isLoading = false,
15
- } = {}) {
16
- return {
17
- disabled: {
18
- type: Boolean,
19
- default: boolean('disabled', disabled),
20
- },
21
- value: {
22
- type: String,
23
- default: text('value', value),
24
- },
25
- placeholder: {
26
- type: String,
27
- default: text('placeholder', placeholder),
28
- },
29
- isLoading: {
30
- type: Boolean,
31
- default: boolean('isLoading', isLoading),
32
- },
33
- };
34
- }
21
+ isLoading = defaultValue('isLoading'),
22
+ } = {}) => ({
23
+ clearButtonTitle,
24
+ disabled,
25
+ placeholder,
26
+ isLoading,
27
+ });
28
+
29
+ const Template = (args, { argTypes }) => ({
30
+ components: {
31
+ GlSearchBoxByType,
32
+ },
33
+ props: Object.keys(argTypes),
34
+ data: () => ({ searchQuery: '' }),
35
+ template,
36
+ });
37
+ export const Default = Template.bind({});
38
+ Default.args = generateProps();
35
39
 
36
- documentedStoriesOf('base/search-box-by-type', readme)
37
- .addDecorator(withKnobs)
38
- .add('default', () => ({
39
- props: generateProps(),
40
- components,
41
- template: `
42
- <gl-search-box-by-type
43
- :value="value"
44
- :disabled="disabled"
45
- :is-loading="isLoading"
46
- :placeholder="placeholder"
47
- />
48
- `,
49
- }));
40
+ export default {
41
+ title: 'base/search-box-by-type',
42
+ component: GlSearchBoxByType,
43
+ parameters: {
44
+ knobs: { disable: true },
45
+ bootstrapComponent: 'b-form-input',
46
+ docs: {
47
+ description: {
48
+ component: readme,
49
+ },
50
+ },
51
+ },
52
+ argTypes: {
53
+ ...disableControls(['value']),
54
+ },
55
+ };
@@ -4,11 +4,6 @@ import GlFormInput from '../form/form_input/form_input.vue';
4
4
  import GlIcon from '../icon/icon.vue';
5
5
  import GlLoadingIcon from '../loading_icon/loading_icon.vue';
6
6
 
7
- const model = {
8
- prop: 'value',
9
- event: 'input',
10
- };
11
-
12
7
  export default {
13
8
  components: {
14
9
  GlClearIconButton,
@@ -17,8 +12,14 @@ export default {
17
12
  GlLoadingIcon,
18
13
  },
19
14
  inheritAttrs: false,
20
- model,
15
+ model: {
16
+ prop: 'value',
17
+ event: 'input',
18
+ },
21
19
  props: {
20
+ /**
21
+ * If provided, used as value of search input
22
+ */
22
23
  value: {
23
24
  type: String,
24
25
  required: false,
@@ -29,16 +30,25 @@ export default {
29
30
  required: false,
30
31
  default: 'Clear',
31
32
  },
33
+ /**
34
+ * If provided and true, disables the input and controls
35
+ */
32
36
  disabled: {
33
37
  type: Boolean,
34
38
  required: false,
35
39
  default: false,
36
40
  },
41
+ /**
42
+ * Puts search box into loading state, rendering spinner
43
+ */
37
44
  isLoading: {
38
45
  type: Boolean,
39
46
  required: false,
40
47
  default: false,
41
48
  },
49
+ /**
50
+ * Container for tooltip. Valid values: DOM node, selector string or `false` for default
51
+ */
42
52
  tooltipContainer: {
43
53
  required: false,
44
54
  default: false,
@@ -1,5 +1,3 @@
1
- # Hover Load
2
-
3
1
  A Vue Directive to help with preloading resources when hovering over an element.
4
2
 
5
3
  ## Usage
@@ -1,5 +1,3 @@
1
- import { text } from '@storybook/addon-knobs';
2
- import { documentedStoriesOf } from '../../../documentation/documented_stories';
3
1
  import { GlHoverLoadDirective } from '../../index';
4
2
  import readme from './hover_load.md';
5
3
 
@@ -8,39 +6,46 @@ const directives = {
8
6
  };
9
7
 
10
8
  // eslint-disable-next-line no-script-url
11
- function generateProps({ endpoint = 'some/endpoint' } = {}) {
12
- return {
13
- endpoint: {
14
- type: String,
15
- default: text('endpoint', endpoint),
9
+ const generateProps = ({ endpoint = 'some/endpoint' } = {}) => ({
10
+ endpoint,
11
+ });
12
+
13
+ export const Default = (_args, { argTypes }) => ({
14
+ props: Object.keys(argTypes),
15
+ directives,
16
+ data: () => ({
17
+ isPreloaded: false,
18
+ }),
19
+ methods: {
20
+ handlePreload() {
21
+ fetch(this.endpoint);
22
+ this.isPreloaded = true;
16
23
  },
17
- };
18
- }
24
+ },
25
+ template: `
26
+ <div>
27
+ <a
28
+ :href="endpoint"
29
+ v-gl-hover-load="handlePreload"
30
+ >
31
+ Hover me to preload
32
+ </a>
33
+
34
+ <span>(Preloaded: {{isPreloaded}})</span>
35
+ </div>
36
+ `,
37
+ });
38
+ Default.args = generateProps();
19
39
 
20
- documentedStoriesOf('directives/hover-load-directive', readme)
21
- .addParameters({ storyshots: false })
22
- .add('default', () => ({
23
- props: generateProps(),
24
- directives,
25
- data: () => ({
26
- isPreloaded: false,
27
- }),
28
- methods: {
29
- handlePreload() {
30
- fetch(this.endpoint);
31
- this.isPreloaded = true;
40
+ export default {
41
+ title: 'directives/hover-load-directive',
42
+ component: GlHoverLoadDirective,
43
+ parameters: {
44
+ storyshots: { disable: true },
45
+ docs: {
46
+ description: {
47
+ component: readme,
32
48
  },
33
49
  },
34
- template: `
35
- <div>
36
- <a
37
- :href="endpoint"
38
- v-gl-hover-load="handlePreload"
39
- >
40
- Hover me to preload
41
- </a>
42
-
43
- <span>(Preloaded: {{isPreloaded}})</span>
44
- </div>
45
- `,
46
- }));
50
+ },
51
+ };
@@ -1,8 +1,6 @@
1
- import examples from './examples';
2
1
  import description from './resize_observer.md';
3
2
 
4
3
  export default {
5
4
  followsDesignSystem: false,
6
5
  description,
7
- examples,
8
6
  };
@@ -1,9 +1,3 @@
1
- # Resize Observer
2
-
3
- <!-- STORY -->
4
-
5
- ## Usage
6
-
7
1
  This directive can be used to get notified whenever a given element's size (width or height) changes
8
2
  and to retrieve the updated dimensions.
9
3
 
@@ -1,60 +1,79 @@
1
- import { withKnobs, select } from '@storybook/addon-knobs';
2
- import { documentedStoriesOf } from '../../../documentation/documented_stories';
3
- import { GlResizeObserverDirective } from '../../index';
1
+ import { GlResizeObserverDirective as GlResizeObserver } from '../../index';
4
2
  import readme from './resize_observer.md';
5
3
 
6
- documentedStoriesOf('directives/resize-observer-directive', readme)
7
- .addParameters({ storyshots: false })
8
- .addDecorator(withKnobs)
9
- .add('default', () => ({
10
- props: {
11
- elementWidth: {
12
- default: select('elementWidth', ['100%', '75%', '50%'], '100%'),
13
- },
14
- elementHeight: {
15
- default: select('elementHeight', ['100%', '75%', '50%'], '100%'),
16
- },
17
- },
18
- directives: {
19
- 'gl-resize-observer': GlResizeObserverDirective,
20
- },
21
- data() {
4
+ const generateProps = ({ elementWidth = '100%', elementHeight = '100%' } = {}) => ({
5
+ elementWidth,
6
+ elementHeight,
7
+ });
8
+
9
+ export const Default = (args, { argTypes }) => ({
10
+ props: Object.keys(argTypes),
11
+ directives: {
12
+ GlResizeObserver,
13
+ },
14
+ data() {
15
+ return {
16
+ width: 0,
17
+ height: 0,
18
+ };
19
+ },
20
+ computed: {
21
+ wrapperStyles() {
22
22
  return {
23
- width: 0,
24
- height: 0,
23
+ height: '400px',
25
24
  };
26
25
  },
27
- computed: {
28
- wrapperStyles() {
29
- return {
30
- height: '400px',
31
- };
32
- },
33
- elementStyles() {
34
- return {
35
- height: this.elementHeight,
36
- width: this.elementWidth,
37
- };
38
- },
26
+ elementStyles() {
27
+ return {
28
+ height: this.elementHeight,
29
+ width: this.elementWidth,
30
+ };
39
31
  },
40
- methods: {
41
- handleResize({ contentRect: { width, height } }) {
42
- this.width = Math.round(width);
43
- this.height = Math.round(height);
44
- },
32
+ },
33
+ methods: {
34
+ handleResize({ contentRect: { width, height } }) {
35
+ this.width = Math.round(width);
36
+ this.height = Math.round(height);
45
37
  },
46
- template: `
38
+ },
39
+ template: `
40
+ <div
41
+ :style="wrapperStyles"
42
+ class="d-flex justify-content-center align-items-center">
47
43
  <div
48
- :style="wrapperStyles"
49
- class="d-flex justify-content-center align-items-center">
50
- <div
51
- v-gl-resize-observer="handleResize"
52
- :style="elementStyles"
53
- class="d-flex position-relative justify-content-center align-items-center bg-light text-dark">
54
- <span class="d-inline-block p-2">
55
- I am {{ width }}px wide and {{ height }}px high.
56
- </span>
57
- </div>
44
+ v-gl-resize-observer="handleResize"
45
+ :style="elementStyles"
46
+ class="d-flex position-relative justify-content-center align-items-center bg-light text-dark">
47
+ <span class="d-inline-block p-2">
48
+ I am {{ width }}px wide and {{ height }}px high.
49
+ </span>
58
50
  </div>
59
- `,
60
- }));
51
+ </div>
52
+ `,
53
+ });
54
+ Default.args = generateProps();
55
+
56
+ const makeControl = () => ({
57
+ options: ['100%', '75%', '50%'],
58
+ control: {
59
+ type: 'select',
60
+ },
61
+ });
62
+
63
+ export default {
64
+ title: 'directives/resize-observer-directive',
65
+ component: GlResizeObserver,
66
+ parameters: {
67
+ knobs: { disable: true },
68
+ storyshots: { disable: true },
69
+ docs: {
70
+ description: {
71
+ component: readme,
72
+ },
73
+ },
74
+ },
75
+ argTypes: {
76
+ elementWidth: makeControl(),
77
+ elementHeight: makeControl(),
78
+ },
79
+ };
@@ -1,9 +1,5 @@
1
- # Safe Html
2
-
3
1
  A Vue Directive to sanitize HTML to avoid any XSS vulnerabilities.
4
2
 
5
- <!-- STORY -->
6
-
7
3
  ## Usage
8
4
 
9
5
  This directive can be used to sanitize HTML code which may contain user input, to prevent cross-site
@@ -1,50 +1,59 @@
1
- import { withKnobs, text } from '@storybook/addon-knobs';
2
1
  import { sanitize } from 'dompurify';
3
- import { escape } from 'lodash';
4
- import { documentedStoriesOf } from '../../../documentation/documented_stories';
5
- import { GlSafeHtmlDirective } from '../../index';
2
+ import { GlSafeHtmlDirective as GlSafeHtml } from '../../index';
6
3
  import readme from './safe_html.md';
7
4
 
8
- documentedStoriesOf('directives/safe-html-directive', readme)
9
- .addDecorator(withKnobs)
10
- .addParameters({ storyshots: false, knobs: { escapeHTML: false } })
11
- .add('default', () => ({
12
- directives: {
13
- 'gl-safe-html': GlSafeHtmlDirective,
14
- },
15
- props: {
16
- unsafeHTML: {
17
- type: String,
18
- default: text('Unsafe HTML', '<a href="javascript:alert(document.domain)">Click me</a>'),
19
- },
5
+ const generateProps = ({
6
+ unsafeHTML = '<a href="javascript:alert(document.domain)">Click me</a>',
7
+ } = {}) => ({
8
+ unsafeHTML,
9
+ });
10
+
11
+ export const Default = (_args, { argTypes }) => ({
12
+ directives: {
13
+ GlSafeHtml,
14
+ },
15
+ props: Object.keys(argTypes),
16
+ computed: {
17
+ sanitizedHtml() {
18
+ return sanitize(this.unsafeHTML);
20
19
  },
21
- computed: {
22
- sanitizedHtml() {
23
- return sanitize(this.unsafeHTML);
20
+ },
21
+ template: `
22
+ <table class="gl-table">
23
+ <thead>
24
+ <tr>
25
+ <th>Directive</th>
26
+ <th>Output</th>
27
+ <th>Rendered</th>
28
+ </tr>
29
+ </thead>
30
+ <tbody>
31
+ <tr>
32
+ <td><strong>v-html</strong></td>
33
+ <td><code>{{ unsafeHTML }}</code></td>
34
+ <td>N/A for security reasons</td>
35
+ </tr>
36
+ <tr>
37
+ <td><strong>v-safe-html</strong></td>
38
+ <td><code>{{ sanitizedHtml }}</code></td>
39
+ <td v-gl-safe-html="unsafeHTML"></td>
40
+ </tr>
41
+ </tbody>
42
+ </table>
43
+ `,
44
+ });
45
+ Default.args = generateProps();
46
+
47
+ export default {
48
+ title: 'directives/safe-html-directive',
49
+ component: GlSafeHtml,
50
+ parameters: {
51
+ storyshots: { disable: true },
52
+ knobs: { disable: true },
53
+ docs: {
54
+ description: {
55
+ component: readme,
24
56
  },
25
57
  },
26
- escape,
27
- template: `
28
- <table class="gl-table">
29
- <thead>
30
- <tr>
31
- <th>Directive</th>
32
- <th>Output</th>
33
- <th>Rendered</th>
34
- </tr>
35
- </thead>
36
- <tbody>
37
- <tr>
38
- <td><strong>v-html</strong></td>
39
- <td><code v-html="$options.escape(unsafeHTML)"></code></td>
40
- <td>N/A for security reasons</td>
41
- </tr>
42
- <tr>
43
- <td><strong>v-safe-html</strong></td>
44
- <td><code v-html="$options.escape(sanitizedHtml)"></code></td>
45
- <td v-gl-safe-html="unsafeHTML"></td>
46
- </tr>
47
- </tbody>
48
- </table>
49
- `,
50
- }));
58
+ },
59
+ };