@askrjs/cli 0.0.11 → 0.0.13

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.
@@ -1,4 +1,4 @@
1
- import { For } from '@askrjs/askr/control';
1
+ import { Case, For, Match } from '@askrjs/askr/control';
2
2
  import { Skeleton } from '@askrjs/themes/components';
3
3
  import EmptyState from './empty-state';
4
4
  import { joinClasses } from '../utils/join-classes';
@@ -22,54 +22,26 @@ export default function DataTable<Row>(props: {
22
22
  emptyTitle?: string;
23
23
  emptyDescription?: string;
24
24
  }) {
25
- if (props.errorText) {
26
- return (
27
- <EmptyState title="Could not load table" description={props.errorText} />
28
- );
29
- }
30
-
31
- if (props.isLoading) {
32
- return (
33
- <div
34
- class={joinClasses('panel stack-sm', props.class)}
35
- aria-hidden="true"
36
- >
37
- <Skeleton class="skeleton-line" />
38
- <Skeleton class="skeleton-line" />
39
- <Skeleton class="skeleton-line" />
40
- </div>
41
- );
42
- }
43
-
44
- if (props.rows().length === 0) {
45
- return (
46
- <EmptyState
47
- title={props.emptyTitle ?? 'No rows found'}
48
- description={
49
- props.emptyDescription ??
50
- 'Try changing filters or adding new records.'
51
- }
52
- />
53
- );
54
- }
55
-
56
- return (
25
+ const rows = props.rows();
26
+ const table = (
57
27
  <div class={joinClasses('table-wrap', props.class)}>
58
28
  <table class={props.tableClass}>
59
29
  <thead>
60
30
  <tr>
61
- {props.columns.map((column) => (
62
- <th class={column.class}>{column.header}</th>
63
- ))}
31
+ <For each={props.columns} by={(column) => column.key}>
32
+ {(column) => <th class={column.class}>{column.header}</th>}
33
+ </For>
64
34
  </tr>
65
35
  </thead>
66
36
  <tbody>
67
37
  <For each={props.rows} by={props.rowKey}>
68
38
  {(row: Row) => (
69
39
  <tr class={props.rowClass?.(row)}>
70
- {props.columns.map((column) => (
71
- <td class={column.class}>{column.render(row)}</td>
72
- ))}
40
+ <For each={props.columns} by={(column) => column.key}>
41
+ {(column) => (
42
+ <td class={column.class}>{column.render(row)}</td>
43
+ )}
44
+ </For>
73
45
  </tr>
74
46
  )}
75
47
  </For>
@@ -77,4 +49,34 @@ export default function DataTable<Row>(props: {
77
49
  </table>
78
50
  </div>
79
51
  );
52
+
53
+ return (
54
+ <Case fallback={table}>
55
+ <Match when={props.errorText}>
56
+ <EmptyState
57
+ title="Could not load table"
58
+ description={props.errorText ?? 'The table could not be loaded.'}
59
+ />
60
+ </Match>
61
+ <Match when={props.isLoading}>
62
+ <div
63
+ class={joinClasses('panel stack-sm', props.class)}
64
+ aria-hidden="true"
65
+ >
66
+ <Skeleton class="skeleton-line" />
67
+ <Skeleton class="skeleton-line" />
68
+ <Skeleton class="skeleton-line" />
69
+ </div>
70
+ </Match>
71
+ <Match when={rows.length === 0}>
72
+ <EmptyState
73
+ title={props.emptyTitle ?? 'No rows found'}
74
+ description={
75
+ props.emptyDescription ??
76
+ 'Try changing filters or adding new records.'
77
+ }
78
+ />
79
+ </Match>
80
+ </Case>
81
+ );
80
82
  }
@@ -1,4 +1,5 @@
1
1
  import { state } from '@askrjs/askr';
2
+ import { For } from '@askrjs/askr/control';
2
3
  import { resource } from '@askrjs/askr/resources';
3
4
  import { Button } from '@askrjs/ui/button';
4
5
  import {
@@ -61,19 +62,21 @@ export default function DashboardPage() {
61
62
  />
62
63
 
63
64
  <div class="stat-grid">
64
- {stats().map((stat) => {
65
- const Icon =
66
- iconByStatKey[stat.key as keyof typeof iconByStatKey] ??
67
- BarChart3Icon;
68
- return (
69
- <StatCard
70
- label={stat.label}
71
- value={stat.value}
72
- trend={stat.trend}
73
- icon={Icon}
74
- />
75
- );
76
- })}
65
+ <For each={stats} by={(stat) => stat.key}>
66
+ {(stat) => {
67
+ const Icon =
68
+ iconByStatKey[stat.key as keyof typeof iconByStatKey] ??
69
+ BarChart3Icon;
70
+ return (
71
+ <StatCard
72
+ label={stat.label}
73
+ value={stat.value}
74
+ trend={stat.trend}
75
+ icon={Icon}
76
+ />
77
+ );
78
+ }}
79
+ </For>
77
80
  </div>
78
81
 
79
82
  <section class="panel stack-md">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askrjs/cli",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Unified CLI for the Askr platform",
5
5
  "homepage": "https://github.com/askrjs/askr-cli#readme",
6
6
  "bugs": {
@@ -36,6 +36,7 @@
36
36
  "clean": "npx rimraf dist node_modules",
37
37
  "build": "vp pack",
38
38
  "dev": "vp pack --watch",
39
+ "analyze": "tsx src/bin/cli.ts analyze --check",
39
40
  "test": "vp test run -c vitest.config.ts",
40
41
  "test:coverage": "vp test run -c vitest.config.ts --coverage",
41
42
  "fmt": "vp fmt .",
@@ -47,7 +48,7 @@
47
48
  "bench": "npm run build --silent && npm run bench:analyze && node --import tsx benchmarks/cli.mjs --gate",
48
49
  "bench:analyze": "vp test bench --run -c vitest.bench.config.ts",
49
50
  "bench:json": "npm run build --silent && node --import tsx benchmarks/cli.mjs --gate --json",
50
- "check": "npm run lint && npm run typecheck && npm run test:coverage && npm run build && npm run test:publint && npm run pack:check",
51
+ "check": "npm run analyze && npm run lint && npm run typecheck && npm run test:coverage && npm run build && npm run test:publint && npm run pack:check",
51
52
  "prepack": "npm run build",
52
53
  "prepublishOnly": "npm run check && npm run test:templates"
53
54
  },
@@ -86,5 +87,12 @@
86
87
  },
87
88
  "engines": {
88
89
  "node": "^20.19.0 || >=22.12.0"
90
+ },
91
+ "askr": {
92
+ "analyze": {
93
+ "exclude": [
94
+ "templates/**"
95
+ ]
96
+ }
89
97
  }
90
98
  }