@ekzo-dev/bootstrap-addons 5.2.25 → 5.2.27

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@ekzo-dev/bootstrap-addons",
3
3
  "description": "Aurelia Bootstrap additional component",
4
- "version": "5.2.25",
4
+ "version": "5.2.27",
5
5
  "homepage": "https://github.com/ekzo-dev/aurelia-components/tree/main/packages/bootstrap-addons",
6
6
  "repository": {
7
7
  "type": "git",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@ekzo-dev/bootstrap": "^5.2.19",
12
+ "@ekzo-dev/bootstrap": "^5.2.20",
13
13
  "@ekzo-dev/vanilla-jsoneditor": "^0.23.7",
14
14
  "@ekzo-dev/toolkit": "^1.2.4",
15
15
  "@fortawesome/free-solid-svg-icons": "^6.5.2",
@@ -21,7 +21,9 @@
21
21
  "immutable-json-patch": "^5.1.3"
22
22
  },
23
23
  "peerDependencies": {
24
- "bootstrap": "^5.2.3"
24
+ "aurelia": "^2.0.0-beta.8",
25
+ "bootstrap": "^5.2.3",
26
+ "@popperjs/core": "^2.11.8"
25
27
  },
26
28
  "main": "src/index.ts",
27
29
  "files": [
@@ -40,12 +40,12 @@
40
40
  ref="control"
41
41
  />
42
42
  <button
43
- if.bind="emptyOption && selectedOption?.value !== emptyOption?.value"
43
+ if.bind="emptyOption && selectedOption?.value !== emptyOption?.value && !disabled"
44
44
  bs-close-button
45
45
  type="button"
46
46
  click.trigger="selectOption(emptyOption)"
47
47
  ></button>
48
- <bs-dropdown-menu>
48
+ <bs-dropdown-menu popper-config.bind="popperConfig">
49
49
  <div bs-dropdown-item="text" if.bind="optionsCount > 10">
50
50
  <input class="form-control" placeholder="Filter options" type="search" value.bind="filter & debounce:250" />
51
51
  </div>
@@ -53,7 +53,8 @@
53
53
  <button
54
54
  type="button"
55
55
  repeat.for="option of ungroupedOptions | filter:filter:emptyOption"
56
- bs-dropdown-item="active.bind: option.value === selectedOption?.value; disabled.bind: option.disabled"
56
+ class="dropdown-item ${option.value === selectedOption?.value ? 'active' : ''}"
57
+ disabled.bind="option.disabled"
57
58
  click.trigger="selectOption(option)"
58
59
  >
59
60
  ${option.text || '&nbsp;'}
@@ -61,10 +62,10 @@
61
62
  <template repeat.for="[k, v] of groupedOptions | filter:filter:emptyOption">
62
63
  <h6 bs-dropdown-item="header">${k}</h6>
63
64
  <button
64
- class="ps-4"
65
65
  type="button"
66
66
  repeat.for="option of v"
67
- bs-dropdown-item="active.bind: option.value === selectedOption?.value; disabled.bind: option.disabled"
67
+ class="ps-4 dropdown-item ${option.value === selectedOption?.value ? 'active' : ''}"
68
+ disabled.bind="option.disabled"
68
69
  click.trigger="selectOption(option)"
69
70
  >
70
71
  ${option.text || '&nbsp;'}
@@ -10,6 +10,7 @@ bs-select {
10
10
  }
11
11
 
12
12
  &:has(.btn-close) .form-select {
13
+ margin-bottom: -0.8rem;
13
14
  padding-right: 4rem;
14
15
  }
15
16
 
@@ -19,20 +20,20 @@ bs-select {
19
20
  box-sizing: border-box;
20
21
  width: 0.8rem;
21
22
  height: 0.8rem;
22
- top: calc(-1px - 1.5rem);
23
+ top: calc(-1px - 0.7rem);
23
24
  left: calc(100% - 3.25rem);
24
25
  }
25
26
 
26
27
  .form-select-lg + .btn-close {
27
- top: calc(-1px - 1.8rem);
28
+ top: calc(-1px - 1rem);
28
29
  }
29
30
 
30
31
  .form-select-sm + .btn-close {
31
- top: calc(-1px - 1.3rem);
32
+ top: calc(-1px - 0.5rem);
32
33
  }
33
34
 
34
35
  &.form-floating .btn-close {
35
- top: calc(-1px - 2.15rem) !important;
36
+ top: calc(-1px - 1.35rem) !important;
36
37
  }
37
38
 
38
39
  .dropdown-menu {
@@ -1,3 +1,4 @@
1
+ import { BsButton, BsOffcanvas } from '@ekzo-dev/bootstrap';
1
2
  import { extractArgTypes, Meta, Story } from '@storybook/aurelia';
2
3
 
3
4
  import { selectControl } from '../../../../../.storybook/helpers';
@@ -47,7 +48,8 @@ Multiple.args = {
47
48
 
48
49
  const LargeOptions: Story = (args) => ({
49
50
  props: args,
50
- template: '<bs-select value.bind="value" options.bind="options" label.bind="label" style="width: 400px"></bs-select>',
51
+ template:
52
+ '<bs-select value.bind="value" options.bind="options" label.bind="label" style="width: 400px; max-width: 100%"></bs-select>',
51
53
  });
52
54
 
53
55
  LargeOptions.args = {
@@ -57,5 +59,23 @@ LargeOptions.args = {
57
59
  })),
58
60
  };
59
61
 
62
+ const InModal: Story = (args) => ({
63
+ props: args,
64
+ template: `
65
+ <button bs-button click.trigger="offcanvas.toggle()">Open modal</button>
66
+ <bs-offcanvas component.ref="offcanvas">
67
+ <bs-select value.bind="value" options.bind="options" label.bind="label" style="width: 100%"></bs-select>
68
+ <div style="height: 2000px"></div>
69
+ </bs-offcanvas>`,
70
+ components: [BsOffcanvas, BsButton],
71
+ });
72
+
73
+ InModal.args = {
74
+ options: Array.from({ length: 1000 }).map((v, i) => ({
75
+ value: i.toString(),
76
+ text: `Option ${i} has long content which forces dropdown menu to scale larger that select box`,
77
+ })),
78
+ };
79
+
60
80
  // eslint-disable-next-line
61
- export { Overview, Multiple, LargeOptions };
81
+ export { Overview, Multiple, LargeOptions, InModal };
@@ -2,6 +2,9 @@ import template from './select.html';
2
2
 
3
3
  import './select.scss';
4
4
 
5
+ import type { Options } from '@popperjs/core';
6
+ import type { Tooltip } from 'bootstrap';
7
+
5
8
  import {
6
9
  BsCloseButton,
7
10
  BsDropdown,
@@ -11,7 +14,7 @@ import {
11
14
  BsSelect as BaseBsSelect,
12
15
  ISelectOption,
13
16
  } from '@ekzo-dev/bootstrap';
14
- import { bindable, customElement, ICustomElementViewModel } from 'aurelia';
17
+ import { bindable, customElement, ICustomElementViewModel, resolve } from 'aurelia';
15
18
 
16
19
  import { Filter } from './filter';
17
20
 
@@ -29,6 +32,8 @@ export class BsSelect extends BaseBsSelect implements ICustomElementViewModel {
29
32
  @bindable()
30
33
  emptyValue?: unknown = null;
31
34
 
35
+ host = resolve(HTMLElement);
36
+
32
37
  control!: HTMLFieldSetElement;
33
38
 
34
39
  filter: string = '';
@@ -39,6 +44,8 @@ export class BsSelect extends BaseBsSelect implements ICustomElementViewModel {
39
44
 
40
45
  emptyOption?: ISelectOption;
41
46
 
47
+ popperConfig: Partial<Options> | Tooltip.PopperConfigFunction | null = null;
48
+
42
49
  binding() {
43
50
  super.binding();
44
51
  this.deactivating = false;
@@ -53,6 +60,8 @@ export class BsSelect extends BaseBsSelect implements ICustomElementViewModel {
53
60
  this.#setHeight();
54
61
  this.#scrollToSelected();
55
62
  }
63
+
64
+ this.setPopperConfig();
56
65
  }
57
66
 
58
67
  propertyChanged(name: keyof this) {
@@ -68,6 +77,24 @@ export class BsSelect extends BaseBsSelect implements ICustomElementViewModel {
68
77
  }
69
78
  }
70
79
 
80
+ setPopperConfig() {
81
+ if (this.multiple) return;
82
+
83
+ const { host } = this;
84
+ const parentModal = host.closest('.modal-body,.popover-body,.offcanvas-body');
85
+ const dropdownMenu: HTMLElement = host.querySelector('.dropdown-menu');
86
+
87
+ if (parentModal != null) {
88
+ this.popperConfig = {
89
+ strategy: 'fixed',
90
+ };
91
+ dropdownMenu.style.minWidth = `${host.offsetWidth}px`;
92
+ } else {
93
+ this.popperConfig = null;
94
+ dropdownMenu.style.minWidth = undefined;
95
+ }
96
+ }
97
+
71
98
  selectOption(option: ISelectOption) {
72
99
  this.value = option.value;
73
100
  this.#dispatchEvents();