@itfin/components 1.0.44 → 1.0.48

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itfin/components",
3
- "version": "1.0.44",
3
+ "version": "1.0.48",
4
4
 
5
5
  "main": "dist/itfin-components.umd.js",
6
6
  "unpkg": "dist/itfin-components.common.js",
@@ -1,9 +1,11 @@
1
1
  <template>
2
2
 
3
3
  <div class="alert d-flex gap-2" :class="`alert-${type}`" role="alert">
4
- <itf-icon :name="iconName" size="36" />
4
+ <itf-icon :name="iconName" size="24" />
5
5
 
6
- <span v-html="message"></span>
6
+ <slot>
7
+ <span v-html="message"></span>
8
+ </slot>
7
9
  </div>
8
10
 
9
11
  </template>
@@ -10,6 +10,8 @@
10
10
  :class="className"
11
11
  :type="type"
12
12
  :content="message"
13
+ :button="button"
14
+ :on-click="onClick"
13
15
  :closable="showClose"
14
16
  :is-collapsed="isCollapsed"
15
17
  @close="close"
@@ -85,8 +87,10 @@ class itfToastContainer extends Vue {
85
87
  width: '',
86
88
  className: '',
87
89
  wrapperClassName: '',
90
+ button: '',
88
91
  supportHTML: false,
89
92
  onClose: null,
93
+ onClick: null,
90
94
  timer: null,
91
95
  closed: false
92
96
  };
@@ -14,11 +14,12 @@
14
14
  <button type="button" class="btn-close" :class="{'btn-close-white': type}" data-bs-dismiss="toast" aria-label="Close" @click="close"></button>
15
15
  </div>
16
16
  <div class="d-flex" v-if="!collapsed">
17
- <div class="toast-body">
17
+ <div class="toast-body flex-shrink-1">
18
18
  <div v-if="supportHtml" v-html="content">
19
19
  <slot />
20
20
  </div>
21
21
  <slot v-else>{{ content }}</slot>
22
+ <itf-button small primary block v-if="button" @click="onClick" class="mt-3">{{button}}</itf-button>
22
23
  </div>
23
24
  <div class="me-2 m-auto" v-if="!title && !$slots.title">
24
25
  <button type="button" class="btn-close" :class="{'btn-close-white': type}" data-bs-dismiss="toast" aria-label="Close" @click="close"></button>
@@ -35,10 +36,12 @@
35
36
  </style>
36
37
  <script>
37
38
  import { Vue, Component, Prop, Emit } from 'vue-property-decorator';
39
+ import itfButton from '../button/Button';
38
40
 
39
41
  export default @Component({
40
42
  name: 'itfToastMessage',
41
43
  components: {
44
+ itfButton
42
45
  }
43
46
  })
