@idds/js 1.0.52 → 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.
@@ -85,28 +85,15 @@ var InaUI = (() => {
85
85
  // src/js/components/stateless/accordion.js
86
86
  function initAccordion(rootSelector = `.${PREFIX}-accordion-group`) {
87
87
  const accordionGroups = document.querySelectorAll(rootSelector);
88
- console.log(
89
- "[InaUI] initAccordion called. Selector:",
90
- rootSelector,
91
- "Found groups:",
92
- accordionGroups.length
93
- );
94
88
  accordionGroups.forEach((group) => {
95
89
  const isMultiple = group.getAttribute("data-multiple-open") === "true" || group.getAttribute("data-behavior") === "multiple";
96
90
  const accordions = group.querySelectorAll(`:scope > .${PREFIX}-accordion`);
97
- console.log("[InaUI] Found direct accordions in group:", accordions.length);
98
91
  accordions.forEach((accordion, _index) => {
99
92
  const toggle = accordion.querySelector(`.${PREFIX}-accordion__toggle`);
100
- const body = accordion.querySelector(`.${PREFIX}-accordion__content`);
101
- if (!toggle || !body) {
102
- console.warn(
103
- "[InaUI] Accordion item missing toggle or body",
104
- accordion
105
- );
106
- return;
107
- }
93
+ const content = accordion.querySelector(`.${PREFIX}-accordion__content`);
94
+ const body = accordion.querySelector(`.${PREFIX}-accordion__body`);
95
+ if (!toggle || !content || !body) return;
108
96
  toggle.addEventListener("click", (e) => {
109
- console.log("[InaUI] Accordion toggle clicked");
110
97
  e.stopPropagation();
111
98
  const isOpen = accordion.classList.contains(
112
99
  `${PREFIX}-accordion--open`
@@ -114,9 +101,9 @@ var InaUI = (() => {
114
101
  const nextState = !isOpen;
115
102
  if (isMultiple) {
116
103
  if (nextState) {
117
- openItem(accordion, toggle, body);
104
+ openItem(accordion, toggle, content, body);
118
105
  } else {
119
- closeItem(accordion, toggle, body);
106
+ closeItem(accordion, toggle, content, body);
120
107
  }
121
108
  } else {
122
109
  if (nextState) {
@@ -125,17 +112,20 @@ var InaUI = (() => {
125
112
  const otherToggle = otherAcc.querySelector(
126
113
  `.${PREFIX}-accordion__toggle`
127
114
  );
128
- const otherBody = otherAcc.querySelector(
115
+ const otherContent = otherAcc.querySelector(
129
116
  `.${PREFIX}-accordion__content`
130
117
  );
131
- if (otherToggle && otherBody) {
132
- 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);
133
123
  }
134
124
  }
135
125
  });
136
- openItem(accordion, toggle, body);
126
+ openItem(accordion, toggle, content, body);
137
127
  } else {
138
- closeItem(accordion, toggle, body);
128
+ closeItem(accordion, toggle, content, body);
139
129
  }
140
130
  }
141
131
  });
@@ -146,36 +136,38 @@ var InaUI = (() => {
146
136
  );
147
137
  standaloneAccordions.forEach((accordion) => {
148
138
  const toggle = accordion.querySelector(`.${PREFIX}-accordion__toggle`);
149
- const body = accordion.querySelector(`.${PREFIX}-accordion__content`);
150
- 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;
151
142
  toggle.addEventListener("click", (e) => {
152
143
  e.stopPropagation();
153
144
  const isOpen = accordion.classList.contains(`${PREFIX}-accordion--open`);
154
145
  if (isOpen) {
155
- closeItem(accordion, toggle, body);
146
+ closeItem(accordion, toggle, content, body);
156
147
  } else {
157
- openItem(accordion, toggle, body);
148
+ openItem(accordion, toggle, content, body);
158
149
  }
159
150
  });
160
151
  });
161
152
  }
162
- function openItem(accordion, toggle, body) {
153
+ function openItem(accordion, toggle, content, body) {
163
154
  accordion.classList.add(`${PREFIX}-accordion--open`);
164
155
  toggle.setAttribute("aria-expanded", "true");
165
156
  const icon = toggle.querySelector(`.${PREFIX}-accordion__icon`);
166
157
  if (icon) icon.classList.add(`${PREFIX}-accordion__icon--open`);
167
- body.classList.add(`${PREFIX}-accordion__content--open`);
158
+ content.classList.add(`${PREFIX}-accordion__content--open`);
159
+ body.classList.add(`${PREFIX}-accordion__body--open`);
168
160
  if (body) {
169
- console.log("[InaUI] Setting maxHeight to", body.scrollHeight);
170
161
  body.style.maxHeight = `${body.scrollHeight}px`;
171
162
  }
172
163
  }
173
- function closeItem(accordion, toggle, body) {
164
+ function closeItem(accordion, toggle, content, body) {
174
165
  accordion.classList.remove(`${PREFIX}-accordion--open`);
175
166
  toggle.setAttribute("aria-expanded", "false");
176
167
  const icon = toggle.querySelector(`.${PREFIX}-accordion__icon`);
177
168
  if (icon) icon.classList.remove(`${PREFIX}-accordion__icon--open`);
178
- body.classList.remove(`${PREFIX}-accordion__content--open`);
169
+ content.classList.remove(`${PREFIX}-accordion__content--open`);
170
+ body.classList.remove(`${PREFIX}-accordion__body--open`);
179
171
  if (body) {
180
172
  body.style.maxHeight = null;
181
173
  }
package/dist/index.js CHANGED
@@ -73,28 +73,15 @@ function initToggle(rootSelector = `.${PREFIX}-toggle`) {
73
73
  // src/js/components/stateless/accordion.js
74
74
  function initAccordion(rootSelector = `.${PREFIX}-accordion-group`) {
75
75
  const accordionGroups = document.querySelectorAll(rootSelector);
76
- console.log(
77
- "[InaUI] initAccordion called. Selector:",
78
- rootSelector,
79
- "Found groups:",
80
- accordionGroups.length
81
- );
82
76
  accordionGroups.forEach((group) => {
83
77
  const isMultiple = group.getAttribute("data-multiple-open") === "true" || group.getAttribute("data-behavior") === "multiple";
84
78
  const accordions = group.querySelectorAll(`:scope > .${PREFIX}-accordion`);
85
- console.log("[InaUI] Found direct accordions in group:", accordions.length);
86
79
  accordions.forEach((accordion, _index) => {
87
80
  const toggle = accordion.querySelector(`.${PREFIX}-accordion__toggle`);
88
- const body = accordion.querySelector(`.${PREFIX}-accordion__content`);
89
- if (!toggle || !body) {
90
- console.warn(
91
- "[InaUI] Accordion item missing toggle or body",
92
- accordion
93
- );
94
- return;
95
- }
81
+ const content = accordion.querySelector(`.${PREFIX}-accordion__content`);
82
+ const body = accordion.querySelector(`.${PREFIX}-accordion__body`);
83
+ if (!toggle || !content || !body) return;
96
84
  toggle.addEventListener("click", (e) => {
97
- console.log("[InaUI] Accordion toggle clicked");
98
85
  e.stopPropagation();
99
86
  const isOpen = accordion.classList.contains(
100
87
  `${PREFIX}-accordion--open`
@@ -102,9 +89,9 @@ function initAccordion(rootSelector = `.${PREFIX}-accordion-group`) {
102
89
  const nextState = !isOpen;
103
90
  if (isMultiple) {
104
91
  if (nextState) {
105
- openItem(accordion, toggle, body);
92
+ openItem(accordion, toggle, content, body);
106
93
  } else {
107
- closeItem(accordion, toggle, body);
94
+ closeItem(accordion, toggle, content, body);
108
95
  }
109
96
  } else {
110
97
  if (nextState) {
@@ -113,17 +100,20 @@ function initAccordion(rootSelector = `.${PREFIX}-accordion-group`) {
113
100
  const otherToggle = otherAcc.querySelector(
114
101
  `.${PREFIX}-accordion__toggle`
115
102
  );
116
- const otherBody = otherAcc.querySelector(
103
+ const otherContent = otherAcc.querySelector(
117
104
  `.${PREFIX}-accordion__content`
118
105
  );
119
- if (otherToggle && otherBody) {
120
- 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);
121
111
  }
122
112
  }
123
113
  });
124
- openItem(accordion, toggle, body);
114
+ openItem(accordion, toggle, content, body);
125
115
  } else {
126
- closeItem(accordion, toggle, body);
116
+ closeItem(accordion, toggle, content, body);
127
117
  }
128
118
  }
129
119
  });
@@ -134,36 +124,38 @@ function initAccordion(rootSelector = `.${PREFIX}-accordion-group`) {
134
124
  );
135
125
  standaloneAccordions.forEach((accordion) => {
136
126
  const toggle = accordion.querySelector(`.${PREFIX}-accordion__toggle`);
137
- const body = accordion.querySelector(`.${PREFIX}-accordion__content`);
138
- 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;
139
130
  toggle.addEventListener("click", (e) => {
140
131
  e.stopPropagation();
141
132
  const isOpen = accordion.classList.contains(`${PREFIX}-accordion--open`);
142
133
  if (isOpen) {
143
- closeItem(accordion, toggle, body);
134
+ closeItem(accordion, toggle, content, body);
144
135
  } else {
145
- openItem(accordion, toggle, body);
136
+ openItem(accordion, toggle, content, body);
146
137
  }
147
138
  });
148
139
  });
149
140
  }
150
- function openItem(accordion, toggle, body) {
141
+ function openItem(accordion, toggle, content, body) {
151
142
  accordion.classList.add(`${PREFIX}-accordion--open`);
152
143
  toggle.setAttribute("aria-expanded", "true");
153
144
  const icon = toggle.querySelector(`.${PREFIX}-accordion__icon`);
154
145
  if (icon) icon.classList.add(`${PREFIX}-accordion__icon--open`);
155
- body.classList.add(`${PREFIX}-accordion__content--open`);
146
+ content.classList.add(`${PREFIX}-accordion__content--open`);
147
+ body.classList.add(`${PREFIX}-accordion__body--open`);
156
148
  if (body) {
157
- console.log("[InaUI] Setting maxHeight to", body.scrollHeight);
158
149
  body.style.maxHeight = `${body.scrollHeight}px`;
159
150
  }
160
151
  }
161
- function closeItem(accordion, toggle, body) {
152
+ function closeItem(accordion, toggle, content, body) {
162
153
  accordion.classList.remove(`${PREFIX}-accordion--open`);
163
154
  toggle.setAttribute("aria-expanded", "false");
164
155
  const icon = toggle.querySelector(`.${PREFIX}-accordion__icon`);
165
156
  if (icon) icon.classList.remove(`${PREFIX}-accordion__icon--open`);
166
- body.classList.remove(`${PREFIX}-accordion__content--open`);
157
+ content.classList.remove(`${PREFIX}-accordion__content--open`);
158
+ body.classList.remove(`${PREFIX}-accordion__body--open`);
167
159
  if (body) {
168
160
  body.style.maxHeight = null;
169
161
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idds/js",
3
- "version": "1.0.52",
3
+ "version": "1.0.53",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },