@lmzhen/dsh-evolution-client-kit 0.37.0 → 0.38.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
@@ -9,6 +9,12 @@ import { createElement, useState } from "react";
9
9
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
10
10
  //#endregion
11
11
  //#region lib/types/panel.js
12
+ /** Fail loud when a client bundle is mounted without the shell seats it consumes. */
13
+ function requireClientSeats(ctx, owner) {
14
+ const candidate = ctx;
15
+ if (candidate.slots === void 0 || candidate.locale === void 0) throw new Error(owner + ": the client slots/locale seats are not mounted");
16
+ return candidate;
17
+ }
12
18
  function interpolate(text, values) {
13
19
  if (values === void 0) return text;
14
20
  return text.replace(/\{(\w+)\}/g, (_match, key) => String(values[key] ?? ""));
@@ -438,6 +444,20 @@ var AsyncResource = class {
438
444
  };
439
445
  //#endregion
440
446
  //#region lib/types/format.js
447
+ /** Parse an ISO string, epoch ms, or null into a valid Date; null when absent/invalid. */
448
+ function toLocalDate(value) {
449
+ if (value === null || value === void 0) return null;
450
+ const ms = typeof value === "number" ? value : Date.parse(value);
451
+ if (!Number.isFinite(ms)) return null;
452
+ const date = new Date(ms);
453
+ return Number.isNaN(date.getTime()) ? null : date;
454
+ }
455
+ const pad = (part) => String(part).padStart(2, "0");
456
+ /** The local clock part, HH:MM[:SS]. */
457
+ function clockOf(date, options) {
458
+ const head = pad(date.getHours()) + ":" + pad(date.getMinutes());
459
+ return options.seconds === false ? head : head + ":" + pad(date.getSeconds());
460
+ }
441
461
  /**
442
462
  * Format an ISO string, epoch milliseconds, or null as local wall time.
443
463
  * Invalid values return null; callers decide how to say "unknown".
@@ -446,14 +466,30 @@ var AsyncResource = class {
446
466
  * @returns the formatted local time, or null when the value is absent/invalid.
447
467
  */
448
468
  function formatLocalDateTime(value, options = {}) {
449
- if (value === null || value === void 0) return null;
450
- const ms = typeof value === "number" ? value : Date.parse(value);
451
- if (!Number.isFinite(ms)) return null;
452
- const date = new Date(ms);
453
- if (Number.isNaN(date.getTime())) return null;
454
- const pad = (part) => String(part).padStart(2, "0");
455
- const head = String(date.getFullYear()) + "-" + pad(date.getMonth() + 1) + "-" + pad(date.getDate()) + " " + pad(date.getHours()) + ":" + pad(date.getMinutes());
456
- return options.seconds === false ? head : head + ":" + pad(date.getSeconds());
469
+ const date = toLocalDate(value);
470
+ if (date === null) return null;
471
+ return String(date.getFullYear()) + "-" + pad(date.getMonth() + 1) + "-" + pad(date.getDate()) + " " + clockOf(date, options);
472
+ }
473
+ /**
474
+ * Format only the local clock part, HH:MM[:SS]; null when the value is absent/invalid.
475
+ * @param value - ISO string, epoch ms, or null.
476
+ * @param options - seconds on/off; defaults to on.
477
+ * @returns the local clock text, or null.
478
+ */
479
+ function formatLocalClock(value, options = {}) {
480
+ const date = toLocalDate(value);
481
+ return date === null ? null : clockOf(date, options);
482
+ }
483
+ /**
484
+ * True when the value falls on the same local calendar day as now.
485
+ * @param value - ISO string, epoch ms, or null.
486
+ * @param now - the reference instant; defaults to the current time.
487
+ * @returns whether both are the same local day; false for invalid input.
488
+ */
489
+ function isSameLocalDay(value, now = /* @__PURE__ */ new Date()) {
490
+ const date = toLocalDate(value);
491
+ if (date === null) return false;
492
+ return date.getFullYear() === now.getFullYear() && date.getMonth() === now.getMonth() && date.getDate() === now.getDate();
457
493
  }
458
494
  //#endregion
459
495
  //#region lib/types/notice.js
@@ -574,6 +610,29 @@ function EmptyState({ title, description, tone = "neutral", primary, secondary,
574
610
  }, createElement("h2", { "data-role": "empty-title" }, title), description === void 0 || description === "" ? null : createElement("p", { "data-role": "empty-description" }, description), actions);
575
611
  }
