@nan0web/ui 1.12.2 → 3.1.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 (160) hide show
  1. package/README.md +18 -355
  2. package/package.json +36 -22
  3. package/src/Component/index.js +1 -5
  4. package/src/Model/Element.js +183 -0
  5. package/src/Model/index.js +2 -2
  6. package/src/Theme/AppTheme.js +19 -0
  7. package/src/Theme/CustomTheme.js +32 -0
  8. package/src/Theme/DarkLightTheme.js +34 -0
  9. package/src/Theme/Theme.js +25 -0
  10. package/src/Theme/atoms/Avatar.js +20 -0
  11. package/src/Theme/atoms/Badge.js +28 -0
  12. package/src/Theme/atoms/Button.js +88 -0
  13. package/src/Theme/atoms/Checkbox.js +26 -0
  14. package/src/Theme/atoms/Input.js +28 -0
  15. package/src/Theme/atoms/Radio.js +26 -0
  16. package/src/Theme/atoms/Select.js +16 -0
  17. package/src/Theme/atoms/TextArea.js +17 -0
  18. package/src/Theme/atoms/Typography.js +26 -0
  19. package/src/Theme/atoms/index.js +11 -0
  20. package/src/Theme/createTheme.js +22 -0
  21. package/src/Theme/index.js +20 -0
  22. package/src/Theme/molecules/Card.js +24 -0
  23. package/src/Theme/molecules/index.js +3 -0
  24. package/src/Theme/organisms/Modal.js +24 -0
  25. package/src/Theme/organisms/index.js +3 -0
  26. package/src/Theme/presets/HighContrastTheme.js +65 -0
  27. package/src/Theme/presets/NightTheme.js +66 -0
  28. package/src/Theme/presets/index.js +4 -0
  29. package/src/Theme/tokens.js +115 -0
  30. package/src/core/InputAdapter.js +1 -2
  31. package/src/core/Intent.js +22 -8
  32. package/src/core/Message/Message.js +3 -0
  33. package/src/core/OutputAdapter.js +9 -13
  34. package/src/core/index.js +7 -4
  35. package/src/core/resolvePositionalArgs.js +51 -0
  36. package/src/domain/Content.js +5 -5
  37. package/src/domain/Document.js +1 -1
  38. package/src/domain/HeroModel.js +1 -1
  39. package/src/domain/ModelAsApp.js +310 -20
  40. package/src/domain/ModelAsApp.story.js +117 -0
  41. package/src/domain/app/GalleryCommand.js +9 -8
  42. package/src/domain/app/{GalleryRenderIntent.js → GalleryRenderCommand.js} +20 -20
  43. package/src/domain/app/IntentAuditor.js +53 -0
  44. package/src/domain/app/JsIntentAuditor.js +145 -0
  45. package/src/domain/app/PyIntentAuditor.js +144 -0
  46. package/src/domain/app/SnapshotAuditor.js +82 -86
  47. package/src/domain/app/SnapshotRunner.js +1 -1
  48. package/src/domain/app/UIApp.js +12 -21
  49. package/src/domain/components/ShellModel.js +2 -2
  50. package/src/index.js +38 -10
  51. package/src/inspect.js +4 -0
  52. package/src/testing/SnapshotRunner.js +2 -1
  53. package/src/utils/format.js +21 -0
  54. package/src/utils/processI18n.js +27 -0
  55. package/src/utils/resolveContext.js +79 -0
  56. package/types/Component/index.d.ts +1 -5
  57. package/types/Model/Element.d.ts +87 -0
  58. package/types/Model/index.d.ts +2 -2
  59. package/types/Theme/AppTheme.d.ts +14 -0
  60. package/types/Theme/CustomTheme.d.ts +21 -0
  61. package/types/Theme/DarkLightTheme.d.ts +16 -0
  62. package/types/Theme/Theme.d.ts +18 -0
  63. package/types/Theme/atoms/Avatar.d.ts +14 -0
  64. package/types/Theme/atoms/Badge.d.ts +22 -0
  65. package/types/Theme/atoms/Button.d.ts +144 -0
  66. package/types/Theme/atoms/Checkbox.d.ts +20 -0
  67. package/types/Theme/atoms/Input.d.ts +22 -0
  68. package/types/Theme/atoms/Radio.d.ts +20 -0
  69. package/types/Theme/atoms/Select.d.ts +15 -0
  70. package/types/Theme/atoms/TextArea.d.ts +17 -0
  71. package/types/Theme/atoms/Typography.d.ts +47 -0
  72. package/types/Theme/atoms/index.d.ts +10 -0
  73. package/types/Theme/createTheme.d.ts +7 -0
  74. package/types/Theme/index.d.ts +10 -0
  75. package/types/Theme/molecules/Card.d.ts +18 -0
  76. package/types/Theme/molecules/index.d.ts +2 -0
  77. package/types/Theme/organisms/Modal.d.ts +18 -0
  78. package/types/Theme/organisms/index.d.ts +2 -0
  79. package/types/Theme/presets/HighContrastTheme.d.ts +2 -0
  80. package/types/Theme/presets/NightTheme.d.ts +2 -0
  81. package/types/Theme/presets/index.d.ts +3 -0
  82. package/types/Theme/tokens.d.ts +119 -0
  83. package/types/core/Intent.d.ts +10 -7
  84. package/types/core/Message/Message.d.ts +3 -0
  85. package/types/core/OutputAdapter.d.ts +2 -4
  86. package/types/core/index.d.ts +5 -2
  87. package/types/core/resolvePositionalArgs.d.ts +24 -0
  88. package/types/docs/README.md.d.ts +1 -0
  89. package/types/domain/Content.d.ts +2 -2
  90. package/types/domain/Document.d.ts +4 -3
  91. package/types/domain/FooterModel.d.ts +2 -1
  92. package/types/domain/HeroModel.d.ts +2 -2
  93. package/types/domain/ModelAsApp.d.ts +49 -5
  94. package/types/domain/ModelAsApp.story.d.ts +1 -0
  95. package/types/domain/app/GalleryCommand.d.ts +6 -37
  96. package/types/domain/app/GalleryRenderCommand.d.ts +27 -0
  97. package/types/domain/app/IntentAuditor.d.ts +23 -0
  98. package/types/domain/app/JsIntentAuditor.d.ts +22 -0
  99. package/types/domain/app/PyIntentAuditor.d.ts +22 -0
  100. package/types/domain/app/SnapshotAuditor.d.ts +34 -25
  101. package/types/domain/app/SnapshotRunner.d.ts +2 -2
  102. package/types/domain/app/UIApp.d.ts +14 -11
  103. package/types/domain/components/ShellModel.d.ts +1 -5
  104. package/types/index.d.ts +10 -10
  105. package/types/inspect.d.ts +4 -0
  106. package/types/testing/verifySnapshot.d.ts +1 -1
  107. package/types/utils/format.d.ts +5 -0
  108. package/types/utils/processI18n.d.ts +8 -0
  109. package/types/utils/resolveContext.d.ts +21 -0
  110. package/src/App/Command/DepsCommand.js +0 -24
  111. package/src/App/Core/CoreApp.js +0 -125
  112. package/src/App/Core/UI.js +0 -63
  113. package/src/App/Core/Widget.js +0 -61
  114. package/src/App/Core/index.js +0 -11
  115. package/src/App/Scenario.js +0 -45
  116. package/src/App/User/Command/Message.js +0 -3
  117. package/src/App/User/Command/index.js +0 -5
  118. package/src/App/User/UserApp.js +0 -85
  119. package/src/App/User/UserUI.js +0 -20
  120. package/src/App/User/index.js +0 -9
  121. package/src/App/index.js +0 -14
  122. package/src/Component/Process/Input.js +0 -63
  123. package/src/Component/Process/Process.js +0 -24
  124. package/src/Component/Process/index.js +0 -5
  125. package/src/Component/Welcome/Input.js +0 -48
  126. package/src/Component/Welcome/Welcome.js +0 -22
  127. package/src/Component/Welcome/index.js +0 -5
  128. package/src/Frame/Frame.js +0 -608
  129. package/src/Frame/Props.js +0 -96
  130. package/src/StdIn.js +0 -100
  131. package/src/StdOut.js +0 -95
  132. package/src/View/RenderOptions.js +0 -48
  133. package/src/View/View.js +0 -306
  134. package/src/core/Message/index.js +0 -6
  135. package/types/App/Command/DepsCommand.d.ts +0 -14
  136. package/types/App/Core/CoreApp.d.ts +0 -70
  137. package/types/App/Core/UI.d.ts +0 -38
  138. package/types/App/Core/Widget.d.ts +0 -39
  139. package/types/App/Core/index.d.ts +0 -10
  140. package/types/App/Scenario.d.ts +0 -26
  141. package/types/App/User/Command/Message.d.ts +0 -2
  142. package/types/App/User/Command/index.d.ts +0 -3
  143. package/types/App/User/UserApp.d.ts +0 -41
  144. package/types/App/User/UserUI.d.ts +0 -9
  145. package/types/App/User/index.d.ts +0 -8
  146. package/types/App/index.d.ts +0 -12
  147. package/types/Component/Process/Input.d.ts +0 -48
  148. package/types/Component/Process/Process.d.ts +0 -13
  149. package/types/Component/Process/index.d.ts +0 -4
  150. package/types/Component/Welcome/Input.d.ts +0 -34
  151. package/types/Component/Welcome/Welcome.d.ts +0 -13
  152. package/types/Component/Welcome/index.d.ts +0 -4
  153. package/types/Frame/Frame.d.ts +0 -186
  154. package/types/Frame/Props.d.ts +0 -77
  155. package/types/StdIn.d.ts +0 -62
  156. package/types/StdOut.d.ts +0 -52
  157. package/types/View/RenderOptions.d.ts +0 -29
  158. package/types/View/View.d.ts +0 -124
  159. package/types/core/Message/index.d.ts +0 -4
  160. package/types/domain/app/GalleryRenderIntent.d.ts +0 -31
