igniteui-webcomponents 7.0.1 → 7.1.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 (149) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/components/combo/themes/shared/combo.common.css.js +1 -1
  3. package/components/combo/themes/shared/combo.common.css.js.map +1 -1
  4. package/components/combo/types.js.map +1 -1
  5. package/components/common/definitions/defineAllComponents.js +4 -0
  6. package/components/common/definitions/defineAllComponents.js.map +1 -1
  7. package/components/common/mixins/forms/form-transformers.js.map +1 -1
  8. package/components/common/util.d.ts +11 -1
  9. package/components/common/util.js +3 -0
  10. package/components/common/util.js.map +1 -1
  11. package/components/date-picker/date-picker.js.map +1 -1
  12. package/components/file-input/file-input.js.map +1 -1
  13. package/components/highlight/highlight.d.ts +130 -0
  14. package/components/highlight/highlight.js +77 -0
  15. package/components/highlight/highlight.js.map +1 -0
  16. package/components/highlight/service.d.ts +58 -0
  17. package/components/highlight/service.js +132 -0
  18. package/components/highlight/service.js.map +1 -0
  19. package/components/highlight/themes/dark/highlight.bootstrap.css.js +3 -0
  20. package/components/highlight/themes/dark/highlight.bootstrap.css.js.map +1 -0
  21. package/components/highlight/themes/dark/highlight.fluent.css.d.ts +1 -0
  22. package/components/highlight/themes/dark/highlight.fluent.css.js +3 -0
  23. package/components/highlight/themes/dark/highlight.fluent.css.js.map +1 -0
  24. package/components/highlight/themes/dark/highlight.indigo.css.d.ts +1 -0
  25. package/components/highlight/themes/dark/highlight.indigo.css.js +3 -0
  26. package/components/highlight/themes/dark/highlight.indigo.css.js.map +1 -0
  27. package/components/highlight/themes/dark/highlight.material.css.d.ts +1 -0
  28. package/components/highlight/themes/dark/highlight.material.css.js +3 -0
  29. package/components/highlight/themes/dark/highlight.material.css.js.map +1 -0
  30. package/components/highlight/themes/dark/highlight.shared.css.d.ts +1 -0
  31. package/components/highlight/themes/dark/highlight.shared.css.js +3 -0
  32. package/components/highlight/themes/dark/highlight.shared.css.js.map +1 -0
  33. package/components/highlight/themes/light/highlight.bootstrap.css.d.ts +1 -0
  34. package/components/highlight/themes/light/highlight.bootstrap.css.js +3 -0
  35. package/components/highlight/themes/light/highlight.bootstrap.css.js.map +1 -0
  36. package/components/highlight/themes/light/highlight.fluent.css.d.ts +1 -0
  37. package/components/highlight/themes/light/highlight.fluent.css.js +3 -0
  38. package/components/highlight/themes/light/highlight.fluent.css.js.map +1 -0
  39. package/components/highlight/themes/light/highlight.indigo.css.d.ts +1 -0
  40. package/components/highlight/themes/light/highlight.indigo.css.js +3 -0
  41. package/components/highlight/themes/light/highlight.indigo.css.js.map +1 -0
  42. package/components/highlight/themes/light/highlight.material.css.d.ts +1 -0
  43. package/components/highlight/themes/light/highlight.material.css.js +3 -0
  44. package/components/highlight/themes/light/highlight.material.css.js.map +1 -0
  45. package/components/highlight/themes/light/highlight.shared.css.d.ts +1 -0
  46. package/components/highlight/themes/light/highlight.shared.css.js +3 -0
  47. package/components/highlight/themes/light/highlight.shared.css.js.map +1 -0
  48. package/components/highlight/themes/shared/highlight.common.css.d.ts +1 -0
  49. package/components/highlight/themes/shared/highlight.common.css.js +3 -0
  50. package/components/highlight/themes/shared/highlight.common.css.js.map +1 -0
  51. package/components/highlight/themes/themes.d.ts +2 -0
  52. package/components/highlight/themes/themes.js +47 -0
  53. package/components/highlight/themes/themes.js.map +1 -0
  54. package/components/splitter/splitter.d.ts +240 -0
  55. package/components/splitter/splitter.js +608 -0
  56. package/components/splitter/splitter.js.map +1 -0
  57. package/components/splitter/themes/dark/splitter.bootstrap.css.d.ts +1 -0
  58. package/components/splitter/themes/dark/splitter.bootstrap.css.js +3 -0
  59. package/components/splitter/themes/dark/splitter.bootstrap.css.js.map +1 -0
  60. package/components/splitter/themes/dark/splitter.fluent.css.d.ts +1 -0
  61. package/components/splitter/themes/dark/splitter.fluent.css.js +3 -0
  62. package/components/splitter/themes/dark/splitter.fluent.css.js.map +1 -0
  63. package/components/splitter/themes/dark/splitter.indigo.css.d.ts +1 -0
  64. package/components/splitter/themes/dark/splitter.indigo.css.js +3 -0
  65. package/components/splitter/themes/dark/splitter.indigo.css.js.map +1 -0
  66. package/components/splitter/themes/dark/splitter.material.css.d.ts +1 -0
  67. package/components/splitter/themes/dark/splitter.material.css.js +3 -0
  68. package/components/splitter/themes/dark/splitter.material.css.js.map +1 -0
  69. package/components/splitter/themes/dark/splitter.shared.css.d.ts +1 -0
  70. package/components/splitter/themes/dark/splitter.shared.css.js +3 -0
  71. package/components/splitter/themes/dark/splitter.shared.css.js.map +1 -0
  72. package/components/splitter/themes/light/splitter.bootstrap.css.d.ts +1 -0
  73. package/components/splitter/themes/light/splitter.bootstrap.css.js +3 -0
  74. package/components/splitter/themes/light/splitter.bootstrap.css.js.map +1 -0
  75. package/components/splitter/themes/light/splitter.fluent.css.d.ts +1 -0
  76. package/components/splitter/themes/light/splitter.fluent.css.js +3 -0
  77. package/components/splitter/themes/light/splitter.fluent.css.js.map +1 -0
  78. package/components/splitter/themes/light/splitter.indigo.css.d.ts +1 -0
  79. package/components/splitter/themes/light/splitter.indigo.css.js +3 -0
  80. package/components/splitter/themes/light/splitter.indigo.css.js.map +1 -0
  81. package/components/splitter/themes/light/splitter.material.css.d.ts +1 -0
  82. package/components/splitter/themes/light/splitter.material.css.js +3 -0
  83. package/components/splitter/themes/light/splitter.material.css.js.map +1 -0
  84. package/components/splitter/themes/light/splitter.shared.css.d.ts +1 -0
  85. package/components/splitter/themes/light/splitter.shared.css.js +3 -0
  86. package/components/splitter/themes/light/splitter.shared.css.js.map +1 -0
  87. package/components/splitter/themes/shared/splitter.common.css.d.ts +1 -0
  88. package/components/splitter/themes/shared/splitter.common.css.js +3 -0
  89. package/components/splitter/themes/shared/splitter.common.css.js.map +1 -0
  90. package/components/splitter/themes/shared/splitter.indigo.css.d.ts +1 -0
  91. package/components/splitter/themes/shared/splitter.indigo.css.js +3 -0
  92. package/components/splitter/themes/shared/splitter.indigo.css.js.map +1 -0
  93. package/components/splitter/themes/splitter.base.css.d.ts +1 -0
  94. package/components/splitter/themes/splitter.base.css.js +3 -0
  95. package/components/splitter/themes/splitter.base.css.js.map +1 -0
  96. package/components/splitter/themes/themes.d.ts +2 -0
  97. package/components/splitter/themes/themes.js +48 -0
  98. package/components/splitter/themes/themes.js.map +1 -0
  99. package/components/splitter/types.d.ts +39 -0
  100. package/components/splitter/types.js +2 -0
  101. package/components/splitter/types.js.map +1 -0
  102. package/components/stepper/{animations.d.ts → common/animations.d.ts} +2 -2
  103. package/components/stepper/{animations.js → common/animations.js} +2 -2
  104. package/components/stepper/common/animations.js.map +1 -0
  105. package/components/stepper/common/context.d.ts +9 -0
  106. package/components/stepper/common/context.js +3 -0
  107. package/components/stepper/common/context.js.map +1 -0
  108. package/components/stepper/common/state.d.ts +67 -0
  109. package/components/stepper/common/state.js +134 -0
  110. package/components/stepper/common/state.js.map +1 -0
  111. package/components/stepper/common/types.js +2 -0
  112. package/components/stepper/common/types.js.map +1 -0
  113. package/components/stepper/step.d.ts +101 -55
  114. package/components/stepper/step.js +145 -160
  115. package/components/stepper/step.js.map +1 -1
  116. package/components/stepper/stepper.d.ts +98 -53
  117. package/components/stepper/stepper.js +168 -308
  118. package/components/stepper/stepper.js.map +1 -1
  119. package/components/stepper/themes/step/shared/step.bootstrap.css.js +1 -1
  120. package/components/stepper/themes/step/shared/step.bootstrap.css.js.map +1 -1
  121. package/components/stepper/themes/step/shared/step.common.css.js +1 -1
  122. package/components/stepper/themes/step/shared/step.common.css.js.map +1 -1
  123. package/components/stepper/themes/step/shared/step.indigo.css.js +1 -1
  124. package/components/stepper/themes/step/shared/step.indigo.css.js.map +1 -1
  125. package/components/stepper/themes/step/themes.js +2 -3
  126. package/components/stepper/themes/step/themes.js.map +1 -1
  127. package/components/tabs/themes/tabs.base.css.js +1 -1
  128. package/components/tabs/themes/tabs.base.css.js.map +1 -1
  129. package/components/textarea/textarea.js.map +1 -1
  130. package/components/types.d.ts +1 -0
  131. package/components/types.js.map +1 -1
  132. package/components/visually-hidden/visually-hidden.d.ts +49 -0
  133. package/components/visually-hidden/visually-hidden.js +26 -0
  134. package/components/visually-hidden/visually-hidden.js.map +1 -0
  135. package/custom-elements.json +2681 -379
  136. package/igniteui-webcomponents.css-data.json +2 -2
  137. package/igniteui-webcomponents.html-data.json +1 -1
  138. package/index.d.ts +6 -2
  139. package/index.js +2 -0
  140. package/index.js.map +1 -1
  141. package/package.json +3 -1
  142. package/web-types.json +3 -3
  143. package/components/stepper/animations.js.map +0 -1
  144. package/components/stepper/stepper.common.js +0 -2
  145. package/components/stepper/stepper.common.js.map +0 -1
  146. package/components/stepper/themes/step/shared/step.fluent.css.js +0 -3
  147. package/components/stepper/themes/step/shared/step.fluent.css.js.map +0 -1
  148. /package/components/{stepper/themes/step/shared/step.fluent.css.d.ts → highlight/themes/dark/highlight.bootstrap.css.d.ts} +0 -0
  149. /package/components/stepper/{stepper.common.d.ts → common/types.d.ts} +0 -0
