@skiddph/prui 0.1.1 → 0.2.1

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/dist/app/app.d.ts CHANGED
@@ -1,13 +1,7 @@
1
- import { AppliedTheme, ThemeName } from '../theme';
1
+ import { AppliedTheme, ThemeDefault } from '../theme';
2
2
  import { PropsMeta } from '../core/props-meta';
3
3
  import { PageSetName } from './auto-pages';
4
4
  import * as React from "react";
5
- /**
6
- * <App> is the whole shell: responsive sidebar with collapsible nav groups and
7
- * mobile drawer plus scroll lock, sticky header with brand and theme switch,
8
- * built-in command palette on the "/" hotkey, and router wiring (BrowserRouter
9
- * by default, memory mode for embedded use).
10
- */
11
5
  export type NavIconType = React.ComponentType<{
12
6
  className?: string;
13
7
  }>;
@@ -33,21 +27,37 @@ export interface SearchConfig {
33
27
  placeholder?: string;
34
28
  }
35
29
  export interface ThemeConfig {
36
- default?: ThemeName;
30
+ /** Named theme or the 'dark' / 'light' shorthand. Default 'control'. */
31
+ default?: ThemeDefault;
37
32
  persist?: boolean;
38
33
  }
39
34
  export interface SidebarConfig {
40
35
  /** Width in px, default 240. */
41
36
  width?: number;
37
+ /** Whether the mobile hamburger/drawer is available. Default true. */
38
+ collapsible?: boolean;
39
+ /** Whether the mobile drawer starts open. Default false. */
42
40
  defaultOpen?: boolean;
43
41
  }
