@itfin/components 1.3.19 → 1.3.21

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.3.19",
3
+ "version": "1.3.21",
4
4
  "author": "Vitalii Savchuk <esvit666@gmail.com>",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -88,7 +88,7 @@
88
88
  pointer-events: none;
89
89
  display: block;
90
90
  position: relative;
91
- z-index: 2;
91
+ //z-index: 2;
92
92
  -webkit-transition: all .2s ease;
93
93
  transition: all .2s ease;
94
94
  will-change: transform;
@@ -96,7 +96,7 @@
96
96
  }
97
97
 
98
98
  input {
99
- z-index: 2;
99
+ //z-index: 2;
100
100
  position: absolute;
101
101
  top: 0;
102
102
  left: 0;
@@ -119,7 +119,7 @@
119
119
  &:checked + label::before,
120
120
  &:checked + label::after {
121
121
  background: var(--itf-segmeneted-control--background);
122
- z-index: 1;
122
+ //z-index: 1;
123
123
  }
124
124
  }
125
125
  }
@@ -132,7 +132,7 @@
132
132
  border-radius: var(--itf-segmeneted-control--border-radius);
133
133
  grid-column: 1;
134
134
  grid-row: 1;
135
- z-index: 2;
135
+ //z-index: 2;
136
136
  will-change: transform;
137
137
  -webkit-transition: transform .2s ease;
138
138
  transition: transform .2s ease;
@@ -1,13 +1,16 @@
1
1
  <script>
2
2
  import { Vue, Component, Prop, Watch, PropSync } from 'vue-property-decorator';
3
3
  import itfButton from '../button/Button';
4
+ import itfDropdownMenu from './DropdownMenu';
4
5
 
5
6
  let globalModalIndex = 0; // base modal z-index
6
7
 
7
8
  export default @Component({
9
+ functional: true,
8
10
  name: 'itfDropdown',
9
11
  components: {
10
- itfButton
12
+ itfButton,
13
+ itfDropdownMenu
11
14
  },
12
15
  })