@@ -1,29 +0,0 @@
1
- export default RenderOptions;
2
- declare class RenderOptions {
3
- static DEFAULTS: {
4
- resizeToView: boolean;
5
- translateFrame: boolean;
6
- render: boolean;
7
- renderMethod: string;
8
- };
9
- static from(props?: {}): RenderOptions;
10
- constructor(props?: {});
11
- /** @type {boolean} [false] */
12
- resizeToView: boolean;
13
- /** @type {boolean} [false] */
14
- translateFrame: boolean;
15
- /** @type {boolean} [true] */
16
- render: boolean;
17
- /** @type {string} */
18
- renderMethod: string;
19
- /** @type {number} */
20
- width: number;
21
- /** @type {number} */
22
- height: number;
23
- get DEFAULTS(): {
24
- resizeToView: boolean;
25
- translateFrame: boolean;
26
- render: boolean;
27
- renderMethod: string;
28
- };
29
- }
@@ -1,124 +0,0 @@
1
- /**
2
- * @typedef {Object} ComponentFn
3
- * @property {string} name
4
- * @property {(input: UiMessage) => Promise<any>} ask
5
- * @property {Function} bind
6
- */
7
- export default class View {
8
- /** @type {typeof RenderOptions} */
9
- static RenderOptions: typeof RenderOptions;
10
- /** @type {typeof FrameRenderMethod} */
11
- static RenderMethod: typeof FrameRenderMethod;
12
- /**
13
- * @param {Frame} frame
14
- * @param {RenderOptions} [options]
15
- * @returns {Frame}
16
- */
17
- static fixFrame(frame: Frame, options?: RenderOptions): Frame;
18
- /**
19
- * @param {object} [input]
20
- * @param {StdIn} [input.stdin]
21
- * @param {StdOut} [input.stdout]
22
- * @param {number} [input.startedAt]
23
- * @param {Frame} [input.frame]
24
- * @param {Locale} [input.locale]
25
- * @param {Map<string, string>} [input.vocab]
26
- * @param {number[]} [input.windowSize]
27
- * @param {Map<string, ComponentFn>} [input.components]
28
- * @param {string} [input.renderMethod]
29
- */
30
- constructor(input?: {
31
- stdin?: StdIn | undefined;
32
- stdout?: StdOut | undefined;
33
- startedAt?: number | undefined;
34
- frame?: Frame | undefined;
35
- locale?: Locale | undefined;
36
- vocab?: Map<string, string> | undefined;
37
- windowSize?: number[] | undefined;
38
- components?: Map<string, ComponentFn> | undefined;
39
- renderMethod?: string | undefined;
40
- });
41
- /** @type {StdIn} */
42
- stdin: StdIn;
43
- /** @type {StdOut} */
44
- stdout: StdOut;
45
- /** @type {number} */
46
- startedAt: number;
47
- /** @type {Frame} */
48
- frame: Frame;
49
- /** @type {Locale} */
50
- locale: Locale;
51
- /** @type {Map<string, string>} */
52
- vocab: Map<string, string>;
53
- /** @type {number[]} */
54
- windowSize: number[];
55
- /** @type {Map<string, ComponentFn>} */
56
- components: Map<string, ComponentFn>;
57
- /** @type {string} */
58
- renderMethod: string;
59
- get empty(): boolean;
60
- get RenderMethod(): typeof FrameRenderMethod;
61
- get RenderOptions(): typeof RenderOptions;
62
- getWindowSize(): number[];
63
- /**
64
- * @param {number} width
65
- * @param {number} height
66
- */
67
- setWindowSize(width: number, height: number): void;
68
- startTimer(): void;
69
- spent(checkpoint?: number): number;
70
- /**
71
- * @param {boolean | number | Function | ComponentFn} [shouldRender=0]
72
- * @param {RenderOptions} [options]
73
- * @returns {(value: Frame|string|string[], ...args: any) => Frame}
74
- */
75
- render(shouldRender?: boolean | number | Function | ComponentFn, options?: RenderOptions): (value: Frame | string | string[], ...args: any) => Frame;
76
- clear(shouldRender?: number): Frame;
77
- progress(shouldRender?: boolean): (value: any) => Frame;
78
- /** @param {any} value */
79
- t(value: any): any;
80
- /** @param {any[]} args */
81
- debug(...args: any[]): Frame;
82
- /** @param {any[]} args */
83
- info(...args: any[]): Frame;
84
- /** @param {any[]} args */
85
- warn(...args: any[]): Frame;
86
- /** @param {any[]} args */
87
- error(...args: any[]): Frame;
88
- /**
89
- * @param {string} name
90
- * @param {ComponentFn} component
91
- */
92
- register(name: string, component: ComponentFn): void;
93
- /**
94
- * @param {string} name
95
- */
96
- unregister(name: string): void;
97
- /**
98
- * @param {string} name
99
- * @returns {boolean}
100
- */
101
- has(name: string): boolean;
102
- /**
103
- * @param {string} name
104
- * @returns {ComponentFn | undefined}
105
- */
106
- get(name: string): ComponentFn | undefined;
107
- /**
108
- * @param {UiMessage} input
109
- * @returns {Promise<UiMessage | null>}
110
- */
111
- ask(input: UiMessage): Promise<UiMessage | null>;
112
- }
113
- export type ComponentFn = {
114
- name: string;
115
- ask: (input: UiMessage) => Promise<any>;
116
- bind: Function;
117
- };
118
- import StdIn from '../StdIn.js';
119
- import StdOut from '../StdOut.js';
120
- import Frame from '../Frame/Frame.js';
121
- import Locale from '../Locale.js';
122
- import { FrameRenderMethod } from '../Frame/Frame.js';
123
- import RenderOptions from './RenderOptions.js';
124
- import UiMessage from '../core/Message/Message.js';
@@ -1,4 +0,0 @@
1
- export default UiMessage;
2
- import UiMessage from './Message.js';
3
- import OutputMessage from './OutputMessage.js';
4
- export { UiMessage, OutputMessage };
@@ -1,31 +0,0 @@
1
- export class GalleryRenderIntent extends Model {
2
- static alias: string;
3
- static UI: {
4
- rendering: string;
5
- success: string;
6
- failed: string;
7
- };
8
- static dataDir: {
9
- type: string;
10
- default: string;
11
- help: string;
12
- };
13
- static dir: {
14
- type: string;
15
- default: string;
16
- help: string;
17
- };
18
- /**
19
-
20
- * @param {Partial<GalleryRenderIntent> | Record<string, any>} [data={}]
21
-
22
- * @param {import('@nan0web/types').ModelOptions} [options={}]
23
-
24
- */
25
- constructor(data?: Partial<GalleryRenderIntent> | Record<string, any>, options?: import("@nan0web/types").ModelOptions);
26
- /** @type {string} */ dataDir: string;
27
- /** @type {string} */ dir: string;
28
- run(): AsyncGenerator<import("../../core/Intent.js").ShowIntent, import("../../core/Intent.js").ResultIntent | undefined, unknown>;
29
- }
30
- export default GalleryRenderIntent;
31
- import { Model } from '@nan0web/types';