44
47
  class itfToastMessage extends Vue {
@@ -47,6 +50,8 @@ class itfToastMessage extends Vue {
47
50
  @Prop(Boolean) closable;
48
51
  @Prop(String) title;
49
52
  @Prop(String) content;
53
+ @Prop(String) button;
54
+ @Prop(Function) onClick;
50
55
 
51
56
  @Prop(Boolean) supportHtml;
52
57
  @Prop({ type: Boolean, default: true }) isCollapsed;
@@ -26,7 +26,7 @@ storiesOf('Common', module)
26
26
 
27
27
  <button @click="$showSuccess('Success')">Show success</button>
28
28
  <button @click="$showError('Error')">Show error</button>
29
- <button @click="$showMessage({ title: 'Cool title', message: 'This is the test message' })">Test message</button>
29
+ <button @click="$showMessage({ title: 'New version released', message: 'Pss... Hey, we have released a new version of ITFin! Please refresh the page to reach out to new features.', button: 'Refresh', onClick: () => location.reload() })">Test message</button>
30
30
  <button @click="$try(() => { throw new Error('Invalid function'); })">Try function with error</button>
31
31
 
32
32
  </itf-app>
@@ -20,7 +20,7 @@ const Message = function (options) {
20
20
  'is-' + position,
21
21
  hasMask ? 'has-mask' : ''
22
22
  ].filter(function (e) { return !!e; }).join(' ');
23
- document.body.appendChild(containerEl);
23
+ document.getElementById('itf-app').appendChild(containerEl);
24
24
  }
25
25
 
26
26
  if (options.zIndex) {
@@ -33,6 +33,7 @@ const Message = function (options) {
33
33
  };
34
34
 
35
35
  const instance = new MessageConstructor({
36
+ parent: document.getElementById('itf-app').__vue__,
36
37
  el: document.createElement('div'),
37
38
  data: options
38
39
  });
@@ -8,6 +8,7 @@
8
8
  type="button"
9
9
  :tag="isLink ? 'a' : 'button'"
10
10
  :href="href"
11
+ :event="isLink ? 'click' : []"
11
12
  :to="to || {}"
12
13
  :target="target"
13
14
  :class="{
@@ -196,8 +196,8 @@
196
196
  &__dropdown-menu {
197
197
  background-color: $body-bg;
198
198
  border: 2px solid $input-focus-border;
199
- padding-left: 0.125rem;
200
- padding-right: 0.125rem;
199
+ padding-left: 0.125rem !important;
200
+ padding-right: 0.125rem !important;
201
201
  left: -2px;
202
202
  right: -2px;
203
203
  width: auto;
@@ -729,7 +729,7 @@ export default {
729
729
  _value: [], // Internal value managed by Vue Select if no `value` prop is passed
730
730
  }
731
731
  },
732
- inject: { itemLabel: { default: null } },
732
+ inject: { itemLabel: { default: null }, appendContext: { default: null } },
733
733
  computed: {
734
734
  /**
735
735
  * Determine if the component needs to
@@ -18,6 +18,7 @@
18
18
  :disabled="disabled"
19
19
  :readonly="readonly"
20
20
  @input="onInput($event.target.value)"
21
+ @keydown="$emit('keydown', $event)"
21
22
  />
22
23
 
23
24
  <div class="addon-end" v-if="clearable && value">
@@ -17,6 +17,7 @@
17
17
  class="itf-textarea__input form-control"
18
18
  :value="value"
19
19
  @input="onInput($event.target.value)"
20
+ @keydown="$emit('keydown', $event)"
20
21
  />
21
22
  </div>
22
23
 
@@ -1,23 +1,40 @@
1
1
  export default {
2
2
  inserted(el, bindings, { context }) {
3
3
  if (context.appendToBody) {
4
- const {
4
+ let {
5
5
  height,
6
6
  top,
7
7
  left,
8
8
  width,
9
- } = context.$refs.toggle.getBoundingClientRect()
9
+ } = context.$refs.toggle.getBoundingClientRect();
10
10
 
11
- let scrollX = window.scrollX || window.pageXOffset
12
- let scrollY = window.scrollY || window.pageYOffset
11
+ const { calculatePosition } = context;
12
+ const { appendContext } = context;
13
+ const rootEl = appendContext && appendContext();
14
+ if (rootEl) {
15
+ let {
16
+ top: parentTop,
17
+ left: parentLeft
18
+ } = rootEl.getBoundingClientRect();
19
+ left -= parentLeft + rootEl.scrollLeft;
20
+ top -= parentTop + rootEl.scrollTop;
21
+ } else {
22
+ let scrollX = window.scrollX || window.pageXOffset
23
+ let scrollY = window.scrollY || window.pageYOffset
13
24
 
14
- el.unbindPosition = context.calculatePosition(el, context, {
15
- width: width + 'px',
16
- left: scrollX + left + 'px',
17
- top: scrollY + top + height + 'px',
18
- })
25
+ left += scrollX;
26
+ top += scrollY;
27
+ }
28
+
29
+ if (calculatePosition) {
30
+ el.unbindPosition = calculatePosition(el, context, {
31
+ width: width + 'px',
32
+ left: left + 'px',
33
+ top: (top + height) + 'px',
34
+ });
35
+ }
19
36
 
20
- document.body.appendChild(el)
37
+ (rootEl || document.body).appendChild(el)
21
38
  }
22
39
  },
23
40