13
16
  class itfDropdown extends Vue {
@@ -20,88 +23,41 @@ class itfDropdown extends Vue {
20
23
  @Prop({ type: Boolean }) shadow;
21
24
  @Prop({ type: Boolean }) disabled;
22
25
  @Prop({ type: Boolean }) text;
23
- @Prop({ type: Boolean, default: true }) appendToBody;
26
+ @Prop({ type: Boolean }) appendToBody;
24
27
  @Prop({ validator: (value) => [true, false, 'inside', 'outside'].includes(value), default: true }) autoclose;
25
28
  @Prop({ type: Object, default: () => ({}) }) buttonOptions;
26
29
  @Prop({ type: Object, default: () => ({}) }) menuOptions;
27
30
 
28
31
  modalId = '';
29
- modalEl = null;
30
32
 
31
- beforeDestroy () {
32
- // this.hide();
33
- }
34
-
35
- // @Watch('value')
36
- // onVisibleChanged(newValue) {
37
- // if (!this.modalEl) {
38
- // return;
39
- // }
40
- // if (newValue) {
41
- // this.modalEl.show();
42
- // } else {
43
- // this.modalEl.hide();
44
- // }
45
- // }
46
-
47
- render (createElement) {
48
- const modalId = `dropdownId${this._uid}`;
49
- const { right, shadow, label } = this;
50
- return createElement('div', {
51
- staticClass: 'dropdown'
52
- }, [
33
+ render (createElement, context) {
34
+ const { props, slots, data } = context;
35
+ const modalId = `dropdownId${globalModalIndex++}`;
36
+ const { buttonOptions, toggle, right, shadow, label, appendToBody } = props;
37
+ const { button, default: defaultSlot } = slots();
38
+ let elements = [
53
39
  createElement(
54
- 'itf-button',
40
+ itfButton,
55
41
  {
56
- props: this.buttonOptions || {},
57
- class: { 'dropdown-toggle': this.toggle },
42
+ props: buttonOptions || {},
43
+ class: { 'dropdown-toggle': toggle },
58
44
  attrs: { id: modalId, 'data-bs-toggle': 'dropdown', 'aria-expanded': 'false' },
59
45
  ref: 'toggle',
60
46
  },
61
- this.$slots.button || label
47
+ button || label
62
48
  ),
63
49
  createElement(
64
- 'div',
50
+ itfDropdownMenu,
65
51
  {
66
- attrs: { rel: 'dropdown' , 'aria-labelledby': modalId},
67
- class: { 'dropdown-menu-end': right, 'shadow': shadow },
68
- staticClass: 'itf-dropdown__menu dropdown-menu',
69
- ref: 'dropdown',
52
+ props: { ...props, toggleId: modalId },
70
53
  },
71
- this.$slots.default
54
+ defaultSlot
72
55
  )
73
- ]);
74
- }
75
-
76
- created() {
77
- console.info(this);
78
- }
79
-
80
- async mounted() {
81
- console.info(this);
82
- if (typeof window === 'undefined' || !this.$refs.toggle) {
83
- return;
56
+ ];
57
+ if (!appendToBody) {
58
+ elements = [createElement('div', { class: `dropdown ${data.staticClass || ''}` }, elements)];
84
59
  }
85
- const { default: Dropdown } = await import('bootstrap/js/src/dropdown.js');
86
- this.modalEl = new Dropdown(this.$refs.toggle, {
87
- reference: 'toggle',
88
- autoClose: this.autoclose
89
- });
90
- let context = document.body;
91
- console.info(this.$refs.dropdown);
92
- if (this.appendToBody && this.$refs.dropdown instanceof Node && this.$refs.dropdown.parentNode) {
93
- this.$refs.dropdown.parentNode.removeChild(this.$refs.dropdown);
94
- context.appendChild(this.$refs.dropdown); // should append only to body
95
- }
96
-
97
- this.$el.addEventListener('shown.bs.dropdown', () => {
98
- setTimeout(() => {
99
- this.$emit('open');
100
- }, 500);
101
- });
102
- this.$el.addEventListener('hidden.bs.dropdown', () => {
103
- this.$emit('close');
104
- });
60
+ return elements;
105
61
  }
106
62
 
107
63
  show() {
@@ -0,0 +1,72 @@
1
+ <template>
2
+ <div class="itf-dropdown__menu dropdown-menu" ref="dropdown" :aria-labelledby="modalId" :class="{'dropdown-menu-end': right, 'shadow': shadow}">
3
+ <slot></slot>
4
+ </div>
5
+ </template>
6
+ <script>
7
+ import { Vue, Component, Prop, Watch, PropSync } from 'vue-property-decorator';
8
+
9
+ let globalModalIndex = 0; // base modal z-index
10
+
11
+ export default @Component({
12
+ name: 'itfDropdownMenu'
13
+ })
14
+ class itfDropdownMenu extends Vue {
15
+ @PropSync('visible') value;
16
+ @Prop({ type: String, default: 'down', validator: (value) => ['down', 'start', 'end', 'up'].includes(value) }) placement;
17
+ @Prop({ type: String, default: 'click', validator: (value) => ['click', 'focus', 'hover', 'manual'].includes(value) }) trigger;
18
+ @Prop({ type: String, default: 'Dropdown' }) label;
19
+ @Prop({ type: Boolean }) right;
20
+ @Prop({ type: Boolean }) toggle;
21
+ @Prop({ type: Boolean }) shadow;
22
+ @Prop({ type: Boolean }) disabled;
23
+ @Prop({ type: Boolean }) text;
24
+ @Prop({ type: Boolean }) appendToBody;
25
+ @Prop({ type: String }) toggleId;
26
+ @Prop({ validator: (value) => [true, false, 'inside', 'outside'].includes(value), default: true }) autoclose;
27
+ @Prop({ type: Object, default: () => ({}) }) buttonOptions;
28
+ @Prop({ type: Object, default: () => ({}) }) menuOptions;
29
+
30
+ modalId = '';
31
+ modalEl = null;
32
+
33
+ async mounted() {
34
+ this.modalId = `dropdownId${globalModalIndex++}`;
35
+ const toggle = document.getElementById(this.toggleId);
36
+ if (typeof window === 'undefined' || !toggle) {
37
+ return;
38
+ }
39
+ const { default: Dropdown } = await import('bootstrap/js/src/dropdown.js');
40
+ let context = document.body;
41
+ this.modalEl = new Dropdown(toggle, {
42
+ reference: 'toggle',
43
+ autoClose: this.autoclose
44
+ });
45
+ if (this.appendToBody && this.$el instanceof Node && this.$el.parentNode) {
46
+ this.$el.parentNode.removeChild(this.$el);
47
+ context.appendChild(this.$el); // should append only to body
48
+ }
49
+
50
+ this.$el.addEventListener('shown.bs.dropdown', () => {
51
+ setTimeout(() => {
52
+ this.$emit('open');
53
+ }, 500);
54
+ });
55
+ this.$el.addEventListener('hidden.bs.dropdown', () => {
56
+ this.$emit('close');
57
+ });
58
+ }
59
+
60
+ show() {
61
+ if (this.modalEl) {
62
+ this.modalEl.show();
63
+ }
64
+ }
65
+
66
+ hide() {
67
+ if (this.modalEl) {
68
+ this.modalEl.hide();
69
+ }
70
+ }
71
+ }
72
+ </script>