@robert-stackflow/oneui 0.3.0 → 0.4.1

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.
@@ -1,4 +1,6 @@
1
1
  .pagination {
2
+ min-width: 0;
3
+ max-width: 100%;
2
4
  display: flex;
3
5
  align-items: center;
4
6
  justify-content: space-between;
@@ -12,6 +14,8 @@
12
14
  font-size: 12px;
13
15
  }
14
16
  .controls {
17
+ min-width: 0;
18
+ max-width: 100%;
15
19
  display: flex;
16
20
  align-items: center;
17
21
  gap: 16px;
@@ -27,6 +31,16 @@
27
31
  gap: 4px;
28
32
  align-items: center;
29
33
  }
34
+ .pages {
35
+ flex-wrap: wrap;
36
+ }
37
+ .compact {
38
+ width: 100%;
39
+ padding: 0;
40
+ }
41
+ .small {
42
+ --control-height: var(--control-small);
43
+ }
30
44
  .pages .arrow,
31
45
  .pages .page {
32
46
  height: var(--control-height);
@@ -67,4 +81,29 @@
67
81
  .pages {
68
82
  gap: 2px;
69
83
  }
84
+ .compact {
85
+ display: grid;
86
+ grid-template-columns: minmax(0, 1fr) auto;
87
+ gap: 8px;
88
+ }
89
+ .compact .controls {
90
+ display: contents;
91
+ }
92
+ .compact .pages {
93
+ grid-column: 1 / -1;
94
+ grid-row: 1;
95
+ justify-content: center;
96
+ }
97
+ .compact .summary {
98
+ grid-column: 1;
99
+ grid-row: 2;
100
+ }
101
+ .compact .jump {
102
+ grid-column: 2;
103
+ grid-row: 2;
104
+ }
105
+ .compact .controls > [role="combobox"] {
106
+ grid-column: 1 / -1;
107
+ grid-row: 3;
108
+ }
70
109
  }
@@ -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
+ };
@@ -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
+ };
@@ -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";
@@ -65,6 +65,9 @@ import { ContextMenuPanel } from "./ContextMenuPanel.js";
65
65
  import { SelectOptionContent } from "./SelectOptionContent.js";
66
66
  import { MenuItem } from "./MenuItem.js";
67
67
  import { Form } from "./Form.js";
68
+ import { AccountItem } from "./AccountItem.js";
69
+ import { PasskeyItem } from "./PasskeyItem.js";
70
+ import { SessionItem } from "./SessionItem.js";
68
71
  import { FormField } from "./FormField.js";
69
72
  import { FieldLabel } from "./FieldLabel.js";
70
73
  import { FormGroup } from "./FormGroup.js";
@@ -113,6 +116,7 @@ import {
113
116
  } from "./createToaster.js";
114
117
  export {
115
118
  Accordion,
119
+ AccountItem,
116
120
  Alert,
117
121
  AppShell,
118
122
  AppearanceSettings,
@@ -169,6 +173,7 @@ export {
169
173
  NumberInput,
170
174
  Page,
171
175
  Pagination,
176
+ PasskeyItem,
172
177
  PasswordField,
173
178
  PinInput,
174
179
  Placeholder,
@@ -184,6 +189,7 @@ export {
184
189
  Select,
185
190
  SelectOptionContent,
186
191
  SelectTrigger,
192
+ SessionItem,
187
193
  SettingRow,
188
194
  SettingsCard,
189
195
  SettingsLayout,
@@ -0,0 +1,6 @@
1
+ import { type RefObject } from "react";
2
+ /** Shared lifecycle for animated closure and conditionally mounted surfaces. */
3
+ export declare function useModalFocus(ref: RefObject<HTMLDialogElement | null>, returnFocus?: RefObject<HTMLElement | null>): {
4
+ rememberFocus: () => void;
5
+ restoreFocus: () => void;
6
+ };
@@ -0,0 +1,35 @@
1
+ import { useCallback, useEffect, useRef } from "react";
2
+ function useModalFocus(ref, returnFocus) {
3
+ const previous = useRef(null);
4
+ const requested = useRef(returnFocus);
5
+ const mounted = useRef(false);
6
+ requested.current = returnFocus;
7
+ const rememberFocus = useCallback(() => {
8
+ const active = document.activeElement;
9
+ if (active instanceof HTMLElement && active !== document.body && !ref.current?.contains(active))
10
+ previous.current = active;
11
+ }, [ref]);
12
+ const restoreFocus = useCallback(() => {
13
+ const target = requested.current?.current || previous.current;
14
+ const modal = [...document.querySelectorAll("dialog:modal")].at(-1);
15
+ if (target?.isConnected && !target.matches(":disabled") && !target.closest("[inert]") && (!modal || modal.contains(target)))
16
+ target.focus({ preventScroll: true });
17
+ }, []);
18
+ useEffect(() => {
19
+ mounted.current = true;
20
+ const node = ref.current;
21
+ return () => {
22
+ mounted.current = false;
23
+ if (!node?.open) return;
24
+ requestAnimationFrame(() => {
25
+ if (mounted.current) return;
26
+ if (node.open) node.close();
27
+ restoreFocus();
28
+ });
29
+ };
30
+ }, [ref, restoreFocus]);
31
+ return { rememberFocus, restoreFocus };
32
+ }
33
+ export {
34
+ useModalFocus
35
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robert-stackflow/oneui",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "OneUI React components, application shell and portable visual themes",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -794,7 +794,28 @@
794
794
  "types": "./components/createToaster.d.ts",
795
795
  "import": "./components/createToaster.js",
796
796
  "default": "./components/createToaster.js"
797
- }
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"
798
819
  },
799
820
  "files": [
800
821
  "components",