576
612
  //#endregion
613
+ //#region lib/types/presentation/table.js
614
+ /**
615
+ * Responsive table contract shared by family panels.
616
+ *
617
+ * Markup: wrap any table in an element carrying data-evo-table-wrap. At a
618
+ * narrow container (including a 200% browser zoom) the rows become stacked
619
+ * definition blocks: rule/name on its own line, the metric on the next, so a
620
+ * fixed numeric column can never squeeze a label to one character.
621
+ */
622
+ const RESPONSIVE_TABLE_CSS = [
623
+ "[data-evo-table-wrap]{container-type:inline-size;}",
624
+ "@container (max-width: 700px) {",
625
+ " [data-evo-table-wrap] table{display:block;width:100%;table-layout:auto;border:0;}",
626
+ " [data-evo-table-wrap] thead{display:none;}",
627
+ " [data-evo-table-wrap] tbody{display:flex;flex-direction:column;gap:var(--evo-space-4);}",
628
+ " [data-evo-table-wrap] tr{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:var(--evo-space-2) var(--evo-space-8);padding:var(--evo-space-6) var(--evo-space-8);border:var(--evo-hairline-width) solid var(--dsw-alias-border-l1);border-radius:var(--evo-radius-control);}",
629
+ " [data-evo-table-wrap] td{display:block;padding:0;text-align:left;white-space:normal;overflow-wrap:anywhere;}",
630
+ " [data-evo-table-wrap] td[data-role=\"rule-name\"], [data-evo-table-wrap] td[data-role=\"name\"]{grid-column:1/-1;font-weight:500;}",
631
+ " [data-evo-table-wrap] td[data-role=\"rule-count\"], [data-evo-table-wrap] td[data-role=\"count\"]{grid-column:2;text-align:right;font-variant-numeric:tabular-nums;}",
632
+ " [data-evo-table-wrap] td[data-role=\"skills\"]{grid-column:1/-1;}",
633
+ "}"
634
+ ].join(String.fromCharCode(10));
635
+ //#endregion
577
636
  //#region lib/types/presentation/disclosure-group.js
578
637
  /** A native details group for normal/secondary facts. */
579
638
  /** Render a closed-by-default disclosure without introducing another accordion model. */
@@ -801,4 +860,4 @@ function createSettingsGatewayCache(binder, api) {
801
860
  };
802
861
  }
803
862
  //#endregion
