@lobehub/ui 1.120.16 → 1.122.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.
Files changed (75) hide show
  1. package/es/ActionIcon/index.js +4 -1
  2. package/es/ActionIcon/style.js +1 -1
  3. package/es/ActionIconGroup/index.js +4 -3
  4. package/es/ActionIconGroup/style.d.ts +0 -1
  5. package/es/ActionIconGroup/style.js +2 -3
  6. package/es/ColorScales/ScaleRow.js +5 -1
  7. package/es/ColorScales/index.js +14 -5
  8. package/es/ColorScales/style.d.ts +0 -1
  9. package/es/ColorScales/style.js +4 -5
  10. package/es/ContextMenu/index.d.ts +4 -17
  11. package/es/ContextMenu/index.js +6 -249
  12. package/es/DraggablePanel/components/DraggablePanelBody.js +4 -2
  13. package/es/DraggablePanel/components/DraggablePanelContainer.js +2 -1
  14. package/es/DraggablePanel/components/DraggablePanelFooter.js +8 -2
  15. package/es/DraggablePanel/components/DraggablePanelHeader.js +8 -2
  16. package/es/DraggablePanel/components/style.js +4 -4
  17. package/es/FluentEmoji/style.d.ts +0 -1
  18. package/es/FluentEmoji/style.js +3 -5
  19. package/es/Form/components/FormFooter.js +6 -6
  20. package/es/Form/components/FormGroup.js +3 -1
  21. package/es/Form/components/FormTitle.js +2 -1
  22. package/es/Form/components/style.d.ts +0 -1
  23. package/es/Form/components/style.js +9 -10
  24. package/es/Form/style.d.ts +0 -1
  25. package/es/Form/style.js +2 -3
  26. package/es/GaussianBackground/index.d.ts +17 -0
  27. package/es/GaussianBackground/index.js +48 -0
  28. package/es/GaussianBackground/style.d.ts +5 -0
  29. package/es/GaussianBackground/style.js +11 -0
  30. package/es/GaussianBackground/useGaussianBackground.d.ts +7 -0
  31. package/es/GaussianBackground/useGaussianBackground.js +19 -0
  32. package/es/GaussianBackground/vendor/gaussianBackground.d.ts +38 -0
  33. package/es/GaussianBackground/vendor/gaussianBackground.js +222 -0
  34. package/es/GaussianBackground/vendor/stackBlur.d.ts +1 -0
  35. package/es/GaussianBackground/vendor/stackBlur.js +184 -0
  36. package/es/GaussianBackground/vendor/stackBlurTable.d.ts +2 -0
  37. package/es/GaussianBackground/vendor/stackBlurTable.js +2 -0
  38. package/es/Header/index.js +4 -1
  39. package/es/Header/style.js +1 -1
  40. package/es/Hero/index.js +4 -1
  41. package/es/Hero/style.js +1 -1
  42. package/es/Highlighter/SyntaxHighlighter/index.js +4 -2
  43. package/es/Highlighter/SyntaxHighlighter/style.js +1 -1
  44. package/es/List/ListItem/time.d.ts +0 -1
  45. package/es/List/ListItem/time.js +0 -4
  46. package/es/MessageModal/index.js +1 -1
  47. package/es/SideNav/index.js +5 -2
  48. package/es/SideNav/style.js +1 -1
  49. package/es/SliderWithInput/index.d.ts +2 -0
  50. package/es/SliderWithInput/index.js +3 -2
  51. package/es/Snippet/index.js +6 -2
  52. package/es/Snippet/style.js +1 -1
  53. package/es/SpotlightCard/SpotlightCardItem.js +1 -1
  54. package/es/SpotlightCard/style.js +1 -1
  55. package/es/StoryBook/index.js +10 -3
  56. package/es/StoryBook/style.js +2 -2
  57. package/es/Tag/index.js +1 -1
  58. package/es/ThemeProvider/GlobalStyle/antdOverride.js +1 -1
  59. package/es/TokenTag/index.js +6 -1
  60. package/es/TokenTag/style.js +1 -1
  61. package/es/index.d.ts +1 -0
  62. package/es/index.js +1 -0
  63. package/package.json +1 -2
  64. package/es/ContextMenu/MenuItem/icons.d.ts +0 -4
  65. package/es/ContextMenu/MenuItem/icons.js +0 -73
  66. package/es/ContextMenu/MenuItem/index.d.ts +0 -12
  67. package/es/ContextMenu/MenuItem/index.js +0 -73
  68. package/es/ContextMenu/MenuItem/style.d.ts +0 -7
  69. package/es/ContextMenu/MenuItem/style.js +0 -16
  70. package/es/ContextMenu/style.d.ts +0 -4
  71. package/es/ContextMenu/style.js +0 -12
  72. package/es/ContextMenu/types/index.d.ts +0 -5
  73. package/es/ContextMenu/types/index.js +0 -2
  74. package/es/ContextMenu/types/menuItem.d.ts +0 -21
  75. package/es/ContextMenu/types/menuItem.js +0 -1
