@jini-ai/ui-kit 0.1.0 → 0.1.2

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 ADDED
@@ -0,0 +1,15 @@
1
+ # @jini-ai/ui-kit
2
+
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Tovu clean-up release (2026-10-08): code Tovu moved into Jini, plus the Jini clean-up (see the commit log since 0.1.1).
8
+
9
+ ## 0.1.1 — 2026-10-05
10
+
11
+ - Native menu items step by their position among enabled items (from the render closure) instead of re-querying the menu ref. Same order as `focus()`; arrow keys skip a disabled item. Behavior unchanged.
12
+
13
+ ## 0.1.0
14
+
15
+ - First published release.
@@ -1,5 +1,11 @@
1
+ import type { AgentAttrsPort } from '../../attrs.js';
1
2
  import type { ConfirmController, ConfirmDialogProps } from '../types.js';
2
- export declare function useConfirmController(required: ConfirmDialogProps, _optional?: Record<string, never>): ConfirmController;
3
+ /** Shared confirmation policy and execution; adapters may supply their existing agent-attribute port.
4
+ * @example useConfirmController({ open, title, confirmLabel, onConfirm, onCancel }, { agent: agentAttrs })
5
+ */
6
+ export declare function useConfirmController(required: ConfirmDialogProps, optional?: {
7
+ agent?: AgentAttrsPort;
8
+ }): ConfirmController;
3
9
  export declare function useConfirmFacade(required: ConfirmDialogProps, _optional?: Record<string, never>): {
4
10
  Component: import("react").ComponentType<import("../types.js").ConfirmViewProps>;
5
11
  controller: ConfirmController;
@@ -4,7 +4,10 @@ import { useKit, useOverlayContainer } from '../Kit.hooks.js';
4
4
  import { isDevelopment } from '../context.js';
5
5
  import { nativeKit } from '../native/index.js';
6
6
  import { inspectConfirm } from './guard.js';
7
- export function useConfirmController(required, _optional = {}) {
7
+ /** Shared confirmation policy and execution; adapters may supply their existing agent-attribute port.
8
+ * @example useConfirmController({ open, title, confirmLabel, onConfirm, onCancel }, { agent: agentAttrs })
9
+ */
10
+ export function useConfirmController(required, optional = {}) {
8
11
  const context = useKit({}), titleId = useId(), frameId = useId(), consequenceId = useId(), cancelRef = useRef(null);
9
12
  const boundaryRef = useRef(null), latest = useRef(required), mounted = useRef(false);
10
13
  const [executing, setExecuting] = useState(false), [error, setError] = useState(false);
@@ -15,7 +18,8 @@ export function useConfirmController(required, _optional = {}) {
15
18
  const pending = !!required.pending || executing;
16
19
  const plan = planConfirm({ ...required, cancelLabel: required.cancelLabel ?? context.cancelLabel, pending });
17
20
  function actionAttrs(part, spec, label) {
18
- const attrs = spec && context.agent ? context.agent({ handle: spec.handle }, { role: spec.role, label: spec.label }) : {};
21
+ const agent = optional.agent ?? context.agent;
22
+ const attrs = spec && agent ? agent({ handle: spec.handle }, { role: spec.role, label: spec.label }) : {};
19
23
  return Object.freeze({ ...attrs, 'data-jini-part': part, 'aria-label': label,
20
24
  ...(required.actionAccessibleNames && plan.consequence ? { 'aria-describedby': consequenceId } : {}),
21
25
  'aria-busy': pending, 'data-jini-state': pending ? 'pending' : 'ready' });
@@ -1,7 +1,12 @@
1
1
  import type { MouseEvent, SyntheticEvent } from 'react';
2
2
  import type { DialogProps, ConfirmViewProps } from '../types.js';
3
+ /** Native modal lifecycle shared by kit views and compatibility adapters; DOM effects are O(1).
4
+ * The document port preserves hosts' focus injection seam without introducing another lifecycle.
5
+ * @example useNativeDialog({ open, title, onClose }, { initialFocus: () => cancelRef.current?.focus() })
6
+ */
3
7
  export declare function useNativeDialog(required: DialogProps, optional?: {
4
8
  initialFocus?: () => void;
9
+ document?: Pick<Document, 'activeElement'>;
5
10
  }): {
6
11
  title: string;
7
12
  children: import("react").ReactNode;
@@ -1,6 +1,10 @@
1
1
  import { useId, useImperativeHandle, useLayoutEffect, useRef } from 'react';
2
2
  import { Button } from '../facade.js';
3
3
  import { NativeButton } from './Controls.js';
4
+ /** Native modal lifecycle shared by kit views and compatibility adapters; DOM effects are O(1).
5
+ * The document port preserves hosts' focus injection seam without introducing another lifecycle.
6
+ * @example useNativeDialog({ open, title, onClose }, { initialFocus: () => cancelRef.current?.focus() })
7
+ */
4
8
  export function useNativeDialog(required, optional = {}) {
5
9
  const dialogRef = useRef(null), opener = useRef(null), titleId = useId();
6
10
  useImperativeHandle(required.ref, () => dialogRef.current, []);
@@ -13,7 +17,7 @@ export function useNativeDialog(required, optional = {}) {
13
17
  opener.current.focus({ preventScroll: true });
14
18
  return;
15
19
  }
16
- opener.current = document.activeElement;
20
+ opener.current = (optional.document ?? document).activeElement;
17
21
  if (typeof dialog.showModal === 'function') {
18
22
  if (!dialog.open)
19
23
  dialog.showModal();
@@ -58,7 +58,8 @@ export function useNativeMenu(required, _optional = {}) {
58
58
  document.addEventListener('pointerdown', dismiss);
59
59
  return () => document.removeEventListener('pointerdown', dismiss);
60
60
  }, [open]);
61
- function onKeyDown(event) {
61
+ // `current` is the item's position among enabled items, the same order focus() walks, so no DOM lookup is needed.
62
+ function onKeyDown(event, current) {
62
63
  if (event.key === 'Escape') {
63
64
  event.preventDefault();
64
65
  close();
@@ -68,7 +69,6 @@ export function useNativeMenu(required, _optional = {}) {
68
69
  setOpen(false);
69
70
  return;
70
71
  }
71
- const current = Array.from(menu.current?.querySelectorAll('[role="menuitem"]:not(:disabled)') ?? []).indexOf(event.target);
72
72
  const next = event.key === 'Home' ? 0 : event.key === 'End' ? enabled.length - 1 :
73
73
  event.key === 'ArrowDown' ? (current + 1) % enabled.length : event.key === 'ArrowUp' ? (current - 1 + enabled.length) % enabled.length : undefined;
74
74
  if (next !== undefined) {
@@ -81,7 +81,7 @@ export function useNativeMenu(required, _optional = {}) {
81
81
  onClick: () => { if (!item.disabled) {
82
82
  close();
83
83
  item.onPress({});
84
- } }, onKeyDown }, item.label));
84
+ } }, onKeyDown: (event) => onKeyDown(event, enabled.indexOf(item)) }, item.label));
85
85
  const menuProps = { ref: menu, id, role: 'menu', 'aria-label': required.label, hidden: !open, className: 'jini-row-menu-popup', 'data-jini-part': 'kit.menu', style: { position: 'fixed', ...position } };
86
86
  return { label: '⋮', items, popup: open ? createPortal(createElement('div', menuProps, items), document.body) : null,
87
87
  triggerProps: { 'data-jini-part': 'kit.menu-trigger', ...required.attrs, ref: trigger, type: 'button',
@@ -1,3 +1,4 @@
1
1
  import type { ReactKit } from '../types.js';
2
2
  export declare const nativeKit: ReactKit;
3
+ export { useNativeDialog } from './Dialog.hooks.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -6,4 +6,5 @@ export const nativeKit = Object.freeze({ Button: NativeButton, IconButton: Nativ
6
6
  Switch: NativeSwitch, Dialog: NativeDialog, ConfirmDialog: NativeConfirmDialog, Tabs: NativeTabs,
7
7
  Menu: NativeMenu, Toast: NativeToast, Tooltip: NativeTooltip, Notice: NativeNotice, Spinner: NativeSpinner, Badge: NativeBadge });
8
8
  // This is a concrete kit, rather than a forwarding subpath to another package's implementation.
9
+ export { useNativeDialog } from './Dialog.hooks.js';
9
10
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/ui-kit",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Framework-free UI contract, injected React facades and native defaults.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -51,11 +51,13 @@
51
51
  "dist",
52
52
  "src/react/native/styles.css",
53
53
  "README.md",
54
+ "CHANGELOG.md",
54
55
  "docs",
55
56
  "LICENSE",
56
57
  "!dist/**/__tests__/**",
57
58
  "!dist/**/*.test.*",
58
- "!dist/**/*.typecheck.*"
59
+ "!dist/**/*.typecheck.*",
60
+ "!dist/**/*.map"
59
61
  ],
60
62
  "publishConfig": {
61
63
  "access": "public",