@seanyeh77/ui 0.35.0 → 0.36.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/bundle.js +14 -14
- package/dist/bundle.js.map +1 -1
- package/dist/index.d.ts +20 -3
- package/dist/index.js +30 -5
- package/dist/index.js.map +1 -1
- package/dist/styles.css +37 -0
- package/dist/tokens.css +28 -0
- package/docs/DataColors.md +46 -0
- package/docs/LineChart.md +1 -1
- package/docs/Tag.md +9 -0
- package/docs/guidelines.md +6 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1272,7 +1272,7 @@ interface LineSeries {
|
|
|
1272
1272
|
values: number[];
|
|
1273
1273
|
}
|
|
1274
1274
|
interface LineChartProps {
|
|
1275
|
-
/** Up to
|
|
1275
|
+
/** Up to 4 series (chart-1 to chart-4); a legend with each name appears for 2 or more. */
|
|
1276
1276
|
series: LineSeries[];
|
|
1277
1277
|
/** One label per point on the x axis. */
|
|
1278
1278
|
labels: string[];
|
|
@@ -1630,10 +1630,15 @@ interface SegmentedControlProps<V extends string = string> {
|
|
|
1630
1630
|
export declare function SegmentedControl<V extends string = string>({ items, value, onChange, label, iconOnly, className }: SegmentedControlProps<V>): React.JSX.Element;
|
|
1631
1631
|
interface TagProps {
|
|
1632
1632
|
children?: React.ReactNode;
|
|
1633
|
+
/** `plain` (default): small gray text. `forecast`: marks a value as forecast, not measured (accent-soft fill), e.g.
|
|
1634
|
+
* 「預測」 beside it or on a striped `ui-forecast` area. `demo`: a whole page of sample values (warning-soft fill,
|
|
1635
|
+
* bold), e.g. 「示範資料」 beside the brand; one per page. */
|
|
1636
|
+
variant?: 'plain' | 'forecast' | 'demo';
|
|
1633
1637
|
className?: string;
|
|
1634
1638
|
}
|
|
1635
|
-
/** What kind of thing an item is (「外部」「範本」): small gray text. Status uses Badge instead.
|
|
1636
|
-
|
|
1639
|
+
/** What kind of thing an item is (「外部」「範本」): small gray text. Status uses Badge instead. Two filled kinds say
|
|
1640
|
+
* where numbers come from: forecast and demo. */
|
|
1641
|
+
export declare function Tag({ children, variant, className }: TagProps): React.JSX.Element;
|
|
1637
1642
|
interface TermProps {
|
|
1638
1643
|
/** The word or label that needs explaining. */
|
|
1639
1644
|
children?: React.ReactNode;
|
|
@@ -1698,6 +1703,18 @@ export declare function setTheme(t: ThemeSetting): void;
|
|
|
1698
1703
|
export declare function setAccent(hex: string, quiet?: boolean): boolean;
|
|
1699
1704
|
/** Applies the stored theme and accent; call once when the page starts. */
|
|
1700
1705
|
export declare function initTheme(): void;
|
|
1706
|
+
/** The text color for something drawn on a fill (a heat-scale zone, a status band): the near-black ink of the light
|
|
1707
|
+
* theme (#171512) or white, whichever contrasts more with the fill. `fill` is a color (#hex, rgb()) or a token name
|
|
1708
|
+
* such as 'heat-6', read from el (default: the root) so it follows the theme. Every step of heat-*, diverge-* and
|
|
1709
|
+
* chart-* reaches 4.5:1 with its pick. Unreadable colors give the near-black ink. */
|
|
1710
|
+
export declare function textOn(fill: string, el?: Element): '#171512' | '#ffffff';
|
|
1711
|
+
/** The heat-scale token for a value: min (or below) is heat-1, max (or above) is heat-7, evenly in between. */
|
|
1712
|
+
export declare function heatToken(value: number, min: number, max: number): `heat-${1 | 2 | 3 | 4 | 5 | 6 | 7}`;
|
|
1713
|
+
/** The diverging-scale token for a difference: within ±zero it is diverge-zero; from ±strong on, the -strong step. */
|
|
1714
|
+
export declare function divergeToken(diff: number, limits: {
|
|
1715
|
+
zero: number;
|
|
1716
|
+
strong: number;
|
|
1717
|
+
}): 'diverge-neg-strong' | 'diverge-neg' | 'diverge-zero' | 'diverge-pos' | 'diverge-pos-strong';
|
|
1701
1718
|
interface ThemePickerProps {
|
|
1702
1719
|
/** Controlled value. Without it, the picker reads and sets the stored theme itself. */
|
|
1703
1720
|
value?: ThemeSetting;
|
package/dist/index.js
CHANGED
|
@@ -1473,6 +1473,29 @@ function initTheme() {
|
|
|
1473
1473
|
if (storedTheme() === "auto") setTheme("auto");
|
|
1474
1474
|
});
|
|
1475
1475
|
}
|
|
1476
|
+
/** The text color for something drawn on a fill (a heat-scale zone, a status band): the near-black ink of the light
|
|
1477
|
+
* theme (#171512) or white, whichever contrasts more with the fill. `fill` is a color (#hex, rgb()) or a token name
|
|
1478
|
+
* such as 'heat-6', read from el (default: the root) so it follows the theme. Every step of heat-*, diverge-* and
|
|
1479
|
+
* chart-* reaches 4.5:1 with its pick. Unreadable colors give the near-black ink. */
|
|
1480
|
+
function textOn(fill, el) {
|
|
1481
|
+
let c = fill.trim();
|
|
1482
|
+
if (/^[a-z][a-z0-9-]*$/.test(c) && typeof document !== "undefined") c = getComputedStyle(el ?? document.documentElement).getPropertyValue("--" + c);
|
|
1483
|
+
const hex = toHex(c);
|
|
1484
|
+
if (!hex) return "#171512";
|
|
1485
|
+
return contrast(hex, "#171512") >= contrast(hex, "#ffffff") ? "#171512" : "#ffffff";
|
|
1486
|
+
}
|
|
1487
|
+
/** The heat-scale token for a value: min (or below) is heat-1, max (or above) is heat-7, evenly in between. */
|
|
1488
|
+
function heatToken(value, min, max) {
|
|
1489
|
+
const t = max > min ? (value - min) / (max - min) : 0;
|
|
1490
|
+
return `heat-${Math.min(7, Math.max(1, Math.round(t * 6) + 1))}`;
|
|
1491
|
+
}
|
|
1492
|
+
/** The diverging-scale token for a difference: within ±zero it is diverge-zero; from ±strong on, the -strong step. */
|
|
1493
|
+
function divergeToken(diff, limits) {
|
|
1494
|
+
const a = Math.abs(diff);
|
|
1495
|
+
if (a <= limits.zero) return "diverge-zero";
|
|
1496
|
+
const strong = a >= limits.strong;
|
|
1497
|
+
return diff < 0 ? strong ? "diverge-neg-strong" : "diverge-neg" : strong ? "diverge-pos-strong" : "diverge-pos";
|
|
1498
|
+
}
|
|
1476
1499
|
// src/components/AccentPicker/AccentPicker.tsx
|
|
1477
1500
|
const SWATCHES = [
|
|
1478
1501
|
["藍", "#2457d6"],
|
|
@@ -1892,7 +1915,8 @@ function smoothPath(p) {
|
|
|
1892
1915
|
const CHART = [
|
|
1893
1916
|
"var(--chart-1)",
|
|
1894
1917
|
"var(--chart-2)",
|
|
1895
|
-
"var(--chart-3)"
|
|
1918
|
+
"var(--chart-3)",
|
|
1919
|
+
"var(--chart-4)"
|
|
1896
1920
|
];
|
|
1897
1921
|
/** The color of series i. */
|
|
1898
1922
|
const seriesColor = (i) => CHART[i % CHART.length];
|
|
@@ -9698,10 +9722,11 @@ function SegmentedControl({ items, value, onChange, label, iconOnly = false, cla
|
|
|
9698
9722
|
});
|
|
9699
9723
|
}
|
|
9700
9724
|
// src/components/Tag/Tag.tsx
|
|
9701
|
-
/** What kind of thing an item is (「外部」「範本」): small gray text. Status uses Badge instead.
|
|
9702
|
-
|
|
9725
|
+
/** What kind of thing an item is (「外部」「範本」): small gray text. Status uses Badge instead. Two filled kinds say
|
|
9726
|
+
* where numbers come from: forecast and demo. */
|
|
9727
|
+
function Tag({ children, variant = "plain", className }) {
|
|
9703
9728
|
return /* @__PURE__ */ jsx("span", {
|
|
9704
|
-
className: cx("ui-tag", className),
|
|
9729
|
+
className: cx("ui-tag", variant !== "plain" && "is-" + variant, className),
|
|
9705
9730
|
children
|
|
9706
9731
|
});
|
|
9707
9732
|
}
|
|
@@ -12017,6 +12042,6 @@ function Workbench({ ref, ...p }) {
|
|
|
12017
12042
|
})
|
|
12018
12043
|
});
|
|
12019
12044
|
}
|
|
12020
|
-
export { AccentPicker, ActionBar, AiMark, Alert, AppShell, Badge, BarChart, Breadcrumb, Button, Calendar, Card, Checkbox, CodeText, CodeView, CommandPalette, DangerZone, DataTable, DatePicker, DateRangePicker, DetailList, Dialog, Drawer, EmptyState, ErrorPage, FileUpload, FormGrid, GraphDefs, GraphLegend, Grid, Icon, IconButton, InlineCode, KpiCard, LayerGraph, LineChart, LoadingBar, LoginCard, MOTION, Markdown, Menu, MobileTabBar, MultiSelect, NotificationBell, Page, Popover, ProgressBar, ProgressRing, ProjectSwitcher, RadioGroup, SearchField, Section, SectionGroup, SectionGroupToggle, SegmentedControl, Select, SettingsLayout, SettingsSection, SideNav, Skeleton, SplitPane, Suggestion, Switch, Tabs, Tag, Term, TextArea, TextField, ThemePicker, Toast, Tooltip, TopBar, Tour, TreeList, Workbench, addMessages, announce, focusMain, format, icons, initTheme, isCodeRef, safeHref, setAccent, setLocale, setTheme, tr as t, useTour, useWorkbench };
|
|
12045
|
+
export { AccentPicker, ActionBar, AiMark, Alert, AppShell, Badge, BarChart, Breadcrumb, Button, Calendar, Card, Checkbox, CodeText, CodeView, CommandPalette, DangerZone, DataTable, DatePicker, DateRangePicker, DetailList, Dialog, Drawer, EmptyState, ErrorPage, FileUpload, FormGrid, GraphDefs, GraphLegend, Grid, Icon, IconButton, InlineCode, KpiCard, LayerGraph, LineChart, LoadingBar, LoginCard, MOTION, Markdown, Menu, MobileTabBar, MultiSelect, NotificationBell, Page, Popover, ProgressBar, ProgressRing, ProjectSwitcher, RadioGroup, SearchField, Section, SectionGroup, SectionGroupToggle, SegmentedControl, Select, SettingsLayout, SettingsSection, SideNav, Skeleton, SplitPane, Suggestion, Switch, Tabs, Tag, Term, TextArea, TextField, ThemePicker, Toast, Tooltip, TopBar, Tour, TreeList, Workbench, addMessages, announce, divergeToken, focusMain, format, heatToken, icons, initTheme, isCodeRef, safeHref, setAccent, setLocale, setTheme, tr as t, textOn, useTour, useWorkbench };
|
|
12021
12046
|
|
|
12022
12047
|
//# sourceMappingURL=index.js.map
|