@ensi-platform/admin-ui 0.8.2 → 0.8.5

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.
Files changed (34) hide show
  1. package/bin/ai.js +8682 -0
  2. package/dist/{Component-CDgOJr89.js → Component-B73be-FU.js} +2 -2
  3. package/dist/{Component-CDgOJr89.js.map → Component-B73be-FU.js.map} +1 -1
  4. package/dist/{Component-D25FKJAT.js → Component-BRHoDRtF.js} +2 -2
  5. package/dist/{Component-D25FKJAT.js.map → Component-BRHoDRtF.js.map} +1 -1
  6. package/dist/action-popup/index.js +1 -1
  7. package/dist/arrangement-settings/index.js +1 -1
  8. package/dist/bottom-sheet/index.js +1 -1
  9. package/dist/drawer/index.js +1 -1
  10. package/dist/hooks/index.js +1 -1
  11. package/dist/hooks/useOverlayExitComplete.d.ts +2 -1
  12. package/dist/hooks/useOverlayExitComplete.d.ts.map +1 -1
  13. package/dist/modal/index.js +1 -1
  14. package/dist/provider/Component.d.ts +3 -2
  15. package/dist/provider/Component.d.ts.map +1 -1
  16. package/dist/provider/index.js +50 -53
  17. package/dist/provider/index.js.map +1 -1
  18. package/dist/provider/types.d.ts +8 -2
  19. package/dist/provider/types.d.ts.map +1 -1
  20. package/dist/useOverlayExitComplete-Bra8dR0m.js +15 -0
  21. package/dist/useOverlayExitComplete-Bra8dR0m.js.map +1 -0
  22. package/docs/README.md +2 -2
  23. package/docs/ai.md +9 -9
  24. package/package.json +8 -8
  25. package/src/docs/ai/Description.md +9 -9
  26. package/src/provider/docs/Description.md +2 -1
  27. package/src/provider/types.ts +10 -2
  28. package/dist/useOverlayExitComplete-CwaErLze.js +0 -16
  29. package/dist/useOverlayExitComplete-CwaErLze.js.map +0 -1
  30. package/scripts/consumer-root.ts +0 -66
  31. package/scripts/sync-agents-consumer.ts +0 -81
  32. package/scripts/sync-consumer.ts +0 -31
  33. package/scripts/sync-skill-consumer.ts +0 -57
  34. /package/{docs/skills → ai/skills/admin-ui}/SKILL.md +0 -0
@@ -22,6 +22,7 @@ import { AdminUiProvider, useAuiLabels } from '@ensi-platform/admin-ui/provider'
22
22
  | `direction` | `ltr` \| `rtl` | from `locale` | text direction |
23
23
  | `labels` | `Partial<IAuiLabels>` | Russian strings | override built-in strings |
24
24
  | `linkComponent` | link component | `a` | app router (`href` is the item URL) |
25
- | `className` | `string` | — | root `div` |
25
+ | `as` | HTML element | `div` | root element. `body` is the document body |
26
+ | `className` | `string` | — | class on the root |
26
27
 
27
28
  Hooks: `useAuiLabels()`, `useAuiLocale()`, `useAuiDirection()`, `useAuiLink()`.
@@ -1,5 +1,7 @@
1
1
  import { type ComponentPropsWithRef, type ElementType, type ReactNode } from 'react';
2
2
 
3
+ import { type TMergeElementProps } from '@ds/common';
4
+
3
5
  export type TTextDirection = 'ltr' | 'rtl';
4
6
 
5
7
  /** Built-in a11y / UI label strings. */
@@ -86,9 +88,10 @@ export interface IAuiContextValue {
86
88
  linkComponent?: TAuiLinkComponent;
87
89
  }
88
90
 
