@idds/js 1.0.51 → 1.0.53

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.
@@ -90,8 +90,9 @@ var InaUI = (() => {
90
90
  const accordions = group.querySelectorAll(`:scope > .${PREFIX}-accordion`);
91
91
  accordions.forEach((accordion, _index) => {
92
92
  const toggle = accordion.querySelector(`.${PREFIX}-accordion__toggle`);
93
- const body = accordion.querySelector(`.${PREFIX}-accordion__content`);
94
- if (!toggle || !body) return;
93
+ const content = accordion.querySelector(`.${PREFIX}-accordion__content`);
94
+ const body = accordion.querySelector(`.${PREFIX}-accordion__body`);
95
+ if (!toggle || !content || !body) return;
95
96
  toggle.addEventListener("click", (e) => {
96
97
  e.stopPropagation();
97
98
  const isOpen = accordion.classList.contains(
@@ -100,9 +101,9 @@ var InaUI = (() => {
100
101
  const nextState = !isOpen;
101
102
  if (isMultiple) {
102
103
  if (nextState) {
103
- openItem(accordion, toggle, body);
104
+ openItem(accordion, toggle, content, body);
104
105
  } else {
105
- closeItem(accordion, toggle, body);
106
+ closeItem(accordion, toggle, content, body);
106
107
  }
107
108
  } else {
108
109
  if (nextState) {
@@ -111,17 +112,20 @@ var InaUI = (() => {
111
112
  const otherToggle = otherAcc.querySelector(
112
113
  `.${PREFIX}-accordion__toggle`
113
114
  );
114
- const otherBody = otherAcc.querySelector(
115
+ const otherContent = otherAcc.querySelector(
115
116
  `.${PREFIX}-accordion__content`
116
117
  );
117
- if (otherToggle && otherBody) {
118
- closeItem(otherAcc, otherToggle, otherBody);
118
+ const otherBody = otherAcc.querySelector(
119
+ `.${PREFIX}-accordion__body`
120
+ );
121
+ if (otherToggle && otherContent && otherBody) {
122
+ closeItem(otherAcc, otherToggle, otherContent, otherBody);
119
123
  }
120
124
  }
121
125
  });
122
- openItem(accordion, toggle, body);
126
+ openItem(accordion, toggle, content, body);
123
127
  } else {
124
- closeItem(accordion, toggle, body);
128
+ closeItem(accordion, toggle, content, body);
125
129
  }
126
130
  }
127
131
  });
@@ -132,35 +136,38 @@ var InaUI = (() => {
132
136
  );
133
137
  standaloneAccordions.forEach((accordion) => {
134
138
  const toggle = accordion.querySelector(`.${PREFIX}-accordion__toggle`);
135
- const body = accordion.querySelector(`.${PREFIX}-accordion__content`);
136
- if (!toggle || !body) return;
139
+ const content = accordion.querySelector(`.${PREFIX}-accordion__content`);
140
+ const body = accordion.querySelector(`.${PREFIX}-accordion__body`);
141
+ if (!toggle || !content || !body) return;
137
142
  toggle.addEventListener("click", (e) => {
138
143
  e.stopPropagation();
139
144
  const isOpen = accordion.classList.contains(`${PREFIX}-accordion--open`);
140
145
  if (isOpen) {
141
- closeItem(accordion, toggle, body);
146
+ closeItem(accordion, toggle, content, body);
142
147
  } else {
143
- openItem(accordion, toggle, body);
148
+ openItem(accordion, toggle, content, body);
144
149
  }
145
150
  });
146
151
  });
147
152
  }
148
- function openItem(accordion, toggle, body) {
153
+ function openItem(accordion, toggle, content, body) {
149
154
  accordion.classList.add(`${PREFIX}-accordion--open`);
150
155
  toggle.setAttribute("aria-expanded", "true");
151
156
  const icon = toggle.querySelector(`.${PREFIX}-accordion__icon`);
152
157
  if (icon) icon.classList.add(`${PREFIX}-accordion__icon--open`);
153
- body.classList.add(`${PREFIX}-accordion__content--open`);
158
+ content.classList.add(`${PREFIX}-accordion__content--open`);
159
+ body.classList.add(`${PREFIX}-accordion__body--open`);
154
160
  if (body) {
155
161
  body.style.maxHeight = `${body.scrollHeight}px`;
156
162
  }
157
163
  }
158
- function closeItem(accordion, toggle, body) {
164
+ function closeItem(accordion, toggle, content, body) {
159
165
  accordion.classList.remove(`${PREFIX}-accordion--open`);
160
166
  toggle.setAttribute("aria-expanded", "false");
161
167
  const icon = toggle.querySelector(`.${PREFIX}-accordion__icon`);
162
168
  if (icon) icon.classList.remove(`${PREFIX}-accordion__icon--open`);
163
- body.classList.remove(`${PREFIX}-accordion__content--open`);
169
+ content.classList.remove(`${PREFIX}-accordion__content--open`);
170
+ body.classList.remove(`${PREFIX}-accordion__body--open`);
164
171
  if (body) {
165
172
  body.style.maxHeight = null;
166
173
  }
package/dist/index.js CHANGED
@@ -78,8 +78,9 @@ function initAccordion(rootSelector = `.${PREFIX}-accordion-group`) {
78
78
  const accordions = group.querySelectorAll(`:scope > .${PREFIX}-accordion`);
79
79
  accordions.forEach((accordion, _index) => {
80
80
  const toggle = accordion.querySelector(`.${PREFIX}-accordion__toggle`);
81
- const body = accordion.querySelector(`.${PREFIX}-accordion__content`);
82
- if (!toggle || !body) return;
81
+ const content = accordion.querySelector(`.${PREFIX}-accordion__content`);
82
+ const body = accordion.querySelector(`.${PREFIX}-accordion__body`);
83
+ if (!toggle || !content || !body) return;
83
84
  toggle.addEventListener("click", (e) => {
84
85
  e.stopPropagation();
85
86
  const isOpen = accordion.classList.contains(
@@ -88,9 +89,9 @@ function initAccordion(rootSelector = `.${PREFIX}-accordion-group`) {
88
89
  const nextState = !isOpen;
89
90
  if (isMultiple) {
90
91
  if (nextState) {
91
- openItem(accordion, toggle, body);
92
+ openItem(accordion, toggle, content, body);
92
93
  } else {
93
- closeItem(accordion, toggle, body);
94
+ closeItem(accordion, toggle, content, body);
94
95
  }
95
96
  } else {
96
97
  if (nextState) {
@@ -99,17 +100,20 @@ function initAccordion(rootSelector = `.${PREFIX}-accordion-group`) {
99
100
  const otherToggle = otherAcc.querySelector(
100
101
  `.${PREFIX}-accordion__toggle`
101
102
  );
102
- const otherBody = otherAcc.querySelector(
103
+ const otherContent = otherAcc.querySelector(
103
104
  `.${PREFIX}-accordion__content`
104
105
  );
105
- if (otherToggle && otherBody) {
106
- closeItem(otherAcc, otherToggle, otherBody);
106
+ const otherBody = otherAcc.querySelector(
107
+ `.${PREFIX}-accordion__body`
108
+ );
109
+ if (otherToggle && otherContent && otherBody) {
110
+ closeItem(otherAcc, otherToggle, otherContent, otherBody);
107
111
  }
108
112
  }
109
113
  });
110
- openItem(accordion, toggle, body);
114
+ openItem(accordion, toggle, content, body);
111
115
  } else {
112
- closeItem(accordion, toggle, body);
116
+ closeItem(accordion, toggle, content, body);
113
117
  }
114
118
  }
115
119
  });
@@ -120,35 +124,38 @@ function initAccordion(rootSelector = `.${PREFIX}-accordion-group`) {
120
124
  );
121
125
  standaloneAccordions.forEach((accordion) => {
122
126
  const toggle = accordion.querySelector(`.${PREFIX}-accordion__toggle`);
123
- const body = accordion.querySelector(`.${PREFIX}-accordion__content`);
124
- if (!toggle || !body) return;
127
+ const content = accordion.querySelector(`.${PREFIX}-accordion__content`);
128
+ const body = accordion.querySelector(`.${PREFIX}-accordion__body`);
129
+ if (!toggle || !content || !body) return;
125
130
  toggle.addEventListener("click", (e) => {
126
131
  e.stopPropagation();
127
132
  const isOpen = accordion.classList.contains(`${PREFIX}-accordion--open`);
128
133
  if (isOpen) {
129
- closeItem(accordion, toggle, body);
134
+ closeItem(accordion, toggle, content, body);
130
135
  } else {
131
- openItem(accordion, toggle, body);
136
+ openItem(accordion, toggle, content, body);
132
137
  }
133
138
  });
134
139
  });
135
140
  }
136
- function openItem(accordion, toggle, body) {
141
+ function openItem(accordion, toggle, content, body) {
137
142
  accordion.classList.add(`${PREFIX}-accordion--open`);
138
143
  toggle.setAttribute("aria-expanded", "true");
139
144
  const icon = toggle.querySelector(`.${PREFIX}-accordion__icon`);
140
145
  if (icon) icon.classList.add(`${PREFIX}-accordion__icon--open`);
141
- body.classList.add(`${PREFIX}-accordion__content--open`);
146
+ content.classList.add(`${PREFIX}-accordion__content--open`);
147
+ body.classList.add(`${PREFIX}-accordion__body--open`);
142
148
  if (body) {
143
149
  body.style.maxHeight = `${body.scrollHeight}px`;
144
150
  }
145
151
  }
146
- function closeItem(accordion, toggle, body) {
152
+ function closeItem(accordion, toggle, content, body) {
147
153
  accordion.classList.remove(`${PREFIX}-accordion--open`);
148
154
  toggle.setAttribute("aria-expanded", "false");
149
155
  const icon = toggle.querySelector(`.${PREFIX}-accordion__icon`);
150
156
  if (icon) icon.classList.remove(`${PREFIX}-accordion__icon--open`);
151
- body.classList.remove(`${PREFIX}-accordion__content--open`);
157
+ content.classList.remove(`${PREFIX}-accordion__content--open`);
158
+ body.classList.remove(`${PREFIX}-accordion__body--open`);
152
159
  if (body) {
153
160
  body.style.maxHeight = null;
154
161
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idds/js",
3
- "version": "1.0.51",
3
+ "version": "1.0.53",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },