@seanyeh77/ui 0.50.1 → 0.51.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/dist/index.d.ts CHANGED
@@ -42,7 +42,7 @@ import { LineBand, LineChart, LineChartProps, LineSeries, LineThreshold } from "
42
42
  import { StatusBand, StatusBandProps, StatusLegend, StatusSegment } from "./components/StatusBand/StatusBand.js";
43
43
  import { Meter, MeterProps } from "./components/Meter/Meter.js";
44
44
  import { Zone, ZoneMap, ZoneMapProps } from "./components/ZoneMap/ZoneMap.js";
45
- import { FloorPlan, FloorPlanEdge, FloorPlanGroup, FloorPlanProps, FloorPlanZone, MultiPolygon } from "./components/FloorPlan/FloorPlan.js";
45
+ import { FloorPlan, FloorPlanEdge, FloorPlanGroup, FloorPlanProps, FloorPlanView, FloorPlanZone, MultiPolygon } from "./components/FloorPlan/FloorPlan.js";
46
46
  import { EventKind, EventTimeline, EventTimelineProps, TimelineEvent, TimelineKind } from "./components/EventTimeline/EventTimeline.js";
47
47
  import { ConsoleExtra, ConsoleLayout, ConsoleLayoutProps } from "./components/ConsoleLayout/ConsoleLayout.js";
48
48
  import { consoleZoom } from "./deprecated.js";
@@ -94,4 +94,4 @@ import { MOTION } from "./motion.js";
94
94
  import { ThemeSetting, divergeToken, heatToken, initTheme, pickedAccent, resetAccent, setAccent, setTheme, storedAccent, storedTheme, textOn, themePreset, themeScript } from "./theme.js";
95
95
  import { announce } from "./announce.js";
96
96
  import { Workbench, WorkbenchApi, WorkbenchHandle, WorkbenchLayout, WorkbenchProps, WorkbenchRegion, WorkbenchView, useWorkbench } from "./components/Workbench/Workbench.js";