804
- export { ActionMenu, AsyncResource, Block, CommandCopyButton, DecisionFrame, DisclosureGroup, EmptyState, FALLBACKS, FailureBlock, FilterChip, PAGE_SURFACE_CLASS, PAGE_SURFACE_CSS, PLATFORM_MENU, ROUTES, StateNotice, StatusChip, TOKENS, TOKEN_CSS, TaskBanner, TimeText, copyAction, createSettingsGatewayCache, createSettingsSeat, failureText, formatLocalDateTime, loadStateOf, menuPrimitivesFrom, panelWorkspaceId, registerSidebarPanel, registerWorkbenchView, renderPlatformMenu, saveSettings, tokenVars };
863
+ export { ActionMenu, AsyncResource, Block, CommandCopyButton, DecisionFrame, DisclosureGroup, EmptyState, FALLBACKS, FailureBlock, FilterChip, PAGE_SURFACE_CLASS, PAGE_SURFACE_CSS, PLATFORM_MENU, RESPONSIVE_TABLE_CSS, ROUTES, StateNotice, StatusChip, TOKENS, TOKEN_CSS, TaskBanner, TimeText, copyAction, createSettingsGatewayCache, createSettingsSeat, failureText, formatLocalClock, formatLocalDateTime, isSameLocalDay, loadStateOf, menuPrimitivesFrom, panelWorkspaceId, registerSidebarPanel, registerWorkbenchView, renderPlatformMenu, requireClientSeats, saveSettings, tokenVars };
@@ -11,4 +11,18 @@ export interface LocalDateTimeOptions {
11
11
  * @returns the formatted local time, or null when the value is absent/invalid.
12
12
  */
13
13
  export declare function formatLocalDateTime(value: string | number | null | undefined, options?: LocalDateTimeOptions): string | null;
14
+ /**
15
+ * Format only the local clock part, HH:MM[:SS]; null when the value is absent/invalid.
16
+ * @param value - ISO string, epoch ms, or null.
17
+ * @param options - seconds on/off; defaults to on.
18
+ * @returns the local clock text, or null.
19
+ */
20
+ export declare function formatLocalClock(value: string | number | null | undefined, options?: LocalDateTimeOptions): string | null;
21
+ /**
22
+ * True when the value falls on the same local calendar day as now.
23
+ * @param value - ISO string, epoch ms, or null.
24
+ * @param now - the reference instant; defaults to the current time.
25
+ * @returns whether both are the same local day; false for invalid input.
26
+ */
27
+ export declare function isSameLocalDay(value: string | number | null | undefined, now?: Date): boolean;
14
28
  //# sourceMappingURL=format.d.ts.map
@@ -1,3 +1,19 @@
1
+ /** Parse an ISO string, epoch ms, or null into a valid Date; null when absent/invalid. */
2
+ function toLocalDate(value) {
3
+ if (value === null || value === undefined)
4
+ return null;
5
+ const ms = typeof value === 'number' ? value : Date.parse(value);
6
+ if (!Number.isFinite(ms))
7
+ return null;
8
+ const date = new Date(ms);
9
+ return Number.isNaN(date.getTime()) ? null : date;
10
+ }
11
+ const pad = (part) => String(part).padStart(2, '0');
12
+ /** The local clock part, HH:MM[:SS]. */
13
+ function clockOf(date, options) {
14
+ const head = pad(date.getHours()) + ':' + pad(date.getMinutes());
15
+ return options.seconds === false ? head : head + ':' + pad(date.getSeconds());
16
+ }
1
17
  /**
2
18
  * Format an ISO string, epoch milliseconds, or null as local wall time.
3
19
  * Invalid values return null; callers decide how to say "unknown".
@@ -6,17 +22,31 @@
6
22
  * @returns the formatted local time, or null when the value is absent/invalid.
7
23
  */
8
24
  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))
25
+ const date = toLocalDate(value);
26
+ if (date === null)
13
27
  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());
28
+ return String(date.getFullYear()) + '-' + pad(date.getMonth() + 1) + '-' + pad(date.getDate()) + ' ' + clockOf(date, options);
29
+ }
30
+ /**
31
+ * Format only the local clock part, HH:MM[:SS]; null when the value is absent/invalid.
32
+ * @param value - ISO string, epoch ms, or null.
33
+ * @param options - seconds on/off; defaults to on.
34
+ * @returns the local clock text, or null.
35
+ */
36
+ export function formatLocalClock(value, options = {}) {
37
+ const date = toLocalDate(value);
38
+ return date === null ? null : clockOf(date, options);
39
+ }
40
+ /**
41
+ * True when the value falls on the same local calendar day as now.
42
+ * @param value - ISO string, epoch ms, or null.
43
+ * @param now - the reference instant; defaults to the current time.
44
+ * @returns whether both are the same local day; false for invalid input.
45
+ */
46
+ export function isSameLocalDay(value, now = new Date()) {
47
+ const date = toLocalDate(value);
48
+ if (date === null)
49
+ return false;
50
+ return date.getFullYear() === now.getFullYear() && date.getMonth() === now.getMonth() && date.getDate() === now.getDate();
21
51
  }
