@close-by/clay 0.2.3 → 0.2.4

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.
package/package.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
2
  "name": "@close-by/clay",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "NiceGUI-like ui.* facade for Clay apps",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "src/index.ts",
8
8
  "exports": {
9
- ".": "./src/index.ts"
9
+ ".": "./src/index.ts",
10
+ "./page-tsconfig": "./page-tsconfig.json"
10
11
  },
11
12
  "files": [
12
13
  "src",
14
+ "page-tsconfig.json",
13
15
  "README.md",
14
16
  "LICENSE",
15
17
  "!src/**/*.test.ts",
@@ -25,9 +27,10 @@
25
27
  "access": "public"
26
28
  },
27
29
  "dependencies": {
28
- "@close-by/clay-core": "0.2.3",
29
- "@close-by/clay-components": "0.2.3",
30
- "@close-by/clay-server": "0.2.3",
30
+ "@close-by/clay-compiler": "0.2.4",
31
+ "@close-by/clay-core": "0.2.4",
32
+ "@close-by/clay-components": "0.2.4",
33
+ "@close-by/clay-server": "0.2.4",
31
34
  "@tailwindcss/cli": "^4.3.3",
32
35
  "tailwindcss": "^4.3.3"
33
36
  }
@@ -0,0 +1,14 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "lib": ["ESNext"],
5
+ "types": ["bun-types"],
6
+ "target": "ESNext",
7
+ "module": "Preserve",
8
+ "moduleResolution": "bundler",
9
+ "strict": true,
10
+ "skipLibCheck": true,
11
+ "noEmit": true,
12
+ "verbatimModuleSyntax": true
13
+ }
14
+ }
package/src/index.ts CHANGED
@@ -22,6 +22,8 @@ import {
22
22
  progress as progressFactory,
23
23
  separator as separatorFactory,
24
24
  icon as iconFactory,
25
+ iconText as iconTextFactory,
26
+ statusDot as statusDotFactory,
25
27
  stat as statFactory,
26
28
  dataTable as dataTableFactory,
27
29
  areaChart as areaChartFactory,
@@ -111,6 +113,10 @@ import {
111
113
  type ProgressProps,
112
114
  type SeparatorProps,
113
115
  type IconProps,
116
+ type IconTextProps,
117
+ type IconSlotProps,
118
+ type StatusDotProps,
119
+ type StatusDotColor,
114
120
  type StatItem,
115
121
  type DataTableProps,
116
122
  type DataTableAction,
@@ -624,7 +630,10 @@ export function label(text?: string | (() => string), props?: Omit<LabelProps, '
624
630
  }
625
631
 
626
632
  /** Clickable button. Prefer `ui.button`. See {@link ButtonProps}. */
627
- export function button(text?: string, props?: Omit<ButtonProps, 'text'>): Element {
633
+ export function button(
634
+ text?: string | (() => string),
635
+ props?: Omit<ButtonProps, 'text'>,
636
+ ): Element {
628
637
  return buttonFactory(text, props);
629
638
  }
630
639
 
@@ -713,8 +722,11 @@ export function externalLink(
713
722
  }
714
723
 
715
724
  /** Small status badge. Prefer `ui.badge`. See {@link BadgeProps}. */
716
- export function badge(text?: string, props?: Omit<BadgeProps, 'text'>): Element {
717
- return badgeFactory(text, props);
725
+ export function badge(
726
+ text?: string | (() => string) | BadgeProps,
727
+ props?: Omit<BadgeProps, 'text'>,
728
+ ): Element {
729
+ return badgeFactory(text as Parameters<typeof badgeFactory>[0], props);
718
730
  }
719
731
 
720
732
  /**
@@ -766,6 +778,19 @@ export function icon(name: string, props?: Omit<IconProps, 'name'>): Element {
766
778
  return iconFactory(name, props);
767
779
  }
768
780
 
781
+ /** Inline icon + text (replaces manual `ui.row` + `ui.icon` + `ui.label`). See {@link IconTextProps}. */
782
+ export function iconText(
783
+ text?: string | (() => string),
784
+ props?: Omit<IconTextProps, 'text'>,
785
+ ): Element {
786
+ return iconTextFactory(text, props);
787
+ }
788
+
789
+ /** Status dot (or icon) + label for feeds and tables. See {@link StatusDotProps}. */
790
+ export function statusDot(props?: StatusDotProps): Element {
791
+ return statusDotFactory(props);
792
+ }
793
+
769
794
  /** Render markdown to HTML. Prefer `ui.markdown`. See {@link MarkdownProps}. */
770
795
  export function markdown(text?: string, props?: MarkdownProps): Element {
771
796
  return markdownFactory(text, props);
package/src/pages.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  import { fileURLToPath, pathToFileURL } from 'url';
2
2
  import { join } from 'path';
3
+ import { readFile } from 'fs/promises';
3
4
  import {
4
5
  clearPages,
5
6
  getRegisteredPaths,
6
7
  type PageFn,
7
8
  } from '@close-by/clay-core';
9
+ import { warnClayPageIssues } from '@close-by/clay-compiler';
8
10
  import type { AppNavItem } from '@close-by/clay-components';
9
11
 
10
12
  /**
@@ -26,6 +28,15 @@ export async function importFresh(absPath: string): Promise<unknown> {
26
28
  return import(href);
27
29
  }
28
30
 
31
+ async function warnPageModuleIfNeeded(absPath: string): Promise<void> {
32
+ try {
33
+ const text = await readFile(absPath, 'utf8');
34
+ warnClayPageIssues(text, absPath);
35
+ } catch {
36
+ // unreadable — import will surface the error
37
+ }
38
+ }
39
+
29
40
  /**
30
41
  * Optional metadata for a registered page — used by `navFromPages` / `loadPages`.
31
42
  * Export as `pageMeta` from a page module, or pass via `attachPageMeta`.
@@ -108,6 +119,7 @@ export async function loadPages(dir: string | URL): Promise<string[]> {
108
119
  for (const relative of files) {
109
120
  const fullPath = join(absDir, relative);
110
121
  const pathsBefore = new Set(getRegisteredPaths());
122
+ await warnPageModuleIfNeeded(fullPath);
111
123
  const mod = (await importFresh(fullPath)) as { pageMeta?: PageMeta };
112
124
  const added = getRegisteredPaths().filter((p) => !pathsBefore.has(p));
113
125
  if (added.length === 1 && mod.pageMeta) {