mirror of
https://github.com/XFox111/PasswordGeneratorExtension.git
synced 2026-04-22 08:08:01 +03:00
01d048e298
* - Minor code refactoring (#288) - Migrated last SCSS file to Griffel to get rid of SASS dependency - Migrated deprecated FUI components - Fixed FUI unmet peer dependency warning * Bump vite-plugin-web-extension from 4.1.0 to 4.1.1 (#283) Bumps [vite-plugin-web-extension](https://github.com/aklinker1/vite-plugin-web-extension) from 4.1.0 to 4.1.1. - [Release notes](https://github.com/aklinker1/vite-plugin-web-extension/releases) - [Commits](https://github.com/aklinker1/vite-plugin-web-extension/compare/v4.1.0...v4.1.1) --- updated-dependencies: - dependency-name: vite-plugin-web-extension dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump vite from 5.0.10 to 5.0.12 (#287) Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.0.10 to 5.0.12. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v5.0.12/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v5.0.12/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @typescript-eslint/eslint-plugin from 6.16.0 to 6.20.0 (#292) Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 6.16.0 to 6.20.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.20.0/packages/eslint-plugin) --- updated-dependencies: - dependency-name: "@typescript-eslint/eslint-plugin" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump vite from 5.0.10 to 5.0.12 (#293) Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.0.10 to 5.0.12. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v5.0.12/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v5.0.12/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @fluentui/react-components from 9.43.3 to 9.46.3 (#295) Bumps [@fluentui/react-components](https://github.com/microsoft/fluentui) from 9.43.3 to 9.46.3. - [Release notes](https://github.com/microsoft/fluentui/releases) - [Changelog](https://github.com/microsoft/fluentui/blob/master/azure-pipelines.release-fluentui.yml) - [Commits](https://github.com/microsoft/fluentui/compare/@fluentui/react-components_v9.43.3...@fluentui/react-components_v9.46.3) --- updated-dependencies: - dependency-name: "@fluentui/react-components" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @types/react from 18.2.45 to 18.2.48 (#296) Bumps [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) from 18.2.45 to 18.2.48. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react) --- updated-dependencies: - dependency-name: "@types/react" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @vitejs/plugin-react-swc from 3.5.0 to 3.6.0 (#297) Bumps [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) from 3.5.0 to 3.6.0. - [Release notes](https://github.com/vitejs/vite-plugin-react-swc/releases) - [Changelog](https://github.com/vitejs/vite-plugin-react-swc/blob/main/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite-plugin-react-swc/compare/v3.5.0...v3.6.0) --- updated-dependencies: - dependency-name: "@vitejs/plugin-react-swc" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump vite-plugin-static-copy from 1.0.0 to 1.0.1 (#298) Bumps [vite-plugin-static-copy](https://github.com/sapphi-red/vite-plugin-static-copy) from 1.0.0 to 1.0.1. - [Release notes](https://github.com/sapphi-red/vite-plugin-static-copy/releases) - [Changelog](https://github.com/sapphi-red/vite-plugin-static-copy/blob/main/CHANGELOG.md) - [Commits](https://github.com/sapphi-red/vite-plugin-static-copy/compare/vite-plugin-static-copy@1.0.0...vite-plugin-static-copy@1.0.1) --- updated-dependencies: - dependency-name: vite-plugin-static-copy dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Eugene Fox <eugene.xfox@outlook.com> * Bump @fluentui/react-icons from 2.0.224 to 2.0.226 (#299) Bumps [@fluentui/react-icons](https://github.com/microsoft/fluentui-system-icons) from 2.0.224 to 2.0.226. - [Commits](https://github.com/microsoft/fluentui-system-icons/commits) --- updated-dependencies: - dependency-name: "@fluentui/react-icons" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Eugene Fox <eugene.xfox@outlook.com> * Bump wdzeng/edge-addon from 1.2.2 to 1.2.3 (#289) Bumps [wdzeng/edge-addon](https://github.com/wdzeng/edge-addon) from 1.2.2 to 1.2.3. - [Release notes](https://github.com/wdzeng/edge-addon/releases) - [Commits](https://github.com/wdzeng/edge-addon/compare/v1.2.2...v1.2.3) --- updated-dependencies: - dependency-name: wdzeng/edge-addon dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump wdzeng/chrome-extension from 1.2.1 to 1.2.2 (#290) Bumps [wdzeng/chrome-extension](https://github.com/wdzeng/chrome-extension) from 1.2.1 to 1.2.2. - [Release notes](https://github.com/wdzeng/chrome-extension/releases) - [Commits](https://github.com/wdzeng/chrome-extension/compare/v1.2.1...v1.2.2) --- updated-dependencies: - dependency-name: wdzeng/chrome-extension dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump wdzeng/firefox-addon from 1.0.3 to 1.0.4 (#291) Bumps [wdzeng/firefox-addon](https://github.com/wdzeng/firefox-addon) from 1.0.3 to 1.0.4. - [Release notes](https://github.com/wdzeng/firefox-addon/releases) - [Commits](https://github.com/wdzeng/firefox-addon/compare/v1.0.3...v1.0.4) --- updated-dependencies: - dependency-name: wdzeng/firefox-addon dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @typescript-eslint/parser from 6.16.0 to 6.20.0 (#294) Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 6.16.0 to 6.20.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.20.0/packages/parser) --- updated-dependencies: - dependency-name: "@typescript-eslint/parser" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Eugene Fox <eugene.xfox@outlook.com> * Bump @types/react from 18.2.48 to 18.2.55 (#301) Bumps [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) from 18.2.48 to 18.2.55. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react) --- updated-dependencies: - dependency-name: "@types/react" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump vite from 5.0.12 to 5.1.0 (#302) Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.0.12 to 5.1.0. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/create-vite@5.1.0/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @fluentui/react-components from 9.46.3 to 9.46.4 (#306) Bumps [@fluentui/react-components](https://github.com/microsoft/fluentui) from 9.46.3 to 9.46.4. - [Release notes](https://github.com/microsoft/fluentui/releases) - [Changelog](https://github.com/microsoft/fluentui/blob/master/azure-pipelines.release-fluentui.yml) - [Commits](https://github.com/microsoft/fluentui/compare/@fluentui/react-components_v9.46.3...@fluentui/react-components_v9.46.4) --- updated-dependencies: - dependency-name: "@fluentui/react-components" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Improved quick adjustment panel: (#300) - Added length slider range setting (#286) - Added more character options for quick adjustment - QA panel now collapses when settings panel is open * Bump @types/react-dom from 18.2.18 to 18.2.19 (#303) Bumps [@types/react-dom](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react-dom) from 18.2.18 to 18.2.19. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react-dom) --- updated-dependencies: - dependency-name: "@types/react-dom" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Eugene Fox <eugene.xfox@outlook.com> * Bump @typescript-eslint/eslint-plugin from 6.20.0 to 6.21.0 (#304) Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 6.20.0 to 6.21.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.21.0/packages/eslint-plugin) --- updated-dependencies: - dependency-name: "@typescript-eslint/eslint-plugin" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @typescript-eslint/parser from 6.20.0 to 6.21.0 (#305) Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 6.20.0 to 6.21.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.21.0/packages/parser) --- updated-dependencies: - dependency-name: "@typescript-eslint/parser" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update pt-BR (#307) * Improved quick adjustment panel: - Added length slider range setting (#286) - Added more character options for quick adjustment - QA panel now collapses when settings panel is open * Update pt-BR Update pt-BR * Update messages.json * Update messages.json * Update New * Update Final * Update Fix --------- Co-authored-by: Eugene Fox <eugene@xfox111.net> * Update package.json --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Maison da Silva <maisonmdsgreen@hotmail.com>
172 lines
6.2 KiB
TypeScript
172 lines
6.2 KiB
TypeScript
import * as fui from "@fluentui/react-components";
|
|
import * as Icons from "@fluentui/react-icons";
|
|
import { useEffect, useState } from "react";
|
|
import GeneratorOptions from "../Models/GeneratorOptions";
|
|
import { GetLocaleString as loc } from "../Utils/Localization";
|
|
import { GeneratePassword } from "../Utils/PasswordGenerator";
|
|
import { useStorage } from "../Utils/Storage";
|
|
import { useTimeout } from "../Utils/Timeout";
|
|
import { useStyles } from "./GeneratorView.styles";
|
|
|
|
export default function GeneratorView(props: { collapse: boolean; }): JSX.Element
|
|
{
|
|
const { generatorOptions, extOptions } = useStorage();
|
|
const [password, setPassword] = useState<string>("");
|
|
const [quickOpts, _setOpts] = useState<GeneratorOptions>(generatorOptions);
|
|
const [error, setError] = useState<string | null>(null);
|
|
|
|
const [refreshTimer, copyTimer] = [useTimeout(310), useTimeout(1000)];
|
|
const checkedOptions = Object.keys(quickOpts).filter(k => quickOpts[k as keyof GeneratorOptions] as boolean);
|
|
const cls = useStyles();
|
|
|
|
const IncludeIcon: Icons.FluentIcon = Icons.bundleIcon(Icons.AddCircleFilled, Icons.AddCircleRegular);
|
|
const ExcludeIcon: Icons.FluentIcon = Icons.bundleIcon(Icons.SubtractCircleFilled, Icons.SubtractCircleRegular);
|
|
|
|
const resetOptions = (): void =>
|
|
_setOpts(generatorOptions);
|
|
|
|
const setOptions = (opts: Partial<GeneratorOptions>) =>
|
|
_setOpts({ ...quickOpts, ...opts });
|
|
|
|
function RefreshPassword(): void
|
|
{
|
|
setError(null);
|
|
const options: GeneratorOptions = { ...generatorOptions, ...quickOpts };
|
|
|
|
try { setPassword(GeneratePassword(options)); }
|
|
catch (e) { setError((e as Error).message); }
|
|
}
|
|
|
|
async function CopyPassword(): Promise<void>
|
|
{
|
|
await window.navigator.clipboard.writeText(password);
|
|
copyTimer.trigger();
|
|
}
|
|
|
|
function OnCheckedValueChange(_: unknown, e: fui.MenuCheckedValueChangeData): void
|
|
{
|
|
const opts: Partial<Omit<GeneratorOptions, "Length">> = {};
|
|
|
|
let keys = Object.keys(quickOpts).filter(i => i !== "Length") as (keyof Omit<GeneratorOptions, "Length">)[];
|
|
|
|
if (e.name === "include")
|
|
keys = keys.filter(i => !i.startsWith("Exclude"));
|
|
else
|
|
keys = keys.filter(i => i.startsWith("Exclude"));
|
|
|
|
for (const key of keys)
|
|
opts[key] = e.checkedItems.includes(key);
|
|
|
|
setOptions(opts);
|
|
}
|
|
|
|
useEffect(resetOptions, [generatorOptions]);
|
|
useEffect(RefreshPassword, [generatorOptions, quickOpts]);
|
|
useEffect(refreshTimer.trigger, [password]);
|
|
|
|
return (
|
|
<section className={ cls.root }>
|
|
{ error ?
|
|
<fui.MessageBar intent="warning" className={ cls.msgBar }>
|
|
<fui.MessageBarBody>{ error }</fui.MessageBarBody>
|
|
</fui.MessageBar>
|
|
:
|
|
<fui.Input
|
|
className={ cls.input }
|
|
readOnly value={ password }
|
|
contentAfter={ <>
|
|
<fui.Tooltip content={ loc("generator@copy") } relationship="label">
|
|
<fui.Button
|
|
appearance="subtle" onClick={ CopyPassword }
|
|
icon={
|
|
copyTimer.isActive ?
|
|
<Icons.CheckmarkRegular className={ cls.copyIcon } /> :
|
|
<Icons.CopyRegular className={ cls.copyIcon } />
|
|
} />
|
|
</fui.Tooltip>
|
|
|
|
<fui.Tooltip content={ loc("generator@refresh") } relationship="label">
|
|
<fui.Button
|
|
appearance="subtle" onClick={ RefreshPassword }
|
|
icon={
|
|
<Icons.ArrowClockwiseRegular className={ fui.mergeClasses(refreshTimer.isActive && cls.refreshIcon) } />
|
|
} />
|
|
</fui.Tooltip>
|
|
</> } />
|
|
}
|
|
|
|
{ !props.collapse &&
|
|
<div className={ cls.options }>
|
|
<fui.InfoLabel info={ loc("generator@quickOptions__hint") }>
|
|
{ loc("generator@quickOptions") }
|
|
</fui.InfoLabel>
|
|
|
|
<div className={ cls.lengthContainer }>
|
|
<fui.Slider
|
|
min={ extOptions.MinLength } max={ Math.max(extOptions.MaxLength, generatorOptions.Length) }
|
|
value={ quickOpts.Length } onChange={ (_, e) => setOptions({ Length: e.value }) } />
|
|
<fui.Text>{ quickOpts.Length }</fui.Text>
|
|
</div>
|
|
|
|
<div className={ cls.characterOptionsContainer }>
|
|
<fui.Menu
|
|
positioning="after" hasCheckmarks
|
|
checkedValues={ { include: checkedOptions } }
|
|
onCheckedValueChange={ OnCheckedValueChange }>
|
|
|
|
<fui.MenuTrigger disableButtonEnhancement>
|
|
<fui.MenuButton appearance="subtle" icon={ <IncludeIcon /> }>{ loc("generator@include") }</fui.MenuButton>
|
|
</fui.MenuTrigger>
|
|
|
|
<fui.MenuPopover>
|
|
<fui.MenuList>
|
|
<fui.MenuItemCheckbox name="include" value="Uppercase" icon={ <Icons.TextCaseUppercaseRegular /> }>
|
|
{ loc("settings@uppercase") }
|
|
</fui.MenuItemCheckbox>
|
|
<fui.MenuItemCheckbox name="include" value="Lowercase" icon={ <Icons.TextCaseLowercaseRegular /> }>
|
|
{ loc("settings@lowercase") }
|
|
</fui.MenuItemCheckbox>
|
|
<fui.MenuItemCheckbox name="include" value="Numeric" icon={ <Icons.NumberSymbolRegular /> }>
|
|
{ loc("settings@numeric") }
|
|
</fui.MenuItemCheckbox>
|
|
<fui.MenuItemCheckbox name="include" value="Special" icon={ <Icons.MathSymbolsRegular /> }>
|
|
{ loc("settings@special") }
|
|
</fui.MenuItemCheckbox>
|
|
</fui.MenuList>
|
|
</fui.MenuPopover>
|
|
</fui.Menu>
|
|
|
|
<fui.Menu
|
|
positioning="before"
|
|
checkedValues={ { exclude: checkedOptions } }
|
|
onCheckedValueChange={ OnCheckedValueChange }>
|
|
|
|
<fui.MenuTrigger disableButtonEnhancement>
|
|
<fui.MenuButton appearance="subtle" icon={ <ExcludeIcon /> }>{ loc("generator@exclude") }</fui.MenuButton>
|
|
</fui.MenuTrigger>
|
|
|
|
<fui.MenuPopover>
|
|
<fui.MenuList>
|
|
<fui.MenuItemCheckbox name="exclude" value="ExcludeSimilar">
|
|
{ loc("settings@similar") }
|
|
</fui.MenuItemCheckbox>
|
|
<fui.MenuItemCheckbox name="exclude" value="ExcludeAmbiguous" disabled={ !quickOpts.Special }>
|
|
{ loc("settings@ambiguous") }
|
|
</fui.MenuItemCheckbox>
|
|
<fui.MenuItemCheckbox name="exclude" value="ExcludeRepeating">
|
|
{ loc("settings@repeating") }
|
|
</fui.MenuItemCheckbox>
|
|
</fui.MenuList>
|
|
</fui.MenuPopover>
|
|
</fui.Menu>
|
|
|
|
<fui.Tooltip content={ loc("generator@reset") } relationship="label">
|
|
<fui.Button appearance="subtle" icon={ <Icons.ArrowUndoRegular /> } onClick={ resetOptions } />
|
|
</fui.Tooltip>
|
|
</div>
|
|
</div>
|
|
}
|
|
</section>
|
|
);
|
|
}
|