1
0
mirror of https://github.com/XFox111/PasswordGeneratorExtension.git synced 2026-04-22 08:08:01 +03:00

Minor 3.1.0 (#308)

* - 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>
This commit is contained in:
Eugene Fox
2024-02-09 10:55:14 +03:00
committed by GitHub
parent 0b47bf93aa
commit 01d048e298
20 changed files with 1079 additions and 876 deletions
+2 -2
View File
@@ -10,7 +10,7 @@ import { useStyles } from "./AboutSection.styles";
export default function AboutSection(): JSX.Element
{
const theme = useTheme(bmcLightTheme, bmcDarkTheme);
const bmcTheme = useTheme(bmcLightTheme, bmcDarkTheme);
const cls = useStyles();
const link = (text: string, href: string): JSX.Element => (
@@ -54,7 +54,7 @@ export default function AboutSection(): JSX.Element
<fui.Button { ...buttonProps(GetFeedbackLink(), <PersonFeedbackRegular />) }>
{ loc("about@feedback") }
</fui.Button>
<fui.FluentProvider theme={ theme }>
<fui.FluentProvider theme={ bmcTheme }>
<fui.Button { ...buttonProps(PersonalLink.BuyMeACoffee, <BuyMeACoffee />) }>
{ loc("about@sponsor") }
</fui.Button>
+16 -12
View File
@@ -17,17 +17,6 @@ export const useStyles = makeStyles({
alignItems: "center",
paddingRight: tokens.spacingHorizontalM,
},
optionsSpacing:
{
...shorthands.padding(tokens.spacingVerticalS, tokens.spacingHorizontalS),
},
optionsLabel:
{
"> div[role=note].fui-InfoButton__info":
{
zIndex: 1,
},
},
copyIcon:
{
animationName: "scaleUpIn",
@@ -39,5 +28,20 @@ export const useStyles = makeStyles({
animationName: "spin",
animationDuration: tokens.durationSlow,
animationTimingFunction: tokens.curveEasyEaseMax,
}
},
msgBar:
{
...shorthands.padding(tokens.spacingVerticalMNudge, tokens.spacingHorizontalM),
},
options:
{
display: "flex",
flexDirection: "column",
...shorthands.padding(tokens.spacingVerticalS, tokens.spacingHorizontalS),
},
characterOptionsContainer:
{
display: "flex",
...shorthands.gap(tokens.spacingHorizontalXS),
},
});
+122 -56
View File
@@ -1,6 +1,5 @@
import { Button, Checkbox, Input, Slider, Text, Tooltip, mergeClasses } from "@fluentui/react-components";
import { Alert, InfoLabel } from "@fluentui/react-components/unstable";
import { ArrowClockwiseRegular, ArrowUndoRegular, CheckmarkRegular, CopyRegular } from "@fluentui/react-icons";
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";
@@ -9,22 +8,24 @@ import { useStorage } from "../Utils/Storage";
import { useTimeout } from "../Utils/Timeout";
import { useStyles } from "./GeneratorView.styles";
type QuickOptions = Pick<GeneratorOptions, "Length" | "Special" | "ExcludeAmbiguous">;
export default function GeneratorView(): JSX.Element
export default function GeneratorView(props: { collapse: boolean; }): JSX.Element
{
const { generatorOptions } = useStorage();
const { generatorOptions, extOptions } = useStorage();
const [password, setPassword] = useState<string>("");
const [quickOpts, _setOpts] = useState<QuickOptions>(generatorOptions);
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<QuickOptions>) =>
const setOptions = (opts: Partial<GeneratorOptions>) =>
_setOpts({ ...quickOpts, ...opts });
function RefreshPassword(): void
@@ -42,64 +43,129 @@ export default function GeneratorView(): JSX.Element
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]);
const actionButtons: JSX.Element = <>
<Tooltip content={ loc("generator@copy") } relationship="label">
<Button
appearance="subtle" onClick={ CopyPassword }
icon={
copyTimer.isActive ?
<CheckmarkRegular className={ cls.copyIcon } /> :
<CopyRegular className={ cls.copyIcon } />
} />
</Tooltip>
<Tooltip content={ loc("generator@refresh") } relationship="label">
<Button
appearance="subtle" onClick={ RefreshPassword }
icon={
<ArrowClockwiseRegular className={ mergeClasses(refreshTimer.isActive && cls.refreshIcon) } />
} />
</Tooltip>
</>;
return (
<section className={ cls.root }>
{ error ?
<Alert intent="warning">{ error }</Alert> :
<Input readOnly contentAfter={ actionButtons } value={ password } className={ cls.input } />
<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>
</> } />
}
<div className={ mergeClasses(cls.root, cls.optionsSpacing) }>
<InfoLabel info={ loc("generator@quickOptions__hint") } className={ cls.optionsLabel }>
{ loc("generator@quickOptions") }
</InfoLabel>
{ !props.collapse &&
<div className={ cls.options }>
<fui.InfoLabel info={ loc("generator@quickOptions__hint") }>
{ loc("generator@quickOptions") }
</fui.InfoLabel>
<div className={ cls.lengthContainer }>
<Slider
min={ 6 } max={ Math.max(32, generatorOptions.Length) }
value={ quickOpts.Length } onChange={ (_, e) => setOptions({ Length: e.value }) } />
<Text>{ quickOpts.Length }</Text>
<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>
<div>
<Checkbox
label={ loc("settings@special") }
checked={ quickOpts.Special }
onChange={ (_, e) => setOptions({ Special: e.checked as boolean }) } />
<Checkbox
label={ loc("settings@ambiguous") } disabled={ !quickOpts.Special }
checked={ !quickOpts.ExcludeAmbiguous }
onChange={ (_, e) => setOptions({ ExcludeAmbiguous: !e.checked }) } />
<Tooltip content={ loc("generator@reset") } relationship="label">
<Button appearance="subtle" icon={ <ArrowUndoRegular /> } onClick={ resetOptions } />
</Tooltip>
</div>
</div>
}
</section>
);
}
+11
View File
@@ -12,4 +12,15 @@ export const useStyles = makeStyles({
display: "flex",
flexWrap: "wrap",
},
rangeContainer:
{
display: "grid",
gridTemplateColumns: "1fr auto 1fr auto",
alignItems: "center",
...shorthands.gap(tokens.spacingHorizontalS),
},
rangeInput:
{
width: "100%",
},
});
+41 -6
View File
@@ -1,6 +1,5 @@
import * as fui from "@fluentui/react-components";
import { InfoLabel } from "@fluentui/react-components/unstable";
import { SettingsRegular } from "@fluentui/react-icons";
import { ArrowUndoRegular, SettingsRegular } from "@fluentui/react-icons";
import ExtensionOptions from "../Models/ExtensionOptions";
import GeneratorOptions from "../Models/GeneratorOptions";
import { GetLocaleString as loc } from "../Utils/Localization";
@@ -13,12 +12,12 @@ import { useStyles } from "./SettingsSection.styles";
export default function SettingsSection(): JSX.Element
{
const { generatorOptions, updateStorage } = useStorage();
const { extOptions, generatorOptions, updateStorage } = useStorage();
const cls = useStyles();
const infoLabel = (content: string, hint: string) => ({
children: (_: unknown, slotProps: fui.LabelProps) => (
<InfoLabel { ...slotProps } info={ hint }>{ content }</InfoLabel>
<fui.InfoLabel { ...slotProps } info={ hint }>{ content }</fui.InfoLabel>
)
});
@@ -26,6 +25,21 @@ export default function SettingsSection(): JSX.Element
(_: unknown, args: fui.CheckboxOnChangeData) =>
updateStorage({ [option]: args.checked } );
const updateNumberField = (key: keyof (ExtensionOptions & GeneratorOptions), defaultValue: number) =>
(_: unknown, e: fui.InputOnChangeData): void =>
{
if (e.value.length < 1)
{
updateStorage({ [key]: defaultValue });
return;
}
const value = parseInt(e.value);
if (!isNaN(value) && value >= 0)
updateStorage({ [key]: value });
};
return (
<fui.AccordionItem value="settings">
<fui.AccordionHeader as="h2" icon={ <SettingsRegular /> }>{ loc("settings@title") }</fui.AccordionHeader>
@@ -34,9 +48,30 @@ export default function SettingsSection(): JSX.Element
<fui.Field label={ loc("settings@length") } hint={ loc("settings@length__hint") }>
<fui.Input
type="number" min={ 6 }
value={ generatorOptions.Length.toString() }
onChange={ (_, e) => updateStorage({ Length: parseInt(e.value) }) } />
onChange={ updateNumberField("Length", 0) } />
</fui.Field>
<fui.Field label={ loc("settings@lengthRange") }>
<div className={ cls.rangeContainer }>
<fui.Input
input={ { className: cls.rangeInput } }
value={ extOptions.MinLength.toString() }
onChange={ updateNumberField("MinLength", 4) } />
<fui.Divider />
<fui.Input
input={ { className: cls.rangeInput } }
value={ extOptions.MaxLength.toString() }
onChange={ updateNumberField("MaxLength", 32) } />
<fui.Tooltip relationship="label" content={ loc("generator@reset") }>
<fui.Button
appearance="subtle" icon={ <ArrowUndoRegular /> }
onClick={ () => updateStorage({ MinLength: 6, MaxLength: 32 }) } />
</fui.Tooltip>
</div>
</fui.Field>
<fui.Divider />