@nan0web/ui 1.1.0 → 1.3.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.
Files changed (95) hide show
  1. package/README.md +19 -14
  2. package/package.json +6 -4
  3. package/src/App/Command/DepsCommand.js +5 -9
  4. package/src/App/Core/CoreApp.js +18 -17
  5. package/src/App/Core/UI.js +11 -15
  6. package/src/App/Core/Widget.js +6 -10
  7. package/src/App/Core/index.js +3 -3
  8. package/src/App/Scenario.js +4 -4
  9. package/src/App/User/Command/Message.js +1 -1
  10. package/src/App/User/Command/index.js +1 -1
  11. package/src/App/User/UserApp.js +28 -21
  12. package/src/App/User/UserUI.js +2 -2
  13. package/src/App/User/index.js +2 -2
  14. package/src/App/index.js +5 -10
  15. package/src/Component/Process/Input.js +10 -17
  16. package/src/Component/Process/Process.js +3 -5
  17. package/src/Component/Process/index.js +2 -2
  18. package/src/Component/SortableList/SortableList.js +100 -0
  19. package/src/Component/SortableList/index.js +3 -0
  20. package/src/Component/Welcome/Input.js +2 -4
  21. package/src/Component/Welcome/Welcome.js +5 -9
  22. package/src/Component/Welcome/index.js +2 -2
  23. package/src/Component/index.js +5 -3
  24. package/src/Frame/Frame.js +163 -146
  25. package/src/Frame/Props.js +20 -20
  26. package/src/Locale.js +17 -18
  27. package/src/Model/User/User.js +3 -6
  28. package/src/Model/index.js +1 -1
  29. package/src/README.md.js +84 -94
  30. package/src/StdIn.js +8 -12
  31. package/src/StdOut.js +23 -27
  32. package/src/View/RenderOptions.js +1 -1
  33. package/src/View/View.js +40 -36
  34. package/src/core/Error/CancelError.js +2 -2
  35. package/src/core/Error/index.js +3 -5
  36. package/src/core/Flow.js +347 -0
  37. package/src/core/Form/Form.js +35 -33
  38. package/src/core/Form/Input.js +21 -6
  39. package/src/core/Form/Message.js +3 -6
  40. package/src/core/Form/index.js +4 -8
  41. package/src/core/InputAdapter.js +4 -6
  42. package/src/core/Message/Message.js +9 -12
  43. package/src/core/Message/OutputMessage.js +19 -17
  44. package/src/core/Message/index.js +2 -2
  45. package/src/core/OutputAdapter.js +12 -10
  46. package/src/core/Stream.js +1 -1
  47. package/src/core/StreamEntry.js +2 -2
  48. package/src/core/UiAdapter.js +31 -30
  49. package/src/core/index.js +33 -10
  50. package/src/functions.js +8 -15
  51. package/src/index.js +21 -32
  52. package/types/App/Command/DepsCommand.d.ts +1 -1
  53. package/types/App/Command/Options.d.ts +37 -40
  54. package/types/App/Command/index.d.ts +6 -6
  55. package/types/App/Core/CoreApp.d.ts +2 -2
  56. package/types/App/Core/UI.d.ts +4 -4
  57. package/types/App/Core/Widget.d.ts +4 -4
  58. package/types/App/Core/index.d.ts +3 -3
  59. package/types/App/Scenario.d.ts +1 -1
  60. package/types/App/User/Command/Message.d.ts +1 -1
  61. package/types/App/User/Command/Options.d.ts +29 -29
  62. package/types/App/User/Command/index.d.ts +1 -1
  63. package/types/App/User/UserApp.d.ts +5 -5
  64. package/types/App/User/index.d.ts +2 -2
  65. package/types/App/index.d.ts +4 -4
  66. package/types/Component/Process/Process.d.ts +2 -2
  67. package/types/Component/Process/index.d.ts +2 -2
  68. package/types/Component/SortableList/SortableList.d.ts +58 -0
  69. package/types/Component/SortableList/index.d.ts +2 -0
  70. package/types/Component/Welcome/Input.d.ts +1 -1
  71. package/types/Component/Welcome/Welcome.d.ts +1 -1
  72. package/types/Component/Welcome/index.d.ts +2 -2
  73. package/types/Component/index.d.ts +5 -3
  74. package/types/Frame/Frame.d.ts +1 -1
  75. package/types/Frame/Props.d.ts +1 -1
  76. package/types/Model/index.d.ts +1 -1
  77. package/types/StdIn.d.ts +2 -2
  78. package/types/StdOut.d.ts +1 -1
  79. package/types/View/View.d.ts +7 -7
  80. package/types/core/Error/index.d.ts +1 -1
  81. package/types/core/Flow.d.ts +320 -0
  82. package/types/core/Form/Form.d.ts +2 -2
  83. package/types/core/Form/Input.d.ts +11 -0
  84. package/types/core/Form/Message.d.ts +1 -1
  85. package/types/core/Form/index.d.ts +3 -3
  86. package/types/core/InputAdapter.d.ts +2 -2
  87. package/types/core/Intent.d.ts +65 -68
  88. package/types/core/Message/InputMessage.d.ts +65 -65
  89. package/types/core/Message/Message.d.ts +1 -1
  90. package/types/core/Message/OutputMessage.d.ts +1 -1
  91. package/types/core/Message/index.d.ts +2 -2
  92. package/types/core/Stream.d.ts +1 -1
  93. package/types/core/UiAdapter.d.ts +5 -5
  94. package/types/core/index.d.ts +4 -3
  95. package/types/index.d.ts +10 -10