97
- export { AccentPicker, type AccentPickerProps, ActionBar, type ActionBarAction, type ActionBarProps, AiMark, type AiMarkProps, Alert, type AlertProps, type AlertTone, AppShell, type AppShellProps, Badge, type BadgePreset, type BadgeProps, type BadgeStatus, type BadgeTone, BarChart, type BarChartProps, type BarDatum, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, type ButtonProps, Calendar, type CalendarProps, Card, type CardProps, Checkbox, type CheckboxProps, type CodeLanguage, type CodeLink, CodeText, type CodeTextProps, CodeView, type CodeViewHandle, type CodeViewProps, CommandPalette, type CommandPaletteProps, type ConsoleExtra, ConsoleLayout, type ConsoleLayoutProps, type CountUnit, type CustomIcon, type DangerConfirm, DangerZone, type DangerZoneProps, DataTable, type DataTableColumn, type DataTableFilter, type DataTableProps, type DataTableView, DatePicker, type DatePickerProps, type DateRange, DateRangePicker, type DateRangePickerProps, type DayState, type Decimals, DetailList, type DetailListItem, type DetailListProps, Dialog, type DialogProps, Drawer, type DrawerProps, EmptyState, type EmptyStateProps, ErrorPage, type ErrorPageProps, type EventKind, EventTimeline, type EventTimelineProps, type FieldProps, type FilePicker, type FilePickerOptions, FileUpload, type FileUploadProps, type FilterOption, type FilterValue, FloorPlan, type FloorPlanEdge, type FloorPlanGroup, type FloorPlanProps, type FloorPlanZone, type FormErrors, FormGrid, type FormGridProps, GraphDefs, GraphLegend, type GraphLegendItem, type GraphLegendProps, Grid, type GridProps, type GridRatio, Icon, IconButton, type IconButtonHint, type IconButtonProps, type IconName, type IconProps, type IconSource, InlineCode, type InlineCodeProps, KpiCard, type KpiCardProps, LayerGraph, type LayerGraphEdge, type LayerGraphNode, type LayerGraphProps, type LineBand, LineChart, type LineChartProps, type LineSeries, type LineThreshold, Link, type LinkProps, LoadingBar, type LoadingBarProps, LocaleProvider, type LocaleProviderProps, LoginCard, type LoginCardProps, MOTION, Markdown, type MarkdownProps, Menu, type MenuItem, type MenuProps, Meter, type MeterProps, type MobileTab, MobileTabBar, type MobileTabBarProps, type MultiPolygon, MultiSelect, type MultiSelectOption, type MultiSelectProps, type NavBrand, type NavItem, type NavSection, NotificationBell, type NotificationBellProps, type NotificationItem, type OnRef, type OpenChangeReason, type OpenStateProps, Page, PageHeader, type PageHeaderAction, type PageHeaderProps, type PageProps, type PaletteItem, type PaletteKind, Popover, type PopoverProps, ProgressBar, type ProgressBarProps, ProgressRing, type ProgressRingProps, type ProjectOption, type ProjectStatus, ProjectSwitcher, type ProjectSwitcherProps, RadioGroup, type RadioGroupProps, type RadioOption, type RangeValue, type RefHref, RelativeTime, type RelativeTimeProps, type Row, type RowKey, SearchField, type SearchFieldProps, Section, SectionGroup, type SectionGroupProps, SectionGroupToggle, type SectionGroupToggleProps, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedItem, type SegmentedOption, Select, type SelectOption, type SelectProps, type SettingsCategory, SettingsLayout, type SettingsLayoutProps, SettingsRow, type SettingsRowProps, SettingsSection, type SettingsSectionProps, SideNav, type SideNavProps, Skeleton, type SkeletonProps, SplitPane, type SplitPaneProps, StatusBand, type StatusBandProps, StatusLegend, type StatusSegment, Suggestion, type SuggestionProps, Switch, type SwitchProps, TOAST_DURATION, type TabItem, Tabs, type TabsProps, Tag, type TagProps, Term, type TermDef, type TermProps, type TermsMark, TextArea, type TextAreaProps, TextField, type TextFieldProps, ThemePicker, type ThemePickerProps, type ThemePreset, type ThemeSetting, TimeControl, type TimeControlProps, type TimelineEvent, type TimelineKind, Toast, type ToastAction, type ToastOptions, type ToastProps, type ToastTone, Toaster, type ToasterProps, type Token, type TokenClass, type Tokenizer, Tooltip, type TooltipProps, TopBar, type TopBarProps, type Total, Tour, type TourProps, type TourStep, TreeList, type TreeListProps, type TreeMark, type TreeNode, type UploadFile, type UseFormErrors, Workbench, type WorkbenchApi, type WorkbenchHandle, type WorkbenchLayout, type WorkbenchProps, type WorkbenchRegion, type WorkbenchView, type Zone, ZoneMap, type ZoneMapProps, addMessages, announce, consoleZoom, divergeToken, focusMain, format, heatToken, icons, initTheme, isCodeRef, pickedAccent, preloadIcons, resetAccent, safeHref, setAccent, setLocale, setTheme, storedAccent, storedTheme, subscribeLocale, tr as t, textOn, themePreset, themeScript, toast, useFilePicker, useFormErrors, useLocale, useToast, useTour, useWorkbench };
97
+ export { AccentPicker, type AccentPickerProps, ActionBar, type ActionBarAction, type ActionBarProps, AiMark, type AiMarkProps, Alert, type AlertProps, type AlertTone, AppShell, type AppShellProps, Badge, type BadgePreset, type BadgeProps, type BadgeStatus, type BadgeTone, BarChart, type BarChartProps, type BarDatum, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, type ButtonProps, Calendar, type CalendarProps, Card, type CardProps, Checkbox, type CheckboxProps, type CodeLanguage, type CodeLink, CodeText, type CodeTextProps, CodeView, type CodeViewHandle, type CodeViewProps, CommandPalette, type CommandPaletteProps, type ConsoleExtra, ConsoleLayout, type ConsoleLayoutProps, type CountUnit, type CustomIcon, type DangerConfirm, DangerZone, type DangerZoneProps, DataTable, type DataTableColumn, type DataTableFilter, type DataTableProps, type DataTableView, DatePicker, type DatePickerProps, type DateRange, DateRangePicker, type DateRangePickerProps, type DayState, type Decimals, DetailList, type DetailListItem, type DetailListProps, Dialog, type DialogProps, Drawer, type DrawerProps, EmptyState, type EmptyStateProps, ErrorPage, type ErrorPageProps, type EventKind, EventTimeline, type EventTimelineProps, type FieldProps, type FilePicker, type FilePickerOptions, FileUpload, type FileUploadProps, type FilterOption, type FilterValue, FloorPlan, type FloorPlanEdge, type FloorPlanGroup, type FloorPlanProps, type FloorPlanView, type FloorPlanZone, type FormErrors, FormGrid, type FormGridProps, GraphDefs, GraphLegend, type GraphLegendItem, type GraphLegendProps, Grid, type GridProps, type GridRatio, Icon, IconButton, type IconButtonHint, type IconButtonProps, type IconName, type IconProps, type IconSource, InlineCode, type InlineCodeProps, KpiCard, type KpiCardProps, LayerGraph, type LayerGraphEdge, type LayerGraphNode, type LayerGraphProps, type LineBand, LineChart, type LineChartProps, type LineSeries, type LineThreshold, Link, type LinkProps, LoadingBar, type LoadingBarProps, LocaleProvider, type LocaleProviderProps, LoginCard, type LoginCardProps, MOTION, Markdown, type MarkdownProps, Menu, type MenuItem, type MenuProps, Meter, type MeterProps, type MobileTab, MobileTabBar, type MobileTabBarProps, type MultiPolygon, MultiSelect, type MultiSelectOption, type MultiSelectProps, type NavBrand, type NavItem, type NavSection, NotificationBell, type NotificationBellProps, type NotificationItem, type OnRef, type OpenChangeReason, type OpenStateProps, Page, PageHeader, type PageHeaderAction, type PageHeaderProps, type PageProps, type PaletteItem, type PaletteKind, Popover, type PopoverProps, ProgressBar, type ProgressBarProps, ProgressRing, type ProgressRingProps, type ProjectOption, type ProjectStatus, ProjectSwitcher, type ProjectSwitcherProps, RadioGroup, type RadioGroupProps, type RadioOption, type RangeValue, type RefHref, RelativeTime, type RelativeTimeProps, type Row, type RowKey, SearchField, type SearchFieldProps, Section, SectionGroup, type SectionGroupProps, SectionGroupToggle, type SectionGroupToggleProps, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedItem, type SegmentedOption, Select, type SelectOption, type SelectProps, type SettingsCategory, SettingsLayout, type SettingsLayoutProps, SettingsRow, type SettingsRowProps, SettingsSection, type SettingsSectionProps, SideNav, type SideNavProps, Skeleton, type SkeletonProps, SplitPane, type SplitPaneProps, StatusBand, type StatusBandProps, StatusLegend, type StatusSegment, Suggestion, type SuggestionProps, Switch, type SwitchProps, TOAST_DURATION, type TabItem, Tabs, type TabsProps, Tag, type TagProps, Term, type TermDef, type TermProps, type TermsMark, TextArea, type TextAreaProps, TextField, type TextFieldProps, ThemePicker, type ThemePickerProps, type ThemePreset, type ThemeSetting, TimeControl, type TimeControlProps, type TimelineEvent, type TimelineKind, Toast, type ToastAction, type ToastOptions, type ToastProps, type ToastTone, Toaster, type ToasterProps, type Token, type TokenClass, type Tokenizer, Tooltip, type TooltipProps, TopBar, type TopBarProps, type Total, Tour, type TourProps, type TourStep, TreeList, type TreeListProps, type TreeMark, type TreeNode, type UploadFile, type UseFormErrors, Workbench, type WorkbenchApi, type WorkbenchHandle, type WorkbenchLayout, type WorkbenchProps, type WorkbenchRegion, type WorkbenchView, type Zone, ZoneMap, type ZoneMapProps, addMessages, announce, consoleZoom, divergeToken, focusMain, format, heatToken, icons, initTheme, isCodeRef, pickedAccent, preloadIcons, resetAccent, safeHref, setAccent, setLocale, setTheme, storedAccent, storedTheme, subscribeLocale, tr as t, textOn, themePreset, themeScript, toast, useFilePicker, useFormErrors, useLocale, useToast, useTour, useWorkbench };
@@ -13,24 +13,32 @@ function heatRange(zones, min, max) {
13
13
  const hi = max ?? (values.length ? Math.max(...values) : 1);
14
14
  return hi > lo ? [lo, hi] : [lo - 1, lo + 1];
15
15
  }
