svelte-multistyle-ui 0.0.14-alpha → 0.0.16-alpha

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 (176) hide show
  1. package/README.md +116 -7
  2. package/cli/bin.js +94 -92
  3. package/cli/emit.js +237 -225
  4. package/cli/generate.js +504 -499
  5. package/cli/registry.js +105 -97
  6. package/dist/actions/dialog.d.ts +11 -0
  7. package/dist/actions/dialog.js +108 -0
  8. package/dist/components/Accordion.svelte +4 -1
  9. package/dist/components/Accordion.svelte.d.ts +8 -12
  10. package/dist/components/Alert.svelte +5 -2
  11. package/dist/components/Alert.svelte.d.ts +8 -16
  12. package/dist/components/Avatar.svelte +7 -0
  13. package/dist/components/Avatar.svelte.d.ts +8 -14
  14. package/dist/components/Breadcrumb.svelte +3 -0
  15. package/dist/components/Breadcrumb.svelte.d.ts +8 -8
  16. package/dist/components/Button.svelte +5 -0
  17. package/dist/components/Button.svelte.d.ts +8 -20
  18. package/dist/components/ButtonGroup.svelte +4 -1
  19. package/dist/components/ButtonGroup.svelte.d.ts +8 -16
  20. package/dist/components/Card.svelte +3 -0
  21. package/dist/components/Card.svelte.d.ts +8 -12
  22. package/dist/components/Carousel.svelte +11 -6
  23. package/dist/components/Carousel.svelte.d.ts +8 -16
  24. package/dist/components/Checkbox.svelte +4 -1
  25. package/dist/components/Checkbox.svelte.d.ts +8 -14
  26. package/dist/components/Chip.svelte +4 -1
  27. package/dist/components/Chip.svelte.d.ts +8 -20
  28. package/dist/components/CodeEditor.svelte +133 -129
  29. package/dist/components/CodeEditor.svelte.d.ts +8 -16
  30. package/dist/components/Column.svelte +41 -38
  31. package/dist/components/Column.svelte.d.ts +8 -12
  32. package/dist/components/CommandPalette.svelte +8 -2
  33. package/dist/components/CommandPalette.svelte.d.ts +8 -12
  34. package/dist/components/CrudView.svelte +1564 -0
  35. package/dist/components/CrudView.svelte.d.ts +17 -0
  36. package/dist/components/DatePicker.svelte +25 -7
  37. package/dist/components/DatePicker.svelte.d.ts +8 -24
  38. package/dist/components/Divider.svelte +3 -0
  39. package/dist/components/Divider.svelte.d.ts +8 -10
  40. package/dist/components/Drawer.svelte +5 -0
  41. package/dist/components/Drawer.svelte.d.ts +8 -14
  42. package/dist/components/DropdownMenu.svelte +26 -2
  43. package/dist/components/DropdownMenu.svelte.d.ts +8 -18
  44. package/dist/components/FAB.svelte +4 -1
  45. package/dist/components/FAB.svelte.d.ts +8 -14
  46. package/dist/components/FileUpload.svelte +30 -4
  47. package/dist/components/FileUpload.svelte.d.ts +8 -14
  48. package/dist/components/FilterBar.svelte +758 -0
  49. package/dist/components/FilterBar.svelte.d.ts +17 -0
  50. package/dist/components/GraphEditor.svelte +724 -0
  51. package/dist/components/GraphEditor.svelte.d.ts +28 -0
  52. package/dist/components/Grid.svelte +54 -51
  53. package/dist/components/Grid.svelte.d.ts +8 -18
  54. package/dist/components/IconButton.svelte +6 -1
  55. package/dist/components/IconButton.svelte.d.ts +8 -22
  56. package/dist/components/InlineEdit.svelte +142 -0
  57. package/dist/components/InlineEdit.svelte.d.ts +28 -0
  58. package/dist/components/Input.svelte +5 -1
  59. package/dist/components/Input.svelte.d.ts +8 -62
  60. package/dist/components/Modal.svelte +6 -1
  61. package/dist/components/Modal.svelte.d.ts +8 -16
  62. package/dist/components/MultiSelect.svelte +22 -190
  63. package/dist/components/MultiSelect.svelte.d.ts +8 -16
  64. package/dist/components/Pagination.svelte +8 -1
  65. package/dist/components/Pagination.svelte.d.ts +8 -12
  66. package/dist/components/Popover.svelte +3 -0
  67. package/dist/components/Popover.svelte.d.ts +8 -16
  68. package/dist/components/ProgressBar.svelte +76 -73
  69. package/dist/components/ProgressBar.svelte.d.ts +8 -14
  70. package/dist/components/Radio.svelte +4 -1
  71. package/dist/components/Radio.svelte.d.ts +8 -14
  72. package/dist/components/Rating.svelte +22 -2
  73. package/dist/components/Rating.svelte.d.ts +8 -18
  74. package/dist/components/Row.svelte +42 -39
  75. package/dist/components/Row.svelte.d.ts +8 -14
  76. package/dist/components/Select.svelte +258 -33
  77. package/dist/components/Select.svelte.d.ts +8 -16
  78. package/dist/components/Skeleton.svelte +3 -0
  79. package/dist/components/Skeleton.svelte.d.ts +8 -12
  80. package/dist/components/Slider.svelte +7 -3
  81. package/dist/components/Slider.svelte.d.ts +8 -18
  82. package/dist/components/SortableList.svelte +133 -130
  83. package/dist/components/SortableList.svelte.d.ts +6 -14
  84. package/dist/components/Spinner.svelte +3 -0
  85. package/dist/components/Spinner.svelte.d.ts +8 -8
  86. package/dist/components/Stepper.svelte +96 -93
  87. package/dist/components/Stepper.svelte.d.ts +8 -10
  88. package/dist/components/Table.svelte +3 -0
  89. package/dist/components/Table.svelte.d.ts +8 -12
  90. package/dist/components/Tabs.svelte +22 -2
  91. package/dist/components/Tabs.svelte.d.ts +8 -10
  92. package/dist/components/TextEditor.svelte +188 -187
  93. package/dist/components/TextEditor.svelte.d.ts +8 -18
  94. package/dist/components/Textarea.svelte +4 -1
  95. package/dist/components/Textarea.svelte.d.ts +8 -24
  96. package/dist/components/Toast.svelte +44 -11
  97. package/dist/components/Toast.svelte.d.ts +8 -12
  98. package/dist/components/Toggle.svelte +4 -1
  99. package/dist/components/Toggle.svelte.d.ts +8 -14
  100. package/dist/components/Tooltip.svelte +3 -0
  101. package/dist/components/Tooltip.svelte.d.ts +8 -12
  102. package/dist/components/charts/BarChart.svelte +7 -5
  103. package/dist/components/charts/BarChart.svelte.d.ts +8 -22
  104. package/dist/components/charts/BubbleChart.svelte +7 -5
  105. package/dist/components/charts/BubbleChart.svelte.d.ts +8 -22
  106. package/dist/components/charts/Chart.svelte +262 -248
  107. package/dist/components/charts/Chart.svelte.d.ts +8 -30
  108. package/dist/components/charts/ComboChart.svelte +7 -5
  109. package/dist/components/charts/ComboChart.svelte.d.ts +8 -22
  110. package/dist/components/charts/DoughnutChart.svelte +7 -5
  111. package/dist/components/charts/DoughnutChart.svelte.d.ts +8 -22
  112. package/dist/components/charts/LineChart.svelte +7 -5
  113. package/dist/components/charts/LineChart.svelte.d.ts +8 -22
  114. package/dist/components/charts/MermaidChart.svelte +96 -0
  115. package/dist/components/charts/MermaidChart.svelte.d.ts +20 -0
  116. package/dist/components/charts/PieChart.svelte +7 -5
  117. package/dist/components/charts/PieChart.svelte.d.ts +8 -22
  118. package/dist/components/charts/PolarAreaChart.svelte +7 -5
  119. package/dist/components/charts/PolarAreaChart.svelte.d.ts +8 -22
  120. package/dist/components/charts/RadarChart.svelte +7 -5
  121. package/dist/components/charts/RadarChart.svelte.d.ts +8 -22
  122. package/dist/components/charts/ScatterChart.svelte +7 -5
  123. package/dist/components/charts/ScatterChart.svelte.d.ts +8 -22
  124. package/dist/components/charts/StackedBarChart.svelte +20 -18
  125. package/dist/components/charts/StackedBarChart.svelte.d.ts +8 -22
  126. package/dist/components/charts/StackedLineChart.svelte +23 -21
  127. package/dist/components/charts/StackedLineChart.svelte.d.ts +8 -22
  128. package/dist/components/charts/chart-config.d.ts +2 -2
  129. package/dist/components/charts/chart-config.js +714 -733
  130. package/dist/components/charts/mermaid-chart-styles.css +27 -0
  131. package/dist/components/checkbox-styles.css +122 -117
  132. package/dist/components/crudview-styles.css +1057 -0
  133. package/dist/components/fileupload-styles.css +121 -117
  134. package/dist/components/filterbar-styles.css +655 -0
  135. package/dist/components/graph/FlowNode.svelte +82 -0
  136. package/dist/components/graph/FlowNode.svelte.d.ts +17 -0
  137. package/dist/components/graph/GraphNode.svelte +72 -0
  138. package/dist/components/graph/GraphNode.svelte.d.ts +17 -0
  139. package/dist/components/graph-editor-styles.css +439 -0
  140. package/dist/components/inline-edit-styles.css +113 -0
  141. package/dist/components/input-styles.css +17 -34
  142. package/dist/components/liquid-glass-field.css +29 -0
  143. package/dist/components/prism-manual.d.ts +0 -0
  144. package/dist/components/prism-manual.js +4 -0
  145. package/dist/components/radio-styles.css +118 -113
  146. package/dist/components/rating-styles.css +70 -65
  147. package/dist/components/select-styles.css +239 -11
  148. package/dist/components/slider-styles.css +85 -81
  149. package/dist/components/text-editor-core/dom-utils.d.ts +1 -1
  150. package/dist/components/text-editor-core/editor-core.d.ts +9 -9
  151. package/dist/components/text-editor-core/editor-core.js +854 -808
  152. package/dist/components/text-editor-core/sanitizer.d.ts +4 -1
  153. package/dist/components/text-editor-core/sanitizer.js +228 -161
  154. package/dist/components/text-editor-core/selection-engine.d.ts +3 -3
  155. package/dist/components/textarea-styles.css +14 -14
  156. package/dist/components/toggle-styles.css +126 -121
  157. package/dist/config.svelte.d.ts +5 -4
  158. package/dist/config.svelte.js +114 -81
  159. package/dist/graph/flow-routing.d.ts +10 -0
  160. package/dist/graph/flow-routing.js +113 -0
  161. package/dist/graph/geometry.d.ts +48 -0
  162. package/dist/graph/geometry.js +154 -0
  163. package/dist/graph/index.d.ts +111 -0
  164. package/dist/graph/index.js +230 -0
  165. package/dist/graph/node-types.d.ts +24 -0
  166. package/dist/graph/node-types.js +82 -0
  167. package/dist/index.d.ts +10 -1
  168. package/dist/index.js +13 -1
  169. package/dist/themes/generator.js +175 -173
  170. package/dist/themes/presets.d.ts +21 -21
  171. package/dist/utils/dbmr.d.ts +27 -0
  172. package/dist/utils/dbmr.js +381 -0
  173. package/dist/utils/filter.d.ts +103 -0
  174. package/dist/utils/filter.js +617 -0
  175. package/package.json +106 -81
  176. package/dist/components/multiselect-styles.css +0 -364