@@ -1,46 +1,43 @@
1
- export default CommandOptions;
1
+ export default CommandOptions
2
2
  /**
3
3
  * Represents command options with default values.
4
4
  * Provides utilities for handling command line options.
5
5
  */
6
6
  declare class CommandOptions {
7
- /**
8
- * Default option values.
9
- * @type {object}
10
- * @property {boolean} help - Whether help is requested
11
- * @property {string} cwd - Current working directory
12
- */
13
- static DEFAULTS: object;
14
- /**
15
- * Creates a CommandOptions instance from the given props.
16
- * @param {CommandOptions|object} props - The properties to create from
17
- * @returns {CommandOptions} A CommandOptions instance
18
- */
19
- static from(props: CommandOptions | object): CommandOptions;
20
- /**
21
- * Creates a new CommandOptions instance.
22
- * @param {object} props - The properties for command options
23
- * @param {boolean} [props.help=false] - Whether help is requested
24
- * @param {string} [props.cwd=""] - Current working directory
25
- */
26
- constructor(props?: {
27
- help?: boolean | undefined;
28
- cwd?: string | undefined;
29
- });
30
- /** @type {boolean} Whether help is requested */
31
- help: boolean;
32
- /** @type {string} Current working directory */
33
- cwd: string;
34
- /** @type {Record<string, any>} */
35
- get DEFAULTS(): Record<string, any>;
36
- /**
37
- * Checks if all options have their default values.
38
- * @returns {boolean} True if all options are at their default values, false otherwise
39
- */
40
- get empty(): boolean;
41
- /**
42
- * Converts the options to a string representation.
43
- * @returns {string} String representation of the options or "<no options>" if none set
44
- */
45
- toString(): string;
7
+ /**
8
+ * Default option values.
9
+ * @type {object}
10
+ * @property {boolean} help - Whether help is requested
11
+ * @property {string} cwd - Current working directory
12
+ */
13
+ static DEFAULTS: object
14
+ /**
15
+ * Creates a CommandOptions instance from the given props.
16
+ * @param {CommandOptions|object} props - The properties to create from
17
+ * @returns {CommandOptions} A CommandOptions instance
18
+ */
19
+ static from(props: CommandOptions | object): CommandOptions
20
+ /**
21
+ * Creates a new CommandOptions instance.
22
+ * @param {object} props - The properties for command options
23
+ * @param {boolean} [props.help=false] - Whether help is requested
24
+ * @param {string} [props.cwd=""] - Current working directory
25
+ */
26
+ constructor(props?: { help?: boolean | undefined; cwd?: string | undefined })
27
+ /** @type {boolean} Whether help is requested */
28
+ help: boolean
29
+ /** @type {string} Current working directory */
30
+ cwd: string
31
+ /** @type {Record<string, any>} */
32
+ get DEFAULTS(): Record<string, any>
33
+ /**
34
+ * Checks if all options have their default values.
35
+ * @returns {boolean} True if all options are at their default values, false otherwise
36
+ */
37
+ get empty(): boolean
38
+ /**
39
+ * Converts the options to a string representation.
40
+ * @returns {string} String representation of the options or "<no options>" if none set
41
+ */
42
+ toString(): string
46
43
  }
