@rancher/shell 1.2.1 → 1.2.3

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 (56) hide show
  1. package/package.json +1 -1
  2. package/rancher-components/BadgeState/BadgeState.vue +3 -3
  3. package/rancher-components/Banner/Banner.test.ts +5 -1
  4. package/rancher-components/Banner/Banner.vue +2 -2
  5. package/rancher-components/Card/Card.vue +4 -4
  6. package/rancher-components/Form/Checkbox/Checkbox.vue +3 -4
  7. package/rancher-components/Form/LabeledInput/LabeledInput.test.ts +1 -18
  8. package/rancher-components/Form/LabeledInput/LabeledInput.vue +37 -65
  9. package/rancher-components/Form/Radio/RadioButton.test.ts +3 -1
  10. package/rancher-components/Form/Radio/RadioButton.vue +7 -13
  11. package/rancher-components/Form/Radio/RadioGroup.vue +3 -4
  12. package/rancher-components/Form/TextArea/TextAreaAutoGrow.vue +4 -6
  13. package/rancher-components/Form/ToggleSwitch/ToggleSwitch.vue +4 -7
  14. package/rancher-components/LabeledTooltip/LabeledTooltip.vue +4 -9
  15. package/rancher-components/StringList/StringList.test.ts +0 -270
  16. package/rancher-components/StringList/StringList.vue +26 -65
  17. package/scripts/publish-shell.sh +1 -0
  18. package/rancher-components/Accordion/Accordion.test.ts +0 -45
  19. package/rancher-components/Accordion/Accordion.vue +0 -86
  20. package/rancher-components/Accordion/index.ts +0 -1
  21. package/rancher-components/BadgeState/BadgeState.test.ts +0 -12
  22. package/rancher-components/components/Accordion/Accordion.test.ts +0 -45
  23. package/rancher-components/components/Accordion/Accordion.vue +0 -86
  24. package/rancher-components/components/Accordion/index.ts +0 -1
  25. package/rancher-components/components/BadgeState/BadgeState.test.ts +0 -12
  26. package/rancher-components/components/BadgeState/BadgeState.vue +0 -111
  27. package/rancher-components/components/BadgeState/index.ts +0 -1
  28. package/rancher-components/components/Banner/Banner.test.ts +0 -63
  29. package/rancher-components/components/Banner/Banner.vue +0 -244
  30. package/rancher-components/components/Banner/index.ts +0 -1
  31. package/rancher-components/components/Card/Card.test.ts +0 -37
  32. package/rancher-components/components/Card/Card.vue +0 -167
  33. package/rancher-components/components/Card/index.ts +0 -1
  34. package/rancher-components/components/Form/Checkbox/Checkbox.test.ts +0 -68
  35. package/rancher-components/components/Form/Checkbox/Checkbox.vue +0 -420
  36. package/rancher-components/components/Form/Checkbox/index.ts +0 -1
  37. package/rancher-components/components/Form/LabeledInput/LabeledInput.test.ts +0 -23
  38. package/rancher-components/components/Form/LabeledInput/LabeledInput.vue +0 -369
  39. package/rancher-components/components/Form/LabeledInput/index.ts +0 -1
  40. package/rancher-components/components/Form/Radio/RadioButton.test.ts +0 -35
  41. package/rancher-components/components/Form/Radio/RadioButton.vue +0 -287
  42. package/rancher-components/components/Form/Radio/RadioGroup.test.ts +0 -30
  43. package/rancher-components/components/Form/Radio/RadioGroup.vue +0 -258
  44. package/rancher-components/components/Form/Radio/index.ts +0 -2
  45. package/rancher-components/components/Form/TextArea/TextAreaAutoGrow.vue +0 -170
  46. package/rancher-components/components/Form/TextArea/index.ts +0 -1
  47. package/rancher-components/components/Form/ToggleSwitch/ToggleSwitch.test.ts +0 -94
  48. package/rancher-components/components/Form/ToggleSwitch/ToggleSwitch.vue +0 -149
  49. package/rancher-components/components/Form/ToggleSwitch/index.ts +0 -1
  50. package/rancher-components/components/Form/index.ts +0 -5
  51. package/rancher-components/components/LabeledTooltip/LabeledTooltip.vue +0 -151
  52. package/rancher-components/components/LabeledTooltip/index.ts +0 -1
  53. package/rancher-components/components/StringList/StringList.test.ts +0 -484
  54. package/rancher-components/components/StringList/StringList.vue +0 -611
  55. package/rancher-components/components/StringList/index.ts +0 -1
  56. /package/rancher-components/{components/BadgeState → BadgeState}/BadgeState.spec.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rancher/shell",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "Rancher Dashboard Shell",
