@idds/js 1.0.47 → 1.0.49
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/dist/index.iife.js +70 -28
- package/dist/index.js +70 -28
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -83,39 +83,81 @@ var InaUI = (() => {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// src/js/components/stateless/accordion.js
|
|
86
|
-
function initAccordion(rootSelector = `.${PREFIX}-accordion`) {
|
|
87
|
-
document.querySelectorAll(rootSelector)
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (body2) {
|
|
107
|
-
body2.style.maxHeight = null;
|
|
86
|
+
function initAccordion(rootSelector = `.${PREFIX}-accordion-group`) {
|
|
87
|
+
const accordionGroups = document.querySelectorAll(rootSelector);
|
|
88
|
+
accordionGroups.forEach((group) => {
|
|
89
|
+
const isMultiple = group.dataset.multipleOpen === "true" || group.dataset.behavior === "multiple";
|
|
90
|
+
const accordions = group.querySelectorAll(`:scope > .${PREFIX}-accordion`);
|
|
91
|
+
accordions.forEach((accordion, _index) => {
|
|
92
|
+
const toggle = accordion.querySelector(`.${PREFIX}-accordion__toggle`);
|
|
93
|
+
const body = accordion.querySelector(`.${PREFIX}-accordion__content`);
|
|
94
|
+
if (!toggle || !body) return;
|
|
95
|
+
toggle.addEventListener("click", (e) => {
|
|
96
|
+
e.stopPropagation();
|
|
97
|
+
const isOpen = accordion.classList.contains(
|
|
98
|
+
`${PREFIX}-accordion--open`
|
|
99
|
+
);
|
|
100
|
+
const nextState = !isOpen;
|
|
101
|
+
if (isMultiple) {
|
|
102
|
+
if (nextState) {
|
|
103
|
+
openItem(accordion, toggle, body);
|
|
104
|
+
} else {
|
|
105
|
+
closeItem(accordion, toggle, body);
|
|
108
106
|
}
|
|
109
|
-
}
|
|
110
|
-
if (behavior === "single") {
|
|
111
|
-
accordion.querySelectorAll(`.${PREFIX}-accordion__item`).forEach((item) => closeAccordionItem(item));
|
|
112
|
-
if (!isOpen) openAccordionItem(currentItem);
|
|
113
107
|
} else {
|
|
114
|
-
|
|
108
|
+
if (nextState) {
|
|
109
|
+
accordions.forEach((otherAcc) => {
|
|
110
|
+
if (otherAcc !== accordion) {
|
|
111
|
+
const otherToggle = otherAcc.querySelector(
|
|
112
|
+
`.${PREFIX}-accordion__toggle`
|
|
113
|
+
);
|
|
114
|
+
const otherBody = otherAcc.querySelector(
|
|
115
|
+
`.${PREFIX}-accordion__content`
|
|
116
|
+
);
|
|
117
|
+
if (otherToggle && otherBody) {
|
|
118
|
+
closeItem(otherAcc, otherToggle, otherBody);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
openItem(accordion, toggle, body);
|
|
123
|
+
} else {
|
|
124
|
+
closeItem(accordion, toggle, body);
|
|
125
|
+
}
|
|
115
126
|
}
|
|
116
127
|
});
|
|
117
128
|
});
|
|
118
129
|
});
|
|
130
|
+
const standaloneAccordions = document.querySelectorAll(
|
|
131
|
+
`.${PREFIX}-accordion:not(.${PREFIX}-accordion-group .${PREFIX}-accordion)`
|
|
132
|
+
);
|
|
133
|
+
standaloneAccordions.forEach((accordion) => {
|
|
134
|
+
const toggle = accordion.querySelector(`.${PREFIX}-accordion__toggle`);
|
|
135
|
+
const body = accordion.querySelector(`.${PREFIX}-accordion__content`);
|
|
136
|
+
if (!toggle || !body) return;
|
|
137
|
+
toggle.addEventListener("click", (e) => {
|
|
138
|
+
e.stopPropagation();
|
|
139
|
+
const isOpen = accordion.classList.contains(`${PREFIX}-accordion--open`);
|
|
140
|
+
if (isOpen) {
|
|
141
|
+
closeItem(accordion, toggle, body);
|
|
142
|
+
} else {
|
|
143
|
+
openItem(accordion, toggle, body);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function openItem(accordion, toggle, body) {
|
|
149
|
+
accordion.classList.add(`${PREFIX}-accordion--open`);
|
|
150
|
+
toggle.setAttribute("aria-expanded", "true");
|
|
151
|
+
const icon = toggle.querySelector(`.${PREFIX}-accordion__icon`);
|
|
152
|
+
if (icon) icon.classList.add(`${PREFIX}-accordion__icon--open`);
|
|
153
|
+
body.classList.add(`${PREFIX}-accordion__content--open`);
|
|
154
|
+
}
|
|
155
|
+
function closeItem(accordion, toggle, body) {
|
|
156
|
+
accordion.classList.remove(`${PREFIX}-accordion--open`);
|
|
157
|
+
toggle.setAttribute("aria-expanded", "false");
|
|
158
|
+
const icon = toggle.querySelector(`.${PREFIX}-accordion__icon`);
|
|
159
|
+
if (icon) icon.classList.remove(`${PREFIX}-accordion__icon--open`);
|
|
160
|
+
body.classList.remove(`${PREFIX}-accordion__content--open`);
|
|
119
161
|
}
|
|
120
162
|
|
|
121
163
|
// src/js/components/stateful/datepicker.js
|
|
@@ -1020,7 +1062,7 @@ var InaUI = (() => {
|
|
|
1020
1062
|
const wrapper = picker.querySelector(".ina-time-picker__wrapper");
|
|
1021
1063
|
if (!input || !wrapper) return;
|
|
1022
1064
|
const format = picker.dataset.format || "HH:mm";
|
|
1023
|
-
const use12Hours = picker.dataset.use12Hours === "true" || picker.getAttribute("data-use-12-hours") === "true";
|
|
1065
|
+
const use12Hours = picker.dataset.use12Hours === "true" || picker.getAttribute("data-use-12-hours") === "true" || /a/i.test(format);
|
|
1024
1066
|
const showSecond = picker.dataset.showSecond === "true";
|
|
1025
1067
|
const disabled = picker.classList.contains("ina-time-picker--disabled");
|
|
1026
1068
|
const allowClear = picker.dataset.allowClear !== "false";
|
package/dist/index.js
CHANGED
|
@@ -71,39 +71,81 @@ function initToggle(rootSelector = `.${PREFIX}-toggle`) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
// src/js/components/stateless/accordion.js
|
|
74
|
-
function initAccordion(rootSelector = `.${PREFIX}-accordion`) {
|
|
75
|
-
document.querySelectorAll(rootSelector)
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (body2) {
|
|
95
|
-
body2.style.maxHeight = null;
|
|
74
|
+
function initAccordion(rootSelector = `.${PREFIX}-accordion-group`) {
|
|
75
|
+
const accordionGroups = document.querySelectorAll(rootSelector);
|
|
76
|
+
accordionGroups.forEach((group) => {
|
|
77
|
+
const isMultiple = group.dataset.multipleOpen === "true" || group.dataset.behavior === "multiple";
|
|
78
|
+
const accordions = group.querySelectorAll(`:scope > .${PREFIX}-accordion`);
|
|
79
|
+
accordions.forEach((accordion, _index) => {
|
|
80
|
+
const toggle = accordion.querySelector(`.${PREFIX}-accordion__toggle`);
|
|
81
|
+
const body = accordion.querySelector(`.${PREFIX}-accordion__content`);
|
|
82
|
+
if (!toggle || !body) return;
|
|
83
|
+
toggle.addEventListener("click", (e) => {
|
|
84
|
+
e.stopPropagation();
|
|
85
|
+
const isOpen = accordion.classList.contains(
|
|
86
|
+
`${PREFIX}-accordion--open`
|
|
87
|
+
);
|
|
88
|
+
const nextState = !isOpen;
|
|
89
|
+
if (isMultiple) {
|
|
90
|
+
if (nextState) {
|
|
91
|
+
openItem(accordion, toggle, body);
|
|
92
|
+
} else {
|
|
93
|
+
closeItem(accordion, toggle, body);
|
|
96
94
|
}
|
|
97
|
-
}
|
|
98
|
-
if (behavior === "single") {
|
|
99
|
-
accordion.querySelectorAll(`.${PREFIX}-accordion__item`).forEach((item) => closeAccordionItem(item));
|
|
100
|
-
if (!isOpen) openAccordionItem(currentItem);
|
|
101
95
|
} else {
|
|
102
|
-
|
|
96
|
+
if (nextState) {
|
|
97
|
+
accordions.forEach((otherAcc) => {
|
|
98
|
+
if (otherAcc !== accordion) {
|
|
99
|
+
const otherToggle = otherAcc.querySelector(
|
|
100
|
+
`.${PREFIX}-accordion__toggle`
|
|
101
|
+
);
|
|
102
|
+
const otherBody = otherAcc.querySelector(
|
|
103
|
+
`.${PREFIX}-accordion__content`
|
|
104
|
+
);
|
|
105
|
+
if (otherToggle && otherBody) {
|
|
106
|
+
closeItem(otherAcc, otherToggle, otherBody);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
openItem(accordion, toggle, body);
|
|
111
|
+
} else {
|
|
112
|
+
closeItem(accordion, toggle, body);
|
|
113
|
+
}
|
|
103
114
|
}
|
|
104
115
|
});
|
|
105
116
|
});
|
|
106
117
|
});
|
|
118
|
+
const standaloneAccordions = document.querySelectorAll(
|
|
119
|
+
`.${PREFIX}-accordion:not(.${PREFIX}-accordion-group .${PREFIX}-accordion)`
|
|
120
|
+
);
|
|
121
|
+
standaloneAccordions.forEach((accordion) => {
|
|
122
|
+
const toggle = accordion.querySelector(`.${PREFIX}-accordion__toggle`);
|
|
123
|
+
const body = accordion.querySelector(`.${PREFIX}-accordion__content`);
|
|
124
|
+
if (!toggle || !body) return;
|
|
125
|
+
toggle.addEventListener("click", (e) => {
|
|
126
|
+
e.stopPropagation();
|
|
127
|
+
const isOpen = accordion.classList.contains(`${PREFIX}-accordion--open`);
|
|
128
|
+
if (isOpen) {
|
|
129
|
+
closeItem(accordion, toggle, body);
|
|
130
|
+
} else {
|
|
131
|
+
openItem(accordion, toggle, body);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function openItem(accordion, toggle, body) {
|
|
137
|
+
accordion.classList.add(`${PREFIX}-accordion--open`);
|
|
138
|
+
toggle.setAttribute("aria-expanded", "true");
|
|
139
|
+
const icon = toggle.querySelector(`.${PREFIX}-accordion__icon`);
|
|
140
|
+
if (icon) icon.classList.add(`${PREFIX}-accordion__icon--open`);
|
|
141
|
+
body.classList.add(`${PREFIX}-accordion__content--open`);
|
|
142
|
+
}
|
|
143
|
+
function closeItem(accordion, toggle, body) {
|
|
144
|
+
accordion.classList.remove(`${PREFIX}-accordion--open`);
|
|
145
|
+
toggle.setAttribute("aria-expanded", "false");
|
|
146
|
+
const icon = toggle.querySelector(`.${PREFIX}-accordion__icon`);
|
|
147
|
+
if (icon) icon.classList.remove(`${PREFIX}-accordion__icon--open`);
|
|
148
|
+
body.classList.remove(`${PREFIX}-accordion__content--open`);
|
|
107
149
|
}
|
|
108
150
|
|
|
109
151
|
// src/js/components/stateful/datepicker.js
|
|
@@ -1344,7 +1386,7 @@ function initTimepicker() {
|
|
|
1344
1386
|
const wrapper = picker.querySelector(".ina-time-picker__wrapper");
|
|
1345
1387
|
if (!input || !wrapper) return;
|
|
1346
1388
|
const format = picker.dataset.format || "HH:mm";
|
|
1347
|
-
const use12Hours = picker.dataset.use12Hours === "true" || picker.getAttribute("data-use-12-hours") === "true";
|
|
1389
|
+
const use12Hours = picker.dataset.use12Hours === "true" || picker.getAttribute("data-use-12-hours") === "true" || /a/i.test(format);
|
|
1348
1390
|
const showSecond = picker.dataset.showSecond === "true";
|
|
1349
1391
|
const disabled = picker.classList.contains("ina-time-picker--disabled");
|
|
1350
1392
|
const allowClear = picker.dataset.allowClear !== "false";
|