@@ -4,89 +4,63 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
+ import { ContextProvider } from '@lit/context';
7
8
  import { html, LitElement } from 'lit';
8
- import { property, queryAssignedElements } from 'lit/decorators.js';
9
+ import { property } from 'lit/decorators.js';
9
10
  import { addThemingController } from '../../theming/theming-controller.js';
10
- import { watch } from '../common/decorators/watch.js';
11
+ import { addInternalsController } from '../common/controllers/internals.js';
12
+ import { addKeybindings, arrowDown, arrowLeft, arrowRight, arrowUp, endKey, homeKey, } from '../common/controllers/key-bindings.js';
13
+ import { addSlotController, setSlots } from '../common/controllers/slot.js';
11
14
  import { registerComponent } from '../common/definitions/register.js';
12
15
  import { EventEmitterMixin } from '../common/mixins/event-emitter.js';
13
- import { isLTR } from '../common/util.js';
16
+ import { addSafeEventListener, findElementFromEventPath, first, getRoot, isLTR, last, wrap, } from '../common/util.js';
17
+ import { STEPPER_CONTEXT } from './common/context.js';
18
+ import { createStepperState } from './common/state.js';
14
19
  import IgcStepComponent from './step.js';
15
20
  import { styles } from './themes/stepper/stepper.base.css.js';