@@ -1,8 +1,8 @@
1
1
  declare namespace _default {
2
- export { CommandMessage as Message };
3
- export { CommandOptions as Options };
2
+ export { CommandMessage as Message }
3
+ export { CommandOptions as Options }
4
4
  }
5
- export default _default;
6
- import { CommandMessage } from "@nan0web/co";
7
- import CommandOptions from "./Options.js";
8
- export { CommandMessage, CommandOptions };
5
+ export default _default
6
+ import { CommandMessage } from '@nan0web/co'
7
+ import CommandOptions from './Options.js'
8
+ export { CommandMessage, CommandOptions }
@@ -66,5 +66,5 @@ export default class CoreApp {
66
66
  selectCommand(ui: UI): Promise<string>;
67
67
  }
68
68
  export type CommandFn = Function;
69
- import { Message } from "@nan0web/co";
70
- import UI from "./UI.js";
69
+ import { Message } from '@nan0web/co';
70
+ import UI from './UI.js';
@@ -32,7 +32,7 @@ export default class UI extends Widget {
32
32
  output(results: any[]): void;
33
33
  }
34
34
  export type ComponentFn = import("../../View/View.js").ComponentFn;
35
- import Widget from "./Widget.js";
36
- import CoreApp from "./CoreApp.js";
37
- import { Message } from "@nan0web/co";
38
- import View from "../../View/View.js";
35
+ import Widget from './Widget.js';
36
+ import CoreApp from './CoreApp.js';
37
+ import { Message } from '@nan0web/co';
38
+ import View from '../../View/View.js';
@@ -33,7 +33,7 @@ export default class Widget extends EventProcessor {
33
33
  render(viewFnOrName: Function | string, outputData: object): any;
34
34
  }
35
35
  export type ComponentFn = import("./UI.js").ComponentFn;
36
- import EventProcessor from "@nan0web/event/oop";
37
- import View from "../../View/View.js";
38
- import { UiMessage } from "../../core/index.js";
39
- import { StreamEntry } from "@nan0web/db";
36
+ import EventProcessor from '@nan0web/event/oop';
37
+ import View from '../../View/View.js';
38
+ import { UiMessage } from '../../core/index.js';
39
+ import { StreamEntry } from '@nan0web/db';
@@ -4,7 +4,7 @@ declare namespace _default {
4
4
  export { Widget };
5
5
  }
6
6
  export default _default;
7
- import CoreApp from "./CoreApp.js";
8
- import UI from "./UI.js";
9
- import Widget from "./Widget.js";
7
+ import CoreApp from './CoreApp.js';
8
+ import UI from './UI.js';
9
+ import Widget from './Widget.js';
10
10
  export { CoreApp, UI };
@@ -23,4 +23,4 @@ export default class Scenario {
23
23
  run(inputCommands: Array<any[]>, expectedOutputs: Array<any>): Promise<boolean>;
24
24
  }
25
25
  export type CoreApp = import("./Core/CoreApp.js").default;