89
- export interface IAdminUiProviderProps extends Omit<ComponentPropsWithRef<'div'>, 'children' | 'dir'> {
91
+ /** Own / chrome props (not from DOM). */
92
+ export interface IAdminUiProviderOwnProps {
90
93
  children: ReactNode;
91
- /** Text direction. Defaults to `ltr`. */
94
+ /** Text direction. Defaults to the locale direction. */
92
95
  direction?: TTextDirection;
93
96
  /** BCP 47 locale. */
94
97
  locale?: string;
@@ -97,3 +100,8 @@ export interface IAdminUiProviderProps extends Omit<ComponentPropsWithRef<'div'>
97
100
  /** Host router link for menu navigation. Defaults to `a`. */
98
101
  linkComponent?: TAuiLinkComponent;
99
102
  }
103
+
104
+ export type TAdminUiProviderProps<P extends ElementType = 'div'> = {
105
+ /** Root element. Defaults to `div`. */
106
+ as?: P;
107
+ } & Omit<TMergeElementProps<P, IAdminUiProviderOwnProps>, 'dir'>;
@@ -1,16 +0,0 @@
1
- import { useRef as f, useEffect as n } from "react";
2
- const a = (r, t, c) => {
3
- const e = f(!1), u = f(c);
4
- u.current = c, (r || t) && (e.current = !0), n(() => {
5
- !e.current || r || t || (e.current = !1, u.current?.());
6
- }, [r, t]), n(
7
- () => () => {
8
- e.current && (e.current = !1, u.current?.());
9
- },
10
- []
11
- );
12
- };
13
- export {
14
- a as u
15
- };
16
- //# sourceMappingURL=useOverlayExitComplete-CwaErLze.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useOverlayExitComplete-CwaErLze.js","sources":["../src/hooks/useOverlayExitComplete.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\n/**\n * Calls `onExitComplete` once after the overlay has been shown and then fully left\n * (`open === false` and `isExiting === false`), including when exit animation is skipped\n * or the overlay unmounts during exit.\n */\nexport const useOverlayExitComplete = (open: boolean, isExiting: boolean, onExitComplete?: () => void) => {\n const hadPresenceRef = useRef(false);\n const onExitCompleteRef = useRef(onExitComplete);\n onExitCompleteRef.current = onExitComplete;\n\n if (open || isExiting) {\n hadPresenceRef.current = true;\n }\n\n useEffect(() => {\n if (!hadPresenceRef.current || open || isExiting) {\n return;\n }\n\n hadPresenceRef.current = false;\n onExitCompleteRef.current?.();\n }, [open, isExiting]);\n\n useEffect(\n () => () => {\n if (!hadPresenceRef.current) {\n return;\n }\n\n hadPresenceRef.current = false;\n onExitCompleteRef.current?.();\n },\n []\n );\n};\n"],"names":["useOverlayExitComplete","open","isExiting","onExitComplete","hadPresenceRef","useRef","onExitCompleteRef","useEffect"],"mappings":";AAOO,MAAMA,IAAyB,CAACC,GAAeC,GAAoBC,MAAgC;AACtG,QAAMC,IAAiBC,EAAO,EAAK,GAC7BC,IAAoBD,EAAOF,CAAc;AAC/C,EAAAG,EAAkB,UAAUH,IAExBF,KAAQC,OACRE,EAAe,UAAU,KAG7BG,EAAU,MAAM;AACZ,IAAI,CAACH,EAAe,WAAWH,KAAQC,MAIvCE,EAAe,UAAU,IACzBE,EAAkB,UAAA;AAAA,EACtB,GAAG,CAACL,GAAMC,CAAS,CAAC,GAEpBK;AAAA,IACI,MAAM,MAAM;AACR,MAAKH,EAAe,YAIpBA,EAAe,UAAU,IACzBE,EAAkB,UAAA;AAAA,IACtB;AAAA,IACA,CAAA;AAAA,EAAC;AAET;"}
@@ -1,66 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import { dirname, join, resolve } from 'node:path';
3
-
4
- /** Env var to fully disable any consumer-repo sync (skills + AGENTS.md). */
5
- export const SKIP_ENV_VAR = 'ADMIN_UI_SKIP_CONSUMER_SYNC';
6
-
7
- /** Safety bound for walking up from `startDir` while looking for a `.git` root. */
8
- const MAX_ANCESTOR_DEPTH = 20;
9
-
10
- export type TRootStatus = 'skipped-env' | 'skipped-no-git-root' | 'skipped-dev-repo' | 'ok';
11
-
12
- export interface IConsumerRootResult {
13
- status: TRootStatus;
14
- consumerRoot?: string;
15
- }
16
-
17
- /** Walks up from `startDir` looking for the nearest ancestor that contains `.git`. */
18
- const findGitRoot = (startDir: string, maxDepth = MAX_ANCESTOR_DEPTH): string | undefined => {
19
- let dir = resolve(startDir);
20
-
21
- for (let i = 0; i < maxDepth; i += 1) {
22
- if (existsSync(join(dir, '.git'))) {
23
- return dir;
24
- }
25
-
26
- const parent = dirname(dir);
27
- if (parent === dir) {
28
- return undefined;
29
- }
30
-
31
- dir = parent;
32
- }
33
-
34
- return undefined;
35
- };
36
-
37
- /** True when `maybeChild` is `root` itself or nested inside it. */
38
- const isInsideOrEqual = (root: string, maybeChild: string): boolean => {
39
- const normalizedRoot = resolve(root);
40
- const normalizedChild = resolve(maybeChild);
41
-
42
- return normalizedChild === normalizedRoot || normalizedChild.startsWith(`${normalizedRoot}/`);
43
- };
44
-
45
- /**
46
- * Resolves the consumer repo root (nearest `.git` ancestor of `startDir`), guarding
47
- * against the package's own dev install and against a full opt-out env var.
48
- * Shared by skill sync and AGENTS.md sync so both agree on the same root.
49
- */
50
- export const resolveConsumerRoot = (packageRoot: string, startDir: string): IConsumerRootResult => {
51
- if (process.env[SKIP_ENV_VAR]) {
52
- return { status: 'skipped-env' };
53
- }
54
-
55
- const consumerRoot = findGitRoot(startDir);
56
- if (!consumerRoot) {
57
- return { status: 'skipped-no-git-root' };
58
- }
59
-
60
- // Running inside the admin-ui repo itself (dev install) — do not self-mirror.
61
- if (isInsideOrEqual(packageRoot, consumerRoot)) {
62
- return { status: 'skipped-dev-repo' };
63
- }
64
-
65
- return { status: 'ok', consumerRoot };
66
- };
@@ -1,81 +0,0 @@
1
- import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
- import { join } from 'node:path';
3
-
4
- import { resolveConsumerRoot } from './consumer-root.ts';
5
-
6
- const AGENTS_TARGET_RELATIVE = 'AGENTS.md';
7
-
8
- const BLOCK_START = '<!-- @ensi-platform/admin-ui:start -->';
9
- const BLOCK_END = '<!-- @ensi-platform/admin-ui:end -->';
10
-
11
- const BLOCK_BODY = [
12
- '## @ensi-platform/admin-ui',
13
- '',
14
- 'When building or changing Ensi admin screens, forms, filters, or overlays, use `@ensi-platform/admin-ui` primitives.',
15
- 'Before coding, read `node_modules/@ensi-platform/admin-ui/docs/ai.md` and the relevant',
16
- '`src/<name>/docs/Description.md` / `types.ts` — do not invent the API.',
17
- 'For whole screens (lists, filters, detail pages) also follow `node_modules/@ensi-platform/admin-ui/docs/design-language.md`.',
18
- ].join('\n');
19
-
20
- const buildBlock = (): string => `${BLOCK_START}\n${BLOCK_BODY}\n${BLOCK_END}`;
21
-
22
- const resolveSeparator = (existing: string): string => {
23
- if (existing.endsWith('\n\n')) {
24
- return '';
25
- }
26
-
27
- if (existing.endsWith('\n')) {
28
- return '\n';
29
- }
30
-
31
- return '\n\n';
32
- };
33
-
34
- /** Replaces the marked block if present, otherwise appends it; never touches the rest of the file. */
35
- const upsertBlock = (existing: string | undefined, block: string): string => {
36
- if (existing === undefined) {
37
- return `${block}\n`;
38
- }
39
-
40
- const startIndex = existing.indexOf(BLOCK_START);
41
- const endIndex = existing.indexOf(BLOCK_END);
42
-
43
- if (startIndex !== -1 && endIndex !== -1 && endIndex > startIndex) {
44
- const before = existing.slice(0, startIndex);
45
- const after = existing.slice(endIndex + BLOCK_END.length);
46
- return `${before}${block}${after}`;
47
- }
48
-
49
- return `${existing}${resolveSeparator(existing)}${block}\n`;
50
- };
51
-
52
- export type TAgentsSyncStatus = 'skipped-env' | 'skipped-no-git-root' | 'skipped-dev-repo' | 'written' | 'unchanged';
53
-
54
- export interface IAgentsSyncResult {
55
- status: TAgentsSyncStatus;
56
- targetPath?: string;
57
- }
58
-
59
- /**
60
- * Upserts a marker-delimited block in the consumer repo's `AGENTS.md`, so agents
61
- * without a Skills concept (Codex CLI, Copilot coding agent, …) still get a pointer
62
- * to `docs/ai.md`. Never overwrites content outside the marker block.
63
- */
64
- export const syncAgentsToConsumer = (packageRoot: string, startDir: string): IAgentsSyncResult => {
65
- const root = resolveConsumerRoot(packageRoot, startDir);
66
- if (root.status !== 'ok') {
67
- return { status: root.status };
68
- }
69
-
70
- const targetPath = join(root.consumerRoot as string, AGENTS_TARGET_RELATIVE);
71
- const existing = existsSync(targetPath) ? readFileSync(targetPath, 'utf8') : undefined;
72
- const nextContent = upsertBlock(existing, buildBlock());
73
-
74
- if (existing === nextContent) {
75
- return { status: 'unchanged', targetPath };
76
- }
77
-
78
- writeFileSync(targetPath, nextContent);
79
-
80
- return { status: 'written', targetPath };
81
- };
@@ -1,31 +0,0 @@
1
- import { dirname, resolve } from 'node:path';
2
- import { fileURLToPath, pathToFileURL } from 'node:url';
3
-
4
- import { syncAgentsToConsumer } from './sync-agents-consumer.ts';
5
- import { syncSkillToConsumer } from './sync-skill-consumer.ts';
6
-
7
- const isCli = process.argv[1] !== undefined && pathToFileURL(resolve(process.argv[1])).href === import.meta.url;
8
-
9
- if (isCli) {
10
- try {
11
- const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));
12
- const startDir = process.env.INIT_CWD || process.cwd();
13
-
14
- const skillResult = syncSkillToConsumer(packageRoot, startDir);
15
- if (skillResult.status === 'done') {
16
- skillResult.targets?.forEach(target => {
17
- if (target.status === 'written') {
18
- console.info(`[admin-ui] skill synced to ${target.targetPath}`);
19
- }
20
- });
21
- }
22
-
23
- const agentsResult = syncAgentsToConsumer(packageRoot, startDir);
24
- if (agentsResult.status === 'written') {
25
- console.info(`[admin-ui] AGENTS.md updated at ${agentsResult.targetPath}`);
26
- }
27
- } catch (error) {
28
- // Never let a sync failure break `pnpm install` for the consumer.
29
- console.warn('[admin-ui] consumer sync skipped:', error instanceof Error ? error.message : error);
30
- }
31
- }
@@ -1,57 +0,0 @@
1
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
- import { dirname, join } from 'node:path';
3
-
4
- import { resolveConsumerRoot } from './consumer-root.ts';
5
-
6
- /** Published skill doc inside this package. */
7
- const SKILL_SOURCE_RELATIVE = 'docs/skills/SKILL.md';
8
-
9
- /** Where skills-aware agents look for this skill in the consumer repo. */
10
- const SKILL_TARGETS_RELATIVE = ['.cursor/skills/admin-ui/SKILL.md', '.claude/skills/admin-ui/SKILL.md'];
11
-
12
- export interface ITargetResult {
13
- targetPath: string;
14
- status: 'written' | 'unchanged';
15
- }
16
-
17
- export type TSkillSyncStatus =
18
- 'skipped-env' | 'skipped-no-git-root' | 'skipped-dev-repo' | 'skipped-no-source' | 'done';
19
-
20
- export interface ISkillSyncResult {
21
- status: TSkillSyncStatus;
22
- targets?: ITargetResult[];
23
- }
24
-
25
- const writeIfChanged = (targetPath: string, content: string): ITargetResult => {
26
- if (existsSync(targetPath) && readFileSync(targetPath, 'utf8') === content) {
27
- return { targetPath, status: 'unchanged' };
28
- }
29
-
30
- mkdirSync(dirname(targetPath), { recursive: true });
31
- writeFileSync(targetPath, content);
32
-
33
- return { targetPath, status: 'written' };
34
- };
35
-
36
- /**
37
- * Copies the published skill doc into every known skills-aware agent directory
38
- * in the consumer repo (Cursor, Claude Code), so they pick it up without manual
39
- * setup. Never throws — a consumer's install must never fail because of this.
40
- */
41
- export const syncSkillToConsumer = (packageRoot: string, startDir: string): ISkillSyncResult => {
42
- const root = resolveConsumerRoot(packageRoot, startDir);
43
- if (root.status !== 'ok') {
44
- return { status: root.status };
45
- }
46
-
47
- const sourcePath = join(packageRoot, SKILL_SOURCE_RELATIVE);
48
- if (!existsSync(sourcePath)) {
49
- return { status: 'skipped-no-source' };
50
- }
51
-
52
- const content = readFileSync(sourcePath, 'utf8');
53
- const consumerRoot = root.consumerRoot as string;
54
- const targets = SKILL_TARGETS_RELATIVE.map(relative => writeIfChanged(join(consumerRoot, relative), content));
55
-
56
- return { status: 'done', targets };
57
- };
File without changes