react-ui89 0.14.0 → 0.16.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.
@@ -0,0 +1,12 @@
1
+ import React, { ReactNode } from "react";
2
+ type RouterPush = (url: string) => void | Promise<void>;
3
+ interface Ui89OverrideContextType {
4
+ routerPush?: RouterPush;
5
+ }
6
+ export interface Ui89OverrideProviderProps {
7
+ children?: ReactNode;
8
+ routerPush?: RouterPush;
9
+ }
10
+ export declare const Ui89OverrideProvider: React.FC<Ui89OverrideProviderProps>;
11
+ export declare const useUi89Overrides: () => Ui89OverrideContextType;
12
+ export {};
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ export interface TimeAnimationPropsChildrenProps {
3
+ now: Date;
4
+ }
5
+ export interface TimeAnimationProps {
6
+ children: (props: TimeAnimationPropsChildrenProps) => React.ReactNode;
7
+ }
8
+ export declare const TimeAnimation: React.FC<TimeAnimationProps>;
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { TimeAnimation } from "./TimeAnimation";
3
+ declare const meta: Meta<typeof TimeAnimation>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Updates: Story;
@@ -1,5 +1,6 @@
1
1
  import type { Meta, StoryObj } from "@storybook/react";
2
2
  import { Ui89Breadcrumbs } from "./Ui89Breadcrumbs";
3
+ import { Ui89OverrideProviderProps } from "../Ui89Override";
3
4
  declare const meta: Meta<typeof Ui89Breadcrumbs>;
4
5
  export default meta;
5
6
  type Story = StoryObj<typeof meta>;
@@ -7,3 +8,4 @@ export declare const Empty: Story;
7
8
  export declare const OneCrumb: Story;
8
9
  export declare const TwoCrumbs: Story;
9
10
  export declare const FiveCrumbs: Story;
11
+ export declare const OverrideRouterPush: StoryObj<Ui89OverrideProviderProps>;
@@ -10,7 +10,6 @@ interface Ui89ButtonProps {
10
10
  autoDisableOnClick?: boolean;
11
11
  disabled?: boolean;
12
12
  activated?: boolean;
13
- routerPush?: (url: string) => void;
14
13
  }
15
- export declare function Ui89Button({ theme, size, block, onClick, href, children, autoDisableOnClick, disabled, activated, routerPush, }: Ui89ButtonProps): React.JSX.Element;
14
+ export declare function Ui89Button({ theme, size, block, onClick, href, children, autoDisableOnClick, disabled, activated, }: Ui89ButtonProps): React.JSX.Element;
16
15
  export {};
@@ -1,5 +1,6 @@
1
1
  import type { Meta, StoryObj } from "@storybook/react";
2
2
  import { Ui89Button } from "./Ui89Button";
3
+ import { Ui89OverrideProviderProps } from "../Ui89Override";
3
4
  declare const meta: Meta<typeof Ui89Button>;
4
5
  export default meta;
5
6
  type Story = StoryObj<typeof meta>;
@@ -9,3 +10,4 @@ export declare const ThemeSuccess: Story;
9
10
  export declare const ThemeDanger: Story;
10
11
  export declare const ThemeInfo: Story;
11
12
  export declare const ThemeWarning: Story;
