@winkintel/bootstrap-svelte 1.0.5 → 1.0.6
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/README.md +1 -1
- package/dist/Alert/alert.svelte +4 -2
- package/dist/Badge/badge.svelte +6 -4
- package/dist/Badge/badge.svelte.d.ts +2 -2
- package/dist/Badge/types.d.ts +2 -1
- package/dist/Badge/types.js +3 -11
- package/dist/Button/button.svelte +29 -9
- package/dist/ButtonGroup/button-group.svelte +3 -2
- package/dist/ButtonGroup/button-toolbar.svelte +3 -2
- package/dist/ButtonGroup/types.contract.d.ts +1 -0
- package/dist/ButtonGroup/types.contract.js +15 -0
- package/dist/ButtonGroup/types.d.ts +2 -2
- package/dist/Carousel/carousel-indicator-button.svelte +8 -1
- package/dist/Carousel/carousel-item.svelte +29 -9
- package/dist/Carousel/carousel.svelte +12 -5
- package/dist/Carousel/carousel.svelte.js +200 -42
- package/dist/Col/col.svelte +30 -22
- package/dist/Collapse/collapse.svelte +3 -3
- package/dist/Collapse/transition.js +78 -15
- package/dist/Collapse/types.d.ts +1 -0
- package/dist/Dropdown/dropdown-item.svelte +7 -0
- package/dist/Dropdown/dropdown.svelte.js +66 -19
- package/dist/Form/form-check-input.svelte +6 -6
- package/dist/Form/form-color-input.svelte +8 -3
- package/dist/Form/form-date-input.svelte +4 -4
- package/dist/Form/form-datetime-local-input.svelte +4 -4
- package/dist/Form/form-email-input.svelte +4 -4
- package/dist/Form/form-file-input.svelte +46 -6
- package/dist/Form/form-file-input.svelte.d.ts +3 -2
- package/dist/Form/form-hidden-input.svelte +1 -1
- package/dist/Form/form-hidden-input.svelte.d.ts +1 -1
- package/dist/Form/form-image-input.svelte +1 -1
- package/dist/Form/form-image-input.svelte.d.ts +2 -1
- package/dist/Form/form-month-input.svelte +4 -4
- package/dist/Form/form-number-input.svelte +4 -4
- package/dist/Form/form-password-input.svelte +4 -4
- package/dist/Form/form-radio-input.svelte +53 -3
- package/dist/Form/form-radio-input.svelte.d.ts +3 -2
- package/dist/Form/form-range-input.svelte +1 -1
- package/dist/Form/form-range-input.svelte.d.ts +2 -1
- package/dist/Form/form-search-input.svelte +4 -4
- package/dist/Form/form-select.svelte +7 -7
- package/dist/Form/form-switch-input.svelte +4 -4
- package/dist/Form/form-telephone-input.svelte +4 -4
- package/dist/Form/form-text-area.svelte +4 -4
- package/dist/Form/form-text-input.svelte +4 -4
- package/dist/Form/form-time-input.svelte +4 -4
- package/dist/Form/form-url-input.svelte +4 -4
- package/dist/Form/form-week-Input.svelte +4 -4
- package/dist/Form/types.d.ts +26 -20
- package/dist/ListGroup/list-group-item-action.svelte +14 -7
- package/dist/Modal/modal.svelte +86 -26
- package/dist/Modal/modal.svelte.js +15 -0
- package/dist/Nav/nav-link.svelte +12 -8
- package/dist/Navbar/navbar-collapse.svelte +18 -7
- package/dist/Navbar/navbar-collapse.svelte.d.ts +1 -1
- package/dist/Navbar/navbar-nav.svelte +1 -1
- package/dist/Navbar/navbar-toggler.svelte +9 -7
- package/dist/Navbar/navbar-toggler.svelte.d.ts +1 -1
- package/dist/Navbar/types.d.ts +3 -2
- package/dist/Offcanvas/offcanvas.svelte +38 -7
- package/dist/Pagination/pagination-item.svelte +27 -20
- package/dist/Pagination/pagination-link.svelte +20 -5
- package/dist/Pagination/pagination.svelte.js +28 -8
- package/dist/Placeholder/placeholder-item.svelte +7 -2
- package/dist/Placeholder/placeholder-item.svelte.d.ts +1 -1
- package/dist/Placeholder/types.d.ts +1 -0
- package/dist/Portal/portal.svelte +6 -1
- package/dist/Progress/progress-bar.svelte +22 -9
- package/dist/Row/row.svelte +9 -10
- package/dist/Row/types.d.ts +8 -7
- package/dist/Scrollspy/scrollspy-attachment.svelte.js +47 -28
- package/dist/Tooltip/tooltip.svelte +57 -10
- package/dist/common/css.js +96 -24
- package/dist/common/navbar-offcanvas.svelte.d.ts +2 -0
- package/dist/common/navbar-offcanvas.svelte.js +5 -4
- package/dist/common/overlay-stack.d.ts +13 -0
- package/dist/common/overlay-stack.js +49 -0
- package/dist/common/scrollbar.js +24 -8
- package/package.json +1 -1
package/dist/common/css.js
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
import BezierEasing, {} from 'bezier-easing';
|
|
2
2
|
const whitespacePattern = /\s/;
|
|
3
3
|
const classTokenPattern = /\S+/g;
|
|
4
|
-
function appendClassTokens(result, value) {
|
|
4
|
+
function appendClassTokens(result, seenTokens, value) {
|
|
5
5
|
const classValue = typeof value === 'string' ? value : String(value);
|
|
6
6
|
if (!classValue) {
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
9
|
if (!whitespacePattern.test(classValue)) {
|
|
10
|
-
if (
|
|
10
|
+
if (!seenTokens.has(classValue)) {
|
|
11
|
+
seenTokens.add(classValue);
|
|
11
12
|
result.push(classValue);
|
|
12
13
|
}
|
|
13
14
|
return;
|
|
14
15
|
}
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
16
|
+
const classTokens = classValue.match(classTokenPattern);
|
|
17
|
+
if (!classTokens) {
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
|
-
for (let i = 0; i <
|
|
20
|
-
const token =
|
|
21
|
-
if (
|
|
20
|
+
for (let i = 0; i < classTokens.length; i++) {
|
|
21
|
+
const token = classTokens[i];
|
|
22
|
+
if (!seenTokens.has(token)) {
|
|
23
|
+
seenTokens.add(token);
|
|
22
24
|
result.push(token);
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
|
-
function appendClassValue(result, value) {
|
|
28
|
+
function appendClassValue(result, tokens, value) {
|
|
27
29
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
28
|
-
appendClassTokens(result, value);
|
|
30
|
+
appendClassTokens(result, tokens, value);
|
|
29
31
|
return;
|
|
30
32
|
}
|
|
31
33
|
if (!value || typeof value !== 'object') {
|
|
@@ -34,14 +36,14 @@ function appendClassValue(result, value) {
|
|
|
34
36
|
if (Array.isArray(value)) {
|
|
35
37
|
for (let i = 0; i < value.length; i++) {
|
|
36
38
|
if (value[i]) {
|
|
37
|
-
appendClassValue(result, value[i]);
|
|
39
|
+
appendClassValue(result, tokens, value[i]);
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
return;
|
|
41
43
|
}
|
|
42
44
|
for (const key in value) {
|
|
43
45
|
if (value[key]) {
|
|
44
|
-
appendClassTokens(result, key);
|
|
46
|
+
appendClassTokens(result, tokens, key);
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
}
|
|
@@ -88,16 +90,17 @@ export const cubicBezier = (x1, y1, x2, y2) => {
|
|
|
88
90
|
*/
|
|
89
91
|
export function uniqueClsx(...args) {
|
|
90
92
|
const result = [];
|
|
93
|
+
const tokens = new Set();
|
|
91
94
|
for (let i = 0; i < args.length; i++) {
|
|
92
95
|
const value = args[i];
|
|
93
96
|
if (!value) {
|
|
94
97
|
continue;
|
|
95
98
|
}
|
|
96
99
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
97
|
-
appendClassTokens(result, value);
|
|
100
|
+
appendClassTokens(result, tokens, value);
|
|
98
101
|
}
|
|
99
102
|
else {
|
|
100
|
-
appendClassValue(result, value);
|
|
103
|
+
appendClassValue(result, tokens, value);
|
|
101
104
|
}
|
|
102
105
|
}
|
|
103
106
|
return result.join(' ');
|
|
@@ -123,7 +126,7 @@ export function toStyle(styleObj) {
|
|
|
123
126
|
return Object.entries(styleObj)
|
|
124
127
|
.map(([key, value]) => {
|
|
125
128
|
// Convert camelCase to kebab-case (e.g., flexDirection to flex-direction)
|
|
126
|
-
const kebabKey = key.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`);
|
|
129
|
+
const kebabKey = key.startsWith('--') ? key : key.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`);
|
|
127
130
|
return `${kebabKey}: ${value}`;
|
|
128
131
|
})
|
|
129
132
|
.join(';');
|
|
@@ -143,17 +146,48 @@ export function fromStyle(cssString) {
|
|
|
143
146
|
return {};
|
|
144
147
|
}
|
|
145
148
|
const styleObj = {};
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
149
|
+
const appendDeclaration = (declaration) => {
|
|
150
|
+
let quote;
|
|
151
|
+
let parentheses = 0;
|
|
152
|
+
let escaped = false;
|
|
153
|
+
let separator = -1;
|
|
154
|
+
for (let index = 0; index < declaration.length; index++) {
|
|
155
|
+
const character = declaration[index];
|
|
156
|
+
if (escaped) {
|
|
157
|
+
escaped = false;
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
if (quote) {
|
|
161
|
+
if (character === '\\') {
|
|
162
|
+
escaped = true;
|
|
163
|
+
}
|
|
164
|
+
else if (character === quote) {
|
|
165
|
+
quote = undefined;
|
|
166
|
+
}
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (character === '\\') {
|
|
170
|
+
escaped = true;
|
|
171
|
+
}
|
|
172
|
+
else if (character === '"' || character === "'") {
|
|
173
|
+
quote = character;
|
|
174
|
+
}
|
|
175
|
+
else if (character === '(') {
|
|
176
|
+
parentheses++;
|
|
177
|
+
}
|
|
178
|
+
else if (character === ')' && parentheses > 0) {
|
|
179
|
+
parentheses--;
|
|
180
|
+
}
|
|
181
|
+
else if (character === ':' && parentheses === 0) {
|
|
182
|
+
separator = index;
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (separator === -1) {
|
|
150
187
|
return;
|
|
151
188
|
}
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
// Handle case where there might be colons in the value (like in data URLs)
|
|
155
|
-
const value = valueParts.join(':').trim();
|
|
156
|
-
const trimmedProperty = property?.trim();
|
|
189
|
+
const trimmedProperty = declaration.slice(0, separator).trim();
|
|
190
|
+
const value = declaration.slice(separator + 1).trim();
|
|
157
191
|
if (!trimmedProperty || !value) {
|
|
158
192
|
return;
|
|
159
193
|
}
|
|
@@ -170,6 +204,44 @@ export function fromStyle(cssString) {
|
|
|
170
204
|
// Try to convert numeric strings to numbers, but not for CSS variables or var() functions
|
|
171
205
|
const parsedValue = !isNaN(Number(value)) && value.trim() !== '' && !value.includes('var(') ? Number(value) : value;
|
|
172
206
|
styleObj[camelProperty] = parsedValue;
|
|
173
|
-
}
|
|
207
|
+
};
|
|
208
|
+
let declarationStart = 0;
|
|
209
|
+
let quote;
|
|
210
|
+
let parentheses = 0;
|
|
211
|
+
let escaped = false;
|
|
212
|
+
for (let index = 0; index <= cssString.length; index++) {
|
|
213
|
+
const character = cssString[index];
|
|
214
|
+
if (escaped) {
|
|
215
|
+
escaped = false;
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
if (quote) {
|
|
219
|
+
if (character === '\\') {
|
|
220
|
+
escaped = true;
|
|
221
|
+
}
|
|
222
|
+
else if (character === quote) {
|
|
223
|
+
quote = undefined;
|
|
224
|
+
}
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
if (character === '\\') {
|
|
228
|
+
escaped = true;
|
|
229
|
+
}
|
|
230
|
+
else if (character === '"' || character === "'") {
|
|
231
|
+
quote = character;
|
|
232
|
+
}
|
|
233
|
+
else if (character === '(') {
|
|
234
|
+
parentheses++;
|
|
235
|
+
}
|
|
236
|
+
else if (character === ')' && parentheses > 0) {
|
|
237
|
+
parentheses--;
|
|
238
|
+
}
|
|
239
|
+
else if (character === ';' || index === cssString.length) {
|
|
240
|
+
if (parentheses === 0) {
|
|
241
|
+
appendDeclaration(cssString.slice(declarationStart, index));
|
|
242
|
+
declarationStart = index + 1;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
174
246
|
return styleObj;
|
|
175
247
|
}
|
|
@@ -11,6 +11,7 @@ export declare class NavbarRootState {
|
|
|
11
11
|
transitionDuration: number;
|
|
12
12
|
constructor(props: Navbar.RootProps);
|
|
13
13
|
get isExpanded(): boolean;
|
|
14
|
+
get defaultCollapseId(): string;
|
|
14
15
|
toggleIsExpanded(): void;
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
@@ -32,6 +33,7 @@ export declare class NavbarCollapseState {
|
|
|
32
33
|
readonly props: Navbar.CollapseProps;
|
|
33
34
|
readonly root: NavbarRootState;
|
|
34
35
|
isExpanded: boolean;
|
|
36
|
+
id: string;
|
|
35
37
|
constructor(props: Navbar.CollapseProps, root: NavbarRootState);
|
|
36
38
|
}
|
|
37
39
|
/**
|
|
@@ -39,6 +39,9 @@ export class NavbarRootState {
|
|
|
39
39
|
get isExpanded() {
|
|
40
40
|
return this.#isExpanded || this.#mediaQuery?.current || false;
|
|
41
41
|
}
|
|
42
|
+
get defaultCollapseId() {
|
|
43
|
+
return `${this.props.id || 'navbar'}-collapse`;
|
|
44
|
+
}
|
|
42
45
|
toggleIsExpanded() {
|
|
43
46
|
this.#isExpanded = !this.#isExpanded;
|
|
44
47
|
}
|
|
@@ -79,13 +82,11 @@ export class NavbarCollapseState {
|
|
|
79
82
|
props;
|
|
80
83
|
root;
|
|
81
84
|
isExpanded = $derived.by(() => this.root.isExpanded);
|
|
85
|
+
id = $derived.by(() => this.props.id || this.root.defaultCollapseId);
|
|
82
86
|
constructor(props, root) {
|
|
83
87
|
this.props = props;
|
|
84
88
|
this.root = root;
|
|
85
|
-
|
|
86
|
-
console.warn('props.id is required for the Navbar.Collapse to set accessibility correctly');
|
|
87
|
-
}
|
|
88
|
-
this.root.ariaControls = this.props.id || undefined;
|
|
89
|
+
this.root.ariaControls = this.props.id || this.root.defaultCollapseId;
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
/**
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type OverlayStackEntry = {
|
|
2
|
+
baseBackdropZIndex: number;
|
|
3
|
+
baseOverlayZIndex: number;
|
|
4
|
+
containsActiveElement?: () => boolean;
|
|
5
|
+
focus?: () => void;
|
|
6
|
+
onKeydown: (event: KeyboardEvent) => void;
|
|
7
|
+
setLayers: (overlayZIndex: number | undefined, backdropZIndex: number | undefined) => void;
|
|
8
|
+
};
|
|
9
|
+
export declare function registerOverlay(entry: OverlayStackEntry): void;
|
|
10
|
+
export declare function unregisterOverlay(entry: OverlayStackEntry): void;
|
|
11
|
+
export declare function isTopOverlay(entry: OverlayStackEntry): boolean;
|
|
12
|
+
export declare function focusTopOverlay(): void;
|
|
13
|
+
export declare function isFocusInTopOverlay(): boolean;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const overlayStack = [];
|
|
2
|
+
const overlayLayerStep = 20;
|
|
3
|
+
function handleKeydown(event) {
|
|
4
|
+
overlayStack.at(-1)?.onKeydown(event);
|
|
5
|
+
}
|
|
6
|
+
function syncKeydownListener() {
|
|
7
|
+
if (typeof window === 'undefined')
|
|
8
|
+
return;
|
|
9
|
+
window.removeEventListener('keydown', handleKeydown);
|
|
10
|
+
if (overlayStack.length > 0) {
|
|
11
|
+
window.addEventListener('keydown', handleKeydown);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function syncLayers() {
|
|
15
|
+
let previousOverlayZIndex = Number.NEGATIVE_INFINITY;
|
|
16
|
+
overlayStack.forEach((entry) => {
|
|
17
|
+
const overlayZIndex = Math.max(entry.baseOverlayZIndex, previousOverlayZIndex + overlayLayerStep);
|
|
18
|
+
const backdropZIndex = overlayZIndex - (entry.baseOverlayZIndex - entry.baseBackdropZIndex);
|
|
19
|
+
entry.setLayers(overlayZIndex, backdropZIndex);
|
|
20
|
+
previousOverlayZIndex = overlayZIndex;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export function registerOverlay(entry) {
|
|
24
|
+
const existingIndex = overlayStack.indexOf(entry);
|
|
25
|
+
if (existingIndex !== -1) {
|
|
26
|
+
overlayStack.splice(existingIndex, 1);
|
|
27
|
+
}
|
|
28
|
+
overlayStack.push(entry);
|
|
29
|
+
syncLayers();
|
|
30
|
+
syncKeydownListener();
|
|
31
|
+
}
|
|
32
|
+
export function unregisterOverlay(entry) {
|
|
33
|
+
const index = overlayStack.indexOf(entry);
|
|
34
|
+
if (index === -1)
|
|
35
|
+
return;
|
|
36
|
+
overlayStack.splice(index, 1);
|
|
37
|
+
entry.setLayers(undefined, undefined);
|
|
38
|
+
syncLayers();
|
|
39
|
+
syncKeydownListener();
|
|
40
|
+
}
|
|
41
|
+
export function isTopOverlay(entry) {
|
|
42
|
+
return overlayStack.at(-1) === entry;
|
|
43
|
+
}
|
|
44
|
+
export function focusTopOverlay() {
|
|
45
|
+
overlayStack.at(-1)?.focus?.();
|
|
46
|
+
}
|
|
47
|
+
export function isFocusInTopOverlay() {
|
|
48
|
+
return overlayStack.at(-1)?.containsActiveElement?.() ?? false;
|
|
49
|
+
}
|
package/dist/common/scrollbar.js
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import { hasAttribute, isRTL, setAttribute } from './dom.js';
|
|
2
2
|
const SCROLLBAR_INITIAL_OVERFLOW = 'data-scrollbar-initial-overflow-value';
|
|
3
3
|
const SCROLLBAR_INITIAL_PADDING = 'data-scrollbar-initial-padding-value';
|
|
4
|
+
const SCROLLBAR_INITIAL_PADDING_SIDE = 'data-scrollbar-initial-padding-side';
|
|
4
5
|
const SCROLLBAR_LOCK_COUNT = 'data-scrollbar-lock-count';
|
|
6
|
+
const getLockCount = (bodyElement) => {
|
|
7
|
+
const value = Number(bodyElement.getAttribute(SCROLLBAR_LOCK_COUNT));
|
|
8
|
+
return Number.isInteger(value) && value > 0 ? value : 0;
|
|
9
|
+
};
|
|
10
|
+
const hasSavedScrollState = (bodyElement) => hasAttribute(bodyElement, SCROLLBAR_INITIAL_OVERFLOW) ||
|
|
11
|
+
hasAttribute(bodyElement, SCROLLBAR_INITIAL_PADDING) ||
|
|
12
|
+
hasAttribute(bodyElement, SCROLLBAR_INITIAL_PADDING_SIDE);
|
|
13
|
+
const getRecoverableLockCount = (bodyElement) => {
|
|
14
|
+
const count = getLockCount(bodyElement);
|
|
15
|
+
return count || (hasSavedScrollState(bodyElement) ? 1 : 0);
|
|
16
|
+
};
|
|
5
17
|
/**
|
|
6
18
|
* Calculates the width of the browser's scrollbar
|
|
7
19
|
*
|
|
@@ -28,8 +40,10 @@ export const disableBodyScrolling = (bodyElement) => {
|
|
|
28
40
|
const initialPadding = bodyElement.style.getPropertyValue(paddingPropName);
|
|
29
41
|
setAttribute(bodyElement, SCROLLBAR_INITIAL_OVERFLOW, initialOverflow);
|
|
30
42
|
setAttribute(bodyElement, SCROLLBAR_INITIAL_PADDING, initialPadding);
|
|
43
|
+
setAttribute(bodyElement, SCROLLBAR_INITIAL_PADDING_SIDE, paddingPropName);
|
|
31
44
|
// Set the overflow to hidden and add padding-right to prevent layout shift
|
|
32
|
-
const
|
|
45
|
+
const initialPaddingValue = Number.parseFloat(initialPadding);
|
|
46
|
+
const newPaddingRight = (Number.isFinite(initialPaddingValue) ? initialPaddingValue : 0) + scrollbarWidth;
|
|
33
47
|
bodyElement.style.setProperty('overflow', 'hidden');
|
|
34
48
|
bodyElement.style.setProperty(paddingPropName, `${newPaddingRight}px`);
|
|
35
49
|
};
|
|
@@ -43,20 +57,21 @@ export const disableBodyScrolling = (bodyElement) => {
|
|
|
43
57
|
* @param {HTMLElement} bodyElement - The body element to restore scrolling on
|
|
44
58
|
*/
|
|
45
59
|
export const resetBodyScrolling = (bodyElement) => {
|
|
46
|
-
|
|
47
|
-
if (!hasAttribute(bodyElement, SCROLLBAR_INITIAL_OVERFLOW) || !hasAttribute(bodyElement, SCROLLBAR_INITIAL_PADDING)) {
|
|
60
|
+
if (!hasSavedScrollState(bodyElement)) {
|
|
48
61
|
return;
|
|
49
62
|
}
|
|
50
63
|
// Get the initial values from the data attributes
|
|
51
64
|
const initialOverflow = bodyElement.getAttribute(SCROLLBAR_INITIAL_OVERFLOW);
|
|
52
65
|
const initialPadding = bodyElement.getAttribute(SCROLLBAR_INITIAL_PADDING);
|
|
53
66
|
// Reset the overflow and padding-right values to their initial values
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
bodyElement.style.setProperty(
|
|
67
|
+
const savedPaddingSide = bodyElement.getAttribute(SCROLLBAR_INITIAL_PADDING_SIDE);
|
|
68
|
+
const paddingPropName = savedPaddingSide === 'padding-left' ? 'padding-left' : 'padding-right';
|
|
69
|
+
bodyElement.style.setProperty('overflow', initialOverflow ?? '');
|
|
70
|
+
bodyElement.style.setProperty(paddingPropName, initialPadding ?? '');
|
|
57
71
|
// Remove the data attributes
|
|
58
72
|
bodyElement.removeAttribute(SCROLLBAR_INITIAL_OVERFLOW);
|
|
59
73
|
bodyElement.removeAttribute(SCROLLBAR_INITIAL_PADDING);
|
|
74
|
+
bodyElement.removeAttribute(SCROLLBAR_INITIAL_PADDING_SIDE);
|
|
60
75
|
};
|
|
61
76
|
/**
|
|
62
77
|
* Acquires a body scroll lock. The first acquisition disables scrolling;
|
|
@@ -66,7 +81,7 @@ export const resetBodyScrolling = (bodyElement) => {
|
|
|
66
81
|
* @returns {number} the lock count after acquiring
|
|
67
82
|
*/
|
|
68
83
|
export const acquireBodyScrollLock = (bodyElement) => {
|
|
69
|
-
const count =
|
|
84
|
+
const count = getRecoverableLockCount(bodyElement) + 1;
|
|
70
85
|
bodyElement.setAttribute(SCROLLBAR_LOCK_COUNT, `${count}`);
|
|
71
86
|
if (count === 1) {
|
|
72
87
|
disableBodyScrolling(bodyElement);
|
|
@@ -81,8 +96,9 @@ export const acquireBodyScrollLock = (bodyElement) => {
|
|
|
81
96
|
* @returns {number} the lock count after releasing
|
|
82
97
|
*/
|
|
83
98
|
export const releaseBodyScrollLock = (bodyElement) => {
|
|
84
|
-
const current =
|
|
99
|
+
const current = getRecoverableLockCount(bodyElement);
|
|
85
100
|
if (current <= 0) {
|
|
101
|
+
bodyElement.removeAttribute(SCROLLBAR_LOCK_COUNT);
|
|
86
102
|
return 0;
|
|
87
103
|
}
|
|
88
104
|
const count = current - 1;
|