@siiway/ui-react 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +20 -2
- package/dist/components/BrandMark.d.ts +11 -0
- package/dist/components/BrandMark.d.ts.map +1 -0
- package/dist/components/BrandMark.js +11 -0
- package/dist/components/BrandMark.js.map +1 -0
- package/dist/components/CheckboxField.d.ts +15 -0
- package/dist/components/CheckboxField.d.ts.map +1 -0
- package/dist/components/CheckboxField.js +23 -0
- package/dist/components/CheckboxField.js.map +1 -0
- package/dist/components/ColorPickerInput.d.ts +17 -0
- package/dist/components/ColorPickerInput.d.ts.map +1 -0
- package/dist/components/ColorPickerInput.js +97 -0
- package/dist/components/ColorPickerInput.js.map +1 -0
- package/dist/components/CommandPalette.d.ts +53 -0
- package/dist/components/CommandPalette.d.ts.map +1 -0
- package/dist/components/CommandPalette.js +239 -0
- package/dist/components/CommandPalette.js.map +1 -0
- package/dist/components/CopyButton.d.ts +8 -0
- package/dist/components/CopyButton.d.ts.map +1 -0
- package/dist/components/CopyButton.js +17 -0
- package/dist/components/CopyButton.js.map +1 -0
- package/dist/components/CopyIdTrigger.d.ts +31 -0
- package/dist/components/CopyIdTrigger.d.ts.map +1 -0
- package/dist/components/CopyIdTrigger.js +72 -0
- package/dist/components/CopyIdTrigger.js.map +1 -0
- package/dist/components/DataList.d.ts +78 -0
- package/dist/components/DataList.d.ts.map +1 -0
- package/dist/components/DataList.js +150 -0
- package/dist/components/DataList.js.map +1 -0
- package/dist/components/DetailHeader.d.ts +22 -0
- package/dist/components/DetailHeader.d.ts.map +1 -0
- package/dist/components/DetailHeader.js +48 -0
- package/dist/components/DetailHeader.js.map +1 -0
- package/dist/components/DurationInput.d.ts +25 -0
- package/dist/components/DurationInput.d.ts.map +1 -0
- package/dist/components/DurationInput.js +83 -0
- package/dist/components/DurationInput.js.map +1 -0
- package/dist/components/EmptyState.d.ts +14 -0
- package/dist/components/EmptyState.d.ts.map +1 -0
- package/dist/components/EmptyState.js +41 -0
- package/dist/components/EmptyState.js.map +1 -0
- package/dist/components/FormPage.d.ts +22 -0
- package/dist/components/FormPage.d.ts.map +1 -0
- package/dist/components/FormPage.js +65 -0
- package/dist/components/FormPage.js.map +1 -0
- package/dist/components/GetStartedPanel.d.ts +16 -0
- package/dist/components/GetStartedPanel.d.ts.map +1 -0
- package/dist/components/GetStartedPanel.js +96 -0
- package/dist/components/GetStartedPanel.js.map +1 -0
- package/dist/components/LabeledLine.d.ts +12 -0
- package/dist/components/LabeledLine.d.ts.map +1 -0
- package/dist/components/LabeledLine.js +6 -0
- package/dist/components/LabeledLine.js.map +1 -0
- package/dist/components/ListSearch.d.ts +15 -0
- package/dist/components/ListSearch.d.ts.map +1 -0
- package/dist/components/ListSearch.js +23 -0
- package/dist/components/ListSearch.js.map +1 -0
- package/dist/components/LoadingBar.d.ts +8 -0
- package/dist/components/LoadingBar.d.ts.map +1 -0
- package/dist/components/LoadingBar.js +55 -0
- package/dist/components/LoadingBar.js.map +1 -0
- package/dist/components/Outline.d.ts +23 -0
- package/dist/components/Outline.d.ts.map +1 -0
- package/dist/components/Outline.js +150 -0
- package/dist/components/Outline.js.map +1 -0
- package/dist/components/Overview.d.ts +103 -0
- package/dist/components/Overview.d.ts.map +1 -0
- package/dist/components/Overview.js +286 -0
- package/dist/components/Overview.js.map +1 -0
- package/dist/components/PageHeader.d.ts +19 -0
- package/dist/components/PageHeader.d.ts.map +1 -0
- package/dist/components/PageHeader.js +50 -0
- package/dist/components/PageHeader.js.map +1 -0
- package/dist/components/Pagination.d.ts +19 -0
- package/dist/components/Pagination.d.ts.map +1 -0
- package/dist/components/Pagination.js +47 -0
- package/dist/components/Pagination.js.map +1 -0
- package/dist/components/PasswordInput.d.ts +3 -0
- package/dist/components/PasswordInput.d.ts.map +1 -0
- package/dist/components/PasswordInput.js +16 -0
- package/dist/components/PasswordInput.js.map +1 -0
- package/dist/components/PrevNext.d.ts +16 -0
- package/dist/components/PrevNext.d.ts.map +1 -0
- package/dist/components/PrevNext.js +61 -0
- package/dist/components/PrevNext.js.map +1 -0
- package/dist/components/SearchButton.d.ts +16 -0
- package/dist/components/SearchButton.d.ts.map +1 -0
- package/dist/components/SearchButton.js +63 -0
- package/dist/components/SearchButton.js.map +1 -0
- package/dist/components/SearchField.d.ts +10 -0
- package/dist/components/SearchField.d.ts.map +1 -0
- package/dist/components/SearchField.js +67 -0
- package/dist/components/SearchField.js.map +1 -0
- package/dist/components/Segmented.d.ts +28 -0
- package/dist/components/Segmented.d.ts.map +1 -0
- package/dist/components/Segmented.js +74 -0
- package/dist/components/Segmented.js.map +1 -0
- package/dist/components/Select.d.ts +22 -0
- package/dist/components/Select.d.ts.map +1 -0
- package/dist/components/Select.js +50 -0
- package/dist/components/Select.js.map +1 -0
- package/dist/components/Settings.d.ts +103 -0
- package/dist/components/Settings.d.ts.map +1 -0
- package/dist/components/Settings.js +246 -0
- package/dist/components/Settings.js.map +1 -0
- package/dist/components/SideNav.d.ts +34 -0
- package/dist/components/SideNav.d.ts.map +1 -0
- package/dist/components/SideNav.js +99 -0
- package/dist/components/SideNav.js.map +1 -0
- package/dist/components/Skeletons.d.ts +37 -0
- package/dist/components/Skeletons.d.ts.map +1 -0
- package/dist/components/Skeletons.js +109 -0
- package/dist/components/Skeletons.js.map +1 -0
- package/dist/components/StatusPage.d.ts +37 -0
- package/dist/components/StatusPage.d.ts.map +1 -0
- package/dist/components/StatusPage.js +106 -0
- package/dist/components/StatusPage.js.map +1 -0
- package/dist/components/ThemeMenu.d.ts +11 -0
- package/dist/components/ThemeMenu.d.ts.map +1 -0
- package/dist/components/ThemeMenu.js +42 -0
- package/dist/components/ThemeMenu.js.map +1 -0
- package/dist/components/ThemeSwitch.d.ts +14 -0
- package/dist/components/ThemeSwitch.d.ts.map +1 -0
- package/dist/components/ThemeSwitch.js +17 -0
- package/dist/components/ThemeSwitch.js.map +1 -0
- package/dist/components/TopBar.d.ts +45 -0
- package/dist/components/TopBar.d.ts.map +1 -0
- package/dist/components/TopBar.js +145 -0
- package/dist/components/TopBar.js.map +1 -0
- package/dist/components/ViewBanner.d.ts +17 -0
- package/dist/components/ViewBanner.d.ts.map +1 -0
- package/dist/components/ViewBanner.js +14 -0
- package/dist/components/ViewBanner.js.map +1 -0
- package/dist/hooks/platform.d.ts +7 -0
- package/dist/hooks/platform.d.ts.map +1 -0
- package/dist/hooks/platform.js +19 -0
- package/dist/hooks/platform.js.map +1 -0
- package/dist/hooks/useConfirm.d.ts +23 -0
- package/dist/hooks/useConfirm.d.ts.map +1 -0
- package/dist/hooks/useConfirm.js +55 -0
- package/dist/hooks/useConfirm.js.map +1 -0
- package/dist/hooks/useCopy.d.ts +9 -0
- package/dist/hooks/useCopy.d.ts.map +1 -0
- package/dist/hooks/useCopy.js +14 -0
- package/dist/hooks/useCopy.js.map +1 -0
- package/dist/hooks/useDebouncedSearch.d.ts +8 -0
- package/dist/hooks/useDebouncedSearch.d.ts.map +1 -0
- package/dist/hooks/useDebouncedSearch.js +19 -0
- package/dist/hooks/useDebouncedSearch.js.map +1 -0
- package/dist/hooks/usePageClamp.d.ts +4 -0
- package/dist/hooks/usePageClamp.d.ts.map +1 -0
- package/dist/hooks/usePageClamp.js +17 -0
- package/dist/hooks/usePageClamp.js.map +1 -0
- package/dist/hooks/useSearchShortcut.d.ts +8 -0
- package/dist/hooks/useSearchShortcut.d.ts.map +1 -0
- package/dist/hooks/useSearchShortcut.js +38 -0
- package/dist/hooks/useSearchShortcut.js.map +1 -0
- package/dist/hooks/useThemeMode.d.ts +17 -0
- package/dist/hooks/useThemeMode.d.ts.map +1 -0
- package/dist/hooks/useThemeMode.js +62 -0
- package/dist/hooks/useThemeMode.js.map +1 -0
- package/dist/hooks/useToastMessage.d.ts +22 -0
- package/dist/hooks/useToastMessage.d.ts.map +1 -0
- package/dist/hooks/useToastMessage.js +26 -0
- package/dist/hooks/useToastMessage.js.map +1 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/dist/provider/UiProvider.d.ts +37 -0
- package/dist/provider/UiProvider.d.ts.map +1 -0
- package/dist/provider/UiProvider.js +42 -0
- package/dist/provider/UiProvider.js.map +1 -0
- package/dist/provider/canvas.d.ts +2 -0
- package/dist/provider/canvas.d.ts.map +1 -0
- package/dist/provider/canvas.js +15 -0
- package/dist/provider/canvas.js.map +1 -0
- package/dist/provider/context.d.ts +45 -0
- package/dist/provider/context.d.ts.map +1 -0
- package/dist/provider/context.js +39 -0
- package/dist/provider/context.js.map +1 -0
- package/dist/theme/createTheme.d.ts +13 -0
- package/dist/theme/createTheme.d.ts.map +1 -0
- package/dist/theme/createTheme.js +18 -0
- package/dist/theme/createTheme.js.map +1 -0
- package/package.json +49 -4
- package/src/components/BrandMark.tsx +28 -0
- package/src/components/CheckboxField.tsx +50 -0
- package/src/components/ColorPickerInput.tsx +190 -0
- package/src/components/CommandPalette.tsx +437 -0
- package/src/components/CopyButton.tsx +48 -0
- package/src/components/CopyIdTrigger.tsx +127 -0
- package/src/components/DataList.tsx +332 -0
- package/src/components/DetailHeader.tsx +102 -0
- package/src/components/DurationInput.tsx +133 -0
- package/src/components/EmptyState.tsx +67 -0
- package/src/components/FormPage.tsx +109 -0
- package/src/components/GetStartedPanel.tsx +132 -0
- package/src/components/LabeledLine.tsx +28 -0
- package/src/components/ListSearch.tsx +64 -0
- package/src/components/LoadingBar.tsx +81 -0
- package/src/components/Outline.tsx +208 -0
- package/src/components/Overview.tsx +448 -0
- package/src/components/PageHeader.tsx +80 -0
- package/src/components/Pagination.tsx +105 -0
- package/src/components/PasswordInput.tsx +35 -0
- package/src/components/PrevNext.tsx +98 -0
- package/src/components/SearchButton.tsx +90 -0
- package/src/components/SearchField.tsx +97 -0
- package/src/components/Segmented.tsx +136 -0
- package/src/components/Select.tsx +110 -0
- package/src/components/Settings.tsx +432 -0
- package/src/components/SideNav.tsx +188 -0
- package/src/components/Skeletons.tsx +233 -0
- package/src/components/StatusPage.tsx +188 -0
- package/src/components/ThemeMenu.tsx +83 -0
- package/src/components/ThemeSwitch.tsx +39 -0
- package/src/components/TopBar.tsx +280 -0
- package/src/components/ViewBanner.tsx +51 -0
- package/src/hooks/platform.ts +22 -0
- package/src/hooks/useConfirm.tsx +97 -0
- package/src/hooks/useCopy.ts +20 -0
- package/src/hooks/useDebouncedSearch.ts +19 -0
- package/src/hooks/usePageClamp.ts +20 -0
- package/src/hooks/useSearchShortcut.ts +49 -0
- package/src/hooks/useThemeMode.ts +98 -0
- package/src/hooks/useToastMessage.ts +38 -0
- package/src/index.ts +140 -0
- package/src/provider/UiProvider.tsx +95 -0
- package/src/provider/canvas.ts +17 -0
- package/src/provider/context.tsx +85 -0
- package/src/theme/createTheme.ts +29 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, } from "react";
|
|
3
|
+
import { UI_STRINGS } from "@siiway/ui-core";
|
|
4
|
+
function AnchorLink({ to, state: _state, ...rest }) {
|
|
5
|
+
return _jsx("a", { href: to, ...rest });
|
|
6
|
+
}
|
|
7
|
+
function useLocationNavigate() {
|
|
8
|
+
return (to) => window.location.assign(to);
|
|
9
|
+
}
|
|
10
|
+
/** Plain `<a href>` links and full page loads: for apps without a client router. */
|
|
11
|
+
export const DEFAULT_ROUTER = { Link: AnchorLink, useNavigate: useLocationNavigate };
|
|
12
|
+
export const UiContext = createContext({
|
|
13
|
+
scheme: "light",
|
|
14
|
+
strings: UI_STRINGS.en,
|
|
15
|
+
router: DEFAULT_ROUTER,
|
|
16
|
+
onPageTitle: null,
|
|
17
|
+
});
|
|
18
|
+
/** The library's own strings, in the locale given to `<UiProvider>`. */
|
|
19
|
+
export function useUiStrings() {
|
|
20
|
+
return useContext(UiContext).strings;
|
|
21
|
+
}
|
|
22
|
+
/** The scheme `<UiProvider>` renders in. */
|
|
23
|
+
export function useUiScheme() {
|
|
24
|
+
return useContext(UiContext).scheme;
|
|
25
|
+
}
|
|
26
|
+
/** A link through the app's router (React Router's `Link`, or `<a href>`). */
|
|
27
|
+
export function UiLink(props) {
|
|
28
|
+
const { Link } = useContext(UiContext).router;
|
|
29
|
+
return _jsx(Link, { ...props });
|
|
30
|
+
}
|
|
31
|
+
/** A function that navigates to an in-app path. */
|
|
32
|
+
export function useUiNavigate() {
|
|
33
|
+
return useContext(UiContext).router.useNavigate();
|
|
34
|
+
}
|
|
35
|
+
/** The app's page-title handler, if it gave `<UiProvider onPageTitle>`. */
|
|
36
|
+
export function useUiPageTitle() {
|
|
37
|
+
return useContext(UiContext).onPageTitle;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/provider/context.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EACb,UAAU,GAIX,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAA+B,MAAM,iBAAiB,CAAC;AAyB1E,SAAS,UAAU,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAe;IAC7D,OAAO,YAAG,IAAI,EAAE,EAAE,KAAM,IAAI,GAAI,CAAC;AACnC,CAAC;AAED,SAAS,mBAAmB;IAC1B,OAAO,CAAC,EAAU,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACpD,CAAC;AAED,oFAAoF;AACpF,MAAM,CAAC,MAAM,cAAc,GAAa,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC;AAY/F,MAAM,CAAC,MAAM,SAAS,GAAG,aAAa,CAAiB;IACrD,MAAM,EAAE,OAAO;IACf,OAAO,EAAE,UAAU,CAAC,EAAE;IACtB,MAAM,EAAE,cAAc;IACtB,WAAW,EAAE,IAAI;CAClB,CAAC,CAAC;AAEH,wEAAwE;AACxE,MAAM,UAAU,YAAY;IAC1B,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC;AACvC,CAAC;AAED,4CAA4C;AAC5C,MAAM,UAAU,WAAW;IACzB,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC;AACtC,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,MAAM,CAAC,KAAkB;IACvC,MAAM,EAAE,IAAI,EAAE,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC;IAC9C,OAAO,KAAC,IAAI,OAAK,KAAK,GAAI,CAAC;AAC7B,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,aAAa;IAC3B,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;AACpD,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,cAAc;IAC5B,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Theme } from "@fluentui/react-components";
|
|
2
|
+
import { type Scheme } from "@siiway/ui-core";
|
|
3
|
+
export interface CreateThemeOptions {
|
|
4
|
+
scheme: Scheme;
|
|
5
|
+
/** Brand colour, `#rgb` to `#rrggbbaa`. Missing or invalid gives Fluent's blue. */
|
|
6
|
+
accent?: string | null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The SiiWay Fluent theme: Fluent's own theme for the accent's brand ramp,
|
|
10
|
+
* with the neutral greys, radii and shadows replaced.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createTheme({ scheme, accent }: CreateThemeOptions): Theme;
|
|
13
|
+
//# sourceMappingURL=createTheme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTheme.d.ts","sourceRoot":"","sources":["../../src/theme/createTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,KAAK,EACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAA6B,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzE,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,mFAAmF;IACnF,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,kBAAkB,GAAG,KAAK,CASzE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createDarkTheme, createLightTheme, webDarkTheme, webLightTheme, } from "@fluentui/react-components";
|
|
2
|
+
import { brandRamp, themeOverrides } from "@siiway/ui-core";
|
|
3
|
+
/**
|
|
4
|
+
* The SiiWay Fluent theme: Fluent's own theme for the accent's brand ramp,
|
|
5
|
+
* with the neutral greys, radii and shadows replaced.
|
|
6
|
+
*/
|
|
7
|
+
export function createTheme({ scheme, accent }) {
|
|
8
|
+
const brand = brandRamp(accent);
|
|
9
|
+
let base;
|
|
10
|
+
try {
|
|
11
|
+
base = scheme === "dark" ? createDarkTheme(brand) : createLightTheme(brand);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
base = scheme === "dark" ? webDarkTheme : webLightTheme;
|
|
15
|
+
}
|
|
16
|
+
return { ...base, ...themeOverrides(scheme) };
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=createTheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTheme.js","sourceRoot":"","sources":["../../src/theme/createTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,aAAa,GAEd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,cAAc,EAAe,MAAM,iBAAiB,CAAC;AAQzE;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,MAAM,EAAE,MAAM,EAAsB;IAChE,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IAChC,IAAI,IAAW,CAAC;IAChB,IAAI,CAAC;QACH,IAAI,GAAG,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC9E,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,GAAG,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC;IAC1D,CAAC;IACD,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;AAChD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@siiway/ui-react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "SiiWay's Fluent UI v9 theme, provider and components for React.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://ui.siiway.org",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/siiway/ui.git",
|
|
12
|
+
"directory": "packages/react"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./package.json": "./package.json"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"!dist/.tsbuildinfo",
|
|
24
|
+
"src",
|
|
25
|
+
"LICENSE",
|
|
26
|
+
"README.md"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc -b"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@siiway/ui-core": "0.1.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@fluentui/react-components": "^9.73.0",
|
|
36
|
+
"@fluentui/react-icons": "^2.0.300",
|
|
37
|
+
"react": "^18.3.0 || ^19.0.0",
|
|
38
|
+
"react-dom": "^18.3.0 || ^19.0.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@fluentui/react-components": "^9.75.0",
|
|
42
|
+
"@fluentui/react-icons": "^2.0.345",
|
|
43
|
+
"@types/react": "^19.3.0",
|
|
44
|
+
"@types/react-dom": "^19.3.0",
|
|
45
|
+
"react": "^19.3.1",
|
|
46
|
+
"react-dom": "^19.3.1"
|
|
47
|
+
},
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Site logo: the configured site icon, or nothing. With no icon set, the
|
|
2
|
+
// site name beside it carries the brand on its own — a placeholder mark
|
|
3
|
+
// would only invent a logo the operator never chose.
|
|
4
|
+
|
|
5
|
+
import { Image } from "@fluentui/react-components";
|
|
6
|
+
|
|
7
|
+
interface BrandMarkProps {
|
|
8
|
+
/** The image's alt text. Leave it out when the name is written beside the mark. */
|
|
9
|
+
name?: string | null;
|
|
10
|
+
/** The icon's URL. Without one, the mark renders nothing. */
|
|
11
|
+
iconUrl?: string | null;
|
|
12
|
+
/** Width and height, in pixels. */
|
|
13
|
+
size?: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function BrandMark({ name, iconUrl, size = 28 }: BrandMarkProps) {
|
|
17
|
+
if (!iconUrl) return null;
|
|
18
|
+
return (
|
|
19
|
+
<Image
|
|
20
|
+
src={iconUrl}
|
|
21
|
+
alt={name ?? ""}
|
|
22
|
+
fit="cover"
|
|
23
|
+
width={size}
|
|
24
|
+
height={size}
|
|
25
|
+
style={{ borderRadius: Math.round(size * 0.28), flexShrink: 0 }}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// A checkbox for a form that applies on submit, with an optional line of
|
|
2
|
+
// explanation under its label. Switches are for things that take effect
|
|
3
|
+
// the moment they flip; inside a form that waits for Save, this is the
|
|
4
|
+
// control to use.
|
|
5
|
+
|
|
6
|
+
import { Checkbox, makeStyles, tokens } from "@fluentui/react-components";
|
|
7
|
+
|
|
8
|
+
const useStyles = makeStyles({
|
|
9
|
+
// Fluent pads the box; pull it back to the form's text edge.
|
|
10
|
+
root: { marginLeft: "-8px", alignSelf: "flex-start", maxWidth: "100%" },
|
|
11
|
+
label: { display: "flex", flexDirection: "column", gap: "2px" },
|
|
12
|
+
hint: {
|
|
13
|
+
fontSize: tokens.fontSizeBase200,
|
|
14
|
+
lineHeight: tokens.lineHeightBase200,
|
|
15
|
+
color: tokens.colorNeutralForeground3,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
interface CheckboxFieldProps {
|
|
20
|
+
/** The checkbox's label. */
|
|
21
|
+
label: string;
|
|
22
|
+
/** A line of explanation under the label, in smaller, dimmer text. */
|
|
23
|
+
hint?: string;
|
|
24
|
+
/** Whether the box is checked. */
|
|
25
|
+
checked: boolean;
|
|
26
|
+
/** Disables the checkbox. */
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
/** Called with the new checked state. */
|
|
29
|
+
onChange: (checked: boolean) => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function CheckboxField({ label, hint, checked, disabled, onChange }: CheckboxFieldProps) {
|
|
33
|
+
const styles = useStyles();
|
|
34
|
+
return (
|
|
35
|
+
<Checkbox
|
|
36
|
+
className={styles.root}
|
|
37
|
+
checked={checked}
|
|
38
|
+
disabled={disabled}
|
|
39
|
+
onChange={(_, d) => onChange(!!d.checked)}
|
|
40
|
+
label={{
|
|
41
|
+
children: (
|
|
42
|
+
<span className={styles.label}>
|
|
43
|
+
<span>{label}</span>
|
|
44
|
+
{hint && <span className={styles.hint}>{hint}</span>}
|
|
45
|
+
</span>
|
|
46
|
+
),
|
|
47
|
+
}}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
// A hex colour field: a swatch that opens the picker in a popover, beside a
|
|
2
|
+
// short text input for typing or pasting a hex value.
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
ColorArea,
|
|
7
|
+
ColorPicker,
|
|
8
|
+
ColorSlider,
|
|
9
|
+
Input,
|
|
10
|
+
Popover,
|
|
11
|
+
PopoverSurface,
|
|
12
|
+
PopoverTrigger,
|
|
13
|
+
makeStyles,
|
|
14
|
+
mergeClasses,
|
|
15
|
+
tokens,
|
|
16
|
+
type ColorPickerProps,
|
|
17
|
+
} from "@fluentui/react-components";
|
|
18
|
+
import { useState } from "react";
|
|
19
|
+
import { useUiStrings } from "../provider/context.js";
|
|
20
|
+
import { hexToHsv, hsvToHex, normalizeHexColor } from "@siiway/ui-core";
|
|
21
|
+
|
|
22
|
+
const DEFAULT_COLOR = "#0078d4";
|
|
23
|
+
|
|
24
|
+
const useStyles = makeStyles({
|
|
25
|
+
root: {
|
|
26
|
+
display: "flex",
|
|
27
|
+
flexDirection: "column",
|
|
28
|
+
gap: "4px",
|
|
29
|
+
},
|
|
30
|
+
editor: {
|
|
31
|
+
display: "flex",
|
|
32
|
+
alignItems: "center",
|
|
33
|
+
gap: "8px",
|
|
34
|
+
},
|
|
35
|
+
input: { width: "180px" },
|
|
36
|
+
swatch: {
|
|
37
|
+
width: "20px",
|
|
38
|
+
height: "20px",
|
|
39
|
+
padding: 0,
|
|
40
|
+
flexShrink: 0,
|
|
41
|
+
cursor: "pointer",
|
|
42
|
+
borderRadius: tokens.borderRadiusSmall,
|
|
43
|
+
border: `1px solid ${tokens.colorNeutralStroke1}`,
|
|
44
|
+
":focus-visible": {
|
|
45
|
+
outline: `2px solid ${tokens.colorStrokeFocus2}`,
|
|
46
|
+
outlineOffset: "1px",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
// Empty value in a nullable field: a diagonal line through the swatch.
|
|
50
|
+
swatchEmpty: {
|
|
51
|
+
backgroundImage: `linear-gradient(to top right, transparent calc(50% - 1px), ${tokens.colorNeutralStroke1} 50%, transparent calc(50% + 1px))`,
|
|
52
|
+
},
|
|
53
|
+
picker: {
|
|
54
|
+
display: "flex",
|
|
55
|
+
flexDirection: "column",
|
|
56
|
+
gap: "12px",
|
|
57
|
+
width: "240px",
|
|
58
|
+
},
|
|
59
|
+
area: {
|
|
60
|
+
width: "100%",
|
|
61
|
+
minWidth: 0,
|
|
62
|
+
height: "160px",
|
|
63
|
+
},
|
|
64
|
+
error: {
|
|
65
|
+
fontSize: tokens.fontSizeBase200,
|
|
66
|
+
color: tokens.colorPaletteRedForeground1,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
interface ColorPickerInputProps {
|
|
71
|
+
/** The colour as hex, e.g. `#0078d4`, or `null` when empty. */
|
|
72
|
+
value: string | null;
|
|
73
|
+
/** Called with the colour as lowercase `#rrggbb`: as it's picked, or when
|
|
74
|
+
* typed text is read (on blur or Enter). Gets `null` when a `nullable`
|
|
75
|
+
* field is emptied. Text that isn't a hex colour shows an error instead. */
|
|
76
|
+
onChange: (value: string | null) => void;
|
|
77
|
+
/** The field may be left empty, giving `null`. Adds a Clear button while
|
|
78
|
+
* it holds a colour. */
|
|
79
|
+
nullable?: boolean;
|
|
80
|
+
/** The colour the picker starts from while the field is empty. Default
|
|
81
|
+
* `#0078d4`. */
|
|
82
|
+
fallbackColor?: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function ColorPickerInput({
|
|
86
|
+
value,
|
|
87
|
+
onChange,
|
|
88
|
+
nullable = false,
|
|
89
|
+
fallbackColor = DEFAULT_COLOR,
|
|
90
|
+
}: ColorPickerInputProps) {
|
|
91
|
+
const styles = useStyles();
|
|
92
|
+
const strings = useUiStrings();
|
|
93
|
+
const [draft, setDraft] = useState(value ?? "");
|
|
94
|
+
const [lastValue, setLastValue] = useState(value);
|
|
95
|
+
// The popover lines up with the whole field, not just the swatch.
|
|
96
|
+
const [anchor, setAnchor] = useState<HTMLSpanElement | null>(null);
|
|
97
|
+
if (value !== lastValue) {
|
|
98
|
+
setLastValue(value);
|
|
99
|
+
setDraft(value ?? "");
|
|
100
|
+
}
|
|
101
|
+
const normalized = normalizeHexColor(draft);
|
|
102
|
+
const pickerHex = normalized ?? normalizeHexColor(fallbackColor) ?? DEFAULT_COLOR;
|
|
103
|
+
const pickerColor = hexToHsv(pickerHex) ?? { h: 0, s: 0, v: 0 };
|
|
104
|
+
const invalid = draft !== "" && normalized === null;
|
|
105
|
+
const empty = nullable && normalized === null;
|
|
106
|
+
|
|
107
|
+
const handlePickerChange: ColorPickerProps["onColorChange"] = (_, data) => {
|
|
108
|
+
const hex = hsvToHex(data.color);
|
|
109
|
+
setDraft(hex);
|
|
110
|
+
onChange(hex);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const commitDraft = () => {
|
|
114
|
+
if (draft.trim() === "" && nullable) {
|
|
115
|
+
setDraft("");
|
|
116
|
+
onChange(null);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const next = normalizeHexColor(draft);
|
|
120
|
+
if (next) {
|
|
121
|
+
setDraft(next);
|
|
122
|
+
onChange(next);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<div className={styles.root}>
|
|
128
|
+
<div className={styles.editor}>
|
|
129
|
+
<Input
|
|
130
|
+
className={styles.input}
|
|
131
|
+
root={{ ref: setAnchor }}
|
|
132
|
+
value={draft}
|
|
133
|
+
aria-label={strings.hexColor}
|
|
134
|
+
aria-invalid={invalid}
|
|
135
|
+
placeholder={nullable ? strings.optionalHexColor : DEFAULT_COLOR}
|
|
136
|
+
contentBefore={
|
|
137
|
+
<Popover trapFocus positioning={{ target: anchor, position: "below", align: "end" }}>
|
|
138
|
+
<PopoverTrigger disableButtonEnhancement>
|
|
139
|
+
<button
|
|
140
|
+
type="button"
|
|
141
|
+
className={mergeClasses(styles.swatch, empty && styles.swatchEmpty)}
|
|
142
|
+
style={{
|
|
143
|
+
backgroundColor: empty ? "transparent" : (normalized ?? pickerHex),
|
|
144
|
+
}}
|
|
145
|
+
aria-label={strings.pickColor}
|
|
146
|
+
/>
|
|
147
|
+
</PopoverTrigger>
|
|
148
|
+
<PopoverSurface>
|
|
149
|
+
<ColorPicker
|
|
150
|
+
className={styles.picker}
|
|
151
|
+
color={pickerColor}
|
|
152
|
+
onColorChange={handlePickerChange}
|
|
153
|
+
>
|
|
154
|
+
<ColorArea
|
|
155
|
+
className={styles.area}
|
|
156
|
+
aria-label={strings.colorArea}
|
|
157
|
+
inputX={{ "aria-label": strings.saturation }}
|
|
158
|
+
inputY={{ "aria-label": strings.brightness }}
|
|
159
|
+
/>
|
|
160
|
+
<ColorSlider aria-label={strings.hue} input={{ "aria-label": strings.hue }} />
|
|
161
|
+
</ColorPicker>
|
|
162
|
+
</PopoverSurface>
|
|
163
|
+
</Popover>
|
|
164
|
+
}
|
|
165
|
+
onChange={(event) => setDraft(event.target.value)}
|
|
166
|
+
onBlur={commitDraft}
|
|
167
|
+
onKeyDown={(event) => {
|
|
168
|
+
if (event.key === "Enter") commitDraft();
|
|
169
|
+
}}
|
|
170
|
+
/>
|
|
171
|
+
{nullable && normalized !== null && (
|
|
172
|
+
<Button
|
|
173
|
+
appearance="subtle"
|
|
174
|
+
onClick={() => {
|
|
175
|
+
setDraft("");
|
|
176
|
+
onChange(null);
|
|
177
|
+
}}
|
|
178
|
+
>
|
|
179
|
+
{strings.clear}
|
|
180
|
+
</Button>
|
|
181
|
+
)}
|
|
182
|
+
</div>
|
|
183
|
+
{invalid && (
|
|
184
|
+
<span role="alert" className={styles.error}>
|
|
185
|
+
{strings.invalidHexColor}
|
|
186
|
+
</span>
|
|
187
|
+
)}
|
|
188
|
+
</div>
|
|
189
|
+
);
|
|
190
|
+
}
|