@seanyeh77/ui 0.27.0 → 0.28.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 +19 -19
- package/dist/bundle.js.map +1 -1
- package/dist/index.d.ts +20 -4
- package/dist/index.js +62 -20
- package/dist/index.js.map +1 -1
- package/dist/styles.css +70 -0
- package/docs/AppShell.md +17 -1
- package/docs/SideNav.md +17 -1
- package/docs/guidelines.md +1 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -177,6 +177,17 @@ interface NavItem {
|
|
|
177
177
|
interface NavSection {
|
|
178
178
|
items: NavItem[];
|
|
179
179
|
}
|
|
180
|
+
/** The product at the top of the sidebar. */
|
|
181
|
+
interface NavBrand {
|
|
182
|
+
/** Logo or colour block, at most 24 px: stays where it is, collapsed and open. Default: the first character of
|
|
183
|
+
* `name` in an accent square. */
|
|
184
|
+
mark?: React.ReactNode;
|
|
185
|
+
/** The product name: shown beside the mark when the sidebar is open, the link's name when collapsed. */
|
|
186
|
+
name: string;
|
|
187
|
+
/** Usually the home page. */
|
|
188
|
+
href?: string;
|
|
189
|
+
onClick?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
190
|
+
}
|
|
180
191
|
interface SideNavProps {
|
|
181
192
|
/** Groups separated by a divider. */
|
|
182
193
|
sections: NavSection[];
|
|
@@ -191,7 +202,10 @@ interface SideNavProps {
|
|
|
191
202
|
onPin?: () => void;
|
|
192
203
|
/** Whether the sidebar is pinned: the pin button is filled and says 「取消釘選」. */
|
|
193
204
|
pinned?: boolean;
|
|
194
|
-
|
|
205
|
+
/** The product at the top. Prefer { mark, name, href }: collapsed (72 px) it shows only the mark, still a link
|
|
206
|
+
* named by `name`; open, the mark with the name fading in beside it. Text alone gets its first character in an
|
|
207
|
+
* accent square as the mark. Any other element is hidden while collapsed. */
|
|
208
|
+
brand?: React.ReactNode | NavBrand;
|
|
195
209
|
/** Default 「主要導覽」. */
|
|
196
210
|
label?: string;
|
|
197
211
|
className?: string;
|
|
@@ -219,8 +233,10 @@ interface AppShellProps {
|
|
|
219
233
|
/** Id of the current page. */
|
|
220
234
|
value: string;
|
|
221
235
|
onNavigate: (id: string) => void;
|
|
222
|
-
/**
|
|
223
|
-
|
|
236
|
+
/** The product at the top of the sidebar: { mark, name, href } (see SideNav's NavBrand). Collapsed it shows the mark
|
|
237
|
+
* alone, a link named by `name`; open or pinned, the name fades in beside it. Plain text gets its first character as
|
|
238
|
+
* the mark. */
|
|
239
|
+
brand?: React.ReactNode | NavBrand;
|
|
224
240
|
/** The page title, shown once in the top bar. Do not repeat it as a heading in the page. */
|
|
225
241
|
title?: string;
|
|
226
242
|
breadcrumb?: BreadcrumbItem[];
|
|
@@ -1788,4 +1804,4 @@ export declare const MOTION: {
|
|
|
1788
1804
|
/** Says text to screen readers through the page's polite live region, without moving focus: 「顯示 6 筆」.
|
|
1789
1805
|
* A second call before the first is read replaces it. */
|
|
1790
1806
|
export declare function announce(text: string): void;
|
|
1791
|
-
export { type AccentPickerProps, type ActionBarAction, type ActionBarProps, type AiMarkProps, type AlertProps, type AlertTone, type AppShellProps, type BadgeProps, type BadgeStatus, type BarChartProps, type BarDatum, type BreadcrumbItem, type BreadcrumbProps, type ButtonProps, type CalendarProps, type CardProps, type CheckboxProps, type CodeLanguage, type CodeLink, type CodeTextProps, type CodeViewHandle, type CodeViewProps, type CommandPaletteProps, type CountUnit, type CustomIcon, type DangerConfirm, type DangerZoneProps, type DataTableColumn, type DataTableFilter, type DataTableProps, type DataTableView, type DatePickerProps, type DateRange, type DateRangePickerProps, type DayState, type Decimals, type DetailListItem, type DetailListProps, type DialogProps, type DrawerProps, type EmptyStateProps, type ErrorPageProps, type FileUploadProps, type FilterOption, type FilterValue, type FormGridProps, type GraphLegendItem, type GraphLegendProps, type GridProps, type IconButtonHint, type IconButtonProps, type IconName, type IconProps, type IconSource, type InlineCodeProps, type KpiCardProps, type LayerGraphEdge, type LayerGraphNode, type LayerGraphProps, type LineChartProps, type LineSeries, type LoadingBarProps, type LoginCardProps, type MarkdownProps, type MenuItem, type MenuProps, type MobileTab, type MobileTabBarProps, type MultiSelectOption, type MultiSelectProps, type NavItem, type NavSection, type NotificationBellProps, type NotificationItem, type OnRef, type PageProps, type PaletteItem, type PopoverProps, type ProgressBarProps, type ProgressRingProps, type ProjectOption, type ProjectStatus, type ProjectSwitcherProps, type RadioGroupProps, type RadioOption, type RangeValue, type RefHref, type Row, type RowKey, type SearchFieldProps, type SectionGroupProps, type SectionGroupToggleProps, type SectionProps, type SelectOption, type SelectProps, type SettingsCategory, type SettingsLayoutProps, type SettingsSectionProps, type SideNavProps, type SkeletonProps, type SplitPaneProps, type SuggestionProps, type SwitchProps, type TabItem, type TabsProps, type TagProps, type TermProps, type TextAreaProps, type TextFieldProps, type ThemePickerProps, type ThemeSetting, type ToastProps, type Token, type TokenClass, type Tokenizer, type TooltipProps, type TopBarProps, type Total, type TourProps, type TourStep, type TreeListProps, type TreeNode, type UploadFile, addMessages, format, setLocale, tr as t };
|
|
1807
|
+
export { type AccentPickerProps, type ActionBarAction, type ActionBarProps, type AiMarkProps, type AlertProps, type AlertTone, type AppShellProps, type BadgeProps, type BadgeStatus, type BarChartProps, type BarDatum, type BreadcrumbItem, type BreadcrumbProps, type ButtonProps, type CalendarProps, type CardProps, type CheckboxProps, type CodeLanguage, type CodeLink, type CodeTextProps, type CodeViewHandle, type CodeViewProps, type CommandPaletteProps, type CountUnit, type CustomIcon, type DangerConfirm, type DangerZoneProps, type DataTableColumn, type DataTableFilter, type DataTableProps, type DataTableView, type DatePickerProps, type DateRange, type DateRangePickerProps, type DayState, type Decimals, type DetailListItem, type DetailListProps, type DialogProps, type DrawerProps, type EmptyStateProps, type ErrorPageProps, type FileUploadProps, type FilterOption, type FilterValue, type FormGridProps, type GraphLegendItem, type GraphLegendProps, type GridProps, type IconButtonHint, type IconButtonProps, type IconName, type IconProps, type IconSource, type InlineCodeProps, type KpiCardProps, type LayerGraphEdge, type LayerGraphNode, type LayerGraphProps, type LineChartProps, type LineSeries, type LoadingBarProps, type LoginCardProps, type MarkdownProps, type MenuItem, type MenuProps, type MobileTab, type MobileTabBarProps, type MultiSelectOption, type MultiSelectProps, type NavBrand, type NavItem, type NavSection, type NotificationBellProps, type NotificationItem, type OnRef, type PageProps, type PaletteItem, type PopoverProps, type ProgressBarProps, type ProgressRingProps, type ProjectOption, type ProjectStatus, type ProjectSwitcherProps, type RadioGroupProps, type RadioOption, type RangeValue, type RefHref, type Row, type RowKey, type SearchFieldProps, type SectionGroupProps, type SectionGroupToggleProps, type SectionProps, type SelectOption, type SelectProps, type SettingsCategory, type SettingsLayoutProps, type SettingsSectionProps, type SideNavProps, type SkeletonProps, type SplitPaneProps, type SuggestionProps, type SwitchProps, type TabItem, type TabsProps, type TagProps, type TermProps, type TextAreaProps, type TextFieldProps, type ThemePickerProps, type ThemeSetting, type ToastProps, type Token, type TokenClass, type Tokenizer, type TooltipProps, type TopBarProps, type Total, type TourProps, type TourStep, type TreeListProps, type TreeNode, type UploadFile, addMessages, format, setLocale, tr as t };
|
package/dist/index.js
CHANGED
|
@@ -491,7 +491,66 @@ function announce(text) {
|
|
|
491
491
|
el.textContent = text;
|
|
492
492
|
}, 60);
|
|
493
493
|
}
|
|
494
|
+
// src/internal/dev.ts
|
|
495
|
+
const DEV = typeof __UI_DEV__ === "boolean" ? __UI_DEV__ : (() => {
|
|
496
|
+
try {
|
|
497
|
+
return process.env.NODE_ENV !== "production";
|
|
498
|
+
} catch {
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
})();
|
|
502
|
+
const seen = /* @__PURE__ */ new Set();
|
|
503
|
+
/** Logs once per message when cond is true. */
|
|
504
|
+
function devWarn(cond, component, message) {
|
|
505
|
+
if (!DEV || !cond) return;
|
|
506
|
+
const text = `[@seanyeh77/ui] ${component}: ${message}`;
|
|
507
|
+
if (seen.has(text)) return;
|
|
508
|
+
seen.add(text);
|
|
509
|
+
console.warn(text);
|
|
510
|
+
}
|
|
494
511
|
// src/components/SideNav/SideNav.tsx
|
|
512
|
+
const isBrand = (b) => !!b && typeof b === "object" && !React.isValidElement(b) && !Array.isArray(b) && typeof b.name === "string";
|
|
513
|
+
function NavBrandRow({ brand, collapsed }) {
|
|
514
|
+
const spec = isBrand(brand) ? brand : typeof brand === "string" ? { name: brand } : null;
|
|
515
|
+
devWarn(!spec && collapsed, "SideNav", "brand 是一個元素,收合時讀不出哪部分是 logo,只能整塊藏起來。改傳 brand={{ mark, name, href }}:收合時顯示 mark,展開時加上名稱。");
|
|
516
|
+
if (!spec) return /* @__PURE__ */ jsx("div", {
|
|
517
|
+
className: "ui-nav-brand",
|
|
518
|
+
children: collapsed ? null : brand
|
|
519
|
+
});
|
|
520
|
+
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
521
|
+
className: "ui-nav-mark",
|
|
522
|
+
"aria-hidden": "true",
|
|
523
|
+
children: spec.mark ?? /* @__PURE__ */ jsx("span", {
|
|
524
|
+
className: "ui-nav-monogram",
|
|
525
|
+
children: Array.from(spec.name)[0]
|
|
526
|
+
})
|
|
527
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
528
|
+
className: "ui-nav-brand-name",
|
|
529
|
+
children: spec.name
|
|
530
|
+
})] });
|
|
531
|
+
const label = collapsed ? spec.name : void 0;
|
|
532
|
+
return /* @__PURE__ */ jsx("div", {
|
|
533
|
+
className: "ui-nav-brand has-mark",
|
|
534
|
+
children: spec.href ? /* @__PURE__ */ jsx("a", {
|
|
535
|
+
className: "ui-nav-brand-link",
|
|
536
|
+
href: spec.href,
|
|
537
|
+
onClick: spec.onClick,
|
|
538
|
+
"aria-label": label,
|
|
539
|
+
children: inner
|
|
540
|
+
}) : spec.onClick ? /* @__PURE__ */ jsx("button", {
|
|
541
|
+
type: "button",
|
|
542
|
+
className: "ui-nav-brand-link",
|
|
543
|
+
onClick: spec.onClick,
|
|
544
|
+
"aria-label": label,
|
|
545
|
+
children: inner
|
|
546
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
547
|
+
className: "ui-nav-brand-link",
|
|
548
|
+
"aria-label": label,
|
|
549
|
+
role: label ? "img" : void 0,
|
|
550
|
+
children: inner
|
|
551
|
+
})
|
|
552
|
+
});
|
|
553
|
+
}
|
|
495
554
|
/** The 240 px dashboard sidebar (72 px collapsed). The selection bar moves like a droplet. */
|
|
496
555
|
function SideNav({ sections, value, onChange, collapsed = false, onToggle, onPin, pinned = false, brand, label, className }) {
|
|
497
556
|
const refs = React.useRef({});
|
|
@@ -594,9 +653,9 @@ function SideNav({ sections, value, onChange, collapsed = false, onToggle, onPin
|
|
|
594
653
|
return /* @__PURE__ */ jsxs("aside", {
|
|
595
654
|
className: cx("ui-sidenav", collapsed && "is-collapsed", className),
|
|
596
655
|
children: [
|
|
597
|
-
brand ? /* @__PURE__ */ jsx(
|
|
598
|
-
|
|
599
|
-
|
|
656
|
+
brand ? /* @__PURE__ */ jsx(NavBrandRow, {
|
|
657
|
+
brand,
|
|
658
|
+
collapsed
|
|
600
659
|
}) : null,
|
|
601
660
|
/* @__PURE__ */ jsx("nav", {
|
|
602
661
|
className: "ui-nav-list",
|
|
@@ -869,23 +928,6 @@ function MobileTabBar({ items, value, onChange, label, labels = true, className
|
|
|
869
928
|
}, t.id))]
|
|
870
929
|
});
|
|
871
930
|
}
|
|
872
|
-
// src/internal/dev.ts
|
|
873
|
-
const DEV = typeof __UI_DEV__ === "boolean" ? __UI_DEV__ : (() => {
|
|
874
|
-
try {
|
|
875
|
-
return process.env.NODE_ENV !== "production";
|
|
876
|
-
} catch {
|
|
877
|
-
return false;
|
|
878
|
-
}
|
|
879
|
-
})();
|
|
880
|
-
const seen = /* @__PURE__ */ new Set();
|
|
881
|
-
/** Logs once per message when cond is true. */
|
|
882
|
-
function devWarn(cond, component, message) {
|
|
883
|
-
if (!DEV || !cond) return;
|
|
884
|
-
const text = `[@seanyeh77/ui] ${component}: ${message}`;
|
|
885
|
-
if (seen.has(text)) return;
|
|
886
|
-
seen.add(text);
|
|
887
|
-
console.warn(text);
|
|
888
|
-
}
|
|
889
931
|
// src/components/Button/Button.tsx
|
|
890
932
|
/** Buttons. Labels are verbs; one primary per section; danger actions are always confirmed. */
|
|
891
933
|
function Button(props) {
|