@1024pix/pix-ui 20.2.2 → 21.0.0

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 (60) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/addon/components/pix-dropdown.hbs +3 -4
  3. package/addon/components/pix-filterable-and-searchable-select.hbs +45 -0
  4. package/addon/components/pix-filterable-and-searchable-select.js +48 -0
  5. package/addon/components/pix-multi-select.hbs +19 -23
  6. package/addon/components/pix-multi-select.js +26 -44
  7. package/addon/components/pix-pagination.hbs +2 -1
  8. package/addon/components/pix-select.hbs +133 -44
  9. package/addon/components/pix-select.js +134 -31
  10. package/addon/components/pix-stars.hbs +1 -1
  11. package/addon/components/pix-tooltip.hbs +3 -2
  12. package/addon/styles/_form.scss +16 -3
  13. package/addon/styles/_pix-filterable-and-searchable-select.scss +57 -0
  14. package/addon/styles/_pix-multi-select.scss +15 -14
  15. package/addon/styles/_pix-select.scss +152 -45
  16. package/addon/styles/_pix-tooltip.scss +7 -5
  17. package/addon/styles/addon.scss +3 -0
  18. package/app/components/pix-filterable-and-searchable-select.js +1 -0
  19. package/app/modifiers/on-arrow-down-up-action.js +3 -3
  20. package/app/modifiers/on-enter-action.js +2 -2
  21. package/app/modifiers/on-space-action.js +20 -0
  22. package/app/stories/form.stories.js +86 -80
  23. package/app/stories/pix-background-header.stories.js +17 -9
  24. package/app/stories/pix-banner.stories.js +9 -10
  25. package/app/stories/pix-block.stories.js +3 -5
  26. package/app/stories/pix-button-link.stories.js +23 -27
  27. package/app/stories/pix-button-upload.stories.js +10 -12
  28. package/app/stories/pix-button.stories.js +30 -31
  29. package/app/stories/pix-checkbox.stories.js +9 -10
  30. package/app/stories/pix-collapsible.stories.js +22 -37
  31. package/app/stories/pix-dropdown.stories.js +17 -19
  32. package/app/stories/pix-filter-banner.stories.js +11 -8
  33. package/app/stories/pix-filterable-and-searchable-select.stories.js +212 -0
  34. package/app/stories/pix-filterable-and-searchable-select.stories.mdx +71 -0
  35. package/app/stories/pix-icon-button.stories.js +10 -12
  36. package/app/stories/pix-input-code.stories.js +7 -9
  37. package/app/stories/pix-input-password.stories.js +9 -11
  38. package/app/stories/pix-input.stories.js +9 -11
  39. package/app/stories/pix-message.stories.js +7 -8
  40. package/app/stories/pix-modal.stories.js +27 -20
  41. package/app/stories/pix-multi-select.stories.js +105 -81
  42. package/app/stories/pix-multi-select.stories.mdx +14 -9
  43. package/app/stories/pix-pagination.stories.js +6 -8
  44. package/app/stories/pix-progress-gauge.stories.js +16 -20
  45. package/app/stories/pix-radio-button.stories.js +2 -14
  46. package/app/stories/pix-return-to.stories.js +4 -8
  47. package/app/stories/pix-select.stories.js +235 -74
  48. package/app/stories/pix-select.stories.mdx +46 -20
  49. package/app/stories/pix-selectable-tag.stories.js +7 -38
  50. package/app/stories/pix-sidebar.stories.js +26 -19
  51. package/app/stories/pix-stars.stories.js +1 -8
  52. package/app/stories/pix-tag.stories.js +6 -10
  53. package/app/stories/pix-textarea.stories.js +7 -9
  54. package/app/stories/pix-tooltip.stories.js +41 -49
  55. package/package.json +43 -44
  56. package/addon/components/pix-tooltip-deprecated.hbs +0 -18
  57. package/addon/components/pix-tooltip-deprecated.js +0 -26
  58. package/app/components/pix-tooltip-deprecated.js +0 -1
  59. package/app/stories/pix-tooltip-deprecated.stories.js +0 -136
  60. package/app/stories/pix-tooltip-deprecated.stories.mdx +0 -143
@@ -1,58 +1,161 @@
1
1
  import Component from '@glimmer/component';
2
- import { guidFor } from '@ember/object/internals';
3
2
  import { tracked } from '@glimmer/tracking';
4
3
  import { action } from '@ember/object';
4
+ import { guidFor } from '@ember/object/internals';
5
5
 
