@jini-ai/ui-kit 0.6.17 → 0.6.23
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 +8 -0
- package/dist/attrs.d.ts +13 -0
- package/dist/attrs.js +12 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/react/SecretInput.js +2 -1
- package/dist/react/native/Controls.hooks.d.ts +4 -0
- package/dist/react/native/Controls.hooks.js +6 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/attrs.d.ts
CHANGED
|
@@ -15,4 +15,17 @@ export type AgentAttrsPort = (required: {
|
|
|
15
15
|
role?: AgentSpec['role'];
|
|
16
16
|
label?: string;
|
|
17
17
|
}) => KitAttrs;
|
|
18
|
+
/**
|
|
19
|
+
* Keeps ordinary control props while excluding agent addressing from a semantic secret, including
|
|
20
|
+
* after reveal changes its native input type. Caller metadata cannot override the private marker.
|
|
21
|
+
* @param required.attrs - Input or reveal-control props; never mutated.
|
|
22
|
+
* @returns A fresh props object with only the enforced agent privacy marker.
|
|
23
|
+
* @complexity O(n) time and space in the number of supplied props; no I/O or effects.
|
|
24
|
+
* @overallScore 100
|
|
25
|
+
*/
|
|
26
|
+
export declare function secretControlAttrs<T extends object>({ attrs }: {
|
|
27
|
+
attrs: T;
|
|
28
|
+
}, _optional?: Record<string, never>): Omit<T, `data-agent-${string}`> & {
|
|
29
|
+
'data-agent-private': '';
|
|
30
|
+
};
|
|
18
31
|
//# sourceMappingURL=attrs.d.ts.map
|
package/dist/attrs.js
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Keeps ordinary control props while excluding agent addressing from a semantic secret, including
|
|
3
|
+
* after reveal changes its native input type. Caller metadata cannot override the private marker.
|
|
4
|
+
* @param required.attrs - Input or reveal-control props; never mutated.
|
|
5
|
+
* @returns A fresh props object with only the enforced agent privacy marker.
|
|
6
|
+
* @complexity O(n) time and space in the number of supplied props; no I/O or effects.
|
|
7
|
+
* @overallScore 100
|
|
8
|
+
*/
|
|
9
|
+
export function secretControlAttrs({ attrs }, _optional = {}) {
|
|
10
|
+
const ordinary = Object.entries(attrs).filter(([name]) => !name.toLowerCase().startsWith('data-agent-'));
|
|
11
|
+
return { ...Object.fromEntries(ordinary), 'data-agent-private': '' };
|
|
12
|
+
}
|
|
2
13
|
//# sourceMappingURL=attrs.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { KIT_CONTRACT, kitSpec, kitParts, implementedComponents } from './kit-contract.js';
|
|
2
2
|
export type { KitComponentName, ImplementedComponentName, KitPart } from './kit-contract.js';
|
|
3
3
|
export type { KitAttrs, AgentSpec, AgentAttrsPort } from './attrs.js';
|
|
4
|
+
export { secretControlAttrs } from './attrs.js';
|
|
4
5
|
export { needs, assertKitContract, KitConfigError } from './needs.js';
|
|
5
6
|
export type { KitNeeds } from './needs.js';
|
|
6
7
|
export { planConfirm, createConfirmController } from './confirm.js';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { KIT_CONTRACT, kitSpec, kitParts, implementedComponents } from './kit-contract.js';
|
|
2
|
+
export { secretControlAttrs } from './attrs.js';
|
|
2
3
|
export { needs, assertKitContract, KitConfigError } from './needs.js';
|
|
3
4
|
export { planConfirm, createConfirmController } from './confirm.js';
|
|
4
5
|
export { createToastService } from './toast.js';
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { useSecretReveal } from './secret-reveal.hooks.js';
|
|
4
4
|
import { eyeIcon } from './native/Controls.hooks.js';
|
|
5
|
+
import { secretControlAttrs } from '../attrs.js';
|
|
5
6
|
/** Masked native input with controlled or local reveal state. Keep its toggle outside a label:
|
|
6
7
|
* the toggle's name must never join the input's accessible name. Hosts own styling and copy.
|
|
7
8
|
* @complexity O(1). */
|
|
@@ -9,6 +10,6 @@ export const SecretInput = forwardRef(function SecretInput(props, ref) {
|
|
|
9
10
|
// The toggle props are pulled off so they never reach the DOM `<input>`.
|
|
10
11
|
const { label, toggleLabels, toggleAttrs, revealed, onRevealedChange, ...inputProps } = props;
|
|
11
12
|
const reveal = useSecretReveal({ value: inputProps.value, labels: toggleLabels ?? { show: `Show ${label}`, hide: `Hide ${label}` } }, { ...(revealed === undefined ? {} : { revealed }), ...(onRevealedChange ? { onRevealedChange } : {}) });
|
|
12
|
-
return _jsxs("span", { className: "jini-secret", children: [_jsx("input", { ...inputProps, spellCheck: false, ref: ref, type: reveal.inputType }), _jsx("button", { ...toggleAttrs, type: "button", className: "jini-secret-toggle", "aria-label": reveal.toggleLabel, title: reveal.toggleLabel, disabled: inputProps.disabled, onClick: reveal.toggle, children: eyeIcon({ revealed: reveal.revealed }) })] });
|
|
13
|
+
return _jsxs("span", { className: "jini-secret", children: [_jsx("input", { ...secretControlAttrs({ attrs: inputProps }), spellCheck: false, ref: ref, type: reveal.inputType }), _jsx("button", { ...secretControlAttrs({ attrs: toggleAttrs ?? {} }), type: "button", className: "jini-secret-toggle", "aria-label": reveal.toggleLabel, title: reveal.toggleLabel, disabled: inputProps.disabled, onClick: reveal.toggle, children: eyeIcon({ revealed: reveal.revealed }) })] });
|
|
13
14
|
});
|
|
14
15
|
//# sourceMappingURL=SecretInput.js.map
|
|
@@ -34,8 +34,12 @@ export declare function useNativeIconButton(required: IconButtonProps, _optional
|
|
|
34
34
|
export declare function eyeIcon(required: {
|
|
35
35
|
revealed: boolean;
|
|
36
36
|
}, _optional?: Record<string, never>): import("react").ReactSVGElement;
|
|
37
|
+
/** Maps native field props; a revealed password remains a private secret rather than a text field.
|
|
38
|
+
* @complexity O(p) time and space in secret field props; O(1) for ordinary fields.
|
|
39
|
+
* @overallScore 100 */
|
|
37
40
|
export declare function useNativeTextField(required: TextFieldProps, _optional?: Record<string, never>): {
|
|
38
41
|
toggle: {
|
|
42
|
+
'data-agent-private': string;
|
|
39
43
|
'data-jini-part': string;
|
|
40
44
|
className: string;
|
|
41
45
|
type: "button";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createElement, useId, useState } from 'react';
|
|
2
|
+
import { secretControlAttrs } from '../../attrs.js';
|
|
2
3
|
export function useNativeButton(required, _optional = {}) {
|
|
3
4
|
const readyState = required.disabled ? 'disabled' : 'ready';
|
|
4
5
|
return { children: required.children, props: { 'data-jini-part': 'kit.button', ref: required.ref, className: `jini-btn jini-btn-${required.variant ?? 'primary'} ${required.className ?? ''}`.trim(),
|
|
@@ -44,14 +45,17 @@ function useSecretReveal(required, _optional = {}) {
|
|
|
44
45
|
return { type: required.type ?? 'text', toggle: null };
|
|
45
46
|
// The name flips Show/Hide; no `aria-pressed` on top, or screen readers hear the state twice.
|
|
46
47
|
const labels = required.secretToggleLabels ?? { show: `Show ${required.label}`, hide: `Hide ${required.label}` };
|
|
47
|
-
return { type: revealed ? 'text' : 'password', toggle: { 'data-jini-part': 'kit.secret-toggle', className: 'jini-secret-toggle', type: 'button',
|
|
48
|
+
return { type: revealed ? 'text' : 'password', toggle: { 'data-agent-private': '', 'data-jini-part': 'kit.secret-toggle', className: 'jini-secret-toggle', type: 'button',
|
|
48
49
|
'aria-label': revealed ? labels.hide : labels.show, disabled: required.disabled,
|
|
49
50
|
onClick: () => setRevealed(shown => !shown), children: eyeIcon({ revealed }) } };
|
|
50
51
|
}
|
|
52
|
+
/** Maps native field props; a revealed password remains a private secret rather than a text field.
|
|
53
|
+
* @complexity O(p) time and space in secret field props; O(1) for ordinary fields.
|
|
54
|
+
* @overallScore 100 */
|
|
51
55
|
export function useNativeTextField(required, _optional = {}) {
|
|
52
56
|
const vm = useField(required);
|
|
53
57
|
const reveal = useSecretReveal(required);
|
|
54
|
-
return { ...vm, toggle: reveal.toggle, props: { ...vm.props, id: vm.id, ref: required.ref, type: reveal.type, value: required.value,
|
|
58
|
+
return { ...vm, toggle: reveal.toggle, props: { ...(reveal.toggle ? secretControlAttrs({ attrs: vm.props }) : vm.props), id: vm.id, ref: required.ref, type: reveal.type, value: required.value,
|
|
55
59
|
// Off on a secret: once revealed as type="text", enhanced spellcheck would send it to a cloud service.
|
|
56
60
|
spellCheck: reveal.toggle ? false : undefined,
|
|
57
61
|
placeholder: required.placeholder, onChange: (event) => {
|