mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-24 17:51:14 +02:00
[](https://renovatebot.com)
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@biomejs/biome](https://biomejs.dev)
([source](https://togithub.com/biomejs/biome)) | [`1.3.3` ->
`1.4.0`](https://renovatebot.com/diffs/npm/@biomejs%2fbiome/1.3.3/1.4.0)
|
[](https://docs.renovatebot.com/merge-confidence/)
|
[](https://docs.renovatebot.com/merge-confidence/)
|
[](https://docs.renovatebot.com/merge-confidence/)
|
[](https://docs.renovatebot.com/merge-confidence/)
|
---
### Release Notes
<details>
<summary>biomejs/biome (@​biomejs/biome)</summary>
###
[`v1.4.0`](https://togithub.com/biomejs/biome/blob/HEAD/CHANGELOG.md#140-2023-11-27)
[Compare
Source](af24597c18...889593e3f9
)
##### CLI
- Remove the CLI options from the `lsp-proxy`, as they were never meant
to be passed to that command. Contributed by
[@​ematipico](https://togithub.com/ematipico)
- Add option `--config-path` to `lsp-proxy` and `start` commands. It's
now possible to tell the Daemon server to load `biome.json` from a
custom path. Contributed by
[@​ematipico](https://togithub.com/ematipico)
- Add new `--diagnostic-level` option to let users control the level of
diagnostics printed by the CLI. Possible values are: `"info"`, `"warn"`,
`"hint"`. Contributed by
[@​simonxabris](https://togithub.com/simonxabris)
- Add option `--line-feed` to the `format` command. Contributed by
[@​SuperchupuDev](https://togithub.com/SuperchupuDev)
- Add option `--bracket-same-line` to the `format` command. Contributed
by [@​faultyserve](https://togithub.com/faultyserve)
- Add option `--bracket-spacing` to the `format` command. Contributed by
[@​faultyserve](https://togithub.com/faultyserve)
##### Bug fixes
- Fix the command `format`, now it returns a non-zero exit code when if
there pending diffs. Contributed by
[@​ematipico](https://togithub.com/ematipico)
##### Configuration
- Add option `formatter.lineFeed`. Contributed by
[@​SuperchupuDev](https://togithub.com/SuperchupuDev)
- Add option `javascript.formatter.bracketSameLine`. Contributed by
[@​faultyserve](https://togithub.com/faultyserve)
- Add option `javascript.formatter.bracketSpacing`. Contributed by
[@​faultyserve](https://togithub.com/faultyserve)
##### Formatter
##### New features
- Add a new option
[`--line-ending`](https://biomejs.dev/reference/configuration/#formatterlineending).
This option allows changing the type of line endings. Contributed by
[@​SuperchupuDev](https://togithub.com/SuperchupuDev)
- Added a new option called `--bracket-spacing` to the formatter. This
option allows you to control whether spaces are inserted around the
brackets of object literals.
[#​627](https://togithub.com/biomejs/biome/issues/627).
Contributed by [@​faultyserver](https://togithub.com/faultyserver)
- Added a new option called `--bracket-same-line` to the formatter. This
option allows you to control whether spaces are inserted around the
brackets of object literals.
[#​627](https://togithub.com/biomejs/biome/issues/627).
Contributed by [@​faultyserver](https://togithub.com/faultyserver)
##### Bug fixes
- Fix [#​832](https://togithub.com/biomejs/biome/issues/832), the
formatter no longer keeps an unnecessary trailing comma in type
parameter lists. Contributed by
[@​Conaclos](https://togithub.com/Conaclos)
- Fix [#​301](https://togithub.com/biomejs/biome/issues/301), the
formatter should not break before the `in` keyword. Contributed by
[@​ematipico](https://togithub.com/ematipico)
##### Linter
##### Promoted rules
-
[a11y/noInteractiveElementToNoninteractiveRole](https://biomejs.dev/linter/rules/no-interactive-element-to-noninteractive-role)
-
[complexity/noThisInStatic](https://biomejs.dev/linter/rules/no-this-in-static)
-
[complexity/useArrowFunction](https://biomejs.dev/linter/rules/use-arrow-function)
-
[correctness/noEmptyCharacterClassInRegex](https://biomejs.dev/linter/rules/no-empty-character-class-in-regex)
-
[correctness/noInvalidNewBuiltin](https://biomejs.dev/linter/rules/no-invalid-new-builtin)
-
[style/noUselessElse](https://biomejs.dev/linter/rules/no-useless-else)
-
[style/useAsConstAssertion](https://biomejs.dev/linter/rules/use-as-const-assertion)
-
[style/useShorthandAssign](https://biomejs.dev/linter/rules/use-shorthand-assign)
-
[suspicious/noApproximativeNumericConstant](https://biomejs.dev/linter/rules/no-approximative-numeric-constant)
-
[suspicious/noMisleadingInstantiator](https://biomejs.dev/linter/rules/no-misleading-instantiator)
-
[suspicious/noMisrefactoredShorthandAssign](https://biomejs.dev/linter/rules/no-misrefactored-shorthand-assign)
The following rules are now recommended:
- [a11y/noAccessKey](https://biomejs.dev/linter/rules/no-access-key)
-
[a11y/useHeadingContent](https://biomejs.dev/linter/rules/use-heading-content)
-
[complexity/useSimpleNumberKeys](https://biomejs.dev/linter/use-simple-number-keys)
The following rules are now deprecated:
-
[correctness/noNewSymbol](https://biomejs.dev/linter/rules/no-new-symbol)
The rule is replaced by
[correctness/noInvalidNewBuiltin](https://biomejs.dev/linter/rules/no-invalid-new-builtin)
##### New features
- Add
[noDefaultExport](https://biomejs.dev/linter/rules/no-default-export)
which disallows `export default`. Contributed by
[@​Conaclos](https://togithub.com/Conaclos)
- Add
[noAriaHiddenOnFocusable](https://biomejs.dev/linter/rules/no-aria-hidden-on-focusable)
which reports hidden and focusable elements. Contributed by
[@​vasucp1207](https://togithub.com/vasucp1207)
- Add
[noImplicitAnyLet](https://biomejs.dev/linter/rules/no-implicit-any-let)
that reports variables declared with `let` and without initialization
and type annotation. Contributed by
[@​TaKO8Ki](https://togithub.com/TaKO8Ki) and
[@​b4s36t4](https://togithub.com/b4s36t4)
- Add [useAwait](https://biomejs.dev/linter/rules/use-await) that
reports `async` functions that don't use an `await` expression.
- Add
[useValidAriaRole](https://biomejs.dev/linter/rules/use-valid-aria-role).
Contributed by [@​vasucp1207](https://togithub.com/vasucp1207)
- Add [useRegexLiterals](https://biomejs.dev/linter/use-regex-literals)
that suggests turning call to the regex constructor into regex literals.
COntributed by [@​Yuiki](https://togithub.com/Yuiki)
##### Enhancements
- Add an unsafe code fix for
[a11y/useAriaActivedescendantWithTabindex](https://biomejs.dev/linter/rules/use-aria-activedescendant-with-tabindex)
##### Bug fixes
- Fix [#​639](https://togithub.com/biomejs/biome/issues/639) by
ignoring unused TypeScript's mapped key. Contributed by
[@​Conaclos](https://togithub.com/Conaclos)
- Fix [#​565](https://togithub.com/biomejs/biome/issues/565) by
handling several `infer` with the same name in extends clauses of
TypeScript's conditional types. Contributed by
[@​Conaclos](https://togithub.com/Conaclos)
- Fix [#​653](https://togithub.com/biomejs/biome/issues/653).
[noUnusedImports](https://biomejs.dev/linter/rules/no-unused-imports)
now correctly removes the entire line where the unused `import` is.
Contributed by [@​Conaclos](https://togithub.com/Conaclos)
- Fix [#​607](https://togithub.com/biomejs/biome/issues/609)
`useExhaustiveDependencies`, ignore optional chaining, Contributed by
[@​msdlisper](https://togithub.com/msdlisper)
- Fix [#​676](https://togithub.com/biomejs/biome/issues/676), by
using the correct node for the `"noreferrer"` when applying the code
action. Contributed by
[@​ematipico](https://togithub.com/ematipico)
- Fix [#​455](https://togithub.com/biomejs/biome/issues/455). The
CLI can now print complex emojis to the console correctly.
- Fix [#​727](https://togithub.com/biomejs/biome/issues/727).
[noInferrableTypes](https://biomejs.dev/linter/rules/no-inferrable-types)
now correctly keeps type annotations when the initialization expression
is `null`. Contributed by
[@​Conaclos](https://togithub.com/Conaclos)
- Fix [#​784](https://togithub.com/biomejs/biome/issues/784),
[noSvgWithoutTitle](https://biomejs.dev/linter/rules/no-svg-without-title)
fixes false-positives to `aria-label` and reports svg's role attribute
is implicit. Contributed by
[@​unvalley](https://togithub.com/unvalley)
- Fix [#​834](https://togithub.com/biomejs/biome/issues/834) that
made
[noUselessLoneBlockStatements](https://biomejs.dev/linter/rules/no-useless-lone-block-statements)
reports block statements of switch clauses. Contributed by
[@​vasucp1207](https://togithub.com/vasucp1207)
- Fix [#​783](https://togithub.com/biomejs/biome/issues/834) that
made
[noUselessLoneBlockStatements](https://biomejs.dev/linter/rules/no-useless-lone-block-statements)
reports block statements of `try-catch` structures. Contributed by
[@​hougesen](https://togithub.com/hougesen)
- Fix [#​69](https://togithub.com/biomejs/biome/issues/69) that
made
[correctness/noUnnecessaryContinue](https://biomejs.dev/linter/rules/no-unnecessary-continue)
incorrectly reports a `continue` used to break a switch clause.
Contributed by [@​TaKO8Ki](https://togithub.com/TaKO8Ki)
- Fix [#​664](https://togithub.com/biomejs/biome/issues/664) by
improving the diagnostic of
[style/useNamingConvention](https://biomejs.dev/linter/use-naming-convention)
when double capital are detected in strict camel case mode. Contributed
by [@​vasucp1207](https://togithub.com/vasucp1207)
- Fix [#​643](https://togithub.com/biomejs/biome/issues/643) that
erroneously parsed the option of
[complexity/useExhaustiveDependencies](https://biomejs.dev/linter/use-naming-convention).
Contributed by [@​arendjr](https://togithub.com/arendjr)
##### Parser
##### Bug fixes
- Fix [#​846](https://togithub.com/biomejs/biome/issues/846) that
erroneously parsed `<const T,>() => {}` as a JSX tag instead of an arrow
function when both TypeScript and JSX are enabled.
##### VSCode
</details>
---
### Configuration
📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).
🚦 **Automerge**: Enabled.
♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.
🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.
---
- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box
---
This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/Unleash/unleash).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40Ni4wIiwidXBkYXRlZEluVmVyIjoiMzcuNTkuOCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->
---------
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Christopher Kolstad <chriswk@getunleash.io>
290 lines
8.6 KiB
TypeScript
290 lines
8.6 KiB
TypeScript
import Joyride, {
|
|
ACTIONS,
|
|
CallBackProps,
|
|
TooltipRenderProps,
|
|
} from 'react-joyride';
|
|
import { useTheme } from '@mui/material';
|
|
import { ITutorialTopic, ITutorialTopicStep } from '../demo-topics';
|
|
import { useEffect, useState } from 'react';
|
|
import { useLocation, useNavigate } from 'react-router-dom';
|
|
import { DemoStepTooltip } from './DemoStepTooltip/DemoStepTooltip';
|
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
|
|
|
interface IDemoStepsProps {
|
|
setExpanded: React.Dispatch<React.SetStateAction<boolean>>;
|
|
step: number;
|
|
setStep: React.Dispatch<React.SetStateAction<number>>;
|
|
stepsCompletion: number[];
|
|
setStepsCompletion: React.Dispatch<React.SetStateAction<number[]>>;
|
|
topic: number;
|
|
setTopic: React.Dispatch<React.SetStateAction<number>>;
|
|
topics: ITutorialTopic[];
|
|
onFinish: () => void;
|
|
}
|
|
|
|
export const DemoSteps = ({
|
|
setExpanded,
|
|
step,
|
|
setStep,
|
|
stepsCompletion,
|
|
setStepsCompletion,
|
|
topic,
|
|
setTopic,
|
|
topics,
|
|
onFinish,
|
|
}: IDemoStepsProps) => {
|
|
const theme = useTheme();
|
|
const navigate = useNavigate();
|
|
const location = useLocation();
|
|
const { trackEvent } = usePlausibleTracker();
|
|
const [run, setRun] = useState(false);
|
|
const [flow, setFlow] = useState<'next' | 'back' | 'load'>('load');
|
|
|
|
const abortController = new AbortController();
|
|
|
|
const setTopicStep = (topic: number, step?: number) => {
|
|
setRun(false);
|
|
if (step !== undefined) {
|
|
if (stepsCompletion[topic] < step) {
|
|
setStepsCompletion((steps) => {
|
|
const newSteps = [...steps];
|
|
newSteps[topic] = step;
|
|
return newSteps;
|
|
});
|
|
}
|
|
setStep(step);
|
|
}
|
|
setTopic(topic);
|
|
};
|
|
|
|
const close = () => {
|
|
abortController.abort();
|
|
setTopicStep(-1);
|
|
|
|
trackEvent('demo-close', {
|
|
props: {
|
|
topic: topics[topic].title,
|
|
step: step + 1,
|
|
},
|
|
});
|
|
};
|
|
|
|
const back = () => {
|
|
setFlow('back');
|
|
if (step === 0) {
|
|
const newTopic = topic - 1;
|
|
setTopicStep(newTopic, topics[newTopic].steps.length - 1);
|
|
} else {
|
|
setTopicStep(topic, step - 1);
|
|
}
|
|
};
|
|
|
|
const nextTopic = () => {
|
|
const currentTopic = topic;
|
|
|
|
const nextUnfinishedTopic =
|
|
topics.findIndex(
|
|
(topic, index) =>
|
|
index !== currentTopic &&
|
|
stepsCompletion[index] < topic.steps.length,
|
|
) ?? -1;
|
|
|
|
if (nextUnfinishedTopic === -1) {
|
|
setTopicStep(-1);
|
|
setExpanded(false);
|
|
onFinish();
|
|
} else {
|
|
setTopicStep(nextUnfinishedTopic, 0);
|
|
}
|
|
};
|
|
|
|
const next = (index = step) => {
|
|
setFlow('next');
|
|
setTopicStep(topic, index + 1);
|
|
if (index === topics[topic].steps.length - 1) {
|
|
nextTopic();
|
|
}
|
|
};
|
|
|
|
const joyrideCallback = (
|
|
data: CallBackProps & {
|
|
step: ITutorialTopicStep;
|
|
},
|
|
) => {
|
|
const { action, index, step } = data;
|
|
|
|
if (action === ACTIONS.CLOSE) {
|
|
close();
|
|
}
|
|
|
|
if (action === ACTIONS.UPDATE) {
|
|
const el = document.querySelector(
|
|
step.target as string,
|
|
) as HTMLElement | null;
|
|
if (el) {
|
|
el.scrollIntoView({
|
|
block: 'center',
|
|
});
|
|
|
|
if (step.focus) {
|
|
if (step.focus === true) {
|
|
el.focus();
|
|
} else {
|
|
const focusEl = el.querySelector(
|
|
step.focus,
|
|
) as HTMLElement | null;
|
|
focusEl?.focus();
|
|
}
|
|
}
|
|
|
|
if (!step.nextButton) {
|
|
const clickHandler = (e: Event) => {
|
|
abortController.abort();
|
|
next(index);
|
|
if (step.preventDefault) {
|
|
e.preventDefault();
|
|
}
|
|
};
|
|
|
|
if (step.anyClick) {
|
|
window.addEventListener(
|
|
'click',
|
|
(e) => {
|
|
const targetEl = e.target as HTMLElement;
|
|
if (
|
|
!targetEl.closest('.__floater') &&
|
|
!targetEl.className.includes(
|
|
'react-joyride__overlay',
|
|
)
|
|
)
|
|
clickHandler(e);
|
|
},
|
|
{
|
|
signal: abortController.signal,
|
|
},
|
|
);
|
|
} else {
|
|
el.addEventListener('click', clickHandler, {
|
|
signal: abortController.signal,
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
const onBack = (step: ITutorialTopicStep) => {
|
|
if (step.backCloseModal) {
|
|
(
|
|
document.querySelector('.MuiModal-backdrop') as HTMLElement
|
|
)?.click();
|
|
}
|
|
if (step.backCollapseExpanded) {
|
|
(
|
|
document.querySelector(
|
|
'.Mui-expanded[role="button"]',
|
|
) as HTMLElement
|
|
)?.click();
|
|
}
|
|
back();
|
|
};
|
|
|
|
const waitForLoad = (step: ITutorialTopicStep, tries = 0) => {
|
|
setTimeout(() => {
|
|
if (document.querySelector(step.target as string)) {
|
|
setRun(true);
|
|
} else {
|
|
if (flow === 'next' && step.optional) {
|
|
next();
|
|
} else if (flow === 'back' || tries > 4) {
|
|
back();
|
|
} else {
|
|
waitForLoad(step, tries + 1);
|
|
}
|
|
}
|
|
}, 300);
|
|
};
|
|
|
|
useEffect(() => {
|
|
if (topic === -1) return;
|
|
const currentTopic = topics[topic];
|
|
const currentStep = currentTopic.steps[step];
|
|
if (!currentStep) return;
|
|
|
|
setTimeout(
|
|
() => {
|
|
if (
|
|
currentStep.href &&
|
|
!location.pathname.endsWith(currentStep.href.split('?')[0])
|
|
) {
|
|
navigate(currentStep.href);
|
|
}
|
|
waitForLoad(currentStep);
|
|
},
|
|
currentStep.delay ?? 0,
|
|
);
|
|
}, [topic, step]);
|
|
|
|
useEffect(() => {
|
|
if (topic > -1) topics[topic].setup?.();
|
|
}, [topic]);
|
|
|
|
if (topic === -1) return null;
|
|
|
|
const joyrideSteps = topics[topic].steps.map((step) => ({
|
|
...step,
|
|
disableBeacon: true,
|
|
}));
|
|
|
|
return (
|
|
<Joyride
|
|
run={run}
|
|
stepIndex={step}
|
|
callback={joyrideCallback}
|
|
steps={joyrideSteps}
|
|
disableScrolling
|
|
disableOverlayClose
|
|
spotlightClicks
|
|
spotlightPadding={0}
|
|
floaterProps={{
|
|
disableAnimation: true,
|
|
styles: {
|
|
floater: {
|
|
filter: `drop-shadow(rgba(32, 32, 33, .2) 0px 4px 12px)`,
|
|
},
|
|
},
|
|
}}
|
|
styles={{
|
|
options: {
|
|
arrowColor: theme.palette.background.paper,
|
|
zIndex: theme.zIndex.snackbar - 1,
|
|
},
|
|
spotlight: {
|
|
borderRadius: theme.shape.borderRadiusMedium,
|
|
border: `2px solid ${theme.palette.spotlight.border}`,
|
|
outline: `2px solid ${theme.palette.spotlight.outline}`,
|
|
animation: 'pulse 2s infinite',
|
|
},
|
|
overlay: {
|
|
backgroundColor: 'rgba(0, 0, 0, 0.4)',
|
|
},
|
|
}}
|
|
tooltipComponent={(
|
|
props: TooltipRenderProps & {
|
|
step: ITutorialTopicStep;
|
|
},
|
|
) => (
|
|
<DemoStepTooltip
|
|
{...props}
|
|
topic={topic}
|
|
topics={topics}
|
|
stepIndex={step}
|
|
onClose={close}
|
|
onBack={onBack}
|
|
onNext={next}
|
|
/>
|
|
)}
|
|
/>
|
|
);
|
|
};
|