44
- export type RouterMode = "browser" | "memory";
42
+ /** Session-timeout flow config (HRLabs extraction). */
43
+ export interface AuthConfig {
44
+ /** Idle minutes before logout. Default 15. */
45
+ sessionTimeout?: number;
46
+ /** Idle minutes before the countdown warning. Default 2. */
47
+ warningTime?: number;
48
+ /** Called on expiry or early logout; default navigates to loginPath. */
49
+ onTimeout?: () => void;
50
+ loginPath?: string;
51
+ }
52
+ export type RouterMode = "browser" | "memory" | "react-router";
45
53
  export interface AppProps {
46
54
  brand?: BrandConfig;
47
55
  nav?: NavItem[];
48
56
  search?: boolean | SearchConfig;
49
57
  theme?: boolean | ThemeConfig;
50
58
  sidebar?: SidebarConfig;
59
+ /** Session-timeout flow; omit or false to disable. */
60
+ auth?: boolean | AuthConfig;
51
61
  router?: RouterMode;
52
62
  /** Extra header content. */
53
63
  header?: React.ReactNode;
@@ -0,0 +1,52 @@
1
+ import { BrandConfig } from './app';
2
+ import * as React from "react";
3
+ /**
4
+ * AuthShell: the centered card layout for login/OTP/session-timeout screens
5
+ * (proposal: app-layer component sourced from HRLabs' auth screens). Brand
6
+ * mark on top, card below, full-viewport centering.
7
+ */
8
+ export interface AuthShellProps {
9
+ title: string;
10
+ description?: React.ReactNode;
11
+ brand?: BrandConfig;
12
+ /** Column width class for the card. Default max-w-sm. */
13
+ width?: string;
14
+ footer?: React.ReactNode;
15
+ children?: React.ReactNode;
16
+ className?: string;
17
+ }
18
+ export declare function AuthShell({ title, description, brand, width, footer, children, className }: AuthShellProps): React.JSX.Element;
19
+ export declare const authShellPropsMeta: {
20
+ readonly name: "AuthShell";
21
+ readonly props: readonly [{
22
+ readonly name: "title";
23
+ readonly type: "string";
24
+ readonly default: null;
25
+ readonly control: "text";
26
+ }, {
27
+ readonly name: "description";
28
+ readonly type: "ReactNode";
29
+ readonly default: null;
30
+ readonly control: "text";
31
+ }, {
32
+ readonly name: "brand";
33
+ readonly type: "{ name, mark?, href? }";
34
+ readonly default: "undefined";
35
+ readonly control: "object";
36
+ }, {
37
+ readonly name: "width";
38
+ readonly type: "string";
39
+ readonly default: "'max-w-sm'";
40
+ readonly control: "text";
41
+ }, {
42
+ readonly name: "footer";
43
+ readonly type: "ReactNode";
44
+ readonly default: null;
45
+ readonly control: "none";
46
+ }, {
47
+ readonly name: "children";
48
+ readonly type: "ReactNode";
49
+ readonly default: null;
50
+ readonly control: "none";
51
+ }];
52
+ };
@@ -3,19 +3,21 @@ import * as React from "react";
3
3
  /**
4
4
  * Schema-driven Form: fields from a schema, validation display included.
5
5
  * Each field: name, label, type, placeholder, required, options, defaultValue.
6
+ * The schema may be a bare field array or an object `{ fields, submitLabel }`;
7
+ * `defaultValues` is an alias of `initialValues`.
6
8
  */
7
- export type FormFieldType = "text" | "password" | "email" | "number" | "textarea" | "select" | "boolean";
9
+ export type FormFieldType = "text" | "password" | "email" | "number" | "date" | "textarea" | "select" | "boolean";
8
10
  export interface FormFieldSchema {
9
11
  name: string;
10
12
  label: string;
11
13
  type?: FormFieldType;
12
14
  placeholder?: string;
13
15
  required?: boolean;
14
- /** select options: label/value pairs. */
15
- options?: {
16
+ /** select options: label/value pairs; plain strings and numbers are accepted. */
17
+ options?: (string | number | {
16
18
  label: string;
17
19
  value: string;
18
- }[];
20
+ })[];
19
21
  defaultValue?: string | number | boolean;
20
22
  disabled?: boolean;
21
23
  /** Optional inline validation: return an error message or null. */
@@ -29,9 +31,13 @@ export interface FormSchema {
29
31
  /** Render fields in a 2-col grid on md+ when true. */
30
32
  columns?: 1 | 2;
31
33
  }
34
+ /** A schema is either the fields array itself or the full object. */
35
+ export type FormSchemaInput = FormFieldSchema[] | FormSchema;
32
36
  export interface FormProps {
33
- schema: FormSchema;
37
+ schema: FormSchemaInput;
34
38
  initialValues?: Record<string, unknown>;
39
+ /** Alias of initialValues. */
40
+ defaultValues?: Record<string, unknown>;
35
41
  onSubmit?: (values: Record<string, unknown>) => void | Promise<void>;
36
42
  onCancel?: () => void;
37
43
  cancelLabel?: string;
@@ -40,5 +46,5 @@ export interface FormProps {
40
46
  error?: string | null;
41
47
  className?: string;
42
48
  }
43
- export declare function Form({ schema, initialValues, onSubmit, onCancel, cancelLabel, submitting, error, className, }: FormProps): React.JSX.Element;
49
+ export declare function Form({ schema: schemaInput, initialValues, defaultValues, onSubmit, onCancel, cancelLabel, submitting, error, className, }: FormProps): React.JSX.Element;
44
50
  export declare const formPropsMeta: PropsMeta;
@@ -1,8 +1,11 @@
1
1
  /** PRUI App layer: config-driven super-components. */
2
+ export { Routes, Route, Outlet, Link, NavLink, Navigate } from 'react-router-dom';
2
3
  export { AutoPages } from './auto-pages';
3
4
  export type { PagesMode, PagesConfig, PageSetName } from './auto-pages';
4
- export { App, AppShell, SidebarNav, CommandPalette, useThemeState, appPropsMeta, type AppProps, type NavItem, type NavIconType, type BrandConfig, type SearchConfig, type ThemeConfig, type SidebarConfig, type RouterMode, type PaletteEntry, } from './app';
5
- export { Resource, resourcePropsMeta, type ResourceProps, type ResourceColumn, type ResourceRow, type ResourceAction, type ListQuery, type ListResult, } from './resource';
5
+ export { App, AppShell, SidebarNav, CommandPalette, useThemeState, appPropsMeta, type AppProps, type NavItem, type NavIconType, type BrandConfig, type SearchConfig, type ThemeConfig, type AuthConfig, type SidebarConfig, type RouterMode, type PaletteEntry, } from './app';
6
+ export { Resource, resourcePropsMeta, type ResourceProps, type ResourceColumn, type ResourceRow, type ResourceAction, type ResourceFilterOptions, type ListQuery, type ListResult, } from './resource';
6
7
  export { Form, formPropsMeta, type FormProps, type FormSchema, type FormFieldSchema, type FormFieldType, } from './form';
7
8
  export { StatRow, statRowPropsMeta, type StatRowProps, type StatItem } from './stat-row';
8
9
  export { Settings, settingsPropsMeta, type SettingsProps, type SettingsSection, type SettingsField } from './settings';
10
+ export { SessionTimeout, sessionTimeoutPropsMeta, type SessionTimeoutProps, } from './session-timeout';
11
+ export { AuthShell, authShellPropsMeta, type AuthShellProps, } from './auth-shell';
@@ -20,18 +20,24 @@ export interface ListQuery {
20
20
  }
21
21
  export interface ListResult<T> {
22
22
  rows: T[];
23
+ /** Next-page cursor. `cursor` is accepted as an alias. */
23
24
  nextCursor?: string | null;
25
+ cursor?: string | null;
24
26
  }
25
27
  export type ResourceRow = Record<string, unknown>;
28
+ /** Select choices: plain strings/numbers or label/value pairs. */
29
+ export type ResourceFilterOptions = (string | number | {
30
+ label: string;
31
+ value: string;
32
+ count?: number;
33
+ })[];
26
34
  export interface ResourceColumn<T extends ResourceRow> extends Column<T> {
27
35
  /** Filter type rendered in the toolbar. */
28
- filter?: "select" | "daterange" | "numberrange";
29
- /** Options for filter select. */
30
- filterOptions?: {
31
- label: string;
32
- value: string;
33
- count?: number;
34
- }[];
36
+ filter?: "select" | "date" | "daterange" | "number" | "numberrange" | "price" | "time";
37
+ /** Select filter choices: strings/numbers or {label, value} pairs. */
38
+ options?: ResourceFilterOptions;
39
+ /** Select filter choices; `options` is an alias of this. */
40
+ filterOptions?: ResourceFilterOptions;
35
41
  /** Field name for the form; defaults to key. */
36
42
  formField?: boolean;
37
43
  }
@@ -42,9 +48,13 @@ export interface ResourceProps<T extends ResourceRow> {
42
48
  columns: ResourceColumn<T>[];
43
49
  /** (query) => Promise<{rows, cursor}> */
44
50
  list: (query: ListQuery) => Promise<ListResult<T>>;
45
- create?: (values: Record<string, unknown>) => Promise<void> | void;
46
- update?: (row: T, values: Record<string, unknown>) => Promise<void> | void;
47
- remove?: (row: T) => Promise<void> | void;
51
+ /** Return values are ignored resolve or reject to signal outcome. */
52
+ create?: (values: Record<string, unknown>) => unknown;
53
+ update?: (row: T, values: Partial<T>) => unknown;
54
+ /** Deletes a row; `delete` is an alias. */
55
+ remove?: (row: T) => unknown;
56
+ /** Alias of remove. */
57
+ delete?: (row: T) => unknown;
48
58
  /** Enabled actions, default all three when the functions are provided. */
49
59
  actions?: ResourceAction[];
50
60
  /** Custom form node; receives the editing row (null on create). */
@@ -57,5 +67,5 @@ export interface ResourceProps<T extends ResourceRow> {
57
67
  pageSize?: number;
58
68
  className?: string;
59
69
  }
60
- export declare function Resource<T extends ResourceRow>({ name, columns, list, create, update, remove, actions, form, formSchema, rowKey, searchPlaceholder, pageSize: initialPageSize, className, }: ResourceProps<T>): React.JSX.Element;
70
+ export declare function Resource<T extends ResourceRow>({ name, columns, list, create, update, remove, delete: deleteAlias, actions, form, formSchema, rowKey, searchPlaceholder, pageSize: initialPageSize, className, }: ResourceProps<T>): React.JSX.Element;
61
71
  export declare const resourcePropsMeta: PropsMeta;
@@ -0,0 +1,45 @@
1
+ import * as React from "react";
2
+ /**
3
+ * SessionTimeout: idle detection with a countdown warning, extracted from
4
+ * HRLabs' SessionTimeout flow. Tracks mousedown/keydown/scroll/touch activity;
5
+ * after `timeout` minus `warningTime` of inactivity it shows a countdown
6
+ * dialog (Continue session / Log out) and calls onTimeout when it expires.
7
+ */
8
+ export interface SessionTimeoutProps {
9
+ /** Total idle time before logout, in minutes. Default 15. */
10
+ timeout?: number;
11
+ /** How long before the timeout the warning appears, in minutes. Default 2. */
12
+ warningTime?: number;
13
+ /** Called when the session expires (or the user logs out early). */
14
+ onTimeout?: () => void;
15
+ /** Called when the user extends the session. */
16
+ onExtend?: () => void;
17
+ /** Dialog copy overrides. */
18
+ title?: string;
19
+ message?: string;
20
+ }
21
+ export declare function SessionTimeout({ timeout, warningTime, onTimeout, onExtend, title, message, }: SessionTimeoutProps): React.JSX.Element;
22
+ export declare const sessionTimeoutPropsMeta: {
23
+ readonly name: "SessionTimeout";
24
+ readonly props: readonly [{
25
+ readonly name: "timeout";
26
+ readonly type: "number";
27
+ readonly default: "15";
28
+ readonly control: "number";
29
+ }, {
30
+ readonly name: "warningTime";
31
+ readonly type: "number";
32
+ readonly default: "2";
33
+ readonly control: "number";
34
+ }, {
35
+ readonly name: "onTimeout";
36
+ readonly type: "() => void";
37
+ readonly default: null;
38
+ readonly control: "none";
39
+ }, {
40
+ readonly name: "onExtend";
41
+ readonly type: "() => void";
42
+ readonly default: null;
43
+ readonly control: "none";
44
+ }];
45
+ };
@@ -3,16 +3,33 @@ import * as React from "react";
3
3
  /**
4
4
  * Settings: a two-column settings page from a section list.
5
5
  * Left: section nav (in-page anchors). Right: section cards with fields.
6
+ * Fields are either fully typed (`name` + `type` + `value`/`onChange`, which
7
+ * render the matching primitive) or a free `control` node.
6
8
  */
9
+ export type SettingsFieldType = "text" | "number" | "select" | "switch";
7
10
  export interface SettingsField {
8
11
  label: string;
9
12
  description?: string;
10
- /** Controlled content: any node (input, switch, custom). */
13
+ /** Field key; required when type is set. */
14
+ name?: string;
15
+ type?: SettingsFieldType;
16
+ /** Choices for type select: strings/numbers or label/value pairs. */
17
+ options?: (string | number | {
18
+ label: string;
19
+ value: string;
20
+ })[];
21
+ /** Current value for typed fields. */
22
+ value?: string | number | boolean;
23
+ /** Change handler for typed fields. */
24
+ onChange?: (value: string | number | boolean) => void;
25
+ /** Controlled content: any node (input, switch, custom). Overrides type. */
11
26
  control?: React.ReactNode;
12
27
  }
13
28
  export interface SettingsSection {
14
29
  id: string;
15
- title: string;
30
+ title?: string;
31
+ /** Alias of title. */
32
+ label?: string;
16
33
  description?: string;
17
34
  fields?: SettingsField[];
18
35
  /** Fully custom section body. */
package/dist/app.js CHANGED
@@ -1,18 +1,29 @@
1
- import { A as e, a as t, b as o, C as r, F as p, R as P, S as m, c as S, d as u, e as M, f as g, r as A, s as R, g as c, u as d } from "./chunks/settings-DUz5nyX-.js";
1
+ import { Link as e, NavLink as t, Navigate as o, Outlet as r, Route as p, Routes as u } from "react-router-dom";
2
+ import { A as m, a as P, b as S, c as l, C as h, F as n, R as M, S as R, d as g, e as A, f, g as c, h as d, i as k, r as v, s as N, j as T, k as b, u as w } from "./chunks/auth-shell-DsAwGqf8.js";
2
3
  export {
3
- e as App,
4
- t as AppShell,
5
- o as AutoPages,
6
- r as CommandPalette,
7
- p as Form,
8
- P as Resource,
9
- m as Settings,
10
- S as SidebarNav,
11
- u as StatRow,
12
- M as appPropsMeta,
13
- g as formPropsMeta,
14
- A as resourcePropsMeta,
15
- R as settingsPropsMeta,
16
- c as statRowPropsMeta,
17
- d as useThemeState
4
+ m as App,
5
+ P as AppShell,
6
+ S as AuthShell,
7
+ l as AutoPages,
8
+ h as CommandPalette,
9
+ n as Form,
10
+ e as Link,
11
+ t as NavLink,
12
+ o as Navigate,
13
+ r as Outlet,
14
+ M as Resource,
15
+ p as Route,
16
+ u as Routes,
17
+ R as SessionTimeout,
18
+ g as Settings,
19
+ A as SidebarNav,
20
+ f as StatRow,
21
+ c as appPropsMeta,
22
+ d as authShellPropsMeta,
23
+ k as formPropsMeta,
24
+ v as resourcePropsMeta,
25
+ N as sessionTimeoutPropsMeta,
26
+ T as settingsPropsMeta,
27
+ b as statRowPropsMeta,
28
+ w as useThemeState
18
29
  };