package/README.md CHANGED
@@ -21,7 +21,7 @@ npm install svelte-multistyle-ui
21
21
  pnpm add svelte-multistyle-ui
22
22
  ```
23
23
 
24
- > Requires Svelte `^5.0.0` and Chart.js `^4.5.1` as peer dependencies (Chart.js is only needed if you use the chart components).
24
+ > Peer dependencies are Svelte `^5.0.0`, Chart.js `^4.5.1` for data charts, and Mermaid `^12.3.0` for Mermaid diagrams.
25
25
 
26
26
  ## LLM skill
27
27
 
@@ -84,15 +84,103 @@ A Svelte action for portaling content to `document.body`:
84
84
  The library exports the following components from `svelte-multistyle-ui`:
85
85
 
86
86
  - Actions: `Button`, `IconButton`, `FAB`, `ButtonGroup`, `DropdownMenu`, `Popover`
87
- - Form: `Input`, `Textarea`, `TextEditor`, `Select`, `MultiSelect`, `Checkbox`, `Radio`, `Toggle`, `Slider`, `FileUpload`, `DatePicker`, `SortableList`
88
- - Layout: `Card`, `Divider`, `Tabs`, `Accordion`, `Modal`, `Drawer`, `CommandPalette`, `Row`, `Column`, `Grid`
87
+ - Form: `Input`, `Textarea`, `InlineEdit`, `TextEditor`, [`CodeEditor`](skill/references/CodeEditor.md), `Select`, `MultiSelect`, `Checkbox`, `Radio`, `Toggle`, `Slider`, `FileUpload`, `DatePicker`, `SortableList`
88
+ - Layout: `Card`, `Divider`, `Tabs`, [`Carousel`](skill/references/Carousel.md), `Accordion`, `Modal`, `Drawer`, `CommandPalette`, `Row`, `Column`, `Grid`
89
89
  - Navigation: `Breadcrumb`, `Pagination`, `Stepper`
90
90
  - Data display: `Avatar`, `Chip`, `Tooltip`, `ProgressBar`, `Table`, `Spinner`, `Skeleton`, `Rating`
91
91
  - Feedback: `Alert`, `Toast`
92
- - Charts: `BarChart`, `LineChart`, `PieChart`, `DoughnutChart`, `RadarChart`, `PolarAreaChart`, `ScatterChart`, `BubbleChart`, `StackedBarChart`, `StackedLineChart`, `ComboChart`
92
+ - Charts: `BarChart`, `LineChart`, `PieChart`, `DoughnutChart`, `RadarChart`, `PolarAreaChart`, `ScatterChart`, `BubbleChart`, `StackedBarChart`, `StackedLineChart`, `ComboChart`, `MermaidChart`
93
+ - Graphs: `GraphEditor` for flowcharts and executable blueprints
94
+ - Aggregate / CRUD: [`FilterBar`](skill/references/FilterBar.md), [`CrudView`](skill/references/CrudView.md) (with `createDbmrClient`, `normalizeDiscovery`, `mapOptionsToCrudProps`, `serializeDbmrQuery`, `buildDbmrFilterAst`, `serializeDbmrQueryBody`)
93
95
 
94
96
  You can also import individual files from `svelte-multistyle-ui/components/<Component>.svelte`, and chart components from `svelte-multistyle-ui/charts/<Chart>.svelte`.
95
97
 
98
+ ### InlineEdit
99
+
100
+ `InlineEdit` displays dotted-underlined text as a paragraph. Activate the text to edit it in place. The default variant uses a single-line input. Set `variant="multiline"` to use a textarea.
101
+
102
+ ```svelte
103
+ <script>
104
+ import { InlineEdit } from "svelte-multistyle-ui";
105
+
106
+ let title = $state("Project Atlas");
107
+ let notes = $state("Review the new layout.");
108
+ </script>
109
+
110
+ <InlineEdit aria-label="Project title" bind:value={title} />
111
+ <InlineEdit
112
+ aria-label="Release notes"
113
+ variant="multiline"
114
+ value={notes}
115
+ rows={4}
116
+ onUpdate={(next) => (notes = next)}
117
+ />
118
+ ```
119
+
120
+ When the field loses focus, a changed value updates `bind:value` and calls `onUpdate(value, previousValue)`. Enter leaves a single-line edit. In a multiline edit, Enter inserts a newline and Ctrl/⌘+Enter leaves the field. Escape discards the draft. Use `aria-label` to name the field for assistive technology.
121
+
122
+ ### CrudView & FilterBar (`dbmr` or custom backends)
123
+
124
+ `CrudView` and `FilterBar` work with client-side arrays or `serverSide` APIs (including [`dbmr`](https://crates.io/crates/dbmr) v0.0.3 and custom backends). Pass `discovery` directly (either a `dbmr` `DISCOVER` payload `{ columns: [...] }` or a custom field array) and `totalCount` for server-side pagination:
125
+
126
+ ```svelte
127
+ <script>
128
+ import { CrudView, createDbmrClient } from "svelte-multistyle-ui";
129
+
130
+ const client = createDbmrClient("/api/posts");
131
+ let data = $state([]);
132
+ let totalCount = $state(0);
133
+ let discovery = $state(null);
134
+
135
+ async function load(params = {}) {
136
+ const res = await client.list(params);
137
+ data = res.data;
138
+ totalCount = res.count;
139
+ }
140
+ </script>
141
+
142
+ <CrudView
143
+ title="Posts"
144
+ bind:data
145
+ {totalCount}
146
+ {discovery}
147
+ {...client.crudHandlers()}
148
+ onchange={load}
149
+ />
150
+ ```
151
+
152
+ Display and edit mode occupy the same height for the same text. Multiline fields use `rows` as a minimum and grow to fit their content without an internal scrollbar. The active field uses the selected style’s borders. [InlineEdit API](skill/references/InlineEdit.md)
153
+
154
+ ## Graph editor
155
+
156
+ Open **Graph Editor** in the component gallery and choose the **Flowchart** or **Blueprint** variant. Flowchart includes a support conversation with yes/no branches and a billing subgraph. Blueprint includes a runnable order subtotal example. Each variant saves locally and can open, export, or embed graph JSON. The in-page guide includes copyable examples for setup, custom nodes, and connection styles.
157
+
158
+ ```svelte
159
+ <script>
160
+ import 'svelte-multistyle-ui/theme.css';
161
+ import { GraphEditor, createGraph, runGraph } from 'svelte-multistyle-ui';
162
+
163
+ let graph = $state.raw(createGraph('Order logic'));
164
+ </script>
165
+
166
+ <GraphEditor bind:graph mode="blueprint" />
167
+ <button onclick={() => console.log(runGraph(graph).outputs)}>Run graph</button>
168
+ ```
169
+
170
+ Drag nodes from the palette or click to add them. Drag from an output to an input to connect, or activate the two ports in order with the keyboard. Use the canvas controls to zoom and fit the graph. With canvas focus, the arrow keys pan, `+` and `-` zoom, and Home fits the graph.
171
+
172
+ Add a **Subgraph** node and open it to edit its contents. **Graph input** and **Graph output** nodes inside it define ports on the parent node. Their IDs remain stable when their labels change. Call `editor.embedGraph(graph)` on a bound editor instance to insert an independent copy of another graph.
173
+
174
+ `mode="flowchart"` uses conventional shapes and supports loops. Choose **Horizontal** for left-to-right flow or **Vertical** for top-to-bottom flow. Each graph and subgraph saves its own direction. Use `orientFlowGraph(graph, direction)` to change it in code. Select a shape to resize it using its corner handle or the inspector.
175
+
176
+ `mode="blueprint"` shows data nodes for synchronous execution. `mode="all"` shows both sets. Use `runGraph(graph, { inputs, nodeTypes })` to evaluate data links in dependency order. Inputs and outputs are keyed by their boundary node IDs. The runner reports circular data dependencies.
177
+
178
+ Pass custom definitions as `nodeTypes` to both `GraphEditor` and `runGraph`. A definition has a title, input and output ports with stable IDs and types, optional inspector fields, and a synchronous `run(inputs, data)` function that returns values keyed by output port ID. The standalone `svelte-multistyle-ui/graph` entry also exports `createGraphNode`, `connectGraphNodes`, and `parseGraph` for building and validating graphs outside the editor.
179
+
180
+ Use `edgeStyle="straight"`, `"curve"`, or `"orthogonal"` to set the default connection style. Flowcharts default to right-angle routing and blueprints default to curves. Pass a connection’s `style` to `connectGraphNodes` or set it in the inspector to override the default. The override travels with exported graph JSON.
181
+
182
+ [GraphEditor API](skill/references/GraphEditor.md)
183
+
96
184
  ## Theming
97
185
 
98
186
  ### Preset themes
@@ -133,7 +221,7 @@ Key tokens include `--t-primary`, `--t-secondary`, `--t-surface`, `--t-card-bg`,
133
221
 
134
222
  ## Demo & development
135
223
 
136
- This repository contains a Vite demo app in `src/App.svelte` that renders every component across every style and theme.
224
+ The SvelteKit demo at `/` contains the component gallery, including Graph Editor.
137
225
 
138
226
  ```bash