@@ -1,5 +1,5 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13;
2
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12;
3
3
  import { createStyles } from 'antd-style';
4
4
  import { isNumber } from 'lodash-es';
5
5
  export var useStyles = createStyles(function (_ref, itemMinWidth) {
@@ -10,14 +10,13 @@ export var useStyles = createStyles(function (_ref, itemMinWidth) {
10
10
  responsive = _ref.responsive,
11
11
  prefixCls = _ref.prefixCls;
12
12
  return {
13
- footer: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n gap: 8px;\n justify-content: flex-end;\n "]))),
14
- formTitle: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n\n display: flex;\n flex-direction: column;\n gap: 6px;\n\n text-align: left;\n\n > div {\n font-weight: 500;\n line-height: 1;\n }\n\n > small {\n display: block;\n\n line-height: 1;\n color: ", ";\n word-wrap: break-word;\n white-space: pre-wrap;\n }\n\n .", "-tag {\n font-family: ", ";\n }\n "])), token.colorTextDescription, prefixCls, token.fontFamilyCode),
15
- group: cx(isDarkMode && css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n .", "-collapse-content {\n background: transparent;\n }\n\n .", "-collapse-header {\n background: ", ";\n }\n "])), prefixCls, prefixCls, token.colorFillTertiary), css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n .", "-collapse-header {\n align-items: center !important;\n border-radius: 0 !important;\n }\n\n .", "-collapse-content-box {\n padding-top: 0 !important;\n padding-bottom: 0 !important;\n }\n\n .", "-form-item-label {\n display: flex;\n flex-direction: column;\n justify-content: center;\n }\n "])), prefixCls, prefixCls, prefixCls)),
16
- icon: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n transition: all 100ms ", ";\n "])), token.motionEaseOut),
17
- item: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n padding: 16px 0;\n\n .", "-row {\n justify-content: space-between;\n\n > div {\n flex: unset !important;\n flex-grow: unset !important;\n }\n }\n\n .", "-form-item-required::before {\n align-self: flex-start;\n }\n\n ", "\n\n ", " {\n padding: 16px 0;\n\n ", "\n }\n "])), prefixCls, prefixCls, itemMinWidth && css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n .", "-form-item-control {\n width: ", ";\n }\n "])), prefixCls, isNumber(itemMinWidth) ? "".concat(itemMinWidth, "px") : itemMinWidth), responsive.mobile, itemMinWidth ? css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n .", "-row {\n flex-direction: column;\n gap: 4px;\n }\n\n .", "-form-item-control {\n flex: 1;\n width: 100%;\n }\n "])), prefixCls, prefixCls) : css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n .", "-row {\n flex-wrap: wrap;\n gap: 4px;\n }\n "])), prefixCls)),
18
- itemNoDivider: css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n &:not(:first-child) {\n padding-top: 0;\n }\n "]))),
19
- mobileGroupBody: css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n padding: 0 16px;\n background: ", ";\n "])), token.colorBgContainer),
20
- mobileGroupHeader: css(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n padding: 16px;\n background: ", ";\n "])), token.colorBgLayout),
21
- title: css(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n display: flex;\n gap: 8px;\n align-items: center;\n\n font-size: 16px;\n font-weight: 600;\n\n .anticon {\n color: ", ";\n }\n\n ", " {\n font-size: 14px;\n font-weight: 400;\n opacity: 0.5;\n }\n "])), token.colorPrimary, responsive.mobile)
13
+ formTitle: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n text-align: left;\n\n > div {\n font-weight: 500;\n line-height: 1;\n }\n\n > small {\n display: block;\n\n line-height: 1;\n color: ", ";\n word-wrap: break-word;\n white-space: pre-wrap;\n }\n\n .", "-tag {\n font-family: ", ";\n }\n "])), token.colorTextDescription, prefixCls, token.fontFamilyCode),
14
+ group: cx(isDarkMode && css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .", "-collapse-content {\n background: transparent;\n }\n\n .", "-collapse-header {\n background: ", ";\n }\n "])), prefixCls, prefixCls, token.colorFillTertiary), css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n .", "-collapse-header {\n align-items: center !important;\n border-radius: 0 !important;\n }\n\n .", "-collapse-content-box {\n padding-top: 0 !important;\n padding-bottom: 0 !important;\n }\n\n .", "-form-item-label {\n display: flex;\n flex-direction: column;\n justify-content: center;\n }\n "])), prefixCls, prefixCls, prefixCls)),
15
+ icon: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n transition: all 100ms ", ";\n "])), token.motionEaseOut),
16
+ item: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n padding: 16px 0;\n\n .", "-row {\n justify-content: space-between;\n\n > div {\n flex: unset !important;\n flex-grow: unset !important;\n }\n }\n\n .", "-form-item-required::before {\n align-self: flex-start;\n }\n\n ", "\n\n ", " {\n padding: 16px 0;\n\n ", "\n }\n "])), prefixCls, prefixCls, itemMinWidth && css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n .", "-form-item-control {\n width: ", ";\n }\n "])), prefixCls, isNumber(itemMinWidth) ? "".concat(itemMinWidth, "px") : itemMinWidth), responsive.mobile, itemMinWidth ? css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n .", "-row {\n flex-direction: column;\n gap: 4px;\n }\n\n .", "-form-item-control {\n flex: 1;\n width: 100%;\n }\n "])), prefixCls, prefixCls) : css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n .", "-row {\n flex-wrap: wrap;\n gap: 4px;\n }\n "])), prefixCls)),
17
+ itemNoDivider: css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n &:not(:first-child) {\n padding-top: 0;\n }\n "]))),
18
+ mobileGroupBody: css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n padding: 0 16px;\n background: ", ";\n "])), token.colorBgContainer),
19
+ mobileGroupHeader: css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n padding: 16px;\n background: ", ";\n "])), token.colorBgLayout),
20
+ title: css(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n align-items: center;\n font-size: 16px;\n font-weight: 600;\n\n .anticon {\n color: ", ";\n }\n\n ", " {\n font-size: 14px;\n font-weight: 400;\n opacity: 0.5;\n }\n "])), token.colorPrimary, responsive.mobile)
22
21
  };