22
52
  //# sourceMappingURL=format.js.map
@@ -1,17 +1,18 @@
1
1
  /** Shared browser seams and panel lifecycle for the evolution family. */
2
2
  export type { ClientSeam, ConfigFormLike, ConfigFormSnapshotLike, ConfigFormsSeat, ConfigPathOpLike, ConfigWriteKind, ConfigWriteOutcome, LocaleSeat, PanelBodyOptions, PanelRowOptions, SettingsFace, SlotsSeat } from './seam.ts';
3
- export { registerSidebarPanel, type SidebarPanelSpec, type Translate } from './panel.ts';
3
+ export { registerSidebarPanel, requireClientSeats, type SidebarPanelSpec, type Translate } from './panel.ts';
4
4
  export { registerWorkbenchView } from './workbench-view.ts';
5
5
  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';
9
+ export { formatLocalClock, formatLocalDateTime, isSameLocalDay, type LocalDateTimeOptions } from './format.ts';
10
10
  export { StateNotice, type StateNoticeProps, type StateNoticeTone } from './notice.ts';
11
11
  export { DecisionFrame, type DecisionFrameProps } from './presentation/decision-frame.ts';
12
12
  export { TaskBanner, type TaskBannerProps } from './presentation/task-banner.ts';
13
13
  export { StatusChip, FilterChip, type StatusChipProps, type FilterChipProps } from './presentation/chips.ts';
14
14
  export { EmptyState, type EmptyStateProps } from './presentation/empty-state.ts';
15
+ export { RESPONSIVE_TABLE_CSS } from './presentation/table.ts';
15
16
  export { DisclosureGroup, type DisclosureGroupProps } from './presentation/disclosure-group.ts';
16
17
  export { TimeText, type TimeTextProps } from './presentation/time-text.ts';
17
18
  export { ActionMenu, PLATFORM_MENU, renderPlatformMenu, menuPrimitivesFrom, type ActionMenuProps, type RowMenuAction, type MenuPrimitives, type MenuSurfaceComponent, type MenuItemButtonComponent } from './presentation/action-menu.ts';
@@ -1,14 +1,15 @@
1
- export { registerSidebarPanel } from "./panel.js";
1
+ export { registerSidebarPanel, requireClientSeats } from "./panel.js";
2
2
  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";
6
+ export { formatLocalClock, formatLocalDateTime, isSameLocalDay } from "./format.js";
7
7
  export { StateNotice } from "./notice.js";
8
8
  export { DecisionFrame } from "./presentation/decision-frame.js";
9
9
  export { TaskBanner } from "./presentation/task-banner.js";
10
10
  export { StatusChip, FilterChip } from "./presentation/chips.js";
11
11
  export { EmptyState } from "./presentation/empty-state.js";
12
+ export { RESPONSIVE_TABLE_CSS } from "./presentation/table.js";
12
13
  export { DisclosureGroup } from "./presentation/disclosure-group.js";
13
14
  export { TimeText } from "./presentation/time-text.js";
14
15
  export { ActionMenu, PLATFORM_MENU, renderPlatformMenu, menuPrimitivesFrom } from "./presentation/action-menu.js";
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import type { Context as ClientContext } from '@deepseek-ai/cordis';
6
6
  import type { ReactNode } from 'react';
7
+ import type { ClientSeam } from './seam.ts';
7
8
  /** Dictionary lookup used by the panel body and row label. */
8
9
  export type Translate = (key: string, values?: Readonly<Record<string, string | number>>) => string;
9
10
  /** The feature-specific part of one sidebar panel. */