26
- import UI from "./Core/UI.js";
26
+ import UI from './Core/UI.js';
@@ -1,2 +1,2 @@
1
1
  export default UiMessage;
2
- import UiMessage from "../../../core/Message/Message.js";
2
+ import UiMessage from '../../../core/Message/Message.js';
@@ -1,34 +1,34 @@
1
- export default UserAppCommandOptions;
1
+ export default UserAppCommandOptions
2
2
  /**
3
3
  * Extends CommandOptions to include user-specific options.
4
4
  */
5
5
  declare class UserAppCommandOptions {
6
- /**
7
- * Default option values including inherited ones.
8
- * @type {object}
9
- * @property {boolean} help - Whether help is requested
10
- * @property {string} cwd - Current working directory
11
- * @property {string} user - User name
12
- */
13
- static DEFAULTS: object;
14
- /**
15
- * Creates a UserAppCommandOptions instance from the given props.
16
- * @param {UserAppCommandOptions|object} props - The properties to create from
17
- * @returns {UserAppCommandOptions} A UserAppCommandOptions instance
18
- */
19
- static from(props: UserAppCommandOptions | object): UserAppCommandOptions;
20
- /**
21
- * Creates a new UserAppCommandOptions instance.
22
- * @param {object} props - Options properties
23
- * @param {boolean} [props.help=false] - Whether help is requested
24
- * @param {string} [props.cwd=""] - Current working directory
25
- * @param {string} [props.user=""] - User name
26
- */
27
- constructor(props?: {
28
- help?: boolean | undefined;
29
- cwd?: string | undefined;
30
- user?: string | undefined;
31
- });
32
- /** @type {string} User name */
33
- user: string;
6
+ /**
7
+ * Default option values including inherited ones.
8
+ * @type {object}
9
+ * @property {boolean} help - Whether help is requested
10
+ * @property {string} cwd - Current working directory
11
+ * @property {string} user - User name
12
+ */
13
+ static DEFAULTS: object
14
+ /**
15
+ * Creates a UserAppCommandOptions instance from the given props.
16
+ * @param {UserAppCommandOptions|object} props - The properties to create from
17
+ * @returns {UserAppCommandOptions} A UserAppCommandOptions instance
18
+ */
19
+ static from(props: UserAppCommandOptions | object): UserAppCommandOptions
20
+ /**
21
+ * Creates a new UserAppCommandOptions instance.
22
+ * @param {object} props - Options properties
23
+ * @param {boolean} [props.help=false] - Whether help is requested
24
+ * @param {string} [props.cwd=""] - Current working directory
25
+ * @param {string} [props.user=""] - User name
26
+ */
27
+ constructor(props?: {
28
+ help?: boolean | undefined
29
+ cwd?: string | undefined
30
+ user?: string | undefined
31
+ })
32
+ /** @type {string} User name */
33
+ user: string
34
34
  }
@@ -1,3 +1,3 @@
1
1
  export { CommandMessage };
2
2
  export default CommandMessage;
3
- import CommandMessage from "./Message.js";
3
+ import CommandMessage from './Message.js';
@@ -34,8 +34,8 @@ export default class UserApp extends CoreApp {
34
34
  welcome(cmd: UserAppCommandMessage, ui: UserUI): Promise<string[][]>;
35
35
  user: User | undefined;
36
36
  }
37
- import CoreApp from "../Core/CoreApp.js";
38
- import DepsCommand from "./Command/Message.js";
39
- import UserUI from "./UserUI.js";
40
- import UserAppCommandMessage from "./Command/Message.js";
41
- import User from "../../Model/User/User.js";
37
+ import CoreApp from '../Core/CoreApp.js';
38
+ import DepsCommand from './Command/Message.js';
39
+ import UserUI from './UserUI.js';
40
+ import UserAppCommandMessage from './Command/Message.js';
41
+ import User from '../../Model/User/User.js';
@@ -3,6 +3,6 @@ declare namespace _default {
3
3
  export { UserUI as UI };
4
4
  }
