diff --git a/packages/beeq/src/components/icon/_storybook/bq-icon.stories.tsx b/packages/beeq/src/components/icon/_storybook/bq-icon.stories.tsx
index 27f514984..1b8b8a4ec 100644
--- a/packages/beeq/src/components/icon/_storybook/bq-icon.stories.tsx
+++ b/packages/beeq/src/components/icon/_storybook/bq-icon.stories.tsx
@@ -127,13 +127,13 @@ export const ExploreIcons: Story = {
-
+
Explore all the icons available
-
+
-
+
Please notice
The SVG icons will be flipped horizontally when the dir="rtl"
attribute is used.
diff --git a/packages/beeq/src/shared/utils/assetsPath.ts b/packages/beeq/src/shared/utils/assetsPath.ts
index 6edf6050b..6c66571d3 100644
--- a/packages/beeq/src/shared/utils/assetsPath.ts
+++ b/packages/beeq/src/shared/utils/assetsPath.ts
@@ -13,15 +13,23 @@ declare global {
}
}
-Object.defineProperty(window, 'bqSVGBasePath', {
- configurable: true,
- enumerable: false,
- writable: true,
-});
+/**
+ * Define the `bqSVGBasePath` property on the global window object, but only when the window object is available.
+ */
+if (typeof window !== 'undefined') {
+ Object.defineProperty(window, 'bqSVGBasePath', {
+ configurable: true,
+ enumerable: false,
+ writable: true,
+ });
+}
const DATA_BEEQ_ATTRIBUTE = 'data-beeq';
const DEFAULT_SVG_PATH = 'svg';
-const scripts = [...document.getElementsByTagName('script')] as HTMLScriptElement[];
+const scripts: HTMLScriptElement[] =
+ typeof document !== 'undefined' && document
+ ? ([...document.getElementsByTagName('script')] as HTMLScriptElement[])
+ : [];
/**
* Sets the `bqSVGBasePath` in the global window object,
@@ -31,7 +39,9 @@ const scripts = [...document.getElementsByTagName('script')] as HTMLScriptElemen
* @param path - The new base path to set.
*/
export const setBasePath = (path: string) => {
- window.bqSVGBasePath = path;
+ if (typeof window !== 'undefined') {
+ window.bqSVGBasePath = path;
+ }
};
/**
@@ -41,6 +51,8 @@ export const setBasePath = (path: string) => {
* @returns The full base path including the subpath.
*/
export const getBasePath = (subpath = ''): string => {
+ if (typeof window === 'undefined') return undefined;
+
const { bqSVGBasePath } = window;
if (!bqSVGBasePath) {
initializeBasePath();