@@ -42,6 +43,8 @@ export interface SidebarPanelSpec<Face> {
42
43
  /** Optional store owned by this registration; the platform binds it to the occupant. */
43
44
  store?: unknown;
44
45
  }
46
+ /** Fail loud when a client bundle is mounted without the shell seats it consumes. */
47
+ export declare function requireClientSeats(ctx: unknown, owner: string): ClientSeam;
45
48
  /**
46
49
  * Register one sidebar row and its main body under one lifecycle.
47
50
  * @param ctx - the client context carrying the slots and locale seats.
@@ -1,3 +1,11 @@
1
+ /** Fail loud when a client bundle is mounted without the shell seats it consumes. */
2
+ export function requireClientSeats(ctx, owner) {
3
+ const candidate = ctx;
4
+ if (candidate.slots === undefined || candidate.locale === undefined) {
5
+ throw new Error(owner + ': the client slots/locale seats are not mounted');
6
+ }
7
+ return candidate;
8
+ }
1
9
  function interpolate(text, values) {
2
10
  if (values === undefined)
3
11
  return text;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Responsive table contract shared by family panels.
3
+ *
4
+ * Markup: wrap any table in an element carrying data-evo-table-wrap. At a
5
+ * narrow container (including a 200% browser zoom) the rows become stacked
6
+ * definition blocks: rule/name on its own line, the metric on the next, so a
7
+ * fixed numeric column can never squeeze a label to one character.
8
+ */
9
+ export declare const RESPONSIVE_TABLE_CSS: string;
10
+ //# sourceMappingURL=table.d.ts.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Responsive table contract shared by family panels.
3
+ *
4
+ * Markup: wrap any table in an element carrying data-evo-table-wrap. At a
5
+ * narrow container (including a 200% browser zoom) the rows become stacked
6
+ * definition blocks: rule/name on its own line, the metric on the next, so a
7
+ * fixed numeric column can never squeeze a label to one character.
8
+ */
9
+ export const RESPONSIVE_TABLE_CSS = [
10
+ '[data-evo-table-wrap]{container-type:inline-size;}',
11
+ '@container (max-width: 700px) {',
12
+ ' [data-evo-table-wrap] table{display:block;width:100%;table-layout:auto;border:0;}',
13
+ ' [data-evo-table-wrap] thead{display:none;}',
14
+ ' [data-evo-table-wrap] tbody{display:flex;flex-direction:column;gap:var(--evo-space-4);}',
15
+ ' [data-evo-table-wrap] tr{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:var(--evo-space-2) var(--evo-space-8);padding:var(--evo-space-6) var(--evo-space-8);border:var(--evo-hairline-width) solid var(--dsw-alias-border-l1);border-radius:var(--evo-radius-control);}',
16
+ ' [data-evo-table-wrap] td{display:block;padding:0;text-align:left;white-space:normal;overflow-wrap:anywhere;}',
17
+ ' [data-evo-table-wrap] td[data-role="rule-name"], [data-evo-table-wrap] td[data-role="name"]{grid-column:1/-1;font-weight:500;}',
18
+ ' [data-evo-table-wrap] td[data-role="rule-count"], [data-evo-table-wrap] td[data-role="count"]{grid-column:2;text-align:right;font-variant-numeric:tabular-nums;}',
19
+ ' [data-evo-table-wrap] td[data-role="skills"]{grid-column:1/-1;}',
20
+ '}',
21
+ ].join(String.fromCharCode(10));
22
+ //# sourceMappingURL=table.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.37.0",
4
+ "version": "0.38.0",
5
5
  "private": false,
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -61,6 +61,6 @@
61
61
  "react": "^18.2.0"
62
62
  },
63
63
  "engines": {
64
- "dsh": ">=0.2.1-rc.2 <0.2.2-0"
64
+ "dsh": ">=0.2.2-rc.0 <0.2.3-0"
65
65
  }
66
66
  }