5
5
  "repository": "https://github.com/rancherlabs/dashboard",
6
6
  "license": "Apache-2.0",
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { PropType, defineComponent } from 'vue';
2
+ import Vue, { PropType } from 'vue';
3
3
 
4
4
  interface Badge {
5
5
  stateBackground: string;
@@ -11,7 +11,7 @@ interface Badge {
11
11
  * <p>Represents a badge whose label and color is either taken from the value property or
12
12
  * from the label and color properties. The state property takes precedence.</p>
13
13
  */
14
- export default defineComponent({
14
+ export default Vue.extend({
15
15
  props: {
16
16
  /**
17
17
  * A value having the properties `stateBackground` and `stateDisplay`
@@ -59,7 +59,7 @@ export default defineComponent({
59
59
  </script>
60
60
 
61
61
  <template>
62
- <span :class="['badge-state', bg]">
62
+ <span :class="{'badge-state': true, [bg]: true}">
63
63
  <i
64
64
  v-if="icon"
65
65
  class="icon"
@@ -1,12 +1,16 @@
1
1
  import { mount } from '@vue/test-utils';
2
2
  import { Banner } from './index';
3
+ import { cleanHtmlDirective } from '@shell/plugins/clean-html-directive';
3
4
 
4
5
  describe('component: Banner', () => {
5
6
  it('should display text based on label', () => {
6
7
  const label = 'test';
7
8
  const wrapper = mount(
8
9
  Banner,
9
- { propsData: { label } });
10
+ {
11
+ directives: { cleanHtmlDirective },
12
+ propsData: { label }
13
+ });
10
14
 
11
15
  const element = wrapper.find('span').element;
12
16
 
@@ -1,9 +1,9 @@
1
1
  <script lang="ts">
2
- import { defineComponent } from 'vue';
2
+ import Vue from 'vue';
3
3
  import { nlToBr } from '@shell/utils/string';
4
4
  import { stringify } from '@shell/utils/error';
5
5
 
6
- export default defineComponent({
6
+ export default Vue.extend({
7
7
  props: {
8
8
  /**
9
9
  * A color class that represents the color of the banner.
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
- import { defineComponent, PropType } from 'vue';
2
+ import Vue from 'vue';
3
3
 
4
- export default defineComponent({
4
+ export default Vue.extend({
5
5
  name: 'Card',
6
6
  props: {
7
7
  /**
@@ -22,7 +22,7 @@ export default defineComponent({
22
22
  * The function to invoke when the default action button is clicked.
23
23
  */
24
24
  buttonAction: {
25
- type: Function as PropType<(event: MouseEvent) => void>,
25
+ type: Function,
26
26
  default: (): void => { }
27
27
  },
28
28
  /**
@@ -151,7 +151,7 @@ export default defineComponent({
151
151
 
152
152
  .card-body {
153
153
  justify-content: flex-start;
154
- overflow: auto;
154
+ overflow: scroll;
155
155
  }
156
156
 
157
157
  > * {
@@ -1,10 +1,10 @@
1
1
  <script lang="ts">
2
- import { PropType, defineComponent } from 'vue';
2
+ import Vue, { PropType } from 'vue';
3
3
  import { _EDIT, _VIEW } from '@shell/config/query-params';
4
4
  import { addObject, removeObject } from '@shell/utils/array';
5
5
  import cloneDeep from 'lodash/cloneDeep';
6
6
 
7
- export default defineComponent({
7
+ export default Vue.extend({
8
8
  name: 'Checkbox',
9
9
 
10
10
  props: {
@@ -140,7 +140,7 @@ export default defineComponent({
140
140
  /**
141
141
  * Toggles the checked state for the checkbox and emits an 'input' event.
142
142
  */
143
- clicked(event: MouseEvent | KeyboardEvent): boolean | void {
143
+ clicked(event: MouseEvent): boolean | void {
144
144
  if ((event.target as HTMLLinkElement).tagName === 'A' && (event.target as HTMLLinkElement).href) {
145
145
  // Ignore links inside the checkbox label so you can click them
146
146
  return true;
@@ -325,7 +325,6 @@ $fontColor: var(--input-label);
325
325
  border-radius: var(--border-radius);
326
326
  transition: all 0.3s ease-out;
327
327
  border: 1px solid var(--border);
328
- flex-shrink: 0;
329
328
  }
330
329
 
331
330
  input {
@@ -1,3 +1,4 @@
1
+
1
2
  import { mount } from '@vue/test-utils';
2
3
  import { LabeledInput } from './index';
3
4
 
@@ -19,22 +20,4 @@ describe('component: LabeledInput', () => {
19
20
  expect(wrapper.emitted('input')).toHaveLength(1);
20
21
  expect(wrapper.emitted('input')![0][0]).toBe(value);
21
22
  });
22
-
23
- it('using mode "multiline" should emit input value correctly', () => {
24
- const value = 'any-string';
25
- const delay = 1;
26
- const wrapper = mount(LabeledInput as any, {
27
- propsData: { delay, multiline: true },
28
- mocks: { $store: { getters: { 'i18n/t': jest.fn() } } }
29
- });
30
-
31
- jest.useFakeTimers();
32
- wrapper.find('input').setValue('1');
33
- wrapper.find('input').setValue(value);
34
- jest.advanceTimersByTime(delay);
35
- jest.useRealTimers();
36
-
37
- expect(wrapper.emitted('input')).toHaveLength(1);
38
- expect(wrapper.emitted('input')![0][0]).toBe(value);
39
- });
40
23
  });
@@ -1,27 +1,21 @@
1
1
  <script lang="ts">
2
- import { defineComponent } from 'vue';
2
+ import Vue, { VueConstructor } from 'vue';
3
+ import CompactInput from '@shell/mixins/compact-input';
4
+ import LabeledFormElement from '@shell/mixins/labeled-form-element';
3
5
  import TextAreaAutoGrow from '@components/Form/TextArea/TextAreaAutoGrow.vue';
4
6
  import LabeledTooltip from '@components/LabeledTooltip/LabeledTooltip.vue';
5
7
  import { escapeHtml } from '@shell/utils/string';
6
8
  import cronstrue from 'cronstrue';
7
9
  import { isValidCron } from 'cron-validator';
8
10
  import { debounce } from 'lodash';
9
- import { useLabeledFormElement, labeledFormElementProps } from '@shell/composables/useLabeledFormElement';
10
- import { useCompactInput } from '@shell/composables/useCompactInput';
11
11
 
12
- declare module 'vue/types/vue' {
13
- interface Vue {
14
- onInput: (event: Event) => void | ((event: Event) => void);
15
- }
16
- }
17
-
18
- export default defineComponent({
12
+ export default (
13
+ Vue as VueConstructor<Vue & InstanceType<typeof LabeledFormElement> & InstanceType<typeof CompactInput>>
14
+ ).extend({
19
15
  components: { LabeledTooltip, TextAreaAutoGrow },
20
-
21
- inheritAttrs: false,
16
+ mixins: [LabeledFormElement, CompactInput],
22
17
 
23
18
  props: {
24
- ...labeledFormElementProps,
25
19
  /**
26
20
  * The type of the Labeled Input.
27
21
  * @values text, cron, multiline, multiline-password
@@ -96,39 +90,24 @@ export default defineComponent({
96
90
  delay: {
97
91
  type: Number,
98
92
  default: 0
99
- },
100
- },
101
-
102
- setup(props, { emit }) {
103
- const {
104
- focused,
105
- onFocusLabeled,
106
- onBlurLabeled,
107
- isDisabled,
108
- validationMessage,
109
- requiredField
110
- } = useLabeledFormElement(props, emit);
111
- const { isCompact } = useCompactInput(props);
112
-
113
- return {
114
- focused,
115
- onFocusLabeled,
116
- onBlurLabeled,
117
- isDisabled,
118
- validationMessage,
119
- requiredField,
120
- isCompact,
121
- };
93
+ }
122
94
  },
123
95
 
124
96
  data() {
125
97
  return {
126
98
  updated: false,
127
- validationErrors: '',
99
+ validationErrors: ''
128
100
  };
129
101
  },
130
102
 
131
103
  computed: {
104
+ /**
105
+ * Determines if the Labeled Input @input event should be debounced.
106
+ */
107
+ onInput(): ((value: string) => void) | void {
108
+ return this.delay ? debounce(this.delayInput, this.delay) : this.delayInput;
109
+ },
110
+
132
111
  /**
133
112
  * Determines if the Labeled Input should display a label.
134
113
  */
@@ -143,7 +122,7 @@ export default defineComponent({
143
122
  return !!this.tooltip || !!this.tooltipKey;
144
123
  },
145
124
 
146
- tooltipValue(): string | Record<string, unknown> | undefined {
125
+ tooltipValue(): string | undefined {
147
126
  if (this.hasTooltip) {
148
127
  return this.tooltipKey ? this.t(this.tooltipKey) : this.tooltip;
149
128
  }
@@ -165,7 +144,7 @@ export default defineComponent({
165
144
  if (this.type !== 'cron' || !this.value) {
166
145
  return;
167
146
  }
168
- if (typeof this.value === 'string' && !isValidCron(this.value)) {
147
+ if (!isValidCron(this.value)) {
169
148
  return this.t('generic.invalidCron');
170
149
  }
171
150
  try {
@@ -194,22 +173,15 @@ export default defineComponent({
194
173
  /**
195
174
  * The max length for the Labeled Input.
196
175
  */
197
- _maxlength(): number | undefined {
176
+ _maxlength(): number | null {
198
177
  if (this.type === 'text' && this.maxlength) {
199
178
  return this.maxlength;
200
179
  }
201
180
 
202
- return undefined;
181
+ return null;
203
182
  },
204
183
  },
205
184
 
206
- created() {
207
- /**
208
- * Determines if the Labeled Input @input event should be debounced.
209
- */
210
- this.onInput = this.delay ? debounce(this.delayInput, this.delay) : this.delayInput;
211
- },
212
-
213
185
  methods: {
214
186
  /**
215
187
  * Attempts to give the Labeled Input focus.
@@ -244,13 +216,8 @@ export default defineComponent({
244
216
  /**
245
217
  * Emit on input with delay. Note: Arrow function is avoided due context
246
218
  * binding.
247
- *
248
- * NOTE: In multiline, TextAreaAutoGrow emits a string with the value
249
- * https://github.com/rancher/dashboard/issues/10249
250
219
  */
251
- delayInput(val: string | Event): void {
252
- const value = typeof val === 'string' ? val : (val?.target as HTMLInputElement)?.value;
253
-
220
+ delayInput(value: string): void {
254
221
  this.$emit('input', value);
255
222
  },
256
223
 
@@ -267,7 +234,7 @@ export default defineComponent({
267
234
  * event.
268
235
  * @see labeled-form-element.ts mixin for onBlurLabeled()
269
236
  */
270
- onBlur(event: string | FocusEvent): void {
237
+ onBlur(event: string): void {
271
238
  this.$emit('blur', event);
272
239
  this.onBlurLabeled();
273
240
  },
@@ -319,7 +286,7 @@ export default defineComponent({
319
286
  :placeholder="_placeholder"
320
287
  autocapitalize="off"
321
288
  :class="{ conceal: type === 'multiline-password' }"
322
- @input="onInput"
289
+ @input="onInput($event)"
323
290
  @focus="onFocus"
324
291
  @blur="onBlur"
325
292
  />
@@ -336,7 +303,7 @@ export default defineComponent({
336
303
  autocomplete="off"
337
304
  autocapitalize="off"
338
305
  :data-lpignore="ignorePasswordManagers"
339
- @input="onInput"
306
+ @input="onInput($event.target.value)"
340
307
  @focus="onFocus"
341
308
  @blur="onBlur"
342
309
  @change="onChange"
@@ -355,15 +322,20 @@ export default defineComponent({
355
322
  :hover="hoverTooltip"
356
323
  :value="validationMessage"
357
324
  />
358
- <label
359
- v-if="cronHint"
360
- class="cron-label"
361
- >{{ cronHint }}</label>
362
- <label
363
- v-if="subLabel"
364
- v-clean-html="subLabel"
325
+ <div
326
+ v-if="cronHint || subLabel"
365
327
  class="sub-label"
366
- />
328
+ >
329
+ <div
330
+ v-if="cronHint"
331
+ >
332
+ {{ cronHint }}
333
+ </div>
334
+ <div
335
+ v-if="subLabel"
336
+ v-clean-html="subLabel"
337
+ />
338
+ </div>
367
339
  </div>
368
340
  </template>
369
341
  <style scoped lang="scss">
@@ -1,5 +1,6 @@
1
1
  import { shallowMount } from '@vue/test-utils';
2
2
  import { RadioButton } from './index';
3
+ import { cleanHtmlDirective } from '@shell/plugins/clean-html-directive';
3
4
 
4
5
  describe('radioButton.vue', () => {
5
6
  it('renders label slot contents', () => {
@@ -12,7 +13,8 @@ describe('radioButton.vue', () => {
12
13
  const wrapper = shallowMount(
13
14
  RadioButton,
14
15
  {
15
- propsData: {
16
+ directives: { cleanHtmlDirective },
17
+ propsData: {
16
18
  label: 'Test Label', val: {}, value: {}
17
19
  }
18
20
  });
@@ -1,9 +1,8 @@
1
1
  <script lang="ts">
2
- import { defineComponent } from 'vue';
2
+ import Vue from 'vue';
3
3
  import { _VIEW } from '@shell/config/query-params';
4
- import { randomStr } from '@shell/utils/string';
5
4
 
6
- export default defineComponent({
5
+ export default Vue.extend({
7
6
  props: {
8
7
  /**
9
8
  * The name of the input, for grouping.
@@ -72,10 +71,7 @@ export default defineComponent({
72
71
  },
73
72
 
74
73
  data() {
75
- return {
76
- isChecked: this.value === this.val,
77
- randomString: `${ randomStr() }-radio`,
78
- };
74
+ return { isChecked: this.value === this.val };
79
75
  },
80
76
 
81
77
  computed: {
@@ -119,15 +115,13 @@ export default defineComponent({
119
115
  /**
120
116
  * Emits the input event.
121
117
  */
122
- clicked(event: MouseEvent | KeyboardEvent) {
123
- const target = event.target;
124
-
125
- if (this.isDisabled || (target instanceof HTMLElement && target.tagName === 'A')) {
118
+ clicked({ target }: { target?: HTMLElement }) {
119
+ if (this.isDisabled || target?.tagName === 'A') {
126
120
  return;
127
121
  }
128
122
 
129
123
  this.$emit('input', this.val);
130
- },
124
+ }
131
125
  }
132
126
  });
133
127
  </script>
@@ -140,7 +134,7 @@ export default defineComponent({
140
134
  @click.stop="clicked($event)"
141
135
  >
142
136
  <input
143
- :id="randomString"
137
+ :id="_uid+'-radio'"
144
138
  :disabled="isDisabled"
145
139
  :name="name"
146
140
  :value="''+val"
@@ -1,15 +1,14 @@
1
1
  <script lang="ts">
2
- import { PropType, defineComponent } from 'vue';
2
+ import Vue, { PropType } from 'vue';
3
3
  import { _VIEW } from '@shell/config/query-params';
4
4
  import RadioButton from '@components/Form/Radio/RadioButton.vue';
5
5
 
6
6
  interface Option {
7
7
  value: unknown,
8
- label: string,
9
- description?: string,
8
+ label: string
10
9
  }
11
10
 
12
- export default defineComponent({
11
+ export default Vue.extend({
13
12
  components: { RadioButton },
14
13
  props: {
15
14
  /**
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { defineComponent } from 'vue';
2
+ import Vue from 'vue';
3
3
  import debounce from 'lodash/debounce';
4
4
  import { _EDIT, _VIEW } from '@shell/config/query-params';
5
5
 
@@ -10,7 +10,7 @@ declare module 'vue/types/vue' {
10
10
  }
11
11
  }
12
12
 
13
- export default defineComponent({
13
+ export default Vue.extend({
14
14
  inheritAttrs: false,
15
15
 
16
16
  props: {
@@ -115,9 +115,7 @@ export default defineComponent({
115
115
  /**
116
116
  * Emits the input event and resizes the Text Area.
117
117
  */
118
- onInput(event: Event): void {
119
- const val = (event?.target as HTMLInputElement)?.value;
120
-
118
+ onInput(val: string): void {
121
119
  this.$emit('input', val);
122
120
  this.queueResize();
123
121
  },
@@ -165,7 +163,7 @@ export default defineComponent({
165
163
  v-bind="$attrs"
166
164
  :spellcheck="spellcheck"
167
165
  @paste="$emit('paste', $event)"
168
- @input="onInput($event)"
166
+ @input="onInput($event.target.value)"
169
167
  @focus="$emit('focus', $event)"
170
168
  @blur="$emit('blur', $event)"
171
169
  />
@@ -1,9 +1,6 @@
1
1
  <script lang="ts">
2
- import { defineComponent } from 'vue';
3
-
4
- type StateType = boolean | 'true' | 'false' | undefined;
5
-
6
- export default defineComponent({
2
+ import Vue from 'vue';
3
+ export default Vue.extend({
7
4
  props: {
8
5
  value: {
9
6
  type: [Boolean, String, Number],
@@ -31,7 +28,7 @@ export default defineComponent({
31
28
  },
32
29
  },
33
30
  data() {
34
- return { state: false as StateType };
31
+ return { state: false as boolean | string | number };
35
32
  },
36
33
 
37
34
  watch: {
@@ -44,7 +41,7 @@ export default defineComponent({
44
41
  },
45
42
 
46
43
  methods: {
47
- toggle(neu: StateType | null) {
44
+ toggle(neu: boolean | string | number) {
48
45
  this.state = neu === null ? !this.state : neu;
49
46
  this.$emit('input', this.state ? this.onValue : this.offValue);
50
47
  }
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
- import { defineComponent } from 'vue';
2
+ import Vue from 'vue';
3
3
 
4
- export default defineComponent({
4
+ export default Vue.extend({
5
5
  props: {
6
6
  /**
7
7
  * The Labeled Tooltip value.
@@ -29,14 +29,9 @@ export default defineComponent({
29
29
  }
30
30
  },
31
31
  computed: {
32
- iconClass(): string {
32
+ iconClass() {
33
33
  return this.status === 'error' ? 'icon-warning' : 'icon-info';
34
34
  }
35
- },
36
- methods: {
37
- isObject(value: string | Record<string, unknown>): value is Record<string, unknown> {
38
- return typeof value === 'object' && value !== null && !!value.content;
39
- }
40
35
  }
41
36
  });
42
37
  </script>
@@ -49,7 +44,7 @@ export default defineComponent({
49
44
  >
50
45
  <template v-if="hover">
51
46
  <i
52
- v-clean-tooltip="isObject(value) ? { ...{content: value.content, classes: [`tooltip-${status}`]}, ...value } : value"
47
+ v-clean-tooltip="value.content ? { ...{content: value.content, classes: [`tooltip-${status}`]}, ...value } : value"
53
48
  :class="{'hover':!value, [iconClass]: true}"
54
49
  class="icon status-icon"
55
50
  />