create-asciitorium 0.1.20 → 0.1.21

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.
@@ -3,7 +3,7 @@ import { AsciiArt, Box, loadArt } from 'asciitorium';
3
3
  const computer = await loadArt('./art/computer.txt');
4
4
 
5
5
  export const AsciiArtExample = () => (
6
- <Box width={42} height={28} layout="relaxed" label="ASCII Art Example:" border>
6
+ <Box width={42} height={28} layout="aligned" label="ASCII Art Example:" border>
7
7
  <AsciiArt content={computer} align="center" />
8
8
  </Box>
9
9
  );
@@ -12,7 +12,7 @@ export const ButtonExample = () => {
12
12
  onClick={() => (buttonClickCount.value = buttonClickCount.value + 1)}
13
13
  gap={{top: 4, bottom: 3}}
14
14
  />
15
- <Box layout="horizontal" gap={{left: 6, right: 2}} align="center">
15
+ <Box layout="row" gap={{left: 6, right: 2}} align="center">
16
16
  <Text>Click Count: </Text>
17
17
  <Text width={4}>{buttonClickCount}</Text>
18
18
  </Box>
@@ -1,7 +1,7 @@
1
1
  import { Text, HR, VR, Box, CelticBorder } from 'asciitorium';
2
2
 
3
3
  export const LayoutExample = () => (
4
- <Box width={42} height={27} border layout="vertical">
4
+ <Box width={42} height={27} border layout="column">
5
5
  <Text
6
6
  width={40}
7
7
  height={2}
@@ -37,7 +37,7 @@ export const MultiSelectExample = () => {
37
37
  selectedItems={multiValue}
38
38
  gap={{ top: 2, bottom: 2 }}
39
39
  />
40
- <Box align="center" layout="horizontal">
40
+ <Box align="center" layout="row">
41
41
  <Text align="top">Selected: </Text>
42
42
  <Text
43
43
  width={24}
@@ -31,7 +31,7 @@ export const SelectExample = () => {
31
31
  selectedItem={selectValue}
32
32
  />
33
33
  </Box>
34
- <Box align="center" gap={{ left: 5 }} layout="horizontal">
34
+ <Box align="center" gap={{ left: 5 }} layout="row">
35
35
  <Text>Car Selected: </Text>
36
36
  <Text width={20}>{selectValue}</Text>
37
37
  </Box>
@@ -1,23 +1,23 @@
1
1
  import {
2
2
  App,
3
- Text,
4
3
  AsciiArt,
5
4
  Select,
6
- Box,
7
5
  Component,
8
6
  PersistentState,
9
7
  loadArt,
10
8
  } from 'asciitorium';
11
9
 
12
- // Import example components
13
- import { ButtonExample } from './examples/ButtonExample';
14
- import { SelectExample } from './examples/SelectExample';
15
- import { MultiSelectExample } from './examples/MultiSelectExample';
16
- import { TextInputExample } from './examples/TextInputExample';
17
- import { ProgressBarExample } from './examples/ProgressBarExample';
18
- import { TabsExample } from './examples/TabsExample';
19
- import { TextExample } from './examples/TextExample';
20
- import { AsciiArtExample } from './examples/AsciiArtExample';
10
+ import {
11
+ ButtonExample,
12
+ CelticBorderExample,
13
+ SelectExample,
14
+ MultiSelectExample,
15
+ TextInputExample,
16
+ TabsExample,
17
+ TextExample,
18
+ AsciiArtExample,
19
+ SlidersExample,
20
+ } from 'asciitorium/examples';
21
21
 
22
22
  // Load the title ASCII art
23
23
  const titleArt = await loadArt('./art/asciitorium.txt');
@@ -32,102 +32,49 @@ const selectedComponent = new PersistentState(
32
32
  const componentList = [
33
33
  'AsciiArt',
34
34
  'Button',
35
+ 'CelticBorder',
35
36
  'MultiSelect',
36
- 'ProgressBar',
37
37
  'Select',
38
+ 'Sliders',
38
39
  'Tabs',
39
40
  'Text',
40
- 'TextInput'
41
+ 'TextInput',
41
42
  ];
42
43
 
43
- // Component mapping
44
- const examples: Record<string, any> = {
44
+ // Component mapping for dynamic content
45
+ const examples = {
45
46
  Button: ButtonExample,
47
+ CelticBorder: CelticBorderExample,
46
48
  Select: SelectExample,
47
49
  MultiSelect: MultiSelectExample,
48
50
  TextInput: TextInputExample,
49
- ProgressBar: ProgressBarExample,
51
+ Sliders: SlidersExample,
50
52
  Tabs: TabsExample,
51
53
  Text: TextExample,
52
- AsciiArt: AsciiArtExample
54
+ AsciiArt: AsciiArtExample,
53
55
  };
54
56
 
55
- // Create a wrapper component that dynamically switches based on state
56
-
57
- class DynamicExampleWrapper extends Box {
58
- constructor() {
59
- super({ width: 53, height: 28 });
60
-
61
- // Initially set the current example
62
- this.updateExample();
63
-
64
- // Subscribe to changes in selectedComponent
65
- selectedComponent.subscribe(() => {
66
- this.updateExample();
67
- });
68
- }
69
-
70
- private updateExample() {
71
- // Properly remove existing children using removeChild to notify parent
72
- const childrenToRemove = [...this.children]; // Create copy to avoid mutation during iteration
73
- for (const child of childrenToRemove) {
74
- child.destroy();
75
- this.removeChild(child);
76
- }
77
-
78
- // Get the current example factory function
79
- const exampleFactory = examples[selectedComponent.value];
80
- if (exampleFactory) {
81
- // Call the factory function to create a new component instance
82
- const exampleComponent = exampleFactory();
83
- this.addChild(exampleComponent);
84
- } else {
85
- // Fallback for unknown component
86
- this.addChild(
87
- new Text({
88
- width: 40,
89
- height: 5,
90
- border: true,
91
- children: ['Unknown component'],
92
- })
93
- );
94
- }
95
-
96
- // Find the root App component and reset focus manager
97
- this.notifyAppOfFocusChange();
98
- }
99
-
100
- private notifyAppOfFocusChange() {
101
- // Walk up the parent chain to find the App
102
- let current: Component | undefined = this;
103
- while (current && current.constructor.name !== 'App') {
104
- current = current.parent;
105
- }
106
-
107
- // If we found the App, reset its focus manager
108
- if (current && (current as any).focus) {
109
- (current as any).focus.reset(current);
110
- }
111
- }
112
- }
113
-
114
- // Construct the app with horizontal layout
115
57
  const app = (
116
- <App width={67} height={35}>
58
+ <App width={64} height={35}>
117
59
  <AsciiArt content={titleArt} align="center" gap={{ bottom: 2 }} />
118
- <Box layout="horizontal">
119
- {/* Left Panel - Navigation */}
60
+ <Component layout="row">
120
61
  <Select
121
62
  label="Components:"
122
- width={25}
63
+ width={16}
123
64
  height={28}
124
65
  items={componentList}
125
66
  selectedItem={selectedComponent}
126
67
  border
127
68
  />
128
- {/* Right Panel - Dynamic content */}
129
- {new DynamicExampleWrapper()}
130
- </Box>
69
+ <Component
70
+ width={48}
71
+ height={28}
72
+ dynamicContent={{
73
+ selectedKey: selectedComponent,
74
+ componentMap: examples,
75
+ }}
76
+ />
77
+ </Component>
131
78
  </App>
132
79
  );
133
80
 
@@ -1,4 +1,4 @@
1
- import { defineConfig } from 'vite';
1
+ import { defineConfig, Plugin } from 'vite';
2
2
 
3
3
  // Minimal virtual shim for Node built-ins on the web build
4
4
  function nodeBuiltinsShim(): Plugin {
@@ -26,7 +26,11 @@ function nodeBuiltinsShim(): Plugin {
26
26
  }
27
27
 
28
28
  export default defineConfig({
29
- esbuild: { target: 'esnext' },
29
+ esbuild: {
30
+ target: 'esnext',
31
+ jsx: 'automatic',
32
+ jsxImportSource: 'asciitorium',
33
+ },
30
34
  build: { target: 'esnext' },
31
35
  plugins: [nodeBuiltinsShim()],
32
36
  server: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-asciitorium",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "private": false,
5
5
  "description": "Scaffold a Vite + TypeScript project prewired for asciitorium (web + cli).",
6
6
  "bin": {