13
+ export declare const OverrideRouterPush: StoryObj<Ui89OverrideProviderProps>;
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare function Ui89DigitalTimeClock(): React.JSX.Element;
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { Ui89DigitalTimeClock } from "./Ui89DigitalTimeClock";
3
+ declare const meta: Meta<typeof Ui89DigitalTimeClock>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Time: Story;
@@ -0,0 +1,9 @@
1
+ export interface DateComponents {
2
+ hours: number;
3
+ minutes: number;
4
+ seconds: number;
5
+ milliseconds: number;
6
+ day: number;
7
+ month: number;
8
+ year: number;
9
+ }
@@ -4,12 +4,15 @@ export type { Ui89BreadcrumbsProps, Ui89BreadcrumbsPropsItem, Ui89BreadcrumbsPro
4
4
  export { Ui89Breadcrumbs } from "./components/Ui89Breadcrumbs";
5
5
  export { Ui89Button } from "./components/Ui89Button";
6
6
  export { Ui89Card } from "./components/Ui89Card";
7
+ export { Ui89DigitalTimeClock } from "./components/Ui89DigitalTimeClock";
7
8
  export { Ui89HighlightText } from "./components/Ui89HighlightText";
8
9
  export { Ui89InputText } from "./components/Ui89InputText";
9
10
  export { Ui89InputTextNumber } from "./components/Ui89InputTextNumber";
10
11
  export type { Ui89MenuBarItem, Ui89MenuBarProps, } from "./components/Ui89MenuBar";
11
12
  export { Ui89MenuBar } from "./components/Ui89MenuBar";
12
13
  export { Ui89ModalDialog } from "./components/Ui89ModalDialog";
14
+ export type { Ui89OverrideProviderProps } from "./Ui89Override";
15
+ export { Ui89OverrideProvider } from "./Ui89Override";
13
16
  export { Ui89Scene } from "./components/Ui89Scene";
14
17
  export { Ui89Shortcut } from "./components/Ui89Shortcut";
15
18
  export { Ui89SpaceVertical } from "./components/Ui89SpaceVertical";
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default, { useState, useRef, useMemo, useEffect, forwardRef } from 'react';
2
+ import React__default, { createContext, useContext, useState, useEffect, useRef, useMemo, forwardRef } from 'react';
3
3
  import Timeout from 'smart-timeout';
4
4
  import { VariableSizeGrid } from 'react-window';
5
5
  import AutoSizer from 'react-virtualized-auto-sizer';
@@ -27,9 +27,32 @@ var resetStyles = {"a":"reset-module_a__dpZ8C"};
27
27
 
28
28
  var chosenThemeStyles = {"primary":"chosen-theme-module_primary__GwEqU","secondary":"chosen-theme-module_secondary__DI5Gk","info":"chosen-theme-module_info__KYP2h","success":"chosen-theme-module_success__l3hFS","warning":"chosen-theme-module_warning__A7IOL","danger":"chosen-theme-module_danger__CZ3Iq"};
29
29
 
30
+ const Ui89OverrideContext = createContext({});
31
+ const Ui89OverrideProvider = ({ routerPush, children, }) => {
32
+ return (React__default.createElement(Ui89OverrideContext.Provider, { value: { routerPush } }, children));
33
+ };
34
+ const useUi89Overrides = () => {
35
+ const context = useContext(Ui89OverrideContext);
36
+ if (context === undefined) {
37
+ throw new Error("useUi89Overrides must be used within a Ui89OverrideProvider");
38
+ }
39
+ return context;
40
+ };
41
+
30
42
  function Ui89BreadcrumbsItem({ index, item, onSelect, }) {
31
43
  item.url !== undefined ? "a" : "div";
32
- return (React__default.createElement("a", { className: `${resetStyles.a} ${styles$f.breadcrumbsItem}`, href: item.url, style: { "--ui89-index": index } },
44
+ const overrides = useUi89Overrides();
45
+ const onClick = (e) => {
46
+ if (item.url !== undefined) {
47
+ if (item.url.startsWith("/")) {
48
+ if (overrides.routerPush !== undefined) {
49
+ e.preventDefault();
50
+ overrides.routerPush(item.url);
51
+ }
52
+ }
53
+ }
54
+ };
55
+ return (React__default.createElement("a", { className: `${resetStyles.a} ${styles$f.breadcrumbsItem}`, href: item.url, style: { "--ui89-index": index }, onClick: onClick },
33
56
  React__default.createElement("div", { className: styles$f.breadcrumbsItemBackground }),
34
57
  item.label));
35
58
  }
@@ -48,8 +71,8 @@ function HoverShadow({ children, }) {
48
71
  children));
49
72
  }
50
73
 
51
- function Ui89Button({ theme = Ui89Theme.primary, size = "normal", block, onClick, href, children, autoDisableOnClick = true, disabled, activated, routerPush, }) {
52
- //const router = useRouter()
74
+ function Ui89Button({ theme = Ui89Theme.primary, size = "normal", block, onClick, href, children, autoDisableOnClick = true, disabled, activated, }) {
75
+ const overrides = useUi89Overrides();
53
76
  const [clicking, setClicking] = useState(false);
54
77
  let localDisabled = disabled || (autoDisableOnClick && clicking);
55
78
  async function onAnchorClick(e) {
@@ -65,9 +88,9 @@ function Ui89Button({ theme = Ui89Theme.primary, size = "normal", block, onClick
65
88
  setClicking(true);
66
89
  if (href !== undefined) {
67
90
  if (href.startsWith("/")) {
68
- if (routerPush !== undefined) {
91
+ if (overrides.routerPush !== undefined) {
69
92
  e.preventDefault();
70
- routerPush(href);
93
+ overrides.routerPush(href);
71
94
  }
72
95
  }
73
96
  }
@@ -110,7 +133,7 @@ function Ui89Button({ theme = Ui89Theme.primary, size = "normal", block, onClick
110
133
  if (href) {
111
134
  return (React__default.createElement("span", { className: styles$e.container },
112
135
  React__default.createElement(HoverShadow, null,
113
- React__default.createElement("a", { className: buttonClass, href: href, onClick: onAnchorClick },
136
+ React__default.createElement("a", { className: buttonClass, role: "button", href: href, onClick: onAnchorClick },
114
137
  React__default.createElement("span", { className: styles$e.click }),
115
138
  children))));
116
139
  }
@@ -136,6 +159,39 @@ function Ui89Card({ topLeftCenter, topCenter, children, }) {
136
159
  hasTopContent && React__default.createElement("div", { className: "space-vertical-1" }))));
137
160
  }
138
161
 
162
+ const TimeAnimation = ({ children }) => {
163
+ const [currentTime, setCurrentTime] = useState(new Date());
164
+ useEffect(() => {
165
+ const tick = () => {
166
+ const now = new Date();
167
+ setCurrentTime(now);
168
+ // Calculate time until the next exact second
169
+ const msUntilNextSecond = 1000 - now.getMilliseconds();
170
+ setTimeout(tick, msUntilNextSecond);
171
+ };
172
+ // Start the first tick
173
+ const msUntilNextSecond = 1000 - currentTime.getMilliseconds();
174
+ const timeoutId = setTimeout(tick, msUntilNextSecond);
175
+ return () => clearTimeout(timeoutId);
176
+ }, []);
177
+ return React__default.createElement(React__default.Fragment, null, children({ now: currentTime }));
178
+ };
179
+
180
+ function Ui89DigitalTimeClock() {
181
+ const withColon = useRef(false);
182
+ function render({ now }) {
183
+ withColon.current = !withColon.current;
184
+ const separator = withColon.current ? ":" : " ";
185
+ return (now.getHours().toString().padStart(2, "0") +
186
+ separator +
187
+ now.getMinutes().toString().padStart(2, "0") +
188
+ separator +
189
+ now.getSeconds().toString().padStart(2, "0"));
190
+ }
191
+ return (React__default.createElement("span", { className: `${typoStyles.special}` },
192
+ React__default.createElement(TimeAnimation, null, render)));
193
+ }
194
+
139
195
  var style$1 = {"container":"Ui89HighlightText-module_container__gap-L","container--block":"Ui89HighlightText-module_container--block__BDJUL"};
140
196
 
141
197
  function Ui89HighlightText({ theme, block, children, }) {
@@ -31447,5 +31503,5 @@ function Ui89VirtualTable(props) {
31447
31503
  React__default.createElement(Ui89TagBox, { theme: "warn" }, "Empty")))));
31448
31504
  }
31449
31505
 
31450
- export { Ui89Breadcrumbs, Ui89Button, Ui89Card, Ui89HighlightText, Ui89InputText, Ui89InputTextNumber, Ui89Look, Ui89MenuBar, Ui89ModalDialog, Ui89Scene, Ui89Shortcut, Ui89SpaceVertical, Ui89TabbedCard, Ui89Tabs, Ui89TagBox, Ui89Theme, Ui89ThemeBackground, Ui89TitleBox, Ui89TitleUnderline, Ui89VirtualTable };
31506
+ export { Ui89Breadcrumbs, Ui89Button, Ui89Card, Ui89DigitalTimeClock, Ui89HighlightText, Ui89InputText, Ui89InputTextNumber, Ui89Look, Ui89MenuBar, Ui89ModalDialog, Ui89OverrideProvider, Ui89Scene, Ui89Shortcut, Ui89SpaceVertical, Ui89TabbedCard, Ui89Tabs, Ui89TagBox, Ui89Theme, Ui89ThemeBackground, Ui89TitleBox, Ui89TitleUnderline, Ui89VirtualTable };
31451
31507
  //# sourceMappingURL=index.js.map