5
5
  export default _default;
6
- import UserApp from "./UserApp.js";
7
- import UserUI from "./UserUI.js";
6
+ import UserApp from './UserApp.js';
7
+ import UserUI from './UserUI.js';
8
8
  export { UserApp, UserUI };
@@ -5,8 +5,8 @@ declare namespace _default {
5
5
  export { UI };
6
6
  }
7
7
  export default _default;
8
- import Core from "./Core/index.js";
9
- import User from "./User/index.js";
10
- import Scenario from "./Scenario.js";
11
- import UI from "./Core/UI.js";
8
+ import Core from './Core/index.js';
9
+ import User from './User/index.js';
10
+ import Scenario from './Scenario.js';
11
+ import UI from './Core/UI.js';
12
12
  export { Core, User, Scenario, UI };
@@ -9,5 +9,5 @@ declare function Process(this: View, props?: ProcessInput | object): string[][];
9
9
  declare namespace Process {
10
10
  export { ProcessInput as Input };
11
11
  }
12
- import ProcessInput from "./Input.js";
13
- import View from "../../View/View.js";
12
+ import ProcessInput from './Input.js';
13
+ import View from '../../View/View.js';
@@ -1,4 +1,4 @@
1
1
  export default Process;
2
2
  export { ProcessInput };
3
- import Process from "./Process.js";
4
- import ProcessInput from "./Input.js";
3
+ import Process from './Process.js';
4
+ import ProcessInput from './Input.js';
@@ -0,0 +1,58 @@
1
+ export default SortableList;
2
+ /**
3
+ * Headless Sortable List — pure data model with callbacks.
4
+ * Platform-agnostic: works in Node.js, browser, CLI, anywhere.
5
+ *
6
+ * @example
7
+ * const list = SortableList.create({
8
+ * items: ['a', 'b', 'c'],
9
+ * onChange: (items) => console.log(items),
10
+ * })
11
+ * list.moveUp(1) // ['b', 'a', 'c']
12
+ */
13
+ declare class SortableList {
14
+ /**
15
+ * Factory method.
16
+ * @param {object} opts
17
+ * @returns {SortableList}
18
+ */
19
+ static create(opts: object): SortableList;
20
+ /**
21
+ * @param {object} [opts]
22
+ * @param {any[]} [opts.items]
23
+ * @param {function} [opts.onChange]
24
+ */
25
+ constructor({ items, onChange }?: {
26
+ items?: any[] | undefined;
27
+ onChange?: Function | undefined;
28
+ });
29
+ /**
30
+ * Move item at index up (swap with previous).
31
+ * No-op if already at top.
32
+ * @param {number} index
33
+ */
34
+ moveUp(index: number): void;
35
+ /**
36
+ * Move item at index down (swap with next).
37
+ * No-op if already at bottom.
38
+ * @param {number} index
39
+ */
40
+ moveDown(index: number): void;
41
+ /**
42
+ * Returns a copy of the current item order.
43
+ * @returns {any[]}
44
+ */
45
+ getItems(): any[];
46
+ /**
47
+ * Move item from one position to another (drag-n-drop).
48
+ * No-op if indices are equal or out of bounds.
49
+ * @param {number} from - source index
50
+ * @param {number} to - target index
51
+ */
52
+ moveTo(from: number, to: number): void;
53
+ /**
54
+ * Restores the initial order.
55
+ */
56
+ reset(): void;
57
+ #private;
58
+ }
@@ -0,0 +1,2 @@
1
+ export default SortableList;
2
+ import SortableList from './SortableList.js';
@@ -31,4 +31,4 @@ declare class WelcomeInput {
31
31
  */
32
32
  toString(): string;
33
33
  }
34
- import { User } from "../../Model/index.js";
34
+ import { User } from '../../Model/index.js';
@@ -10,4 +10,4 @@ declare namespace Welcome {
10
10
  export { WelcomeInput as Input };
11
11
  export function ask(): Promise<string>;
12
12
  }