139
227
  pnpm install
@@ -157,7 +245,7 @@ The demo supports URL parameters for quick visual regression checks:
157
245
  `svelte-multistyle-ui` ships a YAML → Svelte 5 page generator. It auto-detects three YAML input styles and emits token-efficient markup with auto-bound state and fake data injection.
158
246
 
159
247
  ```bash
160
- npx svelte-multistyle-ui generate --input page.yaml --output ./src/routes/demo/+page.svelte
248
+ npx svelte-multistyle-ui generate --input page.yaml --output ./src/routes/example/+page.svelte
161
249
  ```
162
250
 
163
251
  **Supported YAML styles:**
@@ -203,7 +291,7 @@ npx svelte-multistyle-ui generate --input page.yaml --output ./src/routes/demo/+
203
291
 
204
292
  **Features:**
205
293
 
206
- - **Auto-binding** — `Input`, `Select`, `Checkbox`, `Toggle`, `Radio`, `Slider`, `DatePicker`, `ButtonGroup`, `Rating`, `Tabs`, `Pagination`, `Popover`, `Modal`, `Drawer`, and `CommandPalette` get automatic `$state` vars and the correct `bind:*` directive.
294
+ - **Auto-binding** gives controls such as `Input`, `Textarea`, `InlineEdit`, and `CodeEditor` a `$state` variable and a `bind:value` directive in compact and shorthand pages. Use the verbose schema to initialize a `GraphEditor` binding with a graph object. [Generator binding reference](skill/references/generator-cli.md#auto-binding)
207
295
  - **Fake data** — missing `options` for `Select`/`MultiSelect`, missing `data` for `Table`, and missing chart data are synthesized automatically.
208
296
  - **Option conversion** — `options: [Apple, Banana]` becomes `[{value:"apple",label:"Apple"}, ...]`.
209
297
  - **Lightweight output** — generated files import from `svelte-multistyle-ui`, declare `$state`, include an empty `onMount` stub, and emit markup only; dark/light mode is handled by `initMultistyleUI` in the app layout.
@@ -237,6 +325,27 @@ Chart components are thin styled wrappers around [Chart.js](https://www.chartjs.
237
325
 
238
326
  A shared `Chart` base component is also exported from `svelte-multistyle-ui/charts/Chart.svelte` for building custom chart types.
239
327
 
328
+ ### Mermaid diagrams
329
+
330
+ `MermaidChart` renders Mermaid source as SVG in the browser. Use it for diagrams such as flowcharts, sequence diagrams, and pie charts. Install the `mermaid` peer dependency alongside the library.
331
+
332
+ ```bash
333
+ npm install svelte-multistyle-ui mermaid
334
+ ```
335
+
336
+ ```svelte
337
+ <script>
338
+ import { MermaidChart } from 'svelte-multistyle-ui';
339
+ import 'svelte-multistyle-ui/theme.css';
340
+
341
+ const source = 'flowchart LR\n A[Draft] --> B[Review] --> C[Publish]';
342
+ </script>
343
+
344
+ <MermaidChart {source} title="Release workflow" />
345
+ ```
346
+
347
+ The diagram updates when `source` changes and shows Mermaid’s error message for invalid syntax. It follows the library’s light or dark mode by default. Set `diagramTheme="neutral"` or another Mermaid theme to override it. The usual `style`, `theme`, and `class` props customize the wrapper. Try editable examples in the gallery’s **Charts** tab. [MermaidChart API](skill/references/MermaidChart.md)
348
+
240
349
  ## License
241
350
 
242
351
  MIT
package/cli/bin.js CHANGED
@@ -1,93 +1,95 @@
1
- #!/usr/bin/env node
2
- // svelte-multistyle-ui CLI — YAML -> Svelte 5 route page generator.
3
- // Usage: npx svelte-multistyle-ui generate --input page.yaml --output ./src/routes/demo.svelte
4
- import { generate } from "./generate.js";
5
-
6
- const VERSION = "0.0.4-alpha";
7
-
8
- function parseArgs(argv) {
9
- const positional = [];
10
- const flags = {};
11
- for (let i = 0; i < argv.length; i++) {
12
- const a = argv[i];
13
- if (a === "-h" || a === "--help") { flags.help = true; continue; }
14
- if (a === "-v" || a === "--version") { flags.version = true; continue; }
15
- if (a === "--dry-run") { flags.dryRun = true; continue; }
16
- if (a === "-w" || a === "--watch") { flags.watch = true; continue; }
17
- if (a.startsWith("--")) {
18
- const key = a.slice(2);
19
- const next = argv[i + 1];
20
- if (next === undefined || next.startsWith("-")) {
21
- flags[key] = true;
22
- } else {
23
- flags[key] = next;
24
- i++;
25
- }
26
- } else {
27
- positional.push(a);
28
- }
29
- }
30
- return { positional, flags };
31
- }
32
-
33
- function showHelp() {
34
- process.stdout.write(`svelte-multistyle-ui — UI code generator
35
-
36
- Usage:
37
- npx svelte-multistyle-ui generate --input <file.yaml> --output <path.svelte> [options]
38
-
39
- Subcommands:
40
- generate Convert a YAML file into a Svelte 5 route page.
41
- Supports the standard verbose schema, a proper nested
42
- YAML tree, and a compact indentation-based shorthand
43
- (all auto-detected).
44
-
45
- Options:
46
- --input <path> YAML source file (required)
47
- --output <path> Output .svelte path (required unless --dry-run prints to stdout)
48
- --style <name> Override YAML style (material, fluent, brutalist, ...)
49
- --theme <name> Override YAML theme (default, ocean, ...)
50
- --mode <mode> Override YAML mode: system | light | dark
51
- --dry-run Print generated Svelte to stdout, do not write a file
52
- --watch, -w Re-generate when the input YAML changes
53
- --help, -h Show this help
54
- --version, -v Show version
55
- `);
56
- }
57
-
58
- async function main() {
59
- const { positional, flags } = parseArgs(process.argv.slice(2));
60
- if (flags.help) { showHelp(); return; }
61
- if (flags.version) { process.stdout.write(VERSION + "\n"); return; }
62
-
63
- const sub = positional[0];
64
- if (sub !== "generate") {
65
- console.error(`Unknown subcommand "${sub || ""}". Run with --help.`);
66
- process.exit(1);
67
- }
68
- if (!flags.input) {
69
- console.error("Missing required flag: --input <file.yaml>");
70
- process.exit(1);
71
- }
72
- if (!flags.output && !flags.dryRun) {
73
- console.error('Missing required flag: --output <path.svelte> (or use --dry-run to print to stdout).');
74
- process.exit(1);
75
- }
76
-
77
- try {
78
- await generate({
79
- input: flags.input,
80
- output: flags.output,
81
- style: flags.style,
82
- theme: flags.theme,
83
- mode: flags.mode,
84
- dryRun: Boolean(flags.dryRun),
85
- watch: Boolean(flags.watch),
86
- });
87
- } catch (err) {
88
- console.error(`✗ ${err.message}`);
89
- process.exit(1);
90
- }
91
- }
92
-
1
+ #!/usr/bin/env node
2
+ // svelte-multistyle-ui CLI — YAML -> Svelte 5 route page generator.
3
+ // Usage: npx svelte-multistyle-ui generate --input page.yaml --output ./src/routes/demo.svelte
4
+ import fs from "node:fs";
5
+ import { generate } from "./generate.js";
6
+
7
+ const pkg = JSON.parse(fs.readFileSync(new URL("../package.json", import.meta.url), "utf8"));
8
+ const VERSION = pkg.version || "0.0.0";
9
+
10
+ function parseArgs(argv) {
11
+ const positional = [];
12
+ const flags = {};
13
+ for (let i = 0; i < argv.length; i++) {
14
+ const a = argv[i];
15
+ if (a === "-h" || a === "--help") { flags.help = true; continue; }
16
+ if (a === "-v" || a === "--version") { flags.version = true; continue; }
17
+ if (a === "--dry-run") { flags.dryRun = true; continue; }
18
+ if (a === "-w" || a === "--watch") { flags.watch = true; continue; }
19
+ if (a.startsWith("--")) {
20
+ const key = a.slice(2);
21
+ const next = argv[i + 1];
22
+ if (next === undefined || next.startsWith("-")) {
23
+ flags[key] = true;
24
+ } else {
25
+ flags[key] = next;
26
+ i++;
27
+ }
28
+ } else {
29
+ positional.push(a);
30
+ }
31
+ }
32
+ return { positional, flags };
33
+ }
34
+
35
+ function showHelp() {
36
+ process.stdout.write(`svelte-multistyle-ui — UI code generator
37
+
38
+ Usage:
39
+ npx svelte-multistyle-ui generate --input <file.yaml> --output <path.svelte> [options]
40
+
41
+ Subcommands:
42
+ generate Convert a YAML file into a Svelte 5 route page.
43
+ Supports the standard verbose schema, a proper nested
44
+ YAML tree, and a compact indentation-based shorthand
45
+ (all auto-detected).
46
+
47
+ Options:
48
+ --input <path> YAML source file (required)
49
+ --output <path> Output .svelte path (required unless --dry-run prints to stdout)
50
+ --style <name> Override YAML style (material, fluent, brutalist, ...)
51
+ --theme <name> Override YAML theme (default, ocean, ...)
52
+ --mode <mode> Override YAML mode: system | light | dark
53
+ --dry-run Print generated Svelte to stdout, do not write a file
54
+ --watch, -w Re-generate when the input YAML changes
55
+ --help, -h Show this help
56
+ --version, -v Show version
57
+ `);
58
+ }
59
+
60
+ async function main() {
61
+ const { positional, flags } = parseArgs(process.argv.slice(2));
62
+ if (flags.help) { showHelp(); return; }
63
+ if (flags.version) { process.stdout.write(VERSION + "\n"); return; }
64
+
65
+ const sub = positional[0];
66
+ if (sub !== "generate") {
67
+ console.error(`Unknown subcommand "${sub || ""}". Run with --help.`);
68
+ process.exit(1);
69
+ }
70
+ if (!flags.input) {
71
+ console.error("Missing required flag: --input <file.yaml>");
72
+ process.exit(1);
73
+ }
74
+ if (!flags.output && !flags.dryRun) {
75
+ console.error('Missing required flag: --output <path.svelte> (or use --dry-run to print to stdout).');
76
+ process.exit(1);
77
+ }
78
+
79
+ try {
80
+ await generate({
81
+ input: flags.input,
82
+ output: flags.output,
83
+ style: flags.style,
84
+ theme: flags.theme,
85
+ mode: flags.mode,
86
+ dryRun: Boolean(flags.dryRun),
87
+ watch: Boolean(flags.watch),
88
+ });
89
+ } catch (err) {
90
+ console.error(`✗ ${err.message}`);
91
+ process.exit(1);
92
+ }
93
+ }
94
+
93
95
  main();