Skip to content

Commit 715032d

Browse files
committed
Merge branch 'master' into addons
2 parents 76e20a0 + 55ae9ec commit 715032d

File tree

130 files changed

+26806
-25551
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+26806
-25551
lines changed

.browserslistrc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
last 2 major versions
2-
not <= 0.5%
3-
not dead
4-
# No WebRTC support (including datachannel
5-
not ios_saf < 11
6-
not safari < 11
1+
# Modern browsers - macOS 10.15 (Safari 15.6: 2012 MacBook compat) and iOS 14 (Safari 14.1: iPhone 6S, iPad Air 2 compat) minimum
2+
chrome >= 105 # Pico XR 4 device browser is 105, Meta Quest 1 is Chrome 112, HTC Vive (XRE|Focus Vision) is 121
3+
safari >= 14.1
4+
ios >= 14.5
5+
firefox >= 91 # Lowered to align with Safari 15 capabilities, bump to 115 (Wolvic on HTC) when possible
6+
edge >= 105 # last HoloLens 2 Chromium Edge build with working WebXR
7+
# Exclude legacy browsers
78
not ie >= 0
8-
not edge >= 0
99
not ie_mob >= 0
1010
not and_uc >= 0
1111
# No WebGL or WebRTC support
12-
not op_mini all
12+
not op_mini all

.eslintignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 66 deletions
This file was deleted.