16
21
  import { styles as bootstrap } from './themes/stepper/stepper.bootstrap.css.js';
17
22
  import { styles as fluent } from './themes/stepper/stepper.fluent.css.js';
18
23
  import { styles as indigo } from './themes/stepper/stepper.indigo.css.js';
24
+ const STEPPER_SYNC_PROPERTIES = [
25
+ 'orientation',
26
+ 'stepType',
27
+ 'contentTop',
28
+ 'verticalAnimation',
29
+ 'horizontalAnimation',
30
+ 'animationDuration',
31
+ 'titlePosition',
32
+ ];
19
33
  export default class IgcStepperComponent extends EventEmitterMixin(LitElement) {
20
34
  static { this.tagName = 'igc-stepper'; }
21
35
  static { this.styles = styles; }
22
36
  static register() {
23
37
  registerComponent(IgcStepperComponent, IgcStepComponent);
24
38
  }
25
- orientationChange() {
26
- this.setAttribute('aria-orientation', this.orientation);
27
- this.steps.forEach((step) => {
28
- step.orientation = this.orientation;
29
- this.updateAnimation(step);
30
- });
31
- }
32
- stepTypeChange() {
33
- this.steps.forEach((step) => {
34
- step.stepType = this.stepType;
35
- });
39
+ get _isHorizontal() {
40
+ return this.orientation === 'horizontal';
36
41
  }
37
- titlePositionChange() {
38
- this.steps.forEach((step) => {
39
- step.titlePosition = this.titlePosition;
40
- });
41
- }
42
- contentTopChange() {
43
- this.steps.forEach((step) => {
44
- step.contentTop = this.contentTop;
45
- });
42
+ get steps() {
43
+ return this._state.steps;
46
44
  }
47
- linearChange() {
48
- if (!this.activeStep) {
49
- this._shouldUpdateLinearState = true;
50
- return;
51
- }
52
- this.steps.forEach((step) => {
53
- step.linearDisabled = this.linear;
54
- if (step.index <= this.activeStep.index) {
55
- step.visited = true;
56
- }
57
- else {
58
- step.visited = false;
59
- }
45
+ constructor() {
46
+ super();
47
+ this._state = createStepperState();
48
+ this._contextProvider = new ContextProvider(this, {
49
+ context: STEPPER_CONTEXT,
50
+ initialValue: {
51
+ stepper: this,
52
+ state: this._state,
53
+ },
60
54
  });
61
- if (this.linear) {
62
- this.updateStepsLinearDisabled();
63
- }
64
- }
65
- animationTypeChange() {
66
- this.steps.forEach((step) => {
67
- this.updateAnimation(step);
55
+ this._internals = addInternalsController(this, {
56
+ initialARIA: {
57
+ role: 'tablist',
58
+ },
68
59
  });
69
- }
70
- animationDurationChange() {
71
- this.steps.forEach((step) => {
72
- step.animationDuration = this.animationDuration;
60
+ this._slots = addSlotController(this, {
61
+ slots: setSlots(),
62
+ onChange: this._handleSlotChange,
73
63
  });
74
- }
75
- constructor() {
76
- super();
77
- this.keyDownHandlers = new Map(Object.entries({
78
- Enter: this.activateStep,
79
- Space: this.activateStep,
80
- SpaceBar: this.activateStep,
81
- ' ': this.activateStep,
82
- ArrowUp: this.onArrowUpKeyDown,
83
- ArrowDown: this.onArrowDownKeyDown,
84
- ArrowLeft: this.onArrowLeftKeyDown,
85
- ArrowRight: this.onArrowRightKeyDown,
86
- Home: this.onHomeKey,
87
- End: this.onEndKey,
88
- }));
89
- this._shouldUpdateLinearState = false;
90
64
  this.orientation = 'horizontal';
91
65
  this.stepType = 'full';
92
66
  this.linear = false;
@@ -95,273 +69,181 @@ export default class IgcStepperComponent extends EventEmitterMixin(LitElement) {
95
69
  this.horizontalAnimation = 'slide';
96
70
  this.animationDuration = 320;
97
71
  this.titlePosition = 'auto';
72
+ addSafeEventListener(this, 'click', this._handleInteraction);
98
73
  addThemingController(this, {
99
74
  light: { bootstrap, fluent, indigo },
100
75
  dark: { bootstrap, fluent, indigo },
101
76
  });
102
- this.addEventListener('stepActiveChanged', (event) => {
103
- event.stopPropagation();
104
- this.activateStep(event.target, event.detail);
105
- });
106
- this.addEventListener('stepDisabledInvalidChanged', (event) => {
107
- event.stopPropagation();
108
- if (this.linear) {
109
- this.updateStepsLinearDisabled();
110
- }
111
- });
112
- this.addEventListener('stepCompleteChanged', (event) => {
113
- event.stopPropagation();
114
- const nextStep = this.steps[event.target.index + 1];
115
- if (nextStep) {
116
- nextStep.previousComplete = event.target.complete;
77
+ addKeybindings(this, {
78
+ skip: this._skipKeyboard,
79
+ })
80
+ .set(arrowUp, this._handleArrowUp)
81
+ .set(arrowDown, this._handleArrowDown)
82
+ .set(arrowLeft, this._handleArrowLeft)
83
+ .set(arrowRight, this._handleArrowRight)
84
+ .set(homeKey, this._handleHomeKey)
85
+ .set(endKey, this._handleEndKey)
86
+ .setActivateHandler(this._handleInteraction);
87
+ }
88
+ update(properties) {
89
+ this._syncStepperAttributes(properties);
90
+ if (properties.has('orientation')) {
91
+ this._internals.setARIA({ ariaOrientation: this.orientation });
92
+ }
93
+ if (properties.has('linear')) {
94
+ this._state.setVisitedState(this.linear);
95
+ }
96
+ super.update(properties);
97
+ }
98
+ _skipKeyboard(_, event) {
99
+ return !findElementFromEventPath('[data-step-header]', event);
100
+ }
101
+ _handleHomeKey() {
102
+ this._getStepHeader(first(this._state.accessibleSteps))?.focus();
103
+ }
104
+ _handleEndKey() {
105
+ this._getStepHeader(last(this._state.accessibleSteps))?.focus();
106
+ }
107
+ _handleArrowDown() {
108
+ if (!this._isHorizontal) {
109
+ const step = this._getActiveStepComponent();
110
+ if (step) {
111
+ this._getStepHeader(this._getNextStep(step))?.focus();
117
112
  }
118
- });
119
- this.addEventListener('stepHeaderKeydown', (event) => {
120
- event.stopPropagation();
121
- this.handleKeydown(event.detail.event, event.detail.focusedStep);
122
- });
123
- }
124
- connectedCallback() {
125
- super.connectedCallback();
126
- this.setAttribute('role', 'tablist');
127
- this.setAttribute('aria-orientation', this.orientation);
128
- }
129
- activateFirstStep() {
130
- const firstEnabledStep = this.steps.find((s) => !s.disabled);
131
- if (firstEnabledStep) {
132
- this.activateStep(firstEnabledStep, false);
133
113
  }
134
114
  }
135
- animateSteps(nextStep, currentStep) {
136
- if (nextStep.index > currentStep.index) {
137
- currentStep.toggleAnimation('out');
138
- nextStep.toggleAnimation('in');
139
- }
140
- else {
141
- currentStep.toggleAnimation('in', 'reverse');
142
- nextStep.toggleAnimation('out', 'reverse');
143
- }
144
- }
145
- async activateStep(step, shouldEmit = true) {
146
- if (step === this.activeStep) {
147
- return;
148
- }
149
- if (shouldEmit) {
150
- const args = {
151
- detail: {
152
- owner: this,
153
- oldIndex: this.activeStep.index,
154
- newIndex: step.index,
155
- },
156
- cancelable: true,
157
- };
158
- this.animateSteps(step, this.activeStep);
159
- const allowed = this.emitEvent('igcActiveStepChanging', args);
160
- if (!allowed) {
161
- return;
115
+ _handleArrowUp() {
116
+ if (!this._isHorizontal) {
117
+ const step = this._getActiveStepComponent();
118
+ if (step) {
119
+ this._getStepHeader(this._getPreviousStep(step))?.focus();
162
120
  }
163
- this.changeActiveStep(step);
164
- this.emitEvent('igcActiveStepChanged', {
165
- detail: { owner: this, index: step.index },
166
- });
167
- }
168
- else {
169
- this.changeActiveStep(step);
170
121
  }
171
122
  }
172
- changeActiveStep(step) {
173
- if (this.activeStep) {
174
- this.activeStep.active = false;
123
+ _handleArrowLeft() {
124
+ const step = this._getActiveStepComponent();
125
+ if (step) {
126
+ const next = isLTR(this)
127
+ ? this._getPreviousStep(step)
128
+ : this._getNextStep(step);
129
+ this._getStepHeader(next)?.focus();
175
130
  }
176
- step.active = true;
177
- step.visited = true;
178
- this.activeStep = step;
179
131
  }
180
- moveToNextStep(next = true) {
181
- let steps = this.steps;
182
- let activeStepIndex = this.activeStep.index;
183
- if (!next) {
184
- steps = this.steps.reverse();
185
- activeStepIndex = steps.findIndex((step) => step === this.activeStep);
132
+ _handleArrowRight() {
133
+ const step = this._getActiveStepComponent();
134
+ if (step) {
135
+ const next = isLTR(this)
136
+ ? this._getNextStep(step)
137
+ : this._getPreviousStep(step);
138
+ this._getStepHeader(next)?.focus();
186
139
  }
187
- const nextStep = steps.find((step, i) => i > activeStepIndex && step.isAccessible);
188
- if (nextStep) {
189
- this.animateSteps(nextStep, this.activeStep);
190
- this.activateStep(nextStep, false);
140
+ }
141
+ _handleInteraction(event) {
142
+ const step = findElementFromEventPath(IgcStepComponent.tagName, event);
143
+ if (step && this._state.isAccessible(step)) {
144
+ this._activateStep(step);
191
145
  }
192
146
  }
193
- handleKeydown(event, focusedStep) {
194
- const key = event.key.toLowerCase();
195
- if (this.keyDownHandlers.has(event.key)) {
196
- event.preventDefault();
197
- this.keyDownHandlers.get(event.key)?.call(this, focusedStep);
147
+ _handleSlotChange() {
148
+ this._state.setSteps(this._slots.getAssignedElements('[default]', {
149
+ selector: IgcStepComponent.tagName,
150
+ }));
151
+ this._state.stepsChanged();
152
+ this.style.setProperty('--steps-count', this.steps.length.toString());
153
+ }
154
+ _syncStepperAttributes(properties) {
155
+ if (STEPPER_SYNC_PROPERTIES.some((p) => properties.has(p))) {
156
+ this._contextProvider.updateObservers();
198
157
  }
199
- if (key === 'tab' && this.orientation === 'vertical') {
200
- return;
158
+ }
159
+ _animateSteps(nextStep, currentStep) {
160
+ const steps = this._state.steps;
161
+ if (steps.indexOf(nextStep) > steps.indexOf(currentStep)) {
162
+ currentStep.toggleAnimation('out');
163
+ nextStep.toggleAnimation('in');
201
164
  }
202
- if (key === 'tab' && this.activeStep.index !== focusedStep.index) {
203
- this.activeStep.header.focus();
165
+ else {
166
+ currentStep.toggleAnimation('in', 'reverse');
167
+ nextStep.toggleAnimation('out', 'reverse');
204
168
  }
205
169
  }
206
- onHomeKey() {
207
- this.steps
208
- .filter((step) => step.isAccessible)[0]
209
- ?.header?.focus();
170
+ _emitChanging(args) {
171
+ return this.emitEvent('igcActiveStepChanging', {
172
+ detail: args,
173
+ cancelable: true,
174
+ });
210
175
  }
211
- onEndKey() {
212
- this.steps
213
- .filter((step) => step.isAccessible)
214
- .pop()
215
- ?.header?.focus();
176
+ _emitChanged(args) {
177
+ this.emitEvent('igcActiveStepChanged', {
178
+ detail: args,
179
+ });
216
180
  }
217
- onArrowDownKeyDown(focusedStep) {
218
- if (this.orientation === 'horizontal') {
181
+ _activateStep(step, shouldEmit = true) {
182
+ if (step === this._state.activeStep) {
219
183
  return;
220
184
  }
221
- this.getNextStep(focusedStep)?.header?.focus();
222
- }
223
- onArrowUpKeyDown(focusedStep) {
224
- if (this.orientation === 'horizontal') {
185
+ if (!shouldEmit) {
186
+ this._state.changeActiveStep(step);
225
187
  return;
226
188
  }
227
- this.getPreviousStep(focusedStep)?.header?.focus();
228
- }
229
- onArrowRightKeyDown(focusedStep) {
230
- if (!isLTR(this) && this.orientation === 'horizontal') {
231
- this.getPreviousStep(focusedStep)?.header?.focus();
232
- }
233
- else {
234
- this.getNextStep(focusedStep)?.header?.focus();
235
- }
236
- }
237
- onArrowLeftKeyDown(focusedStep) {
238
- if (!isLTR(this) && this.orientation === 'horizontal') {
239
- this.getNextStep(focusedStep)?.header?.focus();
240
- }
241
- else {
242
- this.getPreviousStep(focusedStep)?.header?.focus();
189
+ const steps = this._state.steps;
190
+ const activeIndex = steps.indexOf(this._state.activeStep);
191
+ const index = steps.indexOf(step);
192
+ const args = { oldIndex: activeIndex, newIndex: index };
193
+ if (!this._emitChanging(args)) {
194
+ return;
243
195
  }
244
- }
245
- getNextStep(focusedStep) {
246
- if (focusedStep.index === this.steps.length - 1) {
247
- return this.steps.find((step) => step.isAccessible);
196
+ if (this._state.activeStep) {
197
+ this._animateSteps(step, this._state.activeStep);
248
198
  }
249
- const nextAccessible = this.steps.find((step, i) => i > focusedStep.index && step.isAccessible);
250
- return nextAccessible
251
- ? nextAccessible
252
- : this.steps.find((step) => step.isAccessible);
199
+ this._state.changeActiveStep(step);
200
+ this._emitChanged({ index });
253
201
  }
254
- getPreviousStep(focusedStep) {
255
- if (focusedStep.index === 0) {
256
- return this.steps
257
- .filter((step) => step.isAccessible)
258
- .pop();
259
- }
260
- let prevStep;
261
- for (let i = focusedStep.index - 1; i >= 0; i--) {
262
- const step = this.steps[i];
263
- if (step.isAccessible) {
264
- prevStep = step;
265
- break;
202
+ _moveToNextStep(next = true) {
203
+ const step = this._state.getAdjacentStep(next);
204
+ if (step) {
205
+ if (this._state.activeStep) {
206
+ this._animateSteps(step, this._state.activeStep);
266
207
  }
208
+ this._state.changeActiveStep(step);
267
209
  }
268
- return prevStep
269
- ? prevStep
270
- : this.steps.filter((step) => step.isAccessible).pop();
271
210
  }
272
- updateStepsLinearDisabled() {
273
- const firstInvalidStep = this.steps
274
- .filter((step) => !step.disabled && !step.optional)
275
- .find((step) => step.invalid);
276
- if (firstInvalidStep) {
277
- this.steps.forEach((step) => {
278
- if (step.index <= firstInvalidStep.index) {
279
- step.linearDisabled = false;
280
- }
281
- else {
282
- step.linearDisabled = true;
283
- }
284
- });
285
- }
286
- else {
287
- this.steps.forEach((step) => {
288
- step.linearDisabled = false;
289
- });
290
- }
211
+ _getNextStep(step) {
212
+ const steps = this._state.accessibleSteps;
213
+ const next = wrap(0, steps.length - 1, steps.indexOf(step) + 1);
214
+ return steps[next];
291
215
  }
292
- updateAnimation(step) {
293
- if (this.orientation === 'horizontal') {
294
- step.animation = this.horizontalAnimation;
295
- }
296
- if (this.orientation === 'vertical') {
297
- step.animation = this.verticalAnimation;
298
- }
216
+ _getPreviousStep(step) {
217
+ const steps = this._state.accessibleSteps;
218
+ const previous = wrap(0, steps.length - 1, steps.indexOf(step) - 1);
219
+ return steps[previous];
299
220
  }
300
- syncProperties() {
301
- this.steps.forEach((step, index) => {
302
- step.orientation = this.orientation;
303
- step.stepType = this.stepType;
304
- step.titlePosition = this.titlePosition;
305
- step.contentTop = this.contentTop;
306
- step.index = index;
307
- step.active = this.activeStep === step;
308
- step.header?.setAttribute('aria-posinset', (index + 1).toString());
309
- step.header?.setAttribute('aria-setsize', this.steps.length.toString());
310
- step.header?.setAttribute('id', `igc-step-header-${index}`);
311
- step.header?.setAttribute('aria-controls', `igc-step-content-${index}`);
312
- if (index > 0) {
313
- step.previousComplete = this.steps[index - 1].complete;
314
- }
315
- step.animationDuration = this.animationDuration;
316
- this.updateAnimation(step);
317
- });
221
+ _getActiveStepComponent() {
222
+ const active = getRoot(this).activeElement;
223
+ return active ? active.closest(IgcStepComponent.tagName) : null;
318
224
  }
319
- stepsChanged() {
320
- this.style.setProperty('--steps-count', this.steps.length.toString());
321
- const lastActiveStep = this.steps
322
- .reverse()
323
- .find((step) => step.active);
324
- if (!lastActiveStep) {
325
- this.activateFirstStep();
326
- }
327
- else {
328
- this.activateStep(lastActiveStep, false);
329
- }
330
- this.syncProperties();
331
- if (this._shouldUpdateLinearState) {
332
- this.linearChange();
333
- this._shouldUpdateLinearState = false;
334
- }
335
- if (this.linear) {
336
- this.updateStepsLinearDisabled();
337
- }
225
+ _getStepHeader(step) {
226
+ return step?.renderRoot.querySelector('[data-step-header]') ?? null;
338
227
  }
339
228
  navigateTo(index) {
340
- const step = this.steps[index];
341
- if (!step) {
342
- return;
229
+ const step = this._state.steps[index];
230
+ if (step) {
231
+ this._activateStep(step, false);
343
232
  }
344
- this.activateStep(step, false);
345
233
  }
346
234
  next() {
347
- this.moveToNextStep();
235
+ this._moveToNextStep();
348
236
  }
349
237
  prev() {
350
- this.moveToNextStep(false);
238
+ this._moveToNextStep(false);
351
239
  }
352
240
  reset() {
353
- this.steps.forEach((step) => {
354
- step.visited = false;
355
- });
356
- this.activateFirstStep();
241
+ this._state.reset();
357
242
  }
358
243
  render() {
359
- return html `<slot @slotchange=${this.stepsChanged}></slot>`;
244
+ return html `<slot></slot>`;
360
245
  }
361
246
  }
362
- __decorate([
363
- queryAssignedElements({ selector: 'igc-step' })
364
- ], IgcStepperComponent.prototype, "steps", void 0);
365
247
  __decorate([
366
248
  property({ reflect: true })
367
249
  ], IgcStepperComponent.prototype, "orientation", void 0);
@@ -369,10 +251,10 @@ __decorate([
369
251
  property({ reflect: true, attribute: 'step-type' })
370
252
  ], IgcStepperComponent.prototype, "stepType", void 0);
371
253
  __decorate([
372
- property({ type: Boolean })
254
+ property({ type: Boolean, reflect: true })
373
255
  ], IgcStepperComponent.prototype, "linear", void 0);
374
256
  __decorate([
375
- property({ reflect: true, type: Boolean, attribute: 'content-top' })
257
+ property({ type: Boolean, reflect: true, attribute: 'content-top' })
376
258
  ], IgcStepperComponent.prototype, "contentTop", void 0);
377
259
  __decorate([
378
260
  property({ attribute: 'vertical-animation' })
@@ -381,31 +263,9 @@ __decorate([
381
263
  property({ attribute: 'horizontal-animation' })
382
264
  ], IgcStepperComponent.prototype, "horizontalAnimation", void 0);
383
265
  __decorate([
384
- property({ attribute: 'animation-duration', type: Number })
266
+ property({ type: Number, attribute: 'animation-duration' })
385
267
  ], IgcStepperComponent.prototype, "animationDuration", void 0);
386
268
  __decorate([
387
269
  property({ reflect: false, attribute: 'title-position' })
388
270
  ], IgcStepperComponent.prototype, "titlePosition", void 0);
389
- __decorate([
390
- watch('orientation', { waitUntilFirstUpdate: true })
391
- ], IgcStepperComponent.prototype, "orientationChange", null);
392
- __decorate([
393
- watch('stepType', { waitUntilFirstUpdate: true })
394
- ], IgcStepperComponent.prototype, "stepTypeChange", null);
395
- __decorate([
396
- watch('titlePosition', { waitUntilFirstUpdate: true })
397
- ], IgcStepperComponent.prototype, "titlePositionChange", null);
398
- __decorate([
399
- watch('contentTop', { waitUntilFirstUpdate: true })
400
- ], IgcStepperComponent.prototype, "contentTopChange", null);
401
- __decorate([
402
- watch('linear', { waitUntilFirstUpdate: true })
403
- ], IgcStepperComponent.prototype, "linearChange", null);
404
- __decorate([
405
- watch('verticalAnimation', { waitUntilFirstUpdate: true }),
406
- watch('horizontalAnimation', { waitUntilFirstUpdate: true })
407
- ], IgcStepperComponent.prototype, "animationTypeChange", null);
408
- __decorate([
409
- watch('animationDuration', { waitUntilFirstUpdate: true })
410
- ], IgcStepperComponent.prototype, "animationDurationChange", null);
411
271
  //# sourceMappingURL=stepper.js.map