@lmzhen/dsh-evolution-client-kit 0.34.0 → 0.35.0

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/lib/index.js CHANGED
@@ -402,6 +402,42 @@ var AsyncResource = class {
402
402
  }
403
403
  };
404
404
  //#endregion
405
+ //#region lib/types/format.js
406
+ /**
407
+ * Format an ISO string, epoch milliseconds, or null as local wall time.
408
+ * Invalid values return null; callers decide how to say "unknown".
409
+ * @param value - ISO string, epoch ms, or null.
410
+ * @param options - seconds on/off; defaults to on.
411
+ * @returns the formatted local time, or null when the value is absent/invalid.
412
+ */
413
+ function formatLocalDateTime(value, options = {}) {
414
+ if (value === null || value === void 0) return null;
415
+ const ms = typeof value === "number" ? value : Date.parse(value);
416
+ if (!Number.isFinite(ms)) return null;
417
+ const date = new Date(ms);
418
+ if (Number.isNaN(date.getTime())) return null;
419
+ const pad = (part) => String(part).padStart(2, "0");
420
+ const head = String(date.getFullYear()) + "-" + pad(date.getMonth() + 1) + "-" + pad(date.getDate()) + " " + pad(date.getHours()) + ":" + pad(date.getMinutes());
421
+ return options.seconds === false ? head : head + ":" + pad(date.getSeconds());
422
+ }
423
+ //#endregion
424
+ //#region lib/types/notice.js
425
+ /** One inline state notice: semantic tone plus text, no surface-specific styling. */
426
+ /**
427
+ * Render one informative/warning/error line. The caller owns the surface class and CSS;
428
+ * this leaf owns only the accessible role and the fact/count split.
429
+ * @param props - tone, text, optional count/class.
430
+ * @returns a semantic state notice.
431
+ */
432
+ function StateNotice({ tone, text, count, className }) {
433
+ return createElement("div", {
434
+ "data-role": "state-notice",
435
+ "data-tone": tone,
436
+ role: tone === "error" ? "alert" : "status",
437
+ ...className === void 0 ? {} : { className }
438
+ }, createElement("span", { "data-role": "state-notice-text" }, text), count === void 0 ? null : createElement("span", { "data-role": "state-notice-count" }, String(count)));
439
+ }
440
+ //#endregion
405
441
  //#region lib/types/action.js
406
442
  /**
407
443
  * Command-only actions. Approval decisions are a separate host API and must never
@@ -519,4 +555,4 @@ function createSettingsGatewayCache(binder, api) {
519
555
  };
520
556
  }
521
557
  //#endregion
522
- export { AsyncResource, Block, CommandCopyButton, FALLBACKS, FailureBlock, PAGE_SURFACE_CLASS, PAGE_SURFACE_CSS, ROUTES, TOKENS, TOKEN_CSS, copyAction, createSettingsGatewayCache, createSettingsSeat, failureText, loadStateOf, panelWorkspaceId, registerSidebarPanel, registerWorkbenchView, saveSettings, tokenVars };
558
+ export { AsyncResource, Block, CommandCopyButton, FALLBACKS, FailureBlock, PAGE_SURFACE_CLASS, PAGE_SURFACE_CSS, ROUTES, StateNotice, TOKENS, TOKEN_CSS, copyAction, createSettingsGatewayCache, createSettingsSeat, failureText, formatLocalDateTime, loadStateOf, panelWorkspaceId, registerSidebarPanel, registerWorkbenchView, saveSettings, tokenVars };
@@ -0,0 +1,14 @@
1
+ /** Locale-independent date/time formatting shared by the reading surfaces. */
2
+ export interface LocalDateTimeOptions {
3
+ /** Include seconds (merge/audit rows) or only minutes (version lists). */
4
+ readonly seconds?: boolean;
5
+ }
6
+ /**
7
+ * Format an ISO string, epoch milliseconds, or null as local wall time.
8
+ * Invalid values return null; callers decide how to say "unknown".
9
+ * @param value - ISO string, epoch ms, or null.
10
+ * @param options - seconds on/off; defaults to on.
11
+ * @returns the formatted local time, or null when the value is absent/invalid.
12
+ */
13
+ export declare function formatLocalDateTime(value: string | number | null | undefined, options?: LocalDateTimeOptions): string | null;
14
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Format an ISO string, epoch milliseconds, or null as local wall time.
3
+ * Invalid values return null; callers decide how to say "unknown".
4
+ * @param value - ISO string, epoch ms, or null.
5
+ * @param options - seconds on/off; defaults to on.
6
+ * @returns the formatted local time, or null when the value is absent/invalid.
7
+ */
8
+ export function formatLocalDateTime(value, options = {}) {
9
+ if (value === null || value === undefined)
10
+ return null;
11
+ const ms = typeof value === 'number' ? value : Date.parse(value);
12
+ if (!Number.isFinite(ms))
13
+ return null;
14
+ const date = new Date(ms);
15
+ if (Number.isNaN(date.getTime()))
16
+ return null;
17
+ const pad = (part) => String(part).padStart(2, '0');
18
+ const head = String(date.getFullYear()) + '-' + pad(date.getMonth() + 1) + '-' + pad(date.getDate())
19
+ + ' ' + pad(date.getHours()) + ':' + pad(date.getMinutes());
20
+ return options.seconds === false ? head : head + ':' + pad(date.getSeconds());
21
+ }
22
+ //# sourceMappingURL=format.js.map
@@ -6,6 +6,8 @@ export { createSettingsSeat } from './settings-seat.ts';
6
6
  export type { WorkbenchViewSpec } from './workbench-view.ts';