23
22
  });
@@ -1,4 +1,3 @@
1
1
  export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
2
- footer: import("antd-style").SerializedStyles;
3
2
  form: import("antd-style").SerializedStyles;
4
3
  }>;
package/es/Form/style.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
- var _templateObject, _templateObject2;
2
+ var _templateObject;
3
3
  import { createStyles } from 'antd-style';
4
4
  export var useStyles = createStyles(function (_ref) {
5
5
  var css = _ref.css,
@@ -7,7 +7,6 @@ export var useStyles = createStyles(function (_ref) {
7
7
  prefixCls = _ref.prefixCls,
8
8
  responsive = _ref.responsive;
9
9
  return {
10
- footer: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n gap: 8px;\n justify-content: flex-end;\n "]))),
11
- form: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n gap: 16px;\n\n ", " {\n gap: 0;\n }\n\n .", "-form-item {\n margin: 0 !important;\n }\n\n .", "-form-item .", "-form-item-label > label {\n height: unset;\n }\n\n .", "-row {\n position: relative;\n flex-wrap: nowrap;\n }\n\n .", "-form-item-label {\n position: relative;\n flex: 1;\n max-width: 100%;\n }\n\n .", "-form-item-control {\n position: relative;\n flex: 0;\n min-width: unset !important;\n }\n\n .", "-collapse-item {\n overflow: hidden !important;\n border-radius: ", "px !important;\n }\n "])), responsive.mobile, prefixCls, prefixCls, prefixCls, prefixCls, prefixCls, prefixCls, prefixCls, token.borderRadius)
10
+ form: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n gap: 16px;\n\n ", " {\n gap: 0;\n }\n\n .", "-form-item {\n margin: 0 !important;\n }\n\n .", "-form-item .", "-form-item-label > label {\n height: unset;\n }\n\n .", "-row {\n position: relative;\n flex-wrap: nowrap;\n }\n\n .", "-form-item-label {\n position: relative;\n flex: 1;\n max-width: 100%;\n }\n\n .", "-form-item-control {\n position: relative;\n flex: 0;\n min-width: unset !important;\n }\n\n .", "-collapse-item {\n overflow: hidden !important;\n border-radius: ", "px !important;\n }\n "])), responsive.mobile, prefixCls, prefixCls, prefixCls, prefixCls, prefixCls, prefixCls, prefixCls, token.borderRadius)
12
11
  };
13
12
  });
@@ -0,0 +1,17 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { DivProps } from "../types";
3
+ import { ColorLayer } from './vendor/gaussianBackground';
4
+ export interface GaussianBackgroundProps extends PropsWithChildren, DivProps {
5
+ classNames?: {
6
+ canvas?: string;
7
+ content?: string;
8
+ };
9
+ layers: ColorLayer[];
10
+ options?: {
11
+ blurRadius?: number;
12
+ fpsCap?: number;
13
+ scale?: number;
14
+ };
15
+ }
16
+ declare const GaussianBackground: import("react").NamedExoticComponent<GaussianBackgroundProps>;
17
+ export default GaussianBackground;
@@ -0,0 +1,48 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["layers", "options", "className", "children", "classNames", "style"];
4
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
+ import { memo, useEffect, useRef } from 'react';
7
+ import { Flexbox } from 'react-layout-kit';
8
+ import { useGaussianBackground } from "./useGaussianBackground";
9
+ import { useStyles } from "./style";
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ var DEFAULT_OPTIONS = {
13
+ blurRadius: 16,
14
+ fpsCap: 60,
15
+ scale: 16
16
+ };
17
+ var GaussianBackground = /*#__PURE__*/memo(function (_ref) {
18
+ var layers = _ref.layers,
19
+ _ref$options = _ref.options,
20
+ options = _ref$options === void 0 ? DEFAULT_OPTIONS : _ref$options,
21
+ className = _ref.className,
22
+ children = _ref.children,
23
+ classNames = _ref.classNames,
24
+ style = _ref.style,
25
+ rest = _objectWithoutProperties(_ref, _excluded);
26
+ var ref = useRef(null);
27
+ var _useStyles = useStyles(),
28
+ cx = _useStyles.cx,
29
+ styles = _useStyles.styles;
30
+ var run = useGaussianBackground(ref);
31
+ useEffect(function () {
32
+ if (!run) return;
33
+ run(layers, options);
34
+ }, [run, options, layers]);
35
+ return /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({
36
+ className: cx(styles.container, className),
37
+ style: style
38
+ }, rest), {}, {
39
+ children: [/*#__PURE__*/_jsx("canvas", {
40
+ className: cx(styles.canvas, classNames === null || classNames === void 0 ? void 0 : classNames.canvas),
41
+ ref: ref
42
+ }), /*#__PURE__*/_jsx(Flexbox, {
43
+ className: cx(styles.content, classNames === null || classNames === void 0 ? void 0 : classNames.content),
44
+ children: children
45
+ })]
46
+ }));
47
+ });
48
+ export default GaussianBackground;
@@ -0,0 +1,5 @@
1
+ export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
2
+ canvas: import("antd-style").SerializedStyles;
3
+ container: import("antd-style").SerializedStyles;
4
+ content: import("antd-style").SerializedStyles;
5
+ }>;
@@ -0,0 +1,11 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2, _templateObject3;
3
+ import { createStyles } from 'antd-style';
4
+ export var useStyles = createStyles(function (_ref) {
5
+ var css = _ref.css;
6
+ return {
7
+ canvas: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n "]))),
8
+ container: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n width: 100%;\n height: 100%;\n "]))),
9
+ content: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: relative;\n z-index: 1;\n width: 100%;\n height: 100%;\n "])))
10
+ };
11
+ });
@@ -0,0 +1,7 @@
1
+ import { RefObject } from 'react';
2
+ import { ColorLayer } from './vendor/gaussianBackground';
3
+ export declare const useGaussianBackground: (ref: RefObject<HTMLCanvasElement>) => (layers: ColorLayer[], options?: {
4
+ blurRadius?: number;
5
+ fpsCap?: number;
6
+ scale?: number;
7
+ }) => void;
@@ -0,0 +1,19 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import { useCallback, useEffect, useState } from 'react';
3
+ import GaussianBackgroundClient from "./vendor/gaussianBackground";
4
+ export var useGaussianBackground = function useGaussianBackground(ref) {
5
+ var _useState = useState(),
6
+ _useState2 = _slicedToArray(_useState, 2),
7
+ client = _useState2[0],
8
+ setClient = _useState2[1];
9
+ useEffect(function () {
10
+ if (!ref.current) return;
11
+ setClient(new GaussianBackgroundClient(ref.current));
12
+ }, []);
13
+ var handleRun = useCallback(function (layers, options) {
14
+ if (!client) return;
15
+ if (options) client.updateOptions(options);
16
+ client.run(layers);
17
+ }, [client]);
18
+ return handleRun;
19
+ };
@@ -0,0 +1,38 @@
1
+ export interface ColorLayer {
2
+ color: string;
3
+ maxVelocity?: number;
4
+ orbs?: number;
5
+ radius?: number;
6
+ splitX?: number;
7
+ splitY?: number;
8
+ }
9
+ export interface GaussianBackgroundOptions {
10
+ blurRadius?: number;
11
+ fpsCap?: number;
12
+ scale?: number;
13
+ }
14
+ declare class GaussianBackground {
15
+ private fpsAverage?;
16
+ private canvas;
17
+ private context;
18
+ private animationFrame;
19
+ private timestep;
20
+ private firstCallTime;
21
+ private lastCallTime;
22
+ private timeElapsed;
23
+ private fpsTotal;
24
+ private layers;
25
+ private options;
26
+ constructor(node: HTMLCanvasElement, options?: GaussianBackgroundOptions);
27
+ run(layers: ColorLayer[]): void;
28
+ private generateLayer;
29
+ private createOrb;
30
+ private displayLoop;
31
+ drawBackground(): void;
32
+ private drawBlur;
33
+ private updateLayers;
34
+ updateOptions({ blurRadius, fpsCap, scale, }: Partial<GaussianBackgroundOptions>): void;
35
+ prototype(): void;
36
+ play(): void;
37
+ }
38
+ export default GaussianBackground;
@@ -0,0 +1,222 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
+ import { stackBlurCanvasRGB } from "./stackBlur";
7
+ var GaussianBackground = /*#__PURE__*/function () {
8
+ function GaussianBackground(node, options) {
9
+ _classCallCheck(this, GaussianBackground);
10
+ _defineProperty(this, "fpsAverage", void 0);
11
+ _defineProperty(this, "canvas", void 0);
12
+ _defineProperty(this, "context", void 0);
13
+ _defineProperty(this, "animationFrame", null);
14
+ _defineProperty(this, "timestep", 0);
15
+ _defineProperty(this, "firstCallTime", 0);
16
+ _defineProperty(this, "lastCallTime", 0);
17
+ _defineProperty(this, "timeElapsed", 0);
18
+ _defineProperty(this, "fpsTotal", 0);
19
+ _defineProperty(this, "layers", []);
20
+ _defineProperty(this, "options", {
21
+ blurRadius: 16,
22
+ fpsCap: 30,
23
+ height: 32,
24
+ scale: 20,
25
+ width: 64
26
+ });
27
+ this.canvas = node;
28
+ this.context = this.canvas.getContext('2d');
29
+ if (!this.context) {
30
+ throw new Error('ERROR: Could not load canvas');
31
+ }
32
+ if (options) {
33
+ this.updateOptions(options);
34
+ }
35
+ }
36
+ _createClass(GaussianBackground, [{
37
+ key: "run",
38
+ value: function run(layers) {
39
+ this.updateLayers(layers);
40
+ this.firstCallTime = Date.now();
41
+ this.lastCallTime = this.firstCallTime;
42
+ if (this.animationFrame) window.cancelAnimationFrame(this.animationFrame);
43
+ this.animationFrame = window.requestAnimationFrame(this.displayLoop.bind(this));
44
+ this.play();
45
+ }
46
+ }, {
47
+ key: "generateLayer",
48
+ value: function generateLayer(_ref, index) {
49
+ var _ref$orbs = _ref.orbs,
50
+ orbs = _ref$orbs === void 0 ? 0 : _ref$orbs,
51
+ _ref$radius = _ref.radius,
52
+ radius = _ref$radius === void 0 ? 0 : _ref$radius,
53
+ _ref$maxVelocity = _ref.maxVelocity,
54
+ maxVelocity = _ref$maxVelocity === void 0 ? 0 : _ref$maxVelocity,
55
+ color = _ref.color,
56
+ splitX = _ref.splitX,
57
+ splitY = _ref.splitY;
58
+ var canvas = document.createElement('canvas');
59
+ var context = canvas.getContext('2d');
60
+ if (!context) {
61
+ throw new Error("Failed to get 2D context for layer ".concat(index));
62
+ }
63
+ var layerOrbs = [];
64
+ for (var i = 0; i < orbs; i++) {
65
+ var orb = this.createOrb(radius, maxVelocity, splitX, splitY);
66
+ layerOrbs.push(orb);
67
+ }
68
+ return {
69
+ color: color,
70
+ context: context,
71
+ orbs: layerOrbs
72
+ };
73
+ }
74
+ }, {
75
+ key: "createOrb",
76
+ value: function createOrb(radius, maxVelocity, splitX, splitY) {
77
+ var optionsWidth = this.options.width;
78
+ var optionsHeight = this.options.height;
79
+ var posX = splitX ? Math.random() * (optionsWidth / splitX) : Math.random() * optionsWidth;
80
+ var posY = splitY ? Math.random() * (optionsHeight / splitY) : Math.random() * optionsHeight;
81
+ return {
82
+ maxX: optionsWidth,
83
+ maxY: optionsHeight,
84
+ minX: 0,
85
+ minY: 0,
86
+ posX: posX,
87
+ posY: posY,
88
+ radius: radius,
89
+ velX: (Math.random() - 0.5) * 2 * maxVelocity,
90
+ velY: (Math.random() - 0.5) * 2 * maxVelocity
91
+ };
92
+ }
93
+ }, {
94
+ key: "displayLoop",
95
+ value: function displayLoop() {
96
+ // Keep going if the user wants animation
97
+ this.animationFrame = window.requestAnimationFrame(this.displayLoop.bind(this));
98
+ var currentTime = Date.now();
99
+ var delta = currentTime - this.lastCallTime;
100
+
101
+ // Ignore timesteping code if there is no animation
102
+ if (delta > this.timestep) {
103
+ this.lastCallTime = currentTime - delta % this.timestep;
104
+ this.timeElapsed = this.lastCallTime - this.firstCallTime;
105
+ this.fpsTotal++;
106
+ this.fpsAverage = this.fpsTotal / (this.timeElapsed / 1000);
107
+ this.drawBackground();
108
+ this.drawBlur();
109
+ }
110
+ }
111
+ }, {
112
+ key: "drawBackground",
113
+ value: function drawBackground() {
114
+ for (var i = Object.keys(this.layers).length - 1; i >= 0; i--) {
115
+ var layerContext = this.layers[i].context;
116
+ var layerOrbs = this.layers[i].orbs;
117
+
118
+ // Draw background
119
+ layerContext.fillStyle = this.layers[i].color;
120
+ layerContext.fillRect(0, 0, this.options.width, this.options.height);
121
+
122
+ // Draw animated layer elements
123
+ for (var x = Object.keys(layerOrbs).length - 1; x >= 0; x--) {
124
+ // Animate the movement
125
+ layerOrbs[x].posX += layerOrbs[x].velX;
126
+ layerOrbs[x].posY += layerOrbs[x].velY;
127
+
128
+ // Check if the orb has custom boundaries
129
+ var minX = void 0;
130
+ var maxX = void 0;
131
+ var minY = void 0;
132
+ var maxY = void 0;
133
+ if (layerOrbs[x].maxX && layerOrbs[x].maxY) {
134
+ minX = layerOrbs[x].minX;
135
+ maxX = layerOrbs[x].maxX;
136
+ minY = layerOrbs[x].minY;
137
+ maxY = layerOrbs[x].maxY;
138
+ } else {
139
+ minX = 0;
140
+ maxX = this.options.width;
141
+ minY = 0;
142
+ maxY = this.options.height;
143
+ }
144
+
145
+ // Collision detection and correction
146
+ if (layerOrbs[x].posX >= maxX) {
147
+ layerOrbs[x].posX = maxX;
148
+ layerOrbs[x].velX = -layerOrbs[x].velX;
149
+ } else if (layerOrbs[x].posX <= minX) {
150
+ layerOrbs[x].posX = minX;
151
+ layerOrbs[x].velX = -layerOrbs[x].velX;
152
+ }
153
+ if (layerOrbs[x].posY >= maxY) {
154
+ layerOrbs[x].posY = maxY;
155
+ layerOrbs[x].velY = -layerOrbs[x].velY;
156
+ } else if (layerOrbs[x].posY <= minY) {
157
+ layerOrbs[x].posY = minY;
158
+ layerOrbs[x].velY = -layerOrbs[x].velY;
159
+ }
160
+ layerContext.save();
161
+ layerContext.globalCompositeOperation = 'destination-out';
162
+ layerContext.beginPath();
163
+ layerContext.arc(layerOrbs[x].posX, layerOrbs[x].posY, layerOrbs[x].radius, 0, 2 * Math.PI, false);
164
+ layerContext.fill();
165
+ layerContext.restore();
166
+ }
167
+
168
+ // Draw the virtual canvas layer onto the main canvas
169
+ this.context.drawImage(layerContext.canvas, 0, 0);
170
+ }
171
+ }
172
+ }, {
173
+ key: "drawBlur",
174
+ value: function drawBlur() {
175
+ stackBlurCanvasRGB(this.canvas, 0, 0, this.options.width, this.options.height, this.options.blurRadius);
176
+ }
177
+ }, {
178
+ key: "updateLayers",
179
+ value: function updateLayers(layers) {
180
+ var _this = this;
181
+ this.layers = layers.map(function (layer, index) {
182
+ return _this.generateLayer(layer, index);
183
+ });
184
+ }
185
+ }, {
186
+ key: "updateOptions",
187
+ value: function updateOptions(_ref2) {
188
+ var _ref2$blurRadius = _ref2.blurRadius,
189
+ blurRadius = _ref2$blurRadius === void 0 ? 16 : _ref2$blurRadius,
190
+ _ref2$fpsCap = _ref2.fpsCap,
191
+ fpsCap = _ref2$fpsCap === void 0 ? 30 : _ref2$fpsCap,
192
+ _ref2$scale = _ref2.scale,
193
+ scale = _ref2$scale === void 0 ? 20 : _ref2$scale;
194
+ this.options = _objectSpread(_objectSpread({}, this.options), {}, {
195
+ blurRadius: blurRadius,
196
+ fpsCap: fpsCap,
197
+ scale: scale
198
+ });
199
+ this.options.height = Math.round(this.canvas.clientHeight / this.options.scale);
200
+ this.options.width = Math.round(this.canvas.clientWidth / this.options.scale);
201
+ this.timestep = 1000 / this.options.fpsCap;
202
+ this.context.canvas.width = this.options.width;
203
+ this.context.canvas.height = this.options.height;
204
+ }
205
+ }, {
206
+ key: "prototype",
207
+ value: function prototype() {
208
+ window.cancelAnimationFrame(this.animationFrame);
209
+ }
210
+ }, {
211
+ key: "play",
212
+ value: function play() {
213
+ var _this2 = this;
214
+ window.cancelAnimationFrame(this.animationFrame);
215
+ this.animationFrame = window.requestAnimationFrame(function () {
216
+ return _this2.displayLoop();
217
+ });
218
+ }
219
+ }]);
220
+ return GaussianBackground;
221
+ }();
222
+ export default GaussianBackground;
@@ -0,0 +1 @@
1
+ export declare const stackBlurCanvasRGB: (canvasIDOrElement: string | HTMLCanvasElement, topX: number, topY: number, width: number, height: number, radius: number) => void;
@@ -0,0 +1,184 @@
1
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
2
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
+ import { mulTable, shgTable } from "./stackBlurTable";
5
+ var BlurStack = /*#__PURE__*/_createClass(function BlurStack() {
6
+ _classCallCheck(this, BlurStack);
7
+ _defineProperty(this, "r", 0);
8
+ _defineProperty(this, "g", 0);
9
+ _defineProperty(this, "b", 0);
10
+ _defineProperty(this, "a", 0);
11
+ _defineProperty(this, "next", void 0);
12
+ });
13
+ var stackBlurGetElement = function stackBlurGetElement(elementOrID) {
14
+ if (typeof elementOrID === 'string') {
15
+ // eslint-disable-next-line unicorn/prefer-query-selector
16
+ return document.getElementById(elementOrID);
17
+ } else if (elementOrID.nodeType === 1) {
18
+ return elementOrID;
19
+ }
20
+ };
21
+ export var stackBlurCanvasRGB = function stackBlurCanvasRGB(canvasIDOrElement, topX, topY, width, height, radius) {
22
+ if (Number.isNaN(radius) || radius < 1) return;
23
+ // eslint-disable-next-line no-param-reassign
24
+ radius = Math.trunc(radius);
25
+ var canvas = stackBlurGetElement(canvasIDOrElement);
26
+ if (!canvas && !(canvas !== null && canvas !== void 0 && canvas.getContext)) return;
27
+ var context = canvas.getContext('2d');
28
+ var imageData = context === null || context === void 0 ? void 0 : context.getImageData(topX, topY, width, height);
29
+ var pixels = imageData.data;
30
+ var x;
31
+ var y;
32
+ var i;
33
+ var p;
34
+ var yp;
35
+ var yi;
36
+ var yw;
37
+ var rSum;
38
+ var gSum;
39
+ var bSum;
40
+ var rOutSum;
41
+ var gOutSum;
42
+ var bOutSum;
43
+ var rInSum;
44
+ var gInSum;
45
+ var bInSum;
46
+ var pr;
47
+ var pg;
48
+ var pb;
49
+ var rbs;
50
+ var stackEnd;
51
+ var div = radius + radius + 1;
52
+ var widthMinus1 = width - 1;
53
+ var heightMinus1 = height - 1;
54
+ var radiusPlus1 = radius + 1;
55
+ var sumFactor = radiusPlus1 * (radiusPlus1 + 1) / 2;
56
+ var stackStart = new BlurStack();
57
+ var stack = stackStart;
58
+ for (i = 1; i < div; i++) {
59
+ stack = stack.next = new BlurStack();
60
+ if (i === radiusPlus1) stackEnd = stack;
61
+ }
62
+ stack.next = stackStart;
63
+ var stackIn;
64
+ var stackOut;
65
+ yw = yi = 0;
66
+ var mulSum = mulTable[radius];
67
+ var shgSum = shgTable[radius];
68
+ for (y = 0; y < height; y++) {
69
+ rInSum = gInSum = bInSum = rSum = gSum = bSum = 0;
70
+ rOutSum = radiusPlus1 * (pr = pixels[yi]);
71
+ gOutSum = radiusPlus1 * (pg = pixels[yi + 1]);
72
+ bOutSum = radiusPlus1 * (pb = pixels[yi + 2]);
73
+ rSum += sumFactor * pr;
74
+ gSum += sumFactor * pg;
75
+ bSum += sumFactor * pb;
76
+ stack = stackStart;
77
+ for (i = 0; i < radiusPlus1; i++) {
78
+ stack.r = pr;
79
+ stack.g = pg;
80
+ stack.b = pb;
81
+ stack = stack.next;
82
+ }
83
+ for (i = 1; i < radiusPlus1; i++) {
84
+ p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);
85
+ rSum += (stack.r = pr = pixels[p]) * (rbs = radiusPlus1 - i);
86
+ gSum += (stack.g = pg = pixels[p + 1]) * rbs;
87
+ bSum += (stack.b = pb = pixels[p + 2]) * rbs;
88
+ rInSum += pr;
89
+ gInSum += pg;
90
+ bInSum += pb;
91
+ stack = stack.next;
92
+ }
93
+ stackIn = stackStart;
94
+ stackOut = stackEnd;
95
+ for (x = 0; x < width; x++) {
96
+ pixels[yi] = rSum * mulSum >> shgSum;
97
+ pixels[yi + 1] = gSum * mulSum >> shgSum;
98
+ pixels[yi + 2] = bSum * mulSum >> shgSum;
99
+ rSum -= rOutSum;
100
+ gSum -= gOutSum;
101
+ bSum -= bOutSum;
102
+ rOutSum -= stackIn.r;
103
+ gOutSum -= stackIn.g;
104
+ bOutSum -= stackIn.b;
105
+ p = yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1) << 2;
106
+ rInSum += stackIn.r = pixels[p];
107
+ gInSum += stackIn.g = pixels[p + 1];
108
+ bInSum += stackIn.b = pixels[p + 2];
109
+ rSum += rInSum;
110
+ gSum += gInSum;
111
+ bSum += bInSum;
112
+ stackIn = stackIn.next;
113
+ rOutSum += pr = stackOut.r;
114
+ gOutSum += pg = stackOut.g;
115
+ bOutSum += pb = stackOut.b;
116
+ rInSum -= pr;
117
+ gInSum -= pg;
118
+ bInSum -= pb;
119
+ stackOut = stackOut.next;
120
+ yi += 4;
121
+ }
122
+ yw += width;
123
+ }
124
+ for (x = 0; x < width; x++) {
125
+ gInSum = bInSum = rInSum = gSum = bSum = rSum = 0;
126
+ yi = x << 2;
127
+ rOutSum = radiusPlus1 * (pr = pixels[yi]);
128
+ gOutSum = radiusPlus1 * (pg = pixels[yi + 1]);
129
+ bOutSum = radiusPlus1 * (pb = pixels[yi + 2]);
130
+ rSum += sumFactor * pr;
131
+ gSum += sumFactor * pg;
132
+ bSum += sumFactor * pb;
133
+ stack = stackStart;
134
+ for (i = 0; i < radiusPlus1; i++) {
135
+ stack.r = pr;
136
+ stack.g = pg;
137
+ stack.b = pb;
138
+ stack = stack.next;
139
+ }
140
+ yp = width;
141
+ for (i = 1; i <= radius; i++) {
142
+ yi = yp + x << 2;
143
+ rSum += (stack.r = pr = pixels[yi]) * (rbs = radiusPlus1 - i);
144
+ gSum += (stack.g = pg = pixels[yi + 1]) * rbs;
145
+ bSum += (stack.b = pb = pixels[yi + 2]) * rbs;
146
+ rInSum += pr;
147
+ gInSum += pg;
148
+ bInSum += pb;
149
+ stack = stack.next;
150
+ if (i < heightMinus1) {
151
+ yp += width;
152
+ }
153
+ }
154
+ yi = x;
155
+ stackIn = stackStart;
156
+ stackOut = stackEnd;
157
+ for (y = 0; y < height; y++) {
158
+ p = yi << 2;
159
+ pixels[p] = rSum * mulSum >> shgSum;
160
+ pixels[p + 1] = gSum * mulSum >> shgSum;
161
+ pixels[p + 2] = bSum * mulSum >> shgSum;
162
+ rSum -= rOutSum;
163
+ gSum -= gOutSum;
164
+ bSum -= bOutSum;
165
+ rOutSum -= stackIn.r;
166
+ gOutSum -= stackIn.g;
167
+ bOutSum -= stackIn.b;
168
+ p = x + ((p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width << 2;
169
+ rSum += rInSum += stackIn.r = pixels[p];
170
+ gSum += gInSum += stackIn.g = pixels[p + 1];
171
+ bSum += bInSum += stackIn.b = pixels[p + 2];
172
+ stackIn = stackIn.next;
173
+ rOutSum += pr = stackOut.r;
174
+ gOutSum += pg = stackOut.g;
175
+ bOutSum += pb = stackOut.b;
176
+ rInSum -= pr;
177
+ gInSum -= pg;
178
+ bInSum -= pb;
179
+ stackOut = stackOut.next;
180
+ yi += width;
181
+ }
182
+ }
183
+ context === null || context === void 0 || context.putImageData(imageData, topX, topY);
184
+ };
@@ -0,0 +1,2 @@
1
+ export declare const mulTable: number[];
2
+ export declare const shgTable: number[];
@@ -0,0 +1,2 @@
1
+ export var mulTable = [512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292, 512, 454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312, 292, 273, 512, 482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259, 496, 475, 456, 437, 420, 404, 388, 374, 360, 347, 335, 323, 312, 302, 292, 282, 273, 265, 512, 497, 482, 468, 454, 441, 428, 417, 405, 394, 383, 373, 364, 354, 345, 337, 328, 320, 312, 305, 298, 291, 284, 278, 271, 265, 259, 507, 496, 485, 475, 465, 456, 446, 437, 428, 420, 412, 404, 396, 388, 381, 374, 367, 360, 354, 347, 341, 335, 329, 323, 318, 312, 307, 302, 297, 292, 287, 282, 278, 273, 269, 265, 261, 512, 505, 497, 489, 482, 475, 468, 461, 454, 447, 441, 435, 428, 422, 417, 411, 405, 399, 394, 389, 383, 378, 373, 368, 364, 359, 354, 350, 345, 341, 337, 332, 328, 324, 320, 316, 312, 309, 305, 301, 298, 294, 291, 287, 284, 281, 278, 274, 271, 268, 265, 262, 259, 257, 507, 501, 496, 491, 485, 480, 475, 470, 465, 460, 456, 451, 446, 442, 437, 433, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 388, 385, 381, 377, 374, 370, 367, 363, 360, 357, 354, 350, 347, 344, 341, 338, 335, 332, 329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292, 289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259];
2
+ export var shgTable = [9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24];
@@ -74,8 +74,11 @@ var Header = /*#__PURE__*/memo(function (_ref) {
74
74
  overflow: 'hidden'
75
75
  }, navStyle),
76
76
  children: nav
77
- }), /*#__PURE__*/_jsxs("section", {
77
+ }), /*#__PURE__*/_jsxs(Flexbox, {
78
78
  className: cx(styles.right, actionsClassName),
79
+ flex: 1,
80
+ horizontal: true,
81
+ justify: 'space-between',
79
82
  style: actionsStyle,
80
83
  children: [/*#__PURE__*/_jsx("div", {}), /*#__PURE__*/_jsx(Flexbox, {
81
84
  align: 'center',