.githooks/pre-commit

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/sh
2+
3+
# Setup for the check for filenames with non-ASCII characters
4+
if git rev-parse --verify HEAD >/dev/null 2>&1
5+
then
6+
against=HEAD
7+
else
8+
# Initial commit: diff against an empty tree object
9+
against=$(git hash-object -t tree /dev/null)
10+
fi
11+
12+
# If you want to allow non-ASCII filenames set this variable to true.
13+
allownonascii=$(git config --type=bool hooks.allownonascii)
14+
15+
# Redirect output to stderr.
16+
exec 1>&2
17+
18+
# Cross platform projects tend to avoid non-ASCII filenames; prevent
19+
# them from being added to the repository. We exploit the fact that the
20+
# printable range starts at the space character and ends with tilde.
21+
if [ "$allownonascii" != "true" ] &&
22+
# Note that the use of brackets around a tr range is ok here, (it's
23+
# even required, for portability to Solaris 10's /usr/bin/tr), since
24+
# the square bracket bytes happen to fall in the designated range.
25+
test $(git diff-index --cached --name-only --diff-filter=A -z $against |
26+
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
27+
then
28+
cat <<\EOF
29+
Error: Attempt to add a non-ASCII file name.
30+
This can cause problems if you want to work with people on other platforms.
31+
To be portable it is advisable to rename the file.
32+
If you know what you are doing you can disable this check using:
33+
git config hooks.allownonascii true
34+
EOF
35+
exit 1
36+
fi
37+
38+
# lints changed JavaScript and TypeScript
39+
changed_js=$(git diff-index --cached --name-only $against | grep -E "(.*\.(js|mjs|ts|mts)|scripts/.*\.(js|mjs|ts|mts)|src/.*\.(js|mjs|ts|mts)|test/.*\.(js|mjs|ts|mts)|admin/.*\.(js|mjs|ts|mts)|admin/src/.*\.(js|mjs|ts|mts))$")
40+
# /dev/null prevents eslint from checking everything
41+
./node_modules/.bin/eslint ${changed_js:-/dev/null}
42+
LINT_STATUS=$?
43+
if [ "$LINT_STATUS" != "0" ]; then
44+
echo 'Fix the errors above, then use `git add` to restage all fixed files'
45+
exit $LINT_STATUS
46+
fi
47+
48+
# lints changed HTML
49+
changed_html=$(git diff-index --cached --name-only $against | grep -E "^src/.*\.html$")
50+
# src/tokens.html prevents htmlhint from checking everything
51+
node_modules/.bin/htmlhint ${changed_html:-src/tokens.html}
52+
LINT_STATUS=$?
53+
if [ "$LINT_STATUS" != "0" ]; then
54+
echo 'Fix the errors above, then use `git add` to restage all fixed files'
55+
exit $LINT_STATUS
56+
fi
57+
58+
# runs all automated tests
59+
npm run test:unit
60+
61+
# If there are whitespace errors, print the offending file names and fail.
62+
exec git diff-index --check --cached $against --

.github/workflows/browser-stack.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: browser-stack
22

33
on:
4-
schedule:
5-
- cron: '0 18 * * *'
4+
# schedule:
5+
# - cron: '0 18 * * *'
66
workflow_dispatch:
77

88
jobs:

.github/workflows/test-and-deploy-storybook.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
- uses: actions/setup-node@v3
1616
with:
17-
node-version: 16
17+
node-version: 22
1818

1919
- run: npm ci
2020
- run: npm test

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ typings/
5959

6060
# Ignore dist folder with webpack build output
6161
dist/
62+
dist-types/
63+
64+
# local storybook files
65+
storybook-static/
66+
admin/storybook-static/
6267

6368
.DS_Store
6469

.storybook/main.js

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const path = require("path");
22
const fs = require("fs");
3+
const webpack = require("webpack");
34
const themesPath = path.resolve(__dirname, "..", "themes.json");
45
if (fs.existsSync(themesPath)) {
56
const appConfig = {};
@@ -10,8 +11,53 @@ if (fs.existsSync(themesPath)) {
1011
}
1112
module.exports = {
1213
stories: ["../src/react-components/**/*.stories.mdx", "../src/react-components/**/*.stories.js"],
13-
addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
14+
addons: ["@storybook/addon-links", "@storybook/addon-docs"],
1415
webpackFinal: async config => {
16+
// Add explicit babel-loader rule for JS files with JSX at the beginning
17+
config.module.rules.unshift({
18+
test: /\.(js|jsx)$/,
19+
exclude: /node_modules/,
20+
use: {
21+
loader: "babel-loader",
22+
options: {
23+
presets: [
24+
["@babel/preset-env", { targets: "defaults" }],
25+
["@babel/preset-react", { runtime: "automatic" }]
26+
],
27+
plugins: [
28+
"formatjs",
29+
["@babel/plugin-proposal-private-property-in-object", { loose: true }],
30+
["@babel/plugin-proposal-private-methods", { loose: true }]
31+
]
32+
}
33+
}
34+
});
35+
36+
// Find and update the existing babel rule to handle JSX properly
37+
const jsRule = config.module.rules.find(
38+
rule => rule.test && rule.test.toString().includes("js") && !rule.test.toString().includes("node_modules")
39+
);
40+
41+
if (jsRule) {
42+
// Make sure it handles .js files with JSX
43+
jsRule.test = /\.(js|jsx|ts|tsx)$/;
44+
if (jsRule.use && Array.isArray(jsRule.use)) {
45+
const babelLoader = jsRule.use.find(
46+
loader => typeof loader === "object" && loader.loader && loader.loader.includes("babel")
47+
);
48+
if (babelLoader && babelLoader.options) {
49+
// Ensure React preset is configured for JSX
50+
babelLoader.options.presets = babelLoader.options.presets || [];
51+
const hasReactPreset = babelLoader.options.presets.some(preset =>
52+
Array.isArray(preset) ? preset[0].includes("react") : preset.includes("react")
53+
);
54+
if (!hasReactPreset) {
55+
babelLoader.options.presets.push(["@babel/preset-react", { runtime: "automatic" }]);
56+
}
57+
}
58+
}
59+
}
60+
1561
config.module.rules.push({
1662
test: /\.scss$/,
1763
use: [
@@ -23,7 +69,10 @@ module.exports = {
2369
localIdentName: "[name]__[local]__[hash:base64:5]",
2470
exportLocalsConvention: "camelCase",
2571
// TODO we ideally would be able to get rid of this but we have some global styles and many :local's that would become superfluous
26-
mode: "global"
72+
mode: "global",
73+
// Restore default export behavior for css-loader 7 compatibility
74+
namedExport: false,
75+
exportOnlyLocals: false
2776
}
2877
}
2978
},
@@ -69,10 +118,36 @@ module.exports = {
69118
use: ["file-loader"],
70119
include: path.resolve(__dirname, "../")
71120
});
121+
122+
// Add DefinePlugin to provide process.env variables
123+
config.plugins.push(
124+
new webpack.DefinePlugin({
125+
"process.env": {
126+
NODE_ENV: JSON.stringify("development"),
127+
RETICULUM_SERVER: JSON.stringify(""),
128+
THUMBNAIL_SERVER: JSON.stringify(""),
129+
CORS_PROXY_SERVER: JSON.stringify(""),
130+
NON_CORS_PROXY_DOMAINS: JSON.stringify(""),
131+
SENTRY_DSN: JSON.stringify(""),
132+
GA_TRACKING_ID: JSON.stringify(""),
133+
SHORTLINK_DOMAIN: JSON.stringify(""),
134+
BASE_ASSETS_PATH: JSON.stringify(""),
135+
UPLOADS_HOST: JSON.stringify(""),
136+
APP_CONFIG: JSON.stringify("")
137+
}
138+
})
139+
);
140+
72141
return config;
73142
},
74143
framework: {
75144
name: "@storybook/react-webpack5",
76145
options: {}
146+
},
147+
babel: async options => {
148+
return {
149+
...options,
150+
presets: [...options.presets, ["@babel/preset-react", { runtime: "automatic" }]]
151+
};
77152
}
78153
};

.storybook/preview.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useEffect } from "react";
22
import { useAccessibleOutlineStyle } from "../src/react-components/input/useAccessibleOutlineStyle";
33
import { WrappedIntlProvider } from "../src/react-components/wrapped-intl-provider";
4-
import { MINIMAL_VIEWPORTS } from "@storybook/addon-viewport";
4+
import { MINIMAL_VIEWPORTS } from "storybook/viewport";
55
import { AVAILABLE_LOCALES } from "../src/assets/locales/locale_config";
66
import { setLocale } from "../src/utils/i18n";
77
import { themes } from "../src/utils/theme";
@@ -13,12 +13,9 @@ const Layout = ({ children, locale, theme }) => {
1313

1414
useAccessibleOutlineStyle();
1515

16-
useEffect(
17-
() => {
18-
setLocale(locale);
19-
},
20-
[locale]
21-
);
16+
useEffect(() => {
17+
setLocale(locale);
18+
}, [locale]);
2219

2320
return <WrappedIntlProvider>{children}</WrappedIntlProvider>;
2421
};

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ Read our [contributor guide](./CONTRIBUTING.md) to learn how you can submit bug
5151

5252
We're also looking for help with localization. The Hubs redesign has a lot of new text and we need help from people like you to translate it. Follow the [localization docs](./src/assets/locales/README.md) to get started.
5353

54+
A Git hook will run before each commit, to lint and test the code.
55+
Fix the issues it complains about, then the hook will allow your commit.
56+
The checks are also run in Continuous Integration, so you'll be requested to fix a Pull Request that fails these checks — the Git hook just gives you faster feedback.
57+
In unusual situations, you can suppress the checks by adding the flag `-n` to your commit command.
58+
59+
To run the checks *before* you commit, run `npm run test`.
60+
5461
Contributors are expected to abide by the project's [Code of Conduct](./CODE_OF_CONDUCT.md) and to be respectful of the project and people working on it.
5562

5663
## Additional Resources

0 commit comments

Comments
 (0)