Skip to content

Commit 047812b

Browse files
committed
fixes for docs after going ESM
1 parent 2c10e4a commit 047812b

File tree

13 files changed

+60
-31
lines changed

13 files changed

+60
-31
lines changed

build/rollup.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ const plugins = [
2323

2424
if (BUNDLE) {
2525
destinationFile += '.bundle'
26-
// Remove Floating UI from externals to bundle it
27-
external.splice(external.indexOf('@floating-ui/dom'), 1)
26+
// Bundle all dependencies (Floating UI, Vanilla Calendar Pro, etc.)
27+
external.length = 0
2828
plugins.push(
2929
replace({
3030
'process.env.NODE_ENV': '"production"',

dist/js/bootstrap.bundle.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/bootstrap.bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/assets/partials/snippets.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@
1111
* For details, see https://creativecommons.org/licenses/by/3.0/.
1212
*/
1313

14-
/* global bootstrap: false */
14+
/* eslint-disable import/namespace */
15+
import {
16+
Tooltip,
17+
Popover,
18+
Toast,
19+
Carousel
20+
} from '../../../../dist/js/bootstrap.bundle.js'
21+
/* eslint-enable import/namespace */
1522

1623
export default () => {
1724
// --------
@@ -20,7 +27,7 @@ export default () => {
2027
// Instantiate all tooltips in a docs or StackBlitz
2128
document.querySelectorAll('[data-bs-toggle="tooltip"]')
2229
.forEach(tooltip => {
23-
new bootstrap.Tooltip(tooltip)
30+
new Tooltip(tooltip)
2431
})
2532

2633
// --------
@@ -29,7 +36,7 @@ export default () => {
2936
// Instantiate all popovers in docs or StackBlitz
3037
document.querySelectorAll('[data-bs-toggle="popover"]')
3138
.forEach(popover => {
32-
new bootstrap.Popover(popover)
39+
new Popover(popover)
3340
})
3441

3542
// -------------------------------
@@ -50,7 +57,7 @@ export default () => {
5057
// Instantiate all toasts in docs pages only
5158
document.querySelectorAll('.bd-example .toast')
5259
.forEach(toastNode => {
53-
const toast = new bootstrap.Toast(toastNode, {
60+
const toast = new Toast(toastNode, {
5461
autohide: false
5562
})
5663

@@ -63,7 +70,7 @@ export default () => {
6370
const toastLiveExample = document.getElementById('liveToast')
6471

6572
if (toastTrigger) {
66-
const toastBootstrap = bootstrap.Toast.getOrCreateInstance(toastLiveExample)
73+
const toastBootstrap = Toast.getOrCreateInstance(toastLiveExample)
6774
toastTrigger.addEventListener('click', () => {
6875
toastBootstrap.show()
6976
})
@@ -103,7 +110,7 @@ export default () => {
103110
// Instantiate all non-autoplaying carousels in docs or StackBlitz
104111
document.querySelectorAll('.carousel:not([data-bs-ride="carousel"])')
105112
.forEach(carousel => {
106-
bootstrap.Carousel.getOrCreateInstance(carousel)
113+
Carousel.getOrCreateInstance(carousel)
107114
})
108115

109116
// -------------------------------

site/src/components/Scripts.astro

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
import { getVersionedBsJsProps } from '@libs/bootstrap'
32
import type { Layout } from '@libs/layout'
43
import DocsScripts from './DocsScripts.astro'
54
@@ -10,8 +9,6 @@ interface Props {
109
const { layout } = Astro.props
1110
---
1211

13-
<script is:inline {...getVersionedBsJsProps()}></script>
14-
1512
<script src="../assets/application.js"></script>
1613
<script src="../assets/search.js"></script>
1714

site/src/components/shortcodes/ButtonPlayground.astro

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ const rounded = ['default', 'pill', 'square']
155155
/>
156156

157157
<script>
158+
import { Dropdown } from '../../../../dist/js/bootstrap.bundle.js'
159+
158160
const colorDropdownButton = document.querySelector('#btn-color-dropdown') as HTMLButtonElement
159161
const colorDropdownItems = document.querySelectorAll('#btn-color-dropdown + .dropdown-menu .dropdown-item')
160162
const sizeDropdownButton = document.querySelector('#btn-size-dropdown') as HTMLButtonElement
@@ -260,7 +262,7 @@ const rounded = ['default', 'pill', 'square']
260262

261263
// Initialize Bootstrap dropdowns
262264
if (colorDropdownButton) {
263-
const colorDropdown = bootstrap.Dropdown.getOrCreateInstance(colorDropdownButton)
265+
const colorDropdown = Dropdown.getOrCreateInstance(colorDropdownButton)
264266

265267
// Handle dropdown item clicks
266268
colorDropdownItems.forEach((item) => {
@@ -292,7 +294,7 @@ const rounded = ['default', 'pill', 'square']
292294
}
293295

294296
if (sizeDropdownButton) {
295-
const sizeDropdown = bootstrap.Dropdown.getOrCreateInstance(sizeDropdownButton)
297+
const sizeDropdown = Dropdown.getOrCreateInstance(sizeDropdownButton)
296298

297299
// Handle dropdown item clicks
298300
sizeDropdownItems.forEach((item) => {

site/src/components/shortcodes/Code.astro

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,15 @@ if (highlightedCode) {
233233
---
234234

235235
<script>
236+
import { Tooltip } from '../../../../dist/js/bootstrap.bundle.js'
236237
import ClipboardJS from 'clipboard'
237238

238239
const btnTitle = 'Copy to clipboard'
239240
const btnEdit = 'Edit on StackBlitz'
240241

241242
function snippetButtonTooltip(selector: string, title: string) {
242243
document.querySelectorAll(selector).forEach((btn) => {
243-
bootstrap.Tooltip.getOrCreateInstance(btn, { title })
244+
Tooltip.getOrCreateInstance(btn, { title })
244245
})
245246
}
246247

@@ -288,7 +289,7 @@ if (highlightedCode) {
288289

289290
clipboard.on('success', (event) => {
290291
const iconFirstChild = event.trigger.querySelector('.bi')?.firstElementChild
291-
const tooltipBtn = bootstrap.Tooltip.getInstance(event.trigger)
292+
const tooltipBtn = Tooltip.getInstance(event.trigger)
292293
const namespace = 'http://www.w3.org/1999/xlink'
293294
const originalXhref = iconFirstChild?.getAttributeNS(namespace, 'href')
294295
const isCheckIconVisible = originalXhref === '#check2'
@@ -323,7 +324,7 @@ if (highlightedCode) {
323324
clipboard.on('error', (event) => {
324325
const modifierKey = /mac/i.test(navigator.userAgent) ? '\u2318' : 'Ctrl-'
325326
const fallbackMsg = `Press ${modifierKey}C to copy`
326-
const tooltipBtn = bootstrap.Tooltip.getInstance(event.trigger)
327+
const tooltipBtn = Tooltip.getInstance(event.trigger)
327328

328329
tooltipBtn?.setContent({ '.tooltip-inner': fallbackMsg })
329330

site/src/components/shortcodes/CodeCopy.astro

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,15 @@ highlightedCode = highlightedCode.replace(/shiki-themes/g, 'astro-code-themes')
7474
---
7575

7676
<script>
77+
import { Tooltip } from '../../../../dist/js/bootstrap.bundle.js'
7778
import ClipboardJS from 'clipboard'
7879

7980
const btnTitle = 'Copy to clipboard'
8081

8182
document.querySelectorAll('.code-copy').forEach((container) => {
8283
const btn = container.querySelector('.btn-clipboard')
8384
if (btn) {
84-
bootstrap.Tooltip.getOrCreateInstance(btn, { title: btnTitle })
85+
Tooltip.getOrCreateInstance(btn, { title: btnTitle })
8586
}
8687
})
8788

@@ -93,7 +94,7 @@ highlightedCode = highlightedCode.replace(/shiki-themes/g, 'astro-code-themes')
9394

9495
clipboard.on('success', (event) => {
9596
const iconFirstChild = event.trigger.querySelector('.bi')?.firstElementChild
96-
const tooltipBtn = bootstrap.Tooltip.getInstance(event.trigger)
97+
const tooltipBtn = Tooltip.getInstance(event.trigger)
9798
const namespace = 'http://www.w3.org/1999/xlink'
9899
const originalXhref = iconFirstChild?.getAttributeNS(namespace, 'href')
99100
const isCheckIconVisible = originalXhref === '#check2'
@@ -128,7 +129,7 @@ highlightedCode = highlightedCode.replace(/shiki-themes/g, 'astro-code-themes')
128129
clipboard.on('error', (event) => {
129130
const modifierKey = /mac/i.test(navigator.userAgent) ? '\u2318' : 'Ctrl-'
130131
const fallbackMsg = `Press ${modifierKey}C to copy`
131-
const tooltipBtn = bootstrap.Tooltip.getInstance(event.trigger)
132+
const tooltipBtn = Tooltip.getInstance(event.trigger)
132133

133134
tooltipBtn?.setContent({ '.tooltip-inner': fallbackMsg })
134135

site/src/components/shortcodes/DropdownPlacementPlayground.astro

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ const logicalPlacements = [
118118
/>
119119

120120
<script>
121+
import { Dropdown } from '../../../../dist/js/bootstrap.bundle.js'
122+
121123
const placementDropdownButton = document.querySelector('#placement-dropdown') as HTMLButtonElement
122124
const placementDropdownItems = document.querySelectorAll('#placement-dropdown + .dropdown-menu .dropdown-item')
123125
const placementTypeInputs = document.querySelectorAll('input[name="placement-type"]')
@@ -165,11 +167,11 @@ const logicalPlacements = [
165167
previewToggle.setAttribute('data-bs-placement', placement)
166168

167169
// Dispose and recreate the dropdown instance to pick up new placement
168-
const instance = bootstrap.Dropdown.getInstance(previewToggle)
170+
const instance = Dropdown.getInstance(previewToggle)
169171
if (instance) {
170172
instance.dispose()
171173
}
172-
bootstrap.Dropdown.getOrCreateInstance(previewToggle)
174+
Dropdown.getOrCreateInstance(previewToggle)
173175

174176
// Update code snippet
175177
updateCodeSnippet(placement)
@@ -199,7 +201,7 @@ const logicalPlacements = [
199201

200202
// Initialize placement dropdown
201203
if (placementDropdownButton) {
202-
const placementDropdown = bootstrap.Dropdown.getOrCreateInstance(placementDropdownButton)
204+
const placementDropdown = Dropdown.getOrCreateInstance(placementDropdownButton)
203205

204206
placementDropdownItems.forEach(item => {
205207
item.addEventListener('click', (e) => {

site/src/components/shortcodes/NavbarPlacementPlayground.astro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ const placements = [
5454
/>
5555

5656
<script>
57+
import { Dropdown } from '../../../../dist/js/bootstrap.bundle.js'
58+
5759
const placementDropdownButton = document.querySelector('#navbar-placement-dropdown') as HTMLButtonElement
5860
const placementDropdownItems = document.querySelectorAll('#navbar-placement-dropdown + .dropdown-menu .dropdown-item')
5961
const previewContainer = document.querySelector('#navbar-placement-preview') as HTMLElement
@@ -128,7 +130,7 @@ const placements = [
128130

129131
// Initialize dropdown
130132
if (placementDropdownButton) {
131-
const placementDropdown = bootstrap.Dropdown.getOrCreateInstance(placementDropdownButton)
133+
const placementDropdown = Dropdown.getOrCreateInstance(placementDropdownButton)
132134

133135
placementDropdownItems.forEach(item => {
134136
item.addEventListener('click', (e) => {

0 commit comments

Comments
 (0)