13
- import WelcomeInput from "./Input.js";
13
+ import WelcomeInput from './Input.js';
@@ -1,4 +1,4 @@
1
1
  export default Welcome;
2
2
  export { WelcomeInput };
3
- import Welcome from "./Welcome.js";
4
- import WelcomeInput from "./Input.js";
3
+ import Welcome from './Welcome.js';
4
+ import WelcomeInput from './Input.js';
@@ -1,8 +1,10 @@
1
1
  declare namespace _default {
2
2
  export { Welcome };
3
3
  export { Process };
4
+ export { SortableList };
4
5
  }
5
6
  export default _default;
6
- import Welcome from "./Welcome/index.js";
7
- import Process from "./Process/index.js";
8
- export { Welcome, Process };
7
+ import Welcome from './Welcome/index.js';
8
+ import Process from './Process/index.js';
9
+ import SortableList from './SortableList/index.js';
10
+ export { Welcome, Process, SortableList };
@@ -183,4 +183,4 @@ export default class Frame {
183
183
  setWindowSize(width: number, height: number): void;
184
184
  #private;
185
185
  }
186
- import FrameProps from "./Props.js";
186
+ import FrameProps from './Props.js';
@@ -74,4 +74,4 @@ declare class FrameProps extends ObjectWithAlias {
74
74
  /** @type {boolean} Strikethrough text flag */
75
75
  strikethrough: boolean;
76
76
  }
77
- import { ObjectWithAlias } from "@nan0web/types";
77
+ import { ObjectWithAlias } from '@nan0web/types';
@@ -3,4 +3,4 @@ declare namespace _default {
3
3
  export { User };
4
4
  }
5
5
  export default _default;
6
- import User from "./User/User.js";
6
+ import User from './User/User.js';
package/types/StdIn.d.ts CHANGED
@@ -55,8 +55,8 @@ export default class StdIn extends EventProcessor {
55
55
  */
56
56
  decode(message: UiMessage | string[] | any): UiMessage;
57
57
  }
58
- import EventProcessor from "@nan0web/event/oop";
59
- import { UiMessage } from "./core/index.js";
58
+ import EventProcessor from '@nan0web/event/oop';
59
+ import { UiMessage } from './core/index.js';
60
60
  declare class Processor extends EventProcessor {
61
61
  }
62
62
  export {};
package/types/StdOut.d.ts CHANGED
@@ -49,4 +49,4 @@ declare class StdOut extends EventProcessor {
49
49
  */
50
50
  getWindowSize(): number[];
51
51
  }
52
- import EventProcessor from "@nan0web/event/oop";
52
+ import EventProcessor from '@nan0web/event/oop';
@@ -106,10 +106,10 @@ export type ComponentFn = {
106
106
  ask: (input: UiMessage) => Promise<any>;
107
107
  bind: Function;
108
108
  };
109
- import StdIn from "../StdIn.js";
110
- import StdOut from "../StdOut.js";
111
- import Frame from "../Frame/Frame.js";
112
- import Locale from "../Locale.js";
113
- import { FrameRenderMethod } from "../Frame/Frame.js";
114
- import RenderOptions from "./RenderOptions.js";
115
- import UiMessage from "../core/Message/Message.js";
109
+ import StdIn from '../StdIn.js';
110
+ import StdOut from '../StdOut.js';
111
+ import Frame from '../Frame/Frame.js';
112
+ import Locale from '../Locale.js';
113
+ import { FrameRenderMethod } from '../Frame/Frame.js';
114
+ import RenderOptions from './RenderOptions.js';
115
+ import UiMessage from '../core/Message/Message.js';
@@ -3,4 +3,4 @@ declare namespace _default {
3
3
  export { CancelError };
4
4
  }
5
5
  export default _default;
6
- import CancelError from "./CancelError.js";
6
+ import CancelError from './CancelError.js';