7
7
  export { panelWorkspaceId } from './workspace.ts';
8
8
  export { AsyncResource } from './async-resource.ts';
9
+ export { formatLocalDateTime, type LocalDateTimeOptions } from './format.ts';
10
+ export { StateNotice, type StateNoticeProps, type StateNoticeTone } from './notice.ts';
9
11
  export { CommandCopyButton, copyAction } from './action.ts';
10
12
  export type { ActionRef, CommandCopyButtonProps, CommandCopyLabels, CopyStatus } from './action.ts';
11
13
  export type { AsyncLoader, AsyncState, AsyncStatus } from './async-resource.ts';
@@ -3,6 +3,8 @@ export { registerWorkbenchView } from "./workbench-view.js";
3
3
  export { createSettingsSeat } from "./settings-seat.js";
4
4
  export { panelWorkspaceId } from "./workspace.js";
5
5
  export { AsyncResource } from "./async-resource.js";
6
+ export { formatLocalDateTime } from "./format.js";
7
+ export { StateNotice } from "./notice.js";
6
8
  export { CommandCopyButton, copyAction } from "./action.js";
7
9
  export { ROUTES } from "./generated/routes.generated.js";
8
10
  export { FALLBACKS } from "./generated/fallbacks.generated.js";
@@ -0,0 +1,18 @@
1
+ /** One inline state notice: semantic tone plus text, no surface-specific styling. */
2
+ import { type ReactNode } from 'react';
3
+ export type StateNoticeTone = 'info' | 'warning' | 'error';
4
+ export interface StateNoticeProps {
5
+ readonly tone: StateNoticeTone;
6
+ readonly text: string;
7
+ /** Optional count shown after the sentence (e.g. "2 expired"). */
8
+ readonly count?: number | undefined;
9
+ readonly className?: string | undefined;
10
+ }
11
+ /**
12
+ * Render one informative/warning/error line. The caller owns the surface class and CSS;
13
+ * this leaf owns only the accessible role and the fact/count split.
14
+ * @param props - tone, text, optional count/class.
15
+ * @returns a semantic state notice.
16
+ */
17
+ export declare function StateNotice({ tone, text, count, className }: StateNoticeProps): ReactNode;
18
+ //# sourceMappingURL=notice.d.ts.map
@@ -0,0 +1,17 @@
1
+ /** One inline state notice: semantic tone plus text, no surface-specific styling. */
2
+ import { createElement } from 'react';
3
+ /**
4
+ * Render one informative/warning/error line. The caller owns the surface class and CSS;
5
+ * this leaf owns only the accessible role and the fact/count split.
6
+ * @param props - tone, text, optional count/class.
7
+ * @returns a semantic state notice.
8
+ */
9
+ export function StateNotice({ tone, text, count, className }) {
10
+ return createElement('div', {
11
+ 'data-role': 'state-notice',
12
+ 'data-tone': tone,
13
+ role: tone === 'error' ? 'alert' : 'status',
14
+ ...(className === undefined ? {} : { className }),
15
+ }, createElement('span', { 'data-role': 'state-notice-text' }, text), count === undefined ? null : createElement('span', { 'data-role': 'state-notice-count' }, String(count)));
16
+ }
17
+ //# sourceMappingURL=notice.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-evolution-client-kit",
3
3
  "description": "Shared browser seams and lifecycle for the evolution family sidebar panels (community build)",
4
- "version": "0.34.0",
4
+ "version": "0.35.0",
5
5
  "private": false,
6
6
  "publishConfig": {
7
7
  "access": "public"