16
+ /** A figure with its decimals; signed, a positive one gets 「+」. A value that rounds to zero has no sign (never 「-0.0」). */
17
+ function signedNumber(v, decimals, signed = false) {
18
+ const r = Number(v.toFixed(decimals));
19
+ const shown = r === 0 ? 0 : v;
20
+ return (signed && r > 0 ? "+" : "") + format.number(shown, decimals);
21
+ }
16
22
  /** True when the zone has no data: a dashed outline, not selectable. */
17
23
  const noData = (z) => z.value == null && !z.forecast;
18
24
  /** The fill (token name or color), its CSS background, the text color for a fill that is not a data token, the state
19
- * with 「⚠ 」 when it needs attention, the figure, the figure with its unit, and the accessible name. */
20
- function zoneText(z, min, max, extra = []) {
25
+ * with 「⚠ 」 when it needs attention, the figure, the figure with its unit, and the accessible name: name, figure,
26
+ * state, `extra`, detail, `after`. */
27
+ function zoneText(z, min, max, extra = [], after = []) {
21
28
  const tone = z.tone ?? "normal";
22
29
  const fill = z.fill ?? (z.value != null ? heatToken(z.value, min, max) : "surface-sub");
23
30
  const bg = /^[a-z][a-z0-9-]*$/.test(fill) ? `var(--${fill})` : fill;
24
31
  const stateWord = z.state ?? (z.forecast ? tr("預測") : tr("正常"));
25
32
  const state = (tone === "normal" ? "" : "⚠ ") + stateWord;
26
- const figure = z.value != null ? format.number(z.value, z.decimals ?? 1) : "—";
33
+ const figure = z.value != null ? signedNumber(z.value, z.decimals ?? 1, z.signed) : "—";
27
34
  const reading = figure + (z.unit ? " " + z.unit : "");
28
35
  const label = [
29
36
  z.name,
30
37
  reading,
31
38
  stateWord,
32
39
  ...extra,
33
- z.detail
40
+ z.detail,
41
+ ...after
34
42
  ].filter(Boolean).join(tr(","));
35
43
  return {
36
44
  tone,
@@ -43,6 +51,6 @@ function zoneText(z, min, max, extra = []) {
43
51
  label
44
52
  };
45
53
  }
46
- export { DATA_TOKEN, heatRange, noData, zoneText };
54
+ export { DATA_TOKEN, heatRange, noData, signedNumber, zoneText };
47
55
 
48
56
  //# sourceMappingURL=zone.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"zone.js","names":[],"sources":["../../src/internal/zone.ts"],"sourcesContent":["// What ZoneMap and FloorPlan share: the heat range, and a zone's fill, figure, state and accessible name.\nimport { format } from '../format';\nimport { tr } from '../i18n';\nimport { heatToken, textOn } from '../theme';\n\n/** The fields of a zone both maps read. */\ninterface ZoneText {\n name: string;\n value?: number | null;\n unit?: string;\n decimals?: number;\n fill?: string;\n tone?: 'normal' | 'warning' | 'danger';\n state?: string;\n forecast?: boolean;\n detail?: string;\n}\n\n/** Data tokens whose text color comes from CSS (it follows the theme); other fills are measured with textOn(). */\nexport const DATA_TOKEN = /^(heat-[1-7]|diverge-(neg|pos)(-strong)?|diverge-zero|chart-[1-4])$/;\n\n/** The heat range: min and max when given, else the zones' own smallest and largest value. One value alone (or all\n * equal) gets that value ± 1, so it lands in the middle of the scale. */\nexport function heatRange(zones: readonly { value?: number | null }[], min?: number, max?: number): [number, number] {\n const values = zones.map((z) => z.value).filter((v): v is number => v != null && Number.isFinite(v));\n const lo = min ?? (values.length ? Math.min(...values) : 0);\n const hi = max ?? (values.length ? Math.max(...values) : 1);\n return hi > lo ? [lo, hi] : [lo - 1, lo + 1];\n}\n\n/** True when the zone has no data: a dashed outline, not selectable. */\nexport const noData = (z: ZoneText): boolean => z.value == null && !z.forecast;\n\n/** The fill (token name or color), its CSS background, the text color for a fill that is not a data token, the state\n * with 「⚠ 」 when it needs attention, the figure, the figure with its unit, and the accessible name. */\nexport function zoneText(z: ZoneText, min: number, max: number, extra: string[] = []) {\n const tone = z.tone ?? 'normal';\n const fill = z.fill ?? (z.value != null ? heatToken(z.value, min, max) : 'surface-sub');\n const bg = /^[a-z][a-z0-9-]*$/.test(fill) ? `var(--${fill})` : fill;\n const stateWord = z.state ?? (z.forecast ? tr('預測') : tr('正常'));\n const state = (tone === 'normal' ? '' : '⚠ ') + stateWord;\n const figure = z.value != null ? format.number(z.value, z.decimals ?? 1) : '—';\n const reading = figure + (z.unit ? ' ' + z.unit : '');\n const label = [z.name, reading, stateWord, ...extra, z.detail].filter(Boolean).join(tr(','));\n const color = DATA_TOKEN.test(fill) ? undefined : textOn(fill);\n return { tone, fill, bg, color, state, figure, reading, label };\n}\n"],"mappings":";;;;;;AAmBA,MAAa,aAAa;;;AAI1B,SAAgB,UAAU,OAA6C,KAAc,KAAgC;CACnH,MAAM,SAAS,MAAM,KAAK,MAAM,EAAE,KAAK,CAAC,CAAC,QAAQ,MAAmB,KAAK,QAAQ,OAAO,SAAS,CAAC,CAAC;CACnG,MAAM,KAAK,QAAQ,OAAO,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI;CACzD,MAAM,KAAK,QAAQ,OAAO,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI;CACzD,OAAO,KAAK,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AAC7C;;AAGA,MAAa,UAAU,MAAyB,EAAE,SAAS,QAAQ,CAAC,EAAE;;;AAItE,SAAgB,SAAS,GAAa,KAAa,KAAa,QAAkB,CAAC,GAAG;CACpF,MAAM,OAAO,EAAE,QAAQ;CACvB,MAAM,OAAO,EAAE,SAAS,EAAE,SAAS,OAAO,UAAU,EAAE,OAAO,KAAK,GAAG,IAAI;CACzE,MAAM,KAAK,oBAAoB,KAAK,IAAI,IAAI,SAAS,KAAK,KAAK;CAC/D,MAAM,YAAY,EAAE,UAAU,EAAE,WAAW,GAAG,IAAI,IAAI,GAAG,IAAI;CAC7D,MAAM,SAAS,SAAS,WAAW,KAAK,QAAQ;CAChD,MAAM,SAAS,EAAE,SAAS,OAAO,OAAO,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,IAAI;CAC3E,MAAM,UAAU,UAAU,EAAE,OAAO,MAAM,EAAE,OAAO;CAClD,MAAM,QAAQ;EAAC,EAAE;EAAM;EAAS;EAAW,GAAG;EAAO,EAAE;CAAM,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC;CAE3F,OAAO;EAAE;EAAM;EAAM;EAAI,OADX,WAAW,KAAK,IAAI,IAAI,KAAA,IAAY,OAAO,IAAI;EAC7B;EAAO;EAAQ;EAAS;CAAM;AAChE"}
1
+ {"version":3,"file":"zone.js","names":[],"sources":["../../src/internal/zone.ts"],"sourcesContent":["// What ZoneMap and FloorPlan share: the heat range, and a zone's fill, figure, state and accessible name.\nimport { format } from '../format';\nimport { tr } from '../i18n';\nimport { heatToken, textOn } from '../theme';\n\n/** The fields of a zone both maps read. */\ninterface ZoneText {\n name: string;\n value?: number | null;\n unit?: string;\n decimals?: number;\n signed?: boolean;\n fill?: string;\n tone?: 'normal' | 'warning' | 'danger';\n state?: string;\n forecast?: boolean;\n detail?: string;\n}\n\n/** Data tokens whose text color comes from CSS (it follows the theme); other fills are measured with textOn(). */\nexport const DATA_TOKEN = /^(heat-[1-7]|diverge-(neg|pos)(-strong)?|diverge-zero|chart-[1-4])$/;\n\n/** The heat range: min and max when given, else the zones' own smallest and largest value. One value alone (or all\n * equal) gets that value ± 1, so it lands in the middle of the scale. */\nexport function heatRange(zones: readonly { value?: number | null }[], min?: number, max?: number): [number, number] {\n const values = zones.map((z) => z.value).filter((v): v is number => v != null && Number.isFinite(v));\n const lo = min ?? (values.length ? Math.min(...values) : 0);\n const hi = max ?? (values.length ? Math.max(...values) : 1);\n return hi > lo ? [lo, hi] : [lo - 1, lo + 1];\n}\n\n/** A figure with its decimals; signed, a positive one gets 「+」. A value that rounds to zero has no sign (never 「-0.0」). */\nexport function signedNumber(v: number, decimals: number, signed = false): string {\n const r = Number(v.toFixed(decimals));\n const shown = r === 0 ? 0 : v;\n return (signed && r > 0 ? '+' : '') + format.number(shown, decimals);\n}\n\n/** True when the zone has no data: a dashed outline, not selectable. */\nexport const noData = (z: ZoneText): boolean => z.value == null && !z.forecast;\n\n/** The fill (token name or color), its CSS background, the text color for a fill that is not a data token, the state\n * with 「⚠ 」 when it needs attention, the figure, the figure with its unit, and the accessible name: name, figure,\n * state, `extra`, detail, `after`. */\nexport function zoneText(z: ZoneText, min: number, max: number, extra: string[] = [], after: string[] = []) {\n const tone = z.tone ?? 'normal';\n const fill = z.fill ?? (z.value != null ? heatToken(z.value, min, max) : 'surface-sub');\n const bg = /^[a-z][a-z0-9-]*$/.test(fill) ? `var(--${fill})` : fill;\n const stateWord = z.state ?? (z.forecast ? tr('預測') : tr('正常'));\n const state = (tone === 'normal' ? '' : '⚠ ') + stateWord;\n const figure = z.value != null ? signedNumber(z.value, z.decimals ?? 1, z.signed) : '—';\n const reading = figure + (z.unit ? ' ' + z.unit : '');\n const label = [z.name, reading, stateWord, ...extra, z.detail, ...after].filter(Boolean).join(tr(','));\n const color = DATA_TOKEN.test(fill) ? undefined : textOn(fill);\n return { tone, fill, bg, color, state, figure, reading, label };\n}\n"],"mappings":";;;;;;AAoBA,MAAa,aAAa;;;AAI1B,SAAgB,UAAU,OAA6C,KAAc,KAAgC;CACnH,MAAM,SAAS,MAAM,KAAK,MAAM,EAAE,KAAK,CAAC,CAAC,QAAQ,MAAmB,KAAK,QAAQ,OAAO,SAAS,CAAC,CAAC;CACnG,MAAM,KAAK,QAAQ,OAAO,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI;CACzD,MAAM,KAAK,QAAQ,OAAO,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI;CACzD,OAAO,KAAK,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AAC7C;;AAGA,SAAgB,aAAa,GAAW,UAAkB,SAAS,OAAe;CAChF,MAAM,IAAI,OAAO,EAAE,QAAQ,QAAQ,CAAC;CACpC,MAAM,QAAQ,MAAM,IAAI,IAAI;CAC5B,QAAQ,UAAU,IAAI,IAAI,MAAM,MAAM,OAAO,OAAO,OAAO,QAAQ;AACrE;;AAGA,MAAa,UAAU,MAAyB,EAAE,SAAS,QAAQ,CAAC,EAAE;;;;AAKtE,SAAgB,SAAS,GAAa,KAAa,KAAa,QAAkB,CAAC,GAAG,QAAkB,CAAC,GAAG;CAC1G,MAAM,OAAO,EAAE,QAAQ;CACvB,MAAM,OAAO,EAAE,SAAS,EAAE,SAAS,OAAO,UAAU,EAAE,OAAO,KAAK,GAAG,IAAI;CACzE,MAAM,KAAK,oBAAoB,KAAK,IAAI,IAAI,SAAS,KAAK,KAAK;CAC/D,MAAM,YAAY,EAAE,UAAU,EAAE,WAAW,GAAG,IAAI,IAAI,GAAG,IAAI;CAC7D,MAAM,SAAS,SAAS,WAAW,KAAK,QAAQ;CAChD,MAAM,SAAS,EAAE,SAAS,OAAO,aAAa,EAAE,OAAO,EAAE,YAAY,GAAG,EAAE,MAAM,IAAI;CACpF,MAAM,UAAU,UAAU,EAAE,OAAO,MAAM,EAAE,OAAO;CAClD,MAAM,QAAQ;EAAC,EAAE;EAAM;EAAS;EAAW,GAAG;EAAO,EAAE;EAAQ,GAAG;CAAK,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC;CAErG,OAAO;EAAE;EAAM;EAAM;EAAI,OADX,WAAW,KAAK,IAAI,IAAI,KAAA,IAAY,OAAO,IAAI;EAC7B;EAAO;EAAQ;EAAS;CAAM;AAChE"}
package/docs/FloorPlan.md CHANGED
@@ -9,34 +9,93 @@ h(UI.FloorPlan, {
9
9
  label: '機房平面圖',
10
10
  value: sel,
11
11
  onChange: setSel,
12
- min: 20, max: 30, warn: 27, limit: 30,
12
+ min: 20,
13
+ max: 30,
14
+ warn: 27,
15
+ limit: 30,
13
16
  groups: [{ id: 'north', name: '北側機櫃列' }],
14
17
  zones: [
15
- { id: 'a', name: '冷通道 A', value: 23.1, unit: '°C', outline: [[[[2, 2], [14, 2], [14, 8], [8, 8], [8, 14], [2, 14]]]], label: [5, 5] },
16
- { id: 'f', name: '機櫃區 F', value: 29.6, unit: '°C', tone: 'danger', state: '超過上限', group: 'north', outline: [[[[16, 17], [26, 17], [26, 22], [16, 22]]]], label: [21, 19.5] },
17
- { id: 'e', name: '走道 E', value: 22.4, unit: '°C', emphasis: 'muted', outline: [[[[16, 14], [38, 14], [38, 16], [16, 16]]]], label: [27, 15] },
18
+ {
19
+ id: 'a',
20
+ name: '冷通道 A',
21
+ value: 23.1,
22
+ unit: '°C',
23
+ outline: [
24
+ [
25
+ [
26
+ [2, 2],
27
+ [14, 2],
28
+ [14, 8],
29
+ [8, 8],
30
+ [8, 14],
31
+ [2, 14],
32
+ ],
33
+ ],
34
+ ],
35
+ label: [5, 5],
36
+ },
37
+ {
38
+ id: 'f',
39
+ name: '機櫃區 F',
40
+ value: 29.6,
41
+ unit: '°C',
42
+ tone: 'danger',
43
+ state: '超過上限',
44
+ group: 'north',
45
+ outline: [
46
+ [
47
+ [
48
+ [16, 17],
49
+ [26, 17],
50
+ [26, 22],
51
+ [16, 22],
52
+ ],
53
+ ],
54
+ ],
55
+ label: [21, 19.5],
56
+ },
57
+ {
58
+ id: 'e',
59
+ name: '走道 E',
60
+ value: 22.4,
61
+ unit: '°C',
62
+ emphasis: 'muted',
63
+ outline: [
64
+ [
65
+ [
66
+ [16, 14],
67
+ [38, 14],
68
+ [38, 16],
69
+ [16, 16],
70
+ ],
71
+ ],
72
+ ],
73
+ label: [27, 15],
74
+ },
18
75
  ],
19
76
  });
20
77
  ```
21
78
 
22
79
  - 分區的欄位和 ZoneMap 的 `Zone` 相同(`tone`、`state`、`forecast`、`detail`、`fill`、`value: null` 是沒有資料),`area` 換成 `outline` 和 `label`。
23
80
  - `outline` 是 MultiPolygon,單位公尺,y 向上是北:`[多邊形][環][點][x, y]`,每個多邊形的第一個環是外框,其餘是洞。元件自己翻轉 y、算出視角。
24
- - `label` 是標籤的位置,由呼叫端算好(例如內部離邊最遠的點),一定要在外框裡。
81
+ - `label` 是標籤的位置,和 `outline` 同一個座標(公尺,y 向上),由呼叫端算好、一定要在外框裡:建議用 polylabel 算多邊形內離邊最遠的點(分成好幾塊時用面積最大的那塊)。
25
82
  - 寬度小於 600 px 時圖很小,大部分標籤會被捨棄:旁邊附 DataTable 的清單檢視,列出同樣的分區。
26
83
  - `warn`、`limit` 只畫在圖例上,數值由呼叫端給,元件不假設門檻。
84
+ - 差值(例如預測減實際)的分區加 `signed`:正數寫「+1.1 °C」,螢幕閱讀器也念出正負;四捨五入成 0 的不加符號。
27
85
 
28
86
  ## 細節
29
87
 
30
88
  - 標籤:在分區裡放得下時寫名稱(16 px 半粗)、主數值(25 px Geist Mono,單位 16 px)和狀態(13 px 半粗);外框包圍盒長寬比大於 4 的細長分區,或完整標籤放不下時,改用一行膠囊(13 px,`surface` 底);膠囊也會和別的標籤重疊時不顯示。標籤一律同樣大小,放大後放得下的就會出現。
31
- - 標籤的優先序:primary 在 muted 之前,各自面積小的先;被捨棄的分區仍然有游標提示,也在 Tab 順序裡。
89
+ - 標籤的優先序:選取中的分區最先,接著 `labelPriority` 大的先(預設 0),再來 primary 在 muted 之前,各自面積小的先;被捨棄的分區仍然有游標提示,也在 Tab 順序裡。Tab 順序不受 `labelPriority` 和選取影響。
32
90
  - `emphasis: 'muted'`:次要區域,填色是原色 40 % 混 `surface`,標籤 13 px 名稱加 16 px 數值,字用 `ink`;可以選,`tone` 的 4 px 內框和「⚠」照常顯示;螢幕閱讀器多念「次要」。有 muted 分區時圖例多一行「淡色=次要區域」。
33
91
  - 填色、字色、4 px 注意內框、預測斜線、沒有資料的虛線框、數值和單位之間的空格,都和 ZoneMap 相同(見 `ui docs ZoneMap`)。
34
92
  - 選取:`ink` 色 2 px 外框,在分區外 4 px。鍵盤焦點:`focus` 色 2 px 外框,緊貼分區外側,並顯示提示。
35
93
  - `groups`:同一組的分區外面畫一圈 1.5 px `ink-muted` 細框(沿著整組的外形),左上角寫組名(13 px)。不計算也不顯示整組的數值。
36
94
  - `shell`:建築外框,`surface-sub` 底加 `line-strong` 邊。`edges`:分區之間的邊界,1.5 px `ink-muted` 虛線。
95
+ - 視角:`defaultView`(`{ x, y, zoom }`,中心點的公尺座標,y 向上;`zoom` 1 是全景,最多 8)是一開始的視角;`onViewChange(view)` 在視角停下來時(拖曳、雙指放開、滾輪一格、按鍵或按鈕的動畫結束)給出新的視角。元件被卸載再掛上時(例如切到清單檢視再切回來),把最後一次的 `view` 存起來、當 `defaultView` 傳回去,就會停在原來的地方。
37
96
  - 縮放與平移:滾輪、雙指縮放、拖曳平移;右下角「放大」「縮小」「重設視角」;鍵盤在圖上(包括分區上)按 + − 縮放、方向鍵平移。最多放大 8 倍,全景時不能平移。按鈕和鍵盤的變化有 200 ms 的動畫,`prefers-reduced-motion` 時直接跳過去。拖曳超過 4 px 不算點選。
38
97
  - 鍵盤:每個分區是按鈕,Tab 順序和標籤的優先序相同;Enter 或空白鍵選取(`aria-pressed`)。螢幕閱讀器念「機櫃區 F,29.6 °C,超過上限,進氣 27.9 °C」。沒有資料的分區不能選。
39
- - 提示:滑鼠停在分區上或鍵盤聚焦時顯示名稱、數值、狀態、`detail`。
98
+ - 提示:滑鼠停在分區上或鍵盤聚焦時顯示名稱、數值、狀態、`detail`,再加上 `tooltip` 的每一行(例如「濕度 48 %」);螢幕閱讀器在 `detail` 後面念這些行。
40
99
  - 觸控:寬度小於 600 px 或觸控螢幕上,畫面上小於 48 px 的分區在標籤位置多一個 48 px 的圓形點擊範圍。圖上的手勢都交給地圖(`touch-action: none`),頁面要在圖外捲動。
41
100
  - 大小:沒有 `fill` 時照外框的比例,高 240~640 px;放在 ConsoleLayout 的主視覺卡片裡時加 `fill`,撐滿卡片的高度(最少 240 px),和 ZoneMap 的 `fill` 相同。
42
101
  - 標籤的寬度用固定的估算(中文 1 em、Geist Mono 0.6 em),網頁字型載入前後、伺服器渲染時排法都一樣。
package/docs/ZoneMap.md CHANGED
@@ -20,6 +20,7 @@ h(UI.ZoneMap, {
20
20
 
21
21
  - 需要注意:`tone: 'warning'`/`'danger'`,畫 4 px 內框,狀態前加「⚠」;和選取的外框樣子不同,可以同時出現。
22
22
  - 預測:`forecast` 疊上預測斜線,狀態預設「預測」。
23
+ - 差值(例如預測減實際):`signed`,正數寫「+1.1 °C」,螢幕閱讀器也念出正負。
23
24
  - 放在 ConsoleLayout 的主視覺卡片裡時加 `fill`,讓分區撐滿卡片。
24
25
 
25
26
  ## 細節
package/docs/agents.md CHANGED
@@ -65,11 +65,11 @@ export default [ui.configs.recommended];
65
65
  ```html
66
66
  <meta charset="utf-8">
67
67
  <meta name="viewport" content="width=device-width, initial-scale=1">
68
- <link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.50.1/fonts.css">
69
- <link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.50.1/tokens.css">
70
- <link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.50.1/styles.css">
68
+ <link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.51.0/fonts.css">
69
+ <link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.51.0/tokens.css">
70
+ <link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.51.0/styles.css">
71
71
  <div id="root"></div>
72
- <script src="https://seanyeh77.github.io/ui-design-system/dist/0.50.1/bundle.js"></script>
72
+ <script src="https://seanyeh77.github.io/ui-design-system/dist/0.51.0/bundle.js"></script>
73
73
  <script>
74
74
  const h = React.createElement;
75
75
  UI.initTheme();
@@ -77,6 +77,6 @@ export default [ui.configs.recommended];
77
77
  </script>
78
78
  ```
79
79
 
80
- Pin a version as above: `/dist/<version>/` never changes; `/dist/` always serves the latest release. jsDelivr has the same files (`https://cdn.jsdelivr.net/npm/@seanyeh77/ui@0.50.1/dist/bundle.js`, `…/dist/styles.css`; the fonts at `https://cdn.jsdelivr.net/npm/@seanyeh77/tokens@0.50.1/fonts.css`). Without a bundler, `@seanyeh77/ui/dist/fonts.css` cannot resolve its import: load the tokens package's `fonts.css` or the pinned site URL.
80
+ Pin a version as above: `/dist/<version>/` never changes; `/dist/` always serves the latest release. jsDelivr has the same files (`https://cdn.jsdelivr.net/npm/@seanyeh77/ui@0.51.0/dist/bundle.js`, `…/dist/styles.css`; the fonts at `https://cdn.jsdelivr.net/npm/@seanyeh77/tokens@0.51.0/fonts.css`). Without a bundler, `@seanyeh77/ui/dist/fonts.css` cannot resolve its import: load the tokens package's `fonts.css` or the pinned site URL.
81
81
 
82
82
  Scope: web UI, and the tokens of SeanYeh's Slidev decks (`initTheme({ preset: 'teaching' })`, see `theme.md`). Slide layout, Notion documents and teaching diagrams follow the separate `teaching-materials-style` skill.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seanyeh77/ui",
3
- "version": "0.50.1",
3
+ "version": "0.51.0",
4
4
  "description": "SeanYeh's design system: typed React components on Base UI, styled with design tokens.",
5
5
  "license": "MIT",
6
6
  "author": "Hsiu-An Yeh",
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "@base-ui/react": "^1.9.0",
61
- "@seanyeh77/tokens": "^0.50.1"
61
+ "@seanyeh77/tokens": "^0.51.0"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "node scripts/theme-defaults.ts && tsdown && node scripts/postbuild.ts",