6
6
  export default class PixSelect extends Component {
7
- @tracked isValueAValidOption = false;
7
+ @tracked isExpanded = false;
8
+ @tracked searchValue = null;
9
+ searchId = 'search-input-' + guidFor(this);
10
+
11
+ constructor(...args) {
12
+ super(...args);
8
13
 
9
- constructor() {
10
- super(...arguments);
14
+ if (!this.args.label && !this.args.id)
15
+ throw new Error('ERROR in PixSelect, a @label or an @id was not provided');
16
+
17
+ const categories = [];
18
+ this.args.options.forEach((element) => {
19
+ if (!categories.includes(element.category) && element.category !== undefined) {
20
+ categories.push(element.category);
21
+ }
22
+ });
23
+
24
+ this.displayCategory = categories.length > 0;
25
+ }
11
26
 
12
- if (this.args.isSearchable) {
13
- this.datalistId = 'pix-select-list-' + guidFor(this);
27
+ get selectId() {
28
+ if (this.args.id) return this.args.id;
29
+ return 'select-' + guidFor(this);
30
+ }
31
+
32
+ get displayDefaultOption() {
33
+ return !this.searchValue && !this.args.hideDefaultOption;
34
+ }
35
+
36
+ get className() {
37
+ const classes = ['pix-select-button'];
38
+ if (this.args.className) {
39
+ classes.push(this.args.className);
40
+ }
41
+ if (this.args.errorMessage) {
42
+ classes.push('pix-select-button--error');
14
43
  }
44
+ return classes.join(' ');
45
+ }
46
+
47
+ get isAriaExpanded() {
48
+ return this.isExpanded ? 'true' : 'false';
49
+ }
50
+
51
+ get listId() {
52
+ return `listbox-${this.selectId}`;
53
+ }
54
+
55
+ get dropDownId() {
56
+ return `dropdown-${this.selectId}`;
57
+ }
58
+
59
+ get placeholder() {
60
+ if (!this.args.value) return this.args.placeholder;
61
+ const option = this.args.options.find((option) => option.value === this.args.value);
62
+ return option ? option.label : this.args.placeholder;
63
+ }
64
+
65
+ get defaultOption() {
66
+ return {
67
+ value: '',
68
+ };
15
69
  }
16
70
 
17
- get label() {
18
- const labelIsDefined = this.args.label?.trim();
19
- const idIsNotDefined = !this.args.id?.trim();
71
+ get results() {
72
+ let results = [];
73
+ let options = this.args.options;
20
74
 
21
- if (labelIsDefined && idIsNotDefined) {
22
- throw new Error('ERROR in PixSelect component, @id param is necessary when giving @label');
75
+ if (this.searchValue) {
76
+ options = this.args.options.filter((option) =>
77
+ option.label.toLowerCase().includes(this.searchValue.toLowerCase())
78
+ );
23
79
  }
24
- return this.args.label || null;
80
+
81
+ if (!this.displayCategory) return options;
82
+
83
+ options.forEach(({ category, value, label }) => {
84
+ const categoryIndex = results.findIndex((result) => result.category === category);
85
+ if (categoryIndex !== -1) {
86
+ results[categoryIndex].options.push({ value, label });
87
+ } else {
88
+ results.push({ category, options: [{ label, value }] });
89
+ }
90
+ });
91
+ return results;
25
92
  }
26
93
 
27
- get isBig() {
28
- return this.args.size === 'big';
94
+ @action
95
+ toggleDropdown(event) {
96
+ if (this.isExpanded) {
97
+ this.hideDropdown(event);
98
+ } else {
99
+ this.showDropdown(event);
100
+ }
29
101
  }
30
102
 
31
- get isValid() {
32
- return this.args.isValidationActive && this.isValueAValidOption;
103
+ @action
104
+ showDropdown(event) {
105
+ event.preventDefault();
106
+
107
+ this.isExpanded = true;
33
108
  }
34
109
 
35
110
  @action
36
- onChange(event) {
37
- if (this.args.onChange) {
38
- this.args.onChange(event);
111
+ hideDropdown(event) {
112
+ if (this.isExpanded) {
113
+ event.preventDefault();
114
+
115
+ this.isExpanded = false;
39
116
  }
117
+ }
40
118
 
41
- if (!this.args.isSearchable || !this.args.options) {
42
- return;
119
+ @action
120
+ onChange(option, event) {
121
+ this.args.onChange(option.value);
122
+
123
+ this.hideDropdown(event);
124
+ document.getElementById(this.selectId).focus();
125
+ }
126
+
127
+ @action
128
+ setSearchValue(event) {
129
+ this.searchValue = event.target.value.trim();
130
+ }
131
+
132
+ @action
133
+ lockTab(event) {
134
+ if (event.code === 'Tab' && this.isExpanded) {
135
+ event.preventDefault();
136
+ document.getElementById(this.searchId).focus();
43
137
  }
138
+ }
44
139
 
45
- if (this.args.isValidationActive) {
46
- this.isValueAValidOption = _checkIfValueIsAValidOption({
47
- value: event.target.value,
48
- options: this.args.options,
49
- });
140
+ @action
141
+ focus() {
142
+ if (this.isExpanded) {
143
+ if (this.args.value) {
144
+ document.querySelector("[aria-selected='true']").focus();
145
+ } else if (this.args.isSearchable) {
146
+ document.getElementById(this.searchId).focus();
147
+ } else if (this.displayDefaultOption) {
148
+ document.querySelector("[aria-selected='true']").focus();
149
+ }
50
150
  }
51
151
  }
52
- }
53
152
 
54
- function _checkIfValueIsAValidOption({ value, options }) {
55
- return value
56
- ? options.some((option) => option.label.toLowerCase() === value.toLowerCase())
57
- : false;
153
+ @action
154
+ setSelectWidth() {
155
+ const baseFontRemRatio = 16;
156
+ const checkIconWidth = 16;
157
+ const listWidth = document.getElementById(this.listId).getBoundingClientRect().width;
158
+ const selectWidth = (listWidth + checkIconWidth) / baseFontRemRatio;
159
+ document.getElementById(`container-${this.selectId}`).style.width = `${selectWidth}rem`;
160
+ }
58
161
  }
@@ -1,4 +1,4 @@
1
- <div class={{this.pixStarsClass}} ...attributes role="img" aria-label={{@alt}}>
1
+ <div class={{this.pixStarsClass}} ...attributes aria-label={{@alt}}>
2
2
  {{#each this.stars as |star|}}
3
3
  <svg
4
4
  class="pix-stars__{{star}}"
@@ -8,9 +8,9 @@
8
8
  ...attributes
9
9
  >
10
10
  {{#if (has-block "triggerElement")}}
11
- <div class={{if this.isVisible "pix-tooltip--visible" ""}}>
11
+ <span class="pix-tooltip__trigger-element">
12
12
  {{yield to="triggerElement"}}
13
- </div>
13
+ </span>
14
14
  {{/if}}
15
15
 
16
16
  {{#if (has-block "tooltip")}}
@@ -19,6 +19,7 @@
19
19
  id={{@id}}
20
20
  role="tooltip"
21
21
  class="pix-tooltip__content pix-tooltip__content--{{this.position}}
22
+ {{if this.isVisible 'pix-tooltip__content--visible'}}
22
23
  {{if @isInline 'pix-tooltip__content--inline'}}
23
24
  {{if @isLight 'pix-tooltip__content--light'}}
24
25
  {{if @isWide 'pix-tooltip__content--wide'}}"
@@ -1,6 +1,7 @@
1
1
  @mixin hoverFormElement() {
2
2
  &:hover {
3
- box-shadow: inset 0px 0px 0px 0.6px $pix-neutral-40;
3
+ box-shadow: inset 0px 0px 0px 0.6px $pix-neutral-70;
4
+ background-color: $pix-neutral-5;
4
5
  }
5
6
  }
6
7
 
@@ -24,14 +25,26 @@
24
25
  display: block;
25
26
  font-family: $font-roboto;
26
27
  font-size: 0.875rem;
27
- color: $pix-neutral-70;
28
- margin-bottom: 4px;
28
+ line-height: 1.375rem;
29
+ color: $pix-neutral-90;
30
+ margin-bottom: $spacing-xxs;
31
+ font-weight: $font-medium;
32
+ }
33
+
34
+ @mixin subLabel() {
35
+ @include label();
36
+
37
+ font-size: 0.813rem;
38
+ line-height: 1rem;
39
+ color: $pix-neutral-60;
40
+ font-weight: $font-normal;
29
41
  }
30
42
 
31
43
  @mixin errorMessage() {
32
44
  font-family: $font-roboto;
33
45
  font-size: 0.75rem;
34
46
  color: $pix-error-70;
47
+ margin-top: $spacing-xxs;
35
48
  }
36
49
 
37
50
  @mixin formElementInError() {
@@ -0,0 +1,57 @@
1
+ .pix-filterable-and-searchable-select {
2
+ display: flex;
3
+ width: fit-content;
4
+ border: 1px $pix-neutral-45 solid;
5
+ border-radius: 4px;
6
+
7
+ &--error {
8
+ @include formElementInError();
9
+ }
10
+
11
+ &__label {
12
+ @include label();
13
+ }
14
+
15
+ &__sub-label {
16
+ @include subLabel();
17
+ }
18
+
19
+ &__pix-multi-select,
20
+ &__pix-select {
21
+ border: none;
22
+ &:hover {
23
+ border: none;
24
+ box-shadow: none;
25
+ }
26
+ }
27
+
28
+ &__error-message {
29
+ @include errorMessage();
30
+ }
31
+ .pix-multi-select {
32
+ margin-right: 2px;
33
+
34
+ [role="menu"] {
35
+ width: fit-content;
36
+ }
37
+ }
38
+
39
+ &__pix-multi-select {
40
+ border-radius: 4px 0px 0px 4px;
41
+ position: relative;
42
+
43
+ &:after {
44
+ height: 22px;
45
+ width: 2px;
46
+ content: '';
47
+ background-color: $pix-neutral-22;
48
+ position: absolute;
49
+ right: -2px;
50
+ border-radius: 50px;
51
+ }
52
+ }
53
+
54
+ &__pix-select {
55
+ border-radius: 0px 4px 4px 0px;
56
+ }
57
+ }
@@ -56,16 +56,13 @@
56
56
  }
57
57
 
58
58
  &__dropdown-icon {
59
- font-size: 11px;
60
- color: $pix-neutral-30;
59
+ @include text-small();
60
+ color: $pix-neutral-60;
61
+ font-weight: $font-heavy;
61
62
  right: 10px;
62
63
  top: calc(50% - 6px);
63
64
  position: absolute;
64
65
  pointer-events: none;
65
-
66
- &--expand {
67
- color: $pix-primary;
68
- }
69
66
  }
70
67
  }
71
68
 
@@ -81,8 +78,9 @@
81
78
  max-height: 200px;
82
79
  list-style-type: none;
83
80
  padding: 0;
84
- box-shadow: 0px 8px 24px 0px rgba(23, 43, 77, 0.1);
85
- transition: all .1s ease-in-out;
81
+ box-shadow: 0px 6px 12px rgba(7, 20, 46, 0.08);
82
+ transition: all 0.1s ease-in-out;
83
+ margin-top: $spacing-xxs;
86
84
 
87
85
  &--hidden {
88
86
  visibility: hidden;
@@ -106,15 +104,18 @@
106
104
  }
107
105
 
108
106
  li.pix-multi-select-list__item {
109
- font-family: $font-roboto;
110
107
  position: relative;
111
- border-bottom: 1px solid $pix-neutral-15;
112
108
  list-style: none;
113
- font-size: 0.9rem;
114
- padding: 8px;
109
+ padding: $spacing-xs $spacing-m;
110
+
111
+
112
+ &:hover,
113
+ &:focus {
114
+ outline: none;
115
+ cursor: pointer;
116
+ background-color: $pix-neutral-10;
117
+ }
115
118
 
116
- @include hoverFormElement();
117
-
118
119
  &--no-result {
119
120
  text-align: center;
120
121
  padding: 12px 0;
@@ -1,70 +1,177 @@
1
1
  .pix-select {
2
- @import 'reset-css';
3
-
2
+ display: inline-block;
4
3
  position: relative;
5
4
 
6
- @mixin pixSelect {
7
- appearance: none;
8
- border: 1px $pix-neutral-40 solid;
9
- border-radius: 4px;
10
- color: $pix-neutral-90;
11
- font-family: $font-roboto;
12
- font-size: 0.875rem;
13
- height: 36px;
14
- width: 100%;
15
- text-overflow: ellipsis;
5
+ &__label {
6
+ @include label();
7
+ }
16
8
 
17
- @include hoverFormElement();
18
- @include focusFormElement();
19
- @include focusWithinFormElement();
9
+ &__sub-label {
10
+ @include subLabel();
20
11
  }
21
12
 
22
- select {
23
- @include pixSelect;
24
- padding: 0 32px 0 16px;
13
+ &__dropdown {
14
+ z-index: 200;
15
+ position: absolute;
16
+ border-top: none;
17
+ border-radius: 0 0 4px 4px;
18
+ overflow-y: auto;
19
+ max-height: 200px;
20
+ width: inherit;
21
+ list-style-type: none;
22
+ padding: 0;
23
+ background-color: $pix-neutral-0;
24
+ box-shadow: 0px 6px 12px rgba(7, 20, 46, 0.08);
25
+ transition: all 0.1s ease-in-out;
26
+ white-space: nowrap;
27
+ margin-top: $spacing-xxs;
25
28
 
26
- &.pix-select--big {
27
- height: 44px;
29
+ &::-webkit-scrollbar {
30
+ width: 0.5rem;
31
+ }
32
+ &::-webkit-scrollbar-track {
33
+ border-radius: 4px;
34
+ border: 1px solid $pix-neutral-20;
35
+ background: $pix-neutral-20;
36
+ }
37
+ &::-webkit-scrollbar-thumb {
38
+ border-radius: 4px;
39
+ width: 0.375rem;
40
+ background: $pix-neutral-30;
41
+ }
42
+ &::-webkit-scrollbar-thumb:hover {
43
+ background: $pix-neutral-35;
28
44
  }
29
45
 
30
- &::-ms-expand {
31
- display: none;
46
+ &--closed {
47
+ visibility: hidden;
48
+ opacity: 0;
32
49
  }
33
50
  }
34
51
 
35
- input {
36
- @include pixSelect;
37
- padding: 0 8px 0 16px;
52
+ &__empty-search-message {
53
+ @include text-small();
54
+ color: $pix-neutral-70;
55
+ text-align: center;
56
+ }
38
57
 
39
- &.pix-select--big {
40
- height: 44px;
41
- }
58
+ &__search {
59
+ display: flex;
60
+ border-bottom: 2px solid $pix-neutral-22;
61
+ margin: $spacing-s $spacing-m;
62
+ color: $pix-neutral-30;
63
+ border-radius: 4px 4px 0 0;
42
64
 
43
- // Remove arrow for Chrome
44
- &::-webkit-calendar-picker-indicator {
45
- display: none;
65
+ &:focus-within {
66
+ background: $pix-neutral-10;
67
+ border-bottom: 2px solid $pix-primary;
46
68
  }
69
+ }
47
70
 
48
- &.pix-select--is-valid:focus,
49
- &.pix-select--is-valid:focus-within {
50
- border-color: $green;
51
- }
71
+ &__options {
72
+ border-top: 1px solid $pix-neutral-20;
52
73
  }
53
74
 
54
- &__icon {
55
- font-size: 11px;
56
- color: $pix-neutral-30;
57
- right: 10px;
58
- top: calc(50% - 6px);
59
- position: absolute;
75
+ &__error-message {
76
+ @include errorMessage();
77
+ }
78
+ }
79
+
80
+ .pix-select-button {
81
+ display: flex;
82
+ flex-direction: row;
83
+ align-items: center;
84
+ font-family: $font-roboto;
85
+ font-weight: $font-normal;
86
+ position: relative;
87
+ border: 1px $pix-neutral-45 solid;
88
+ padding: 0px $spacing-s 0px $spacing-s;
89
+ width: 100%;
90
+ background-color: $pix-neutral-0;
91
+ border-radius: 4px;
92
+ outline: none;
93
+ height: 2.25rem;
94
+ cursor: pointer;
95
+ color: $pix-neutral-90;
96
+ justify-content: space-between;
97
+
98
+ @include text-small();
99
+ @include hoverFormElement();
100
+ @include focusWithinFormElement();
101
+
102
+ &--error {
103
+ @include formElementInError();
104
+ }
105
+
106
+ &__dropdown-icon {
107
+ @include text-small();
108
+ color: $pix-neutral-60;
109
+ font-weight: $font-heavy;
60
110
  pointer-events: none;
61
111
  }
112
+ }
62
113
 
63
- &__label {
64
- @include label();
114
+ .pix-select-options__category {
115
+ list-style: none;
116
+ padding: 0;
117
+ margin: 0;
118
+ }
119
+
120
+ .pix-select-options-category {
121
+ &__name {
122
+ @include text-small();
123
+ padding: $spacing-s $spacing-m $spacing-xs $spacing-m;
124
+ text-transform: uppercase;
125
+ font-family: $font-roboto;
126
+ color: $pix-neutral-45;
65
127
  }
66
128
 
67
- .pix-select__label ~ .pix-select__icon {
68
- top: calc(50% + 6px);
129
+ &__option {
130
+ @include text-small();
131
+ display: flex;
132
+ justify-content: space-between;
133
+ padding: $spacing-xs $spacing-m;
134
+ color: $pix-neutral-70;
135
+
136
+ &:hover,
137
+ &:focus {
138
+ outline: none;
139
+ cursor: pointer;
140
+ background-color: $pix-neutral-10;
141
+ }
142
+
143
+ svg {
144
+ visibility: hidden;
145
+ opacity: 0;
146
+ font-size: 1.125rem;
147
+ }
148
+
149
+ &--selected {
150
+ background-color: $pix-primary-5;
151
+ align-items: center;
152
+
153
+ svg {
154
+ visibility: visible;
155
+ opacity: 1;
156
+ }
157
+ }
158
+ }
159
+ }
160
+
161
+ .pix-select-search {
162
+ &__input {
163
+ @include text-small();
164
+ width: 100%;
165
+ border: none;
166
+ padding-left: $spacing-xs;
167
+ margin: $spacing-xxs;
168
+ &:focus {
169
+ outline: none;
170
+ background: $pix-neutral-10;
171
+ }
172
+ }
173
+
174
+ &__icon {
175
+ margin: auto $spacing-xxs;
69
176
  }
70
177
  }
@@ -6,12 +6,9 @@
6
6
  justify-content: center;
7
7
  align-items: center;
8
8
 
9
- }
10
-
11
- .pix-tooltip--visible {
12
- + .pix-tooltip__content {
9
+ &__trigger-element {
13
10
  display: block;
14
- opacity: 1;
11
+ width: 100%;
15
12
  }
16
13
  }
17
14
 
@@ -31,6 +28,11 @@
31
28
  line-height: 1.4rem;
32
29
  transition: opacity 0.3s;
33
30
 
31
+ &--visible {
32
+ display: block;
33
+ opacity: 1;
34
+ }
35
+
34
36
  &--inline {
35
37
  white-space: nowrap;
36
38
  }
@@ -31,6 +31,9 @@
31
31
  @import 'pix-checkbox';
32
32
  @import 'trap-focus';
33
33
 
34
+ // at the end so it can override it's children scss
35
+ @import 'pix-filterable-and-searchable-select';
36
+
34
37
  html {
35
38
  font-size: 16px;
36
39
  }
@@ -0,0 +1 @@
1
+ export { default } from '@1024pix/pix-ui/components/pix-filterable-and-searchable-select';
@@ -34,7 +34,7 @@ export default modifier((element, [elementId, callback, isExpanded]) => {
34
34
  document.activeElement === lastFocusableElement ||
35
35
  activeIndexElement === -1
36
36
  ) {
37
- firstFocusableElement.focus();
37
+ firstFocusableElement?.focus();
38
38
  } else {
39
39
  focusableElements[activeIndexElement + 1].focus();
40
40
  }
@@ -46,7 +46,7 @@ export default modifier((element, [elementId, callback, isExpanded]) => {
46
46
  document.activeElement === firstFocusableElement ||
47
47
  activeIndexElement === -1
48
48
  ) {
49
- lastFocusableElement.focus();
49
+ lastFocusableElement?.focus();
50
50
  } else {
51
51
  focusableElements[activeIndexElement - 1].focus();
52
52
  }
@@ -62,7 +62,7 @@ export default modifier((element, [elementId, callback, isExpanded]) => {
62
62
  if (!isExpanded) {
63
63
  elementToTarget.addEventListener('transitionend', focusElement);
64
64
 
65
- callback();
65
+ callback(event);
66
66
 
67
67
  return () => {
68
68
  elementToTarget.removeEventListener('transitionend', focusElement);
@@ -1,6 +1,6 @@
1
1
  import { modifier } from 'ember-modifier';
2
2
 
3
- export default modifier((element, [callback, focusId = null]) => {
3
+ export default modifier((element, [callback = null, focusId = null]) => {
4
4
  function handleKeyUp(event) {
5
5
  const ENTER_KEY = 'Enter';
6
6
 
@@ -17,7 +17,7 @@ export default modifier((element, [callback, focusId = null]) => {
17
17
  document.getElementById(focusId).focus();
18
18
  }
19
19
 
20
- callback(event);
20
+ if (callback) callback(event);
21
21
  }
22
22
 
23
23
  element.addEventListener('keydown', handleKeyUp);