@robert-stackflow/oneui 0.2.0 → 0.4.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/CHANGELOG.md +37 -18
- package/README.md +110 -73
- package/components/AccountItem.d.ts +15 -0
- package/components/AccountItem.js +38 -0
- package/components/AccountItem.module.css +103 -0
- package/components/AppShell.d.ts +11 -4
- package/components/AppShell.js +79 -54
- package/components/AppShell.module.css +13 -1
- package/components/Calendar.d.ts +2 -1
- package/components/Calendar.js +4 -3
- package/components/DatePicker.d.ts +3 -0
- package/components/DatePicker.js +41 -21
- package/components/DatePicker.module.css +3 -0
- package/components/Dialog.js +6 -3
- package/components/Form.d.ts +2 -1
- package/components/Form.js +5 -2
- package/components/FormField.d.ts +2 -1
- package/components/FormField.js +45 -19
- package/components/FormField.module.css +40 -0
- package/components/FormGroup.d.ts +2 -1
- package/components/FormGroup.js +26 -12
- package/components/FormLayout.d.ts +6 -0
- package/components/FormLayout.js +7 -0
- package/components/IconPicker.d.ts +14 -4
- package/components/IconPicker.js +67 -25
- package/components/NumberInput.d.ts +12 -4
- package/components/NumberInput.js +41 -20
- package/components/PasskeyItem.d.ts +11 -0
- package/components/PasskeyItem.js +53 -0
- package/components/RadioGroup.js +5 -3
- package/components/SessionItem.d.ts +11 -0
- package/components/SessionItem.js +44 -0
- package/components/ToastProvider.d.ts +4 -4
- package/components/ToastProvider.js +19 -22
- package/components/VirtualPickerList.d.ts +2 -0
- package/components/VirtualPickerList.js +1 -1
- package/components/calendarNow.d.ts +5 -0
- package/components/calendarNow.js +27 -0
- package/components/createToaster.d.ts +12 -0
- package/components/createToaster.js +40 -0
- package/components/index.d.ts +10 -2
- package/components/index.js +13 -1
- package/package.json +30 -4
- package/styles/minimal.css +1 -0
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { type FieldOptions } from "./field";
|
|
2
|
-
export
|
|
3
|
-
value: number;
|
|
4
|
-
onChange(value: number): void;
|
|
2
|
+
export type NumberInputProps = FieldOptions & {
|
|
5
3
|
label: string;
|
|
6
4
|
min?: number;
|
|
7
5
|
max?: number;
|
|
@@ -9,4 +7,14 @@ export declare function NumberInput({ value, onChange, label, min, max, step, di
|
|
|
9
7
|
disabled?: boolean;
|
|
10
8
|
readOnly?: boolean;
|
|
11
9
|
invalid?: boolean;
|
|
12
|
-
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
} & ({
|
|
12
|
+
nullable: true;
|
|
13
|
+
value: number | null;
|
|
14
|
+
onChange(value: number | null): void;
|
|
15
|
+
} | {
|
|
16
|
+
nullable?: false;
|
|
17
|
+
value: number;
|
|
18
|
+
onChange(value: number): void;
|
|
19
|
+
});
|
|
20
|
+
export declare function NumberInput(props: NumberInputProps): import("react").JSX.Element;
|
|
@@ -3,28 +3,48 @@ import { fieldInputProps, useFieldControl } from "./field.js";
|
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { Minus, Plus } from "lucide-react";
|
|
5
5
|
import s from "./NumberInput.module.css";
|
|
6
|
-
function NumberInput({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
function NumberInput(props) {
|
|
7
|
+
const {
|
|
8
|
+
value,
|
|
9
|
+
label,
|
|
10
|
+
min = -Infinity,
|
|
11
|
+
max = Infinity,
|
|
12
|
+
step = 1,
|
|
13
|
+
disabled: suppliedDisabled,
|
|
14
|
+
readOnly: suppliedReadOnly,
|
|
15
|
+
invalid = false,
|
|
16
|
+
nullable = false,
|
|
17
|
+
placeholder,
|
|
18
|
+
...options
|
|
19
|
+
} = props;
|
|
20
|
+
const onChange = (next) => {
|
|
21
|
+
if (props.nullable) props.onChange(next);
|
|
22
|
+
else if (next !== null) props.onChange(next);
|
|
23
|
+
};
|
|
24
|
+
const text = (next) => next === null ? "" : String(next);
|
|
25
|
+
const field = useFieldControl({
|
|
26
|
+
...options,
|
|
27
|
+
label,
|
|
28
|
+
disabled: suppliedDisabled,
|
|
29
|
+
readOnly: suppliedReadOnly
|
|
30
|
+
});
|
|
31
|
+
const { disabled, readOnly } = field;
|
|
32
|
+
const [draft, setDraft] = useState(text(value)), input = useRef(null);
|
|
22
33
|
const safeStep = Number.isFinite(step) && step > 0 ? step : 1;
|
|
23
34
|
const clamp = (n) => Math.min(max, Math.max(min, n));
|
|
24
|
-
useEffect(() => setDraft(
|
|
25
|
-
const parsed = () => draft.trim() && Number.isFinite(Number(draft)) ? Number(draft) : value;
|
|
35
|
+
useEffect(() => setDraft(text(value)), [value]);
|
|
36
|
+
const parsed = () => draft.trim() && Number.isFinite(Number(draft)) ? Number(draft) : value ?? 0;
|
|
26
37
|
const commit = () => {
|
|
27
38
|
if (readOnly) return;
|
|
39
|
+
if (nullable && !draft.trim()) {
|
|
40
|
+
setDraft("");
|
|
41
|
+
if (value !== null) onChange(null);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (!draft.trim() || !Number.isFinite(Number(draft))) {
|
|
45
|
+
setDraft(text(value));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
28
48
|
const next = clamp(parsed());
|
|
29
49
|
setDraft(String(next));
|
|
30
50
|
if (next !== value) onChange(next);
|
|
@@ -64,7 +84,8 @@ function NumberInput({
|
|
|
64
84
|
role: "spinbutton",
|
|
65
85
|
"aria-invalid": field.invalid || invalid,
|
|
66
86
|
"aria-label": label,
|
|
67
|
-
"aria-valuenow": value,
|
|
87
|
+
"aria-valuenow": value ?? void 0,
|
|
88
|
+
placeholder,
|
|
68
89
|
"aria-valuemin": Number.isFinite(min) ? min : void 0,
|
|
69
90
|
"aria-valuemax": Number.isFinite(max) ? max : void 0,
|
|
70
91
|
value: draft,
|
|
@@ -81,7 +102,7 @@ function NumberInput({
|
|
|
81
102
|
} else if (e.key === "Enter") {
|
|
82
103
|
e.preventDefault();
|
|
83
104
|
commit();
|
|
84
|
-
} else if (e.key === "Escape") setDraft(
|
|
105
|
+
} else if (e.key === "Escape") setDraft(text(value));
|
|
85
106
|
else if (e.key === "Home" && Number.isFinite(min)) {
|
|
86
107
|
e.preventDefault();
|
|
87
108
|
setDraft(String(min));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type AccountItemProps } from "./AccountItem";
|
|
2
|
+
export type PasskeyItemProps = {
|
|
3
|
+
name: string;
|
|
4
|
+
createdAt: string;
|
|
5
|
+
lastUsedAt?: string;
|
|
6
|
+
description?: AccountItemProps["description"];
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
onRename?(): void;
|
|
9
|
+
onRemove?(): void;
|
|
10
|
+
};
|
|
11
|
+
export declare function PasskeyItem({ name, createdAt, lastUsedAt, description, disabled, onRename, onRemove, }: PasskeyItemProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { KeyRound, Pencil, Trash2 } from "lucide-react";
|
|
3
|
+
import { AccountItem } from "./AccountItem.js";
|
|
4
|
+
import { IconButton } from "./IconButton.js";
|
|
5
|
+
function PasskeyItem({
|
|
6
|
+
name,
|
|
7
|
+
createdAt,
|
|
8
|
+
lastUsedAt,
|
|
9
|
+
description,
|
|
10
|
+
disabled,
|
|
11
|
+
onRename,
|
|
12
|
+
onRemove
|
|
13
|
+
}) {
|
|
14
|
+
return /* @__PURE__ */ jsx(
|
|
15
|
+
AccountItem,
|
|
16
|
+
{
|
|
17
|
+
title: name,
|
|
18
|
+
icon: /* @__PURE__ */ jsx(KeyRound, {}),
|
|
19
|
+
description,
|
|
20
|
+
metadata: [
|
|
21
|
+
{ label: "\u6DFB\u52A0\u65F6\u95F4", value: createdAt },
|
|
22
|
+
{ label: "\u6700\u8FD1\u4F7F\u7528", value: lastUsedAt || "\u5C1A\u672A\u7528\u4E8E\u767B\u5F55" }
|
|
23
|
+
],
|
|
24
|
+
actions: onRename || onRemove ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
25
|
+
onRename && /* @__PURE__ */ jsx(
|
|
26
|
+
IconButton,
|
|
27
|
+
{
|
|
28
|
+
size: "small",
|
|
29
|
+
variant: "ghost",
|
|
30
|
+
label: "\u91CD\u547D\u540D\u901A\u884C\u5BC6\u94A5 " + name,
|
|
31
|
+
disabled,
|
|
32
|
+
onClick: onRename,
|
|
33
|
+
children: /* @__PURE__ */ jsx(Pencil, {})
|
|
34
|
+
}
|
|
35
|
+
),
|
|
36
|
+
onRemove && /* @__PURE__ */ jsx(
|
|
37
|
+
IconButton,
|
|
38
|
+
{
|
|
39
|
+
size: "small",
|
|
40
|
+
variant: "danger",
|
|
41
|
+
label: "\u79FB\u9664\u901A\u884C\u5BC6\u94A5 " + name,
|
|
42
|
+
disabled,
|
|
43
|
+
onClick: onRemove,
|
|
44
|
+
children: /* @__PURE__ */ jsx(Trash2, {})
|
|
45
|
+
}
|
|
46
|
+
)
|
|
47
|
+
] }) : void 0
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
PasskeyItem
|
|
53
|
+
};
|
package/components/RadioGroup.js
CHANGED
|
@@ -26,12 +26,13 @@ function RadioGroup({
|
|
|
26
26
|
{
|
|
27
27
|
className: s.group,
|
|
28
28
|
disabled: field.disabled,
|
|
29
|
-
id: field.id,
|
|
29
|
+
id: field.id + "-group",
|
|
30
|
+
"aria-label": field.label,
|
|
30
31
|
"aria-invalid": field.invalid,
|
|
31
32
|
"aria-describedby": field.descriptionId,
|
|
32
33
|
"data-orientation": orientation,
|
|
33
34
|
children: [
|
|
34
|
-
/* @__PURE__ */ jsx("legend", { children: /* @__PURE__ */ jsx(
|
|
35
|
+
!field.wrapped && /* @__PURE__ */ jsx("legend", { children: /* @__PURE__ */ jsx(
|
|
35
36
|
FieldLabel,
|
|
36
37
|
{
|
|
37
38
|
as: "span",
|
|
@@ -39,7 +40,7 @@ function RadioGroup({
|
|
|
39
40
|
required: !field.wrapped && field.required
|
|
40
41
|
}
|
|
41
42
|
) }),
|
|
42
|
-
options.map((option) => /* @__PURE__ */ jsxs(
|
|
43
|
+
options.map((option, index) => /* @__PURE__ */ jsxs(
|
|
43
44
|
"label",
|
|
44
45
|
{
|
|
45
46
|
"data-disabled": field.disabled || option.disabled,
|
|
@@ -48,6 +49,7 @@ function RadioGroup({
|
|
|
48
49
|
"input",
|
|
49
50
|
{
|
|
50
51
|
type: "radio",
|
|
52
|
+
id: index === 0 ? field.id : field.id + "-" + index,
|
|
51
53
|
value: option.value,
|
|
52
54
|
name,
|
|
53
55
|
required: field.required,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type AccountItemMetadata } from "./AccountItem";
|
|
2
|
+
export type SessionItemProps = {
|
|
3
|
+
device: string;
|
|
4
|
+
deviceType?: "desktop" | "mobile" | "tablet" | "unknown";
|
|
5
|
+
description?: string;
|
|
6
|
+
current?: boolean;
|
|
7
|
+
metadata: AccountItemMetadata[];
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
onRevoke?(): void;
|
|
10
|
+
};
|
|
11
|
+
export declare function SessionItem({ device, deviceType, description, current, metadata, disabled, onRevoke, }: SessionItemProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Globe, LogOut, Monitor, Smartphone, Tablet } from "lucide-react";
|
|
3
|
+
import { AccountItem } from "./AccountItem.js";
|
|
4
|
+
import { Badge } from "./Badge.js";
|
|
5
|
+
import { Button } from "./Button.js";
|
|
6
|
+
function SessionItem({
|
|
7
|
+
device,
|
|
8
|
+
deviceType = "desktop",
|
|
9
|
+
description,
|
|
10
|
+
current = false,
|
|
11
|
+
metadata,
|
|
12
|
+
disabled,
|
|
13
|
+
onRevoke
|
|
14
|
+
}) {
|
|
15
|
+
const Icon = deviceType === "mobile" ? Smartphone : deviceType === "tablet" ? Tablet : deviceType === "unknown" ? Globe : Monitor;
|
|
16
|
+
return /* @__PURE__ */ jsx(
|
|
17
|
+
AccountItem,
|
|
18
|
+
{
|
|
19
|
+
title: device,
|
|
20
|
+
icon: /* @__PURE__ */ jsx(Icon, {}),
|
|
21
|
+
badge: current ? /* @__PURE__ */ jsx(Badge, { tone: "success", children: "\u5F53\u524D\u4F1A\u8BDD" }) : void 0,
|
|
22
|
+
description,
|
|
23
|
+
metadata,
|
|
24
|
+
highlighted: current,
|
|
25
|
+
actions: onRevoke ? /* @__PURE__ */ jsxs(
|
|
26
|
+
Button,
|
|
27
|
+
{
|
|
28
|
+
size: "small",
|
|
29
|
+
variant: "ghost",
|
|
30
|
+
disabled,
|
|
31
|
+
"aria-label": "\u9000\u51FA" + (current ? "\u5F53\u524D\u4F1A\u8BDD" : device + " \u4F1A\u8BDD"),
|
|
32
|
+
onClick: onRevoke,
|
|
33
|
+
children: [
|
|
34
|
+
/* @__PURE__ */ jsx(LogOut, { size: 15 }),
|
|
35
|
+
current ? "\u9000\u51FA\u5F53\u524D\u4F1A\u8BDD" : "\u9000\u51FA\u4F1A\u8BDD"
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
) : void 0
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
SessionItem
|
|
44
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
+
import { type ToastController, type ToastNotify } from "./createToaster";
|
|
2
3
|
export type ToastPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
3
4
|
export type ToastTone = "neutral" | "success" | "info" | "warning" | "error";
|
|
4
5
|
export type ToastAction = {
|
|
@@ -27,9 +28,8 @@ export type ToastMessage = {
|
|
|
27
28
|
options?: ToastOptions;
|
|
28
29
|
closing?: boolean;
|
|
29
30
|
};
|
|
30
|
-
|
|
31
|
-
export declare function ToastProvider({ children }: {
|
|
31
|
+
export declare function ToastProvider({ children, controller, }: {
|
|
32
32
|
children: ReactNode;
|
|
33
|
+
controller?: ToastController;
|
|
33
34
|
}): import("react").JSX.Element;
|
|
34
|
-
export declare const useToast: () =>
|
|
35
|
-
export {};
|
|
35
|
+
export declare const useToast: () => ToastNotify;
|
|
@@ -1,42 +1,39 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import {
|
|
3
3
|
createContext,
|
|
4
|
-
useCallback,
|
|
5
4
|
useContext,
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
useState,
|
|
6
|
+
useSyncExternalStore
|
|
8
7
|
} from "react";
|
|
9
8
|
import { useUIConfig } from "./UIProvider.js";
|
|
10
9
|
import { Toast } from "./Toast.js";
|
|
10
|
+
import {
|
|
11
|
+
createToaster
|
|
12
|
+
} from "./createToaster.js";
|
|
11
13
|
const Context = createContext(() => () => {
|
|
12
14
|
});
|
|
13
|
-
|
|
15
|
+
const serverSnapshot = () => null;
|
|
16
|
+
function ToastProvider({
|
|
17
|
+
children,
|
|
18
|
+
controller
|
|
19
|
+
}) {
|
|
14
20
|
const config = useUIConfig();
|
|
15
|
-
const [
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
id,
|
|
21
|
-
options: typeof options === "string" ? { tone: options } : options
|
|
22
|
-
});
|
|
23
|
-
return () => setToast(
|
|
24
|
-
(current) => current?.id === id ? { ...current, closing: true } : current
|
|
25
|
-
);
|
|
26
|
-
}, []);
|
|
27
|
-
const clear = useCallback(
|
|
28
|
-
(id) => setToast((current) => current?.id === id ? null : current),
|
|
29
|
-
[]
|
|
21
|
+
const [local] = useState(createToaster), source = controller || local;
|
|
22
|
+
const toast = useSyncExternalStore(
|
|
23
|
+
source.subscribe,
|
|
24
|
+
source.getSnapshot,
|
|
25
|
+
serverSnapshot
|
|
30
26
|
);
|
|
31
|
-
return /* @__PURE__ */ jsxs(Context, { value: notify, children: [
|
|
27
|
+
return /* @__PURE__ */ jsxs(Context, { value: source.notify, children: [
|
|
32
28
|
children,
|
|
33
29
|
/* @__PURE__ */ jsx(
|
|
34
30
|
Toast,
|
|
35
31
|
{
|
|
36
32
|
toast,
|
|
37
33
|
position: toast?.options?.position || config.toastPosition,
|
|
38
|
-
onDismiss: clear
|
|
39
|
-
}
|
|
34
|
+
onDismiss: source.clear
|
|
35
|
+
},
|
|
36
|
+
source.id
|
|
40
37
|
)
|
|
41
38
|
] });
|
|
42
39
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
1
2
|
import { type LucideIconData } from "lucide-react";
|
|
2
3
|
export type PickerCatalogItem = {
|
|
3
4
|
id: string;
|
|
@@ -5,6 +6,7 @@ export type PickerCatalogItem = {
|
|
|
5
6
|
search: string;
|
|
6
7
|
glyph?: string;
|
|
7
8
|
icon?: LucideIconData;
|
|
9
|
+
content?: ReactNode;
|
|
8
10
|
variants?: {
|
|
9
11
|
glyph: string;
|
|
10
12
|
label: string;
|
|
@@ -44,7 +44,7 @@ const Cell = memo(function Cell2({
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
children: [
|
|
47
|
-
item.icon ? /* @__PURE__ */ jsx(Icon, { icon: item.icon }) : item.glyph,
|
|
47
|
+
item.content !== void 0 ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: item.content }) : item.icon ? /* @__PURE__ */ jsx(Icon, { icon: item.icon }) : item.glyph,
|
|
48
48
|
item.variants && item.variants.length > 1 && /* @__PURE__ */ jsx("span", { className: s.variantMark, "aria-hidden": "true" })
|
|
49
49
|
]
|
|
50
50
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { dateKey } from "./dateConstraints.js";
|
|
2
|
+
function calendarNow(timeZone, instant = /* @__PURE__ */ new Date()) {
|
|
3
|
+
if (!timeZone)
|
|
4
|
+
return {
|
|
5
|
+
date: dateKey(instant),
|
|
6
|
+
time: [instant.getHours(), instant.getMinutes(), instant.getSeconds()].map((part2) => String(part2).padStart(2, "0")).join(":")
|
|
7
|
+
};
|
|
8
|
+
const parts = new Intl.DateTimeFormat("en-CA", {
|
|
9
|
+
timeZone,
|
|
10
|
+
numberingSystem: "latn",
|
|
11
|
+
year: "numeric",
|
|
12
|
+
month: "2-digit",
|
|
13
|
+
day: "2-digit",
|
|
14
|
+
hour: "2-digit",
|
|
15
|
+
minute: "2-digit",
|
|
16
|
+
second: "2-digit",
|
|
17
|
+
hourCycle: "h23"
|
|
18
|
+
}).formatToParts(instant);
|
|
19
|
+
const part = (type) => parts.find((item) => item.type === type).value;
|
|
20
|
+
return {
|
|
21
|
+
date: part("year").padStart(4, "0") + "-" + part("month") + "-" + part("day"),
|
|
22
|
+
time: part("hour") + ":" + part("minute") + ":" + part("second")
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
calendarNow
|
|
27
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ToastMessage, ToastOptions, ToastTone } from "./ToastProvider";
|
|
2
|
+
export type ToastNotify = (message: string, options?: ToastOptions | ToastTone) => () => void;
|
|
3
|
+
export interface ToastController {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
notify: ToastNotify;
|
|
6
|
+
dismiss(id?: number): void;
|
|
7
|
+
clear(id?: number): void;
|
|
8
|
+
subscribe(listener: () => void): () => void;
|
|
9
|
+
getSnapshot(): ToastMessage | null;
|
|
10
|
+
}
|
|
11
|
+
/** An isolated notification service; no React or document access is required. */
|
|
12
|
+
export declare function createToaster(): ToastController;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
let nextController = 0;
|
|
2
|
+
function createToaster() {
|
|
3
|
+
let current = null, counter = 0;
|
|
4
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
5
|
+
const publish = (message) => {
|
|
6
|
+
if (current === message) return;
|
|
7
|
+
current = message;
|
|
8
|
+
listeners.forEach((listener) => listener());
|
|
9
|
+
};
|
|
10
|
+
const dismiss = (id = current?.id) => {
|
|
11
|
+
if (current && current.id === id && !current.closing)
|
|
12
|
+
publish({ ...current, closing: true });
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
id: "oneui-toast-" + ++nextController,
|
|
16
|
+
notify(message, options) {
|
|
17
|
+
const id = ++counter;
|
|
18
|
+
publish({
|
|
19
|
+
message,
|
|
20
|
+
id,
|
|
21
|
+
options: typeof options === "string" ? { tone: options } : options
|
|
22
|
+
});
|
|
23
|
+
return () => dismiss(id);
|
|
24
|
+
},
|
|
25
|
+
dismiss,
|
|
26
|
+
clear(id = current?.id) {
|
|
27
|
+
if (current?.id === id) publish(null);
|
|
28
|
+
},
|
|
29
|
+
subscribe(listener) {
|
|
30
|
+
listeners.add(listener);
|
|
31
|
+
return () => {
|
|
32
|
+
listeners.delete(listener);
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
getSnapshot: () => current
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
createToaster
|
|
40
|
+
};
|
package/components/index.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export { CharacterPicker } from "./CharacterPicker";
|
|
|
47
47
|
export { DataTable } from "./DataTable";
|
|
48
48
|
export { EmojiPicker } from "./EmojiPicker";
|
|
49
49
|
export { FileTree } from "./FileTree";
|
|
50
|
-
export { IconPicker } from "./IconPicker";
|
|
50
|
+
export { IconPicker, type IconPickerProps, type IconPickerOption, } from "./IconPicker";
|
|
51
51
|
export { LoadingOverlay } from "./LoadingOverlay";
|
|
52
52
|
export { LoadingState } from "./LoadingState";
|
|
53
53
|
export { Pagination } from "./Pagination";
|
|
@@ -75,6 +75,13 @@ export type { ContextMenuItem, MenuAction } from "./menuTypes";
|
|
|
75
75
|
export { MenuItem } from "./MenuItem";
|
|
76
76
|
export type { MenuItemProps } from "./MenuItem";
|
|
77
77
|
export { Form } from "./Form";
|
|
78
|
+
export { AccountItem } from "./AccountItem";
|
|
79
|
+
export type { AccountItemProps, AccountItemMetadata } from "./AccountItem";
|
|
80
|
+
export { PasskeyItem } from "./PasskeyItem";
|
|
81
|
+
export type { PasskeyItemProps } from "./PasskeyItem";
|
|
82
|
+
export { SessionItem } from "./SessionItem";
|
|
83
|
+
export type { SessionItemProps } from "./SessionItem";
|
|
84
|
+
export type { FormLayout, FormLayoutOptions } from "./FormLayout";
|
|
78
85
|
export { FormField } from "./FormField";
|
|
79
86
|
export { FieldLabel } from "./FieldLabel";
|
|
80
87
|
export { FormGroup } from "./FormGroup";
|
|
@@ -143,10 +150,11 @@ export { ThemeProvider } from "./ThemeProvider";
|
|
|
143
150
|
export type { UITheme, ColorMode } from "./ThemeProvider";
|
|
144
151
|
export { ThemeStylePicker } from "./ThemeStylePicker";
|
|
145
152
|
export { AppShell, ShellHeader } from "./AppShell";
|
|
146
|
-
export type { NavigationItem } from "./AppShell";
|
|
153
|
+
export type { NavigationItem, AppShellProps } from "./AppShell";
|
|
147
154
|
export { SettingsLayout, SettingsCard } from "./SettingsLayout";
|
|
148
155
|
export { AppearanceSettings } from "./AppearanceSettings";
|
|
149
156
|
export { appearanceDefaults, normalizeAppearance } from "./appearance";
|
|
150
157
|
export type { AppearancePreferences } from "./appearance";
|
|
151
158
|
export { MessageDialog, ConfirmDialog, FormDialog } from "./DialogVariants";
|
|
152
159
|
export { TreeTable, type TreeTableProps } from "./TreeTable";
|
|
160
|
+
export { createToaster, type ToastController, type ToastNotify, } from "./createToaster";
|
package/components/index.js
CHANGED
|
@@ -43,7 +43,9 @@ import { CharacterPicker } from "./CharacterPicker.js";
|
|
|
43
43
|
import { DataTable } from "./DataTable.js";
|
|
44
44
|
import { EmojiPicker } from "./EmojiPicker.js";
|
|
45
45
|
import { FileTree } from "./FileTree.js";
|
|
46
|
-
import {
|
|
46
|
+
import {
|
|
47
|
+
IconPicker
|
|
48
|
+
} from "./IconPicker.js";
|
|
47
49
|
import { LoadingOverlay } from "./LoadingOverlay.js";
|
|
48
50
|
import { LoadingState } from "./LoadingState.js";
|
|
49
51
|
import { Pagination } from "./Pagination.js";
|
|
@@ -63,6 +65,9 @@ import { ContextMenuPanel } from "./ContextMenuPanel.js";
|
|
|
63
65
|
import { SelectOptionContent } from "./SelectOptionContent.js";
|
|
64
66
|
import { MenuItem } from "./MenuItem.js";
|
|
65
67
|
import { Form } from "./Form.js";
|
|
68
|
+
import { AccountItem } from "./AccountItem.js";
|
|
69
|
+
import { PasskeyItem } from "./PasskeyItem.js";
|
|
70
|
+
import { SessionItem } from "./SessionItem.js";
|
|
66
71
|
import { FormField } from "./FormField.js";
|
|
67
72
|
import { FieldLabel } from "./FieldLabel.js";
|
|
68
73
|
import { FormGroup } from "./FormGroup.js";
|
|
@@ -106,8 +111,12 @@ import { AppearanceSettings } from "./AppearanceSettings.js";
|
|
|
106
111
|
import { appearanceDefaults, normalizeAppearance } from "./appearance.js";
|
|
107
112
|
import { MessageDialog, ConfirmDialog, FormDialog } from "./DialogVariants.js";
|
|
108
113
|
import { TreeTable } from "./TreeTable.js";
|
|
114
|
+
import {
|
|
115
|
+
createToaster
|
|
116
|
+
} from "./createToaster.js";
|
|
109
117
|
export {
|
|
110
118
|
Accordion,
|
|
119
|
+
AccountItem,
|
|
111
120
|
Alert,
|
|
112
121
|
AppShell,
|
|
113
122
|
AppearanceSettings,
|
|
@@ -164,6 +173,7 @@ export {
|
|
|
164
173
|
NumberInput,
|
|
165
174
|
Page,
|
|
166
175
|
Pagination,
|
|
176
|
+
PasskeyItem,
|
|
167
177
|
PasswordField,
|
|
168
178
|
PinInput,
|
|
169
179
|
Placeholder,
|
|
@@ -179,6 +189,7 @@ export {
|
|
|
179
189
|
Select,
|
|
180
190
|
SelectOptionContent,
|
|
181
191
|
SelectTrigger,
|
|
192
|
+
SessionItem,
|
|
182
193
|
SettingRow,
|
|
183
194
|
SettingsCard,
|
|
184
195
|
SettingsLayout,
|
|
@@ -216,6 +227,7 @@ export {
|
|
|
216
227
|
UploadList,
|
|
217
228
|
VirtualPickerList,
|
|
218
229
|
appearanceDefaults,
|
|
230
|
+
createToaster,
|
|
219
231
|
formatFileSize,
|
|
220
232
|
normalizeAppearance,
|
|
221
233
|
useFormState,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@robert-stackflow/oneui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "OneUI React components, application shell and portable visual themes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -789,7 +789,33 @@
|
|
|
789
789
|
"import": "./components/TreeTable.js",
|
|
790
790
|
"default": "./components/TreeTable.js"
|
|
791
791
|
},
|
|
792
|
-
"./TreeTable.module.css": "./components/TreeTable.module.css"
|
|
792
|
+
"./TreeTable.module.css": "./components/TreeTable.module.css",
|
|
793
|
+
"./createToaster": {
|
|
794
|
+
"types": "./components/createToaster.d.ts",
|
|
795
|
+
"import": "./components/createToaster.js",
|
|
796
|
+
"default": "./components/createToaster.js"
|
|
797
|
+
},
|
|
798
|
+
"./AccountItem": {
|
|
799
|
+
"types": "./components/AccountItem.d.ts",
|
|
800
|
+
"import": "./components/AccountItem.js",
|
|
801
|
+
"default": "./components/AccountItem.js"
|
|
802
|
+
},
|
|
803
|
+
"./PasskeyItem": {
|
|
804
|
+
"types": "./components/PasskeyItem.d.ts",
|
|
805
|
+
"import": "./components/PasskeyItem.js",
|
|
806
|
+
"default": "./components/PasskeyItem.js"
|
|
807
|
+
},
|
|
808
|
+
"./SessionItem": {
|
|
809
|
+
"types": "./components/SessionItem.d.ts",
|
|
810
|
+
"import": "./components/SessionItem.js",
|
|
811
|
+
"default": "./components/SessionItem.js"
|
|
812
|
+
},
|
|
813
|
+
"./FormLayout": {
|
|
814
|
+
"types": "./components/FormLayout.d.ts",
|
|
815
|
+
"import": "./components/FormLayout.js",
|
|
816
|
+
"default": "./components/FormLayout.js"
|
|
817
|
+
},
|
|
818
|
+
"./AccountItem.module.css": "./components/AccountItem.module.css"
|
|
793
819
|
},
|
|
794
820
|
"files": [
|
|
795
821
|
"components",
|
|
@@ -799,8 +825,8 @@
|
|
|
799
825
|
"CHANGELOG.md"
|
|
800
826
|
],
|
|
801
827
|
"peerDependencies": {
|
|
802
|
-
"react": "19.
|
|
803
|
-
"react-dom": "19.
|
|
828
|
+
"react": "^19.2.0",
|
|
829
|
+
"react-dom": "^19.2.0"
|
|
804
830
|
},
|
|
805
831
|
"dependencies": {
|
|
806
832
|
"lucide-react": "1.59.0"
|