@bixlab/mtone 0.5.0 → 0.7.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/README.md +1 -1
- package/dist/index.d.ts +58 -21
- package/dist/index.js +235 -27
- package/dist/styles.css +1 -1
- package/llms.txt +78 -45
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ Node 24 recommended. The documentation app lives in `apps/docs`; its static buil
|
|
|
38
38
|
|
|
39
39
|
Buttons, forms, selection controls, navigation, directory tree, tabs, menus, lists, table, status and property displays, dialogs/drawers, feedback and upload. No block editor or backend. See [API](https://github.com/xingjianxu/mtone/blob/master/docs/API.md), [coverage](https://github.com/xingjianxu/mtone/blob/master/docs/COVERAGE.md) and [verification](https://github.com/xingjianxu/mtone/blob/master/docs/VERIFICATION.md).
|
|
40
40
|
|
|
41
|
-
Default style: text #37352F, muted #787774, border #E9E9E7, subtle surface #F7F7F5, white canvas, 14px text, 28px controls, 4px radius. CSS is precompiled, prefixed and contains no Tailwind Preflight.
|
|
41
|
+
Default style: text #37352F, muted #787774, border #E9E9E7, subtle surface #F7F7F5, white canvas, 14px text, 28px controls, 4px radius. CSS is precompiled, prefixed and contains no Tailwind Preflight. Existing applications remain light by default. Since 0.7.0, set `theme="dark"` or `theme="system"` on `MtoneProvider`; system mode follows the operating system without reloading. `MtoneScope` can override the mode locally and mtone popups follow their trigger context. The library leaves preference storage to the application.
|
|
42
42
|
|
|
43
43
|
## License
|
|
44
44
|
|
package/dist/index.d.ts
CHANGED
|
@@ -682,27 +682,41 @@ interface ListProps<T = unknown> extends Omit<React__default.HTMLAttributes<HTML
|
|
|
682
682
|
ref?: React__default.Ref<ListHandle>;
|
|
683
683
|
}
|
|
684
684
|
/** Compact native list, with optional grouped and windowed data rendering. */
|
|
685
|
-
declare function
|
|
685
|
+
declare function ListRoot<T = unknown>({ children, items, getKey, renderItem, groupBy, renderGroup, stickyGroups, height, contentWidth, virtual, estimatedItemHeight, estimatedGroupHeight, overscan, hoverable, emptyContent, loading, loadingContent, onEndReached, endThreshold, ref, className, style, onScroll, ...props }: ListProps<T>): React__default.JSX.Element;
|
|
686
|
+
/** Drag grip for a controlled sortable list. Supply keyboard reordering separately. */
|
|
687
|
+
type ListSortHandleProps = Omit<React__default.HTMLAttributes<HTMLSpanElement>, "children" | "draggable">;
|
|
688
|
+
declare function ListSortHandle({ className, title, ...props }: ListSortHandleProps): React__default.JSX.Element;
|
|
686
689
|
interface ListItemProps extends React__default.LiHTMLAttributes<HTMLLIElement> {
|
|
690
|
+
sortHandle?: ListSortHandleProps;
|
|
687
691
|
icon?: React__default.ReactNode;
|
|
688
692
|
description?: React__default.ReactNode;
|
|
689
693
|
actions?: React__default.ReactNode;
|
|
690
694
|
}
|
|
691
|
-
declare function ListItem({ children, icon, description, actions, ...props }: ListItemProps): React__default.JSX.Element;
|
|
695
|
+
declare function ListItem({ children, sortHandle, icon, description, actions, ...props }: ListItemProps): React__default.JSX.Element;
|
|
696
|
+
declare const List: typeof ListRoot & {
|
|
697
|
+
SortHandle: typeof ListSortHandle;
|
|
698
|
+
};
|
|
692
699
|
|
|
693
700
|
declare const cn: (...v: (string | false | null | undefined)[]) => string;
|
|
694
701
|
type Locale = "zh" | "en";
|
|
695
702
|
type Tokens = React.CSSProperties & Record<`--mt-${string}`, string | number>;
|
|
703
|
+
type MtoneTheme = "light" | "dark" | "system";
|
|
696
704
|
type Context = {
|
|
705
|
+
theme: MtoneTheme;
|
|
697
706
|
locale: Locale;
|
|
698
707
|
density: "compact" | "comfortable";
|
|
699
708
|
tokens?: Tokens;
|
|
700
709
|
};
|
|
701
710
|
declare const useMtone: () => Context;
|
|
702
|
-
|
|
703
|
-
|
|
711
|
+
interface MtoneScopeProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
712
|
+
/** Inherits the surrounding mtone theme when omitted. */
|
|
713
|
+
theme?: MtoneTheme;
|
|
714
|
+
}
|
|
715
|
+
declare function MtoneScope({ children, className, style, theme, ...props }: MtoneScopeProps): React.JSX.Element;
|
|
716
|
+
type MtoneProviderProps = Partial<Context> & {
|
|
704
717
|
children: React.ReactNode;
|
|
705
|
-
}
|
|
718
|
+
};
|
|
719
|
+
declare function MtoneProvider({ children, locale, density, tokens, theme, }: MtoneProviderProps): React.JSX.Element;
|
|
706
720
|
type ButtonProps = Omit<React.ComponentPropsWithoutRef<typeof Button$1>, "className"> & {
|
|
707
721
|
className?: string;
|
|
708
722
|
variant?: "blue" | "solid" | "outline" | "soft" | "ghost";
|
|
@@ -1271,11 +1285,11 @@ type UploadProps = {
|
|
|
1271
1285
|
declare function Upload({ upload, accept, maxSize, multiple, disabled, onChange, className, children, }: UploadProps): React.JSX.Element;
|
|
1272
1286
|
declare const Dropzone: typeof Upload;
|
|
1273
1287
|
|
|
1274
|
-
type
|
|
1288
|
+
type AdminLayoutProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
1275
1289
|
hasSider?: boolean;
|
|
1276
1290
|
fullHeight?: boolean;
|
|
1277
1291
|
};
|
|
1278
|
-
type
|
|
1292
|
+
type AdminLayoutSiderProps = Omit<SidebarProps, "header" | "footer" | "collapsePlacement"> & {
|
|
1279
1293
|
logo?: React.ReactNode;
|
|
1280
1294
|
version?: React.ReactNode;
|
|
1281
1295
|
collapsedLogo?: React.ReactNode;
|
|
@@ -1284,24 +1298,24 @@ type LayoutSiderProps = Omit<SidebarProps, "header" | "footer" | "collapsePlacem
|
|
|
1284
1298
|
breakpoint?: number;
|
|
1285
1299
|
onBreakpoint?: (broken: boolean) => void;
|
|
1286
1300
|
};
|
|
1287
|
-
declare function
|
|
1288
|
-
type
|
|
1301
|
+
declare function AdminLayoutSider({ logo, version, collapsedLogo, width, collapsedWidth, breakpoint, onBreakpoint, collapsed, defaultCollapsed, onCollapsedChange, collapsible, className, style, ...props }: AdminLayoutSiderProps): React.JSX.Element;
|
|
1302
|
+
type AdminLayoutHeaderProps = React.HTMLAttributes<HTMLElement> & {
|
|
1289
1303
|
breadcrumb?: React.ReactNode;
|
|
1290
1304
|
extra?: React.ReactNode;
|
|
1291
1305
|
};
|
|
1292
|
-
declare function
|
|
1293
|
-
type
|
|
1306
|
+
declare function AdminLayoutHeader({ breadcrumb, extra, children, className, ...props }: AdminLayoutHeaderProps): React.JSX.Element;
|
|
1307
|
+
type AdminLayoutContentProps = React.HTMLAttributes<HTMLElement> & {
|
|
1294
1308
|
as?: "main" | "section" | "div";
|
|
1295
1309
|
};
|
|
1296
|
-
declare function
|
|
1297
|
-
declare function
|
|
1298
|
-
declare function
|
|
1299
|
-
/** Compose nested layouts with the familiar
|
|
1300
|
-
declare const
|
|
1301
|
-
Sider: typeof
|
|
1302
|
-
Header: typeof
|
|
1303
|
-
Content: typeof
|
|
1304
|
-
Footer: typeof
|
|
1310
|
+
declare function AdminLayoutContent({ as: Element, className, ...props }: AdminLayoutContentProps): React.JSX.Element;
|
|
1311
|
+
declare function AdminLayoutFooter({ className, ...props }: React.HTMLAttributes<HTMLElement>): React.JSX.Element;
|
|
1312
|
+
declare function AdminLayoutRoot({ hasSider, fullHeight, className, children, ...props }: AdminLayoutProps): React.JSX.Element;
|
|
1313
|
+
/** Compose nested layouts with the familiar AdminLayout.Sider/Header/Content/Footer API. */
|
|
1314
|
+
declare const AdminLayout: typeof AdminLayoutRoot & {
|
|
1315
|
+
Sider: typeof AdminLayoutSider;
|
|
1316
|
+
Header: typeof AdminLayoutHeader;
|
|
1317
|
+
Content: typeof AdminLayoutContent;
|
|
1318
|
+
Footer: typeof AdminLayoutFooter;
|
|
1305
1319
|
};
|
|
1306
1320
|
|
|
1307
1321
|
interface SpotlightAction {
|
|
@@ -2016,4 +2030,27 @@ type TreeSelectProps = TreeSelectCommonProps & ({
|
|
|
2016
2030
|
});
|
|
2017
2031
|
declare const TreeSelect: React.ForwardRefExoticComponent<TreeSelectProps & React.RefAttributes<HTMLButtonElement>>;
|
|
2018
2032
|
|
|
2019
|
-
|
|
2033
|
+
interface TagSelectOption {
|
|
2034
|
+
value: string;
|
|
2035
|
+
label: React.ReactNode;
|
|
2036
|
+
disabled?: boolean;
|
|
2037
|
+
}
|
|
2038
|
+
interface TagSelectProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "children" | "onChange"> {
|
|
2039
|
+
options: readonly TagSelectOption[];
|
|
2040
|
+
value?: readonly string[];
|
|
2041
|
+
defaultValue?: readonly string[];
|
|
2042
|
+
onValueChange?: (value: string[]) => void;
|
|
2043
|
+
disabled?: boolean;
|
|
2044
|
+
selectAll?: boolean;
|
|
2045
|
+
selectAllLabel?: string;
|
|
2046
|
+
expandable?: boolean;
|
|
2047
|
+
expanded?: boolean;
|
|
2048
|
+
defaultExpanded?: boolean;
|
|
2049
|
+
onExpandedChange?: (expanded: boolean) => void;
|
|
2050
|
+
expandLabel?: string;
|
|
2051
|
+
collapseLabel?: string;
|
|
2052
|
+
}
|
|
2053
|
+
/** An inline group of multi-select tags with optional responsive row disclosure. */
|
|
2054
|
+
declare function TagSelect({ options, value, defaultValue, onValueChange, disabled, selectAll, selectAllLabel, expandable, expanded, defaultExpanded, onExpandedChange, expandLabel, collapseLabel, className, ...props }: TagSelectProps): React.JSX.Element;
|
|
2055
|
+
|
|
2056
|
+
export { AdminLayout, type AdminLayoutContentProps, type AdminLayoutHeaderProps, type AdminLayoutProps, type AdminLayoutSiderProps, Affix, type AffixProps, Alert, AutoComplete, type AutoCompleteGroup, type AutoCompleteOption, type AutoCompleteProps, Avatar, type AvatarBreakpoint, AvatarGroup, type AvatarGroupProps, type AvatarProps, type AvatarSize, Badge, Blockquote, type BlockquoteProps, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, Calendar, type CalendarCellInfo, type CalendarHeaderInfo, type CalendarMode, type CalendarProps, type CalendarSelectInfo, type CalendarSemanticSlot, Card, type CardGridProps, type CardMetaProps, type CardMetaSemantic, type CardProps, type CardSemantic, type CardTabItem, type CardTokens, Cascader, type CascaderKey, type CascaderOption, CascaderPanel, type CascaderPanelProps, type CascaderPath, type CascaderProps, Checkbox, type CheckboxProps, ConfirmDialog, type ConfirmDialogProps, ContextMenu, DatePicker, type DatePickerProps, Dialog, type DialogProps, DirectoryTree, Divider, type DividerProps, DocumentCard, type DocumentItem, DocumentList, Drawer, Dropdown, type DropdownAlign, type DropdownLayoutProps, DropdownMenu, type DropdownMenuProps, type DropdownProps, Dropzone, Empty, Fieldset, type FieldsetProps, FilterBar, FilterChip, Form, FormField, type FormFieldProps, type FormInstance, type FormProps, type FormRule, type FormValidateTrigger, type FormValidationError, type FormValues, HoverCard, type HoverCardProps, IconButton, Image, ImageGroup, type ImageGroupProps, type ImageItem, ImagePreview, type ImagePreviewProps, type ImageProps, Input, type InputControlSize, type InputOTPProps, type InputPasswordProps, type InputProps, type InputSearchProps, type InputTextAreaProps, type InputVariant, Link, type LinkProps, List, type ListHandle, ListItem, type ListItemProps, type ListProps, type ListScrollTarget, type ListSortHandleProps, LoadingOverlay, type LoadingOverlayProps, type Locale, Mention, type MentionOption, Mentions, type MentionsProps, type MentionsRef, type MentionsSemantic, Menu, type MenuCheckboxItem, type MenuDivider, type MenuEntry, type MenuGroup, type MenuItem, type MenuProps, type MenuRadioGroup, Menubar, type MenubarMenu, type MenubarProps, Modal, type ModalProps, MtoneProvider, type MtoneProviderProps, MtoneScope, type MtoneScopeProps, type MtoneTheme, MultiSelect, type MultiSelectProps, NavGroup, NavItem, NumberInput, type NumberInputProps, type OpenProps, type Option, Pagination, type PaginationProps, Paragraph, type ParagraphProps, Popconfirm, type PopconfirmPlacement, type PopconfirmProps, Popover, type PopoverProps, Progress, type ProgressColor, type ProgressProps, type ProgressStatus, type ProgressType, PropertyItem, PropertyList, RadioGroup, type RadioGroupProps, Rate, type RateCharacterInfo, type RateProps, Result, type ResultProps, type ResultSemantic, type ResultStatus, SearchInput, Segmented, Select, type SelectProps, Sidebar, type SidebarProps, Skeleton, Slider, type SliderProps, type SortOrder, Spinner, Splitter, type SplitterPanelProps, type SplitterProps, type SplitterSize, Spotlight, type SpotlightAction, type SpotlightProps, Status, Switch, type TabItem, Table, type TableClassNames, type TableColumn, type TableColumnTitleProps, type TableColumnsType, type TableExpandableConfig, type TableFilterDropdownProps, type TableFilterItem, type TableFilterValue, type TableFilters, type TableLocale, TableOfContents, type TableOfContentsHandle, type TableOfContentsItem, type TableOfContentsProps, type TablePagination, type TableProps, type TableRef, type TableRowSelection, type TableSelectionType, type TableSortResult, type TableState, type TableStyles, Tabs, type TabsProps, TagSelect, type TagSelectOption, type TagSelectProps, Text, type TextProps, Textarea, Timeline, type TimelineItem, type TimelinePlacement, type TimelineProps, type TimelineSemantic, Title, type TitleProps, Toast, type ToastOptions, type ToastPosition, type ToastPromiseOptions, ToastProvider, type ToastProviderProps, type ToastType, type ToastUpdateOptions, type Tokens, type Tone, Tooltip, Transfer, type TransferDirection, type TransferItem, type TransferListContext, type TransferProps, Tree, type TreeCheckedKeys, type TreeDropInfo, type TreeItem, type TreeKey, type TreeNode, type TreeNodeInfo, type TreeProps, type TreeRef, TreeSelect, type TreeSelectCommonProps, type TreeSelectProps, Typography, type TypographyCopyable, type TypographyEditable, type TypographyEllipsis, type TypographyTone, Upload, type UploadAdapter, type UploadContext, type UploadFile, type UploadProps, cn, getMentions, useMtone, useToast };
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
useRef,
|
|
11
11
|
useState
|
|
12
12
|
} from "react";
|
|
13
|
+
import { GripVertical } from "lucide-react";
|
|
13
14
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
15
|
var identity = (key) => `${typeof key}:${String(key)}`;
|
|
15
16
|
var positive = (value, fallback) => Number.isFinite(value) && value > 0 ? value : fallback;
|
|
@@ -23,11 +24,12 @@ function MeasuredRow({
|
|
|
23
24
|
id,
|
|
24
25
|
measure,
|
|
25
26
|
children,
|
|
27
|
+
measureChild = false,
|
|
26
28
|
...props
|
|
27
29
|
}) {
|
|
28
30
|
const ref = useRef(null);
|
|
29
31
|
useLayoutEffect(() => {
|
|
30
|
-
const element = ref.current;
|
|
32
|
+
const element = measureChild ? ref.current?.firstElementChild : ref.current;
|
|
31
33
|
if (!element) return;
|
|
32
34
|
const update = () => measure(id, element.getBoundingClientRect().height);
|
|
33
35
|
update();
|
|
@@ -35,10 +37,10 @@ function MeasuredRow({
|
|
|
35
37
|
const observer = new ResizeObserver(update);
|
|
36
38
|
observer.observe(element);
|
|
37
39
|
return () => observer.disconnect();
|
|
38
|
-
}, [id, measure]);
|
|
40
|
+
}, [id, measure, measureChild]);
|
|
39
41
|
return /* @__PURE__ */ jsx("li", { ...props, ref, children });
|
|
40
42
|
}
|
|
41
|
-
function
|
|
43
|
+
function ListRoot({
|
|
42
44
|
children,
|
|
43
45
|
items,
|
|
44
46
|
getKey,
|
|
@@ -189,7 +191,7 @@ function List({
|
|
|
189
191
|
(i) => layout.offsets[i].top <= top
|
|
190
192
|
);
|
|
191
193
|
if (active !== void 0 && !indices.includes(active))
|
|
192
|
-
indices.
|
|
194
|
+
indices.unshift(active);
|
|
193
195
|
}
|
|
194
196
|
return indices;
|
|
195
197
|
}, [
|
|
@@ -312,10 +314,30 @@ function List({
|
|
|
312
314
|
const row = rows[index];
|
|
313
315
|
const group = row.kind === "group";
|
|
314
316
|
const nextGroup = group ? nextGroups.get(index) : void 0;
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
nextGroup === void 0 ?
|
|
318
|
-
|
|
317
|
+
if (windowed && stickyGroups && row.kind === "group") {
|
|
318
|
+
const start = layout.offsets[index].top;
|
|
319
|
+
const end = nextGroup === void 0 ? layout.total : layout.offsets[nextGroup].top;
|
|
320
|
+
return /* @__PURE__ */ jsx(
|
|
321
|
+
MeasuredRow,
|
|
322
|
+
{
|
|
323
|
+
id: row.id,
|
|
324
|
+
measure,
|
|
325
|
+
measureChild: true,
|
|
326
|
+
role: "presentation",
|
|
327
|
+
className: "mt-list-group-boundary",
|
|
328
|
+
style: { top: start, height: end - start, minWidth: contentWidth },
|
|
329
|
+
children: /* @__PURE__ */ jsx(
|
|
330
|
+
"div",
|
|
331
|
+
{
|
|
332
|
+
className: "mt-list-group mt-list-group-sticky",
|
|
333
|
+
"data-list-group": String(row.key),
|
|
334
|
+
children: renderGroup?.(row.key, row.items) ?? String(row.key)
|
|
335
|
+
}
|
|
336
|
+
)
|
|
337
|
+
},
|
|
338
|
+
row.id
|
|
339
|
+
);
|
|
340
|
+
}
|
|
319
341
|
return /* @__PURE__ */ jsx(
|
|
320
342
|
MeasuredRow,
|
|
321
343
|
{
|
|
@@ -332,7 +354,7 @@ function List({
|
|
|
332
354
|
),
|
|
333
355
|
style: {
|
|
334
356
|
minWidth: contentWidth,
|
|
335
|
-
...windowed ? { position: "absolute", top:
|
|
357
|
+
...windowed ? { position: "absolute", top: layout.offsets[index].top, width: "100%" } : {}
|
|
336
358
|
},
|
|
337
359
|
children: row.kind === "group" ? renderGroup?.(row.key, row.items) ?? String(row.key) : renderItem ? renderItem(row.item, row.index) : String(row.item ?? "")
|
|
338
360
|
},
|
|
@@ -345,14 +367,19 @@ function List({
|
|
|
345
367
|
}
|
|
346
368
|
);
|
|
347
369
|
}
|
|
370
|
+
function ListSortHandle({ className, title = "\u62D6\u52A8\u6392\u5E8F", ...props }) {
|
|
371
|
+
return /* @__PURE__ */ jsx("span", { ...props, title, "aria-hidden": "true", draggable: true, className: cn("mt-list-sort-handle", className), children: /* @__PURE__ */ jsx(GripVertical, { size: 16, focusable: "false" }) });
|
|
372
|
+
}
|
|
348
373
|
function ListItem({
|
|
349
374
|
children,
|
|
375
|
+
sortHandle,
|
|
350
376
|
icon,
|
|
351
377
|
description,
|
|
352
378
|
actions,
|
|
353
379
|
...props
|
|
354
380
|
}) {
|
|
355
381
|
return /* @__PURE__ */ jsxs("li", { ...props, className: cn("mt-list-item", props.className), children: [
|
|
382
|
+
sortHandle && /* @__PURE__ */ jsx(ListSortHandle, { ...sortHandle }),
|
|
356
383
|
icon,
|
|
357
384
|
/* @__PURE__ */ jsxs("div", { className: "mt-list-content", children: [
|
|
358
385
|
/* @__PURE__ */ jsx("div", { children }),
|
|
@@ -361,6 +388,7 @@ function ListItem({
|
|
|
361
388
|
actions
|
|
362
389
|
] });
|
|
363
390
|
}
|
|
391
|
+
var List = Object.assign(ListRoot, { SortHandle: ListSortHandle });
|
|
364
392
|
|
|
365
393
|
// src/fieldset-context.ts
|
|
366
394
|
import * as React2 from "react";
|
|
@@ -3641,6 +3669,7 @@ import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
|
3641
3669
|
var cn = (...v) => v.filter(Boolean).join(" ");
|
|
3642
3670
|
var MtoneContext = React15.createContext({
|
|
3643
3671
|
locale: "zh",
|
|
3672
|
+
theme: "light",
|
|
3644
3673
|
density: "compact"
|
|
3645
3674
|
});
|
|
3646
3675
|
var useMtone = () => React15.useContext(MtoneContext);
|
|
@@ -3648,9 +3677,14 @@ function MtoneScope({
|
|
|
3648
3677
|
children,
|
|
3649
3678
|
className,
|
|
3650
3679
|
style,
|
|
3680
|
+
theme,
|
|
3651
3681
|
...props
|
|
3652
3682
|
}) {
|
|
3653
|
-
const
|
|
3683
|
+
const inherited = useMtone();
|
|
3684
|
+
const c = React15.useMemo(
|
|
3685
|
+
() => theme && theme !== inherited.theme ? { ...inherited, theme } : inherited,
|
|
3686
|
+
[inherited, theme]
|
|
3687
|
+
);
|
|
3654
3688
|
const floatingOwners = React15.useContext(FloatingOwnerContext);
|
|
3655
3689
|
return /* @__PURE__ */ jsx14(
|
|
3656
3690
|
"div",
|
|
@@ -3658,9 +3692,10 @@ function MtoneScope({
|
|
|
3658
3692
|
...props,
|
|
3659
3693
|
className: cn("mt-scope", className),
|
|
3660
3694
|
"data-density": c.density,
|
|
3695
|
+
"data-mt-theme": c.theme,
|
|
3661
3696
|
"data-mt-floating-owners": floatingOwners.length ? floatingOwners.join(" ") : void 0,
|
|
3662
3697
|
style: { ...c.tokens, ...style },
|
|
3663
|
-
children
|
|
3698
|
+
children: /* @__PURE__ */ jsx14(MtoneContext.Provider, { value: c, children })
|
|
3664
3699
|
}
|
|
3665
3700
|
);
|
|
3666
3701
|
}
|
|
@@ -3668,9 +3703,16 @@ function MtoneProvider({
|
|
|
3668
3703
|
children,
|
|
3669
3704
|
locale = "zh",
|
|
3670
3705
|
density = "compact",
|
|
3671
|
-
tokens
|
|
3706
|
+
tokens,
|
|
3707
|
+
theme
|
|
3672
3708
|
}) {
|
|
3673
|
-
|
|
3709
|
+
const inherited = useMtone();
|
|
3710
|
+
const resolvedTheme = theme ?? inherited.theme;
|
|
3711
|
+
const value = React15.useMemo(
|
|
3712
|
+
() => ({ locale, density, tokens, theme: resolvedTheme }),
|
|
3713
|
+
[locale, density, tokens, resolvedTheme]
|
|
3714
|
+
);
|
|
3715
|
+
return /* @__PURE__ */ jsx14(MtoneContext.Provider, { value, children: /* @__PURE__ */ jsx14(MtoneScope, { children }) });
|
|
3674
3716
|
}
|
|
3675
3717
|
var Button = React15.forwardRef(
|
|
3676
3718
|
function Button2({
|
|
@@ -6396,10 +6438,10 @@ function Upload({
|
|
|
6396
6438
|
}
|
|
6397
6439
|
var Dropzone = Upload;
|
|
6398
6440
|
|
|
6399
|
-
// src/layout.tsx
|
|
6441
|
+
// src/admin-layout.tsx
|
|
6400
6442
|
import * as React23 from "react";
|
|
6401
6443
|
import { jsx as jsx22, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
6402
|
-
function
|
|
6444
|
+
function AdminLayoutSider({
|
|
6403
6445
|
logo,
|
|
6404
6446
|
version,
|
|
6405
6447
|
collapsedLogo,
|
|
@@ -6466,7 +6508,7 @@ function LayoutSider({
|
|
|
6466
6508
|
}
|
|
6467
6509
|
);
|
|
6468
6510
|
}
|
|
6469
|
-
function
|
|
6511
|
+
function AdminLayoutHeader({
|
|
6470
6512
|
breadcrumb,
|
|
6471
6513
|
extra,
|
|
6472
6514
|
children,
|
|
@@ -6481,14 +6523,14 @@ function LayoutHeader({
|
|
|
6481
6523
|
extra != null && /* @__PURE__ */ jsx22("div", { className: "mt-layout-header-extra", children: extra })
|
|
6482
6524
|
] });
|
|
6483
6525
|
}
|
|
6484
|
-
function
|
|
6526
|
+
function AdminLayoutContent({
|
|
6485
6527
|
as: Element2 = "main",
|
|
6486
6528
|
className,
|
|
6487
6529
|
...props
|
|
6488
6530
|
}) {
|
|
6489
6531
|
return /* @__PURE__ */ jsx22(Element2, { ...props, className: cn("mt-layout-content", className) });
|
|
6490
6532
|
}
|
|
6491
|
-
function
|
|
6533
|
+
function AdminLayoutFooter({
|
|
6492
6534
|
className,
|
|
6493
6535
|
...props
|
|
6494
6536
|
}) {
|
|
@@ -6496,12 +6538,12 @@ function LayoutFooter({
|
|
|
6496
6538
|
}
|
|
6497
6539
|
function containsSider(children) {
|
|
6498
6540
|
return React23.Children.toArray(children).some(
|
|
6499
|
-
(child) => React23.isValidElement(child) && (child.type ===
|
|
6541
|
+
(child) => React23.isValidElement(child) && (child.type === AdminLayoutSider || child.type === React23.Fragment && containsSider(
|
|
6500
6542
|
child.props.children
|
|
6501
6543
|
))
|
|
6502
6544
|
);
|
|
6503
6545
|
}
|
|
6504
|
-
function
|
|
6546
|
+
function AdminLayoutRoot({
|
|
6505
6547
|
hasSider,
|
|
6506
6548
|
fullHeight = false,
|
|
6507
6549
|
className,
|
|
@@ -6522,11 +6564,11 @@ function LayoutRoot({
|
|
|
6522
6564
|
}
|
|
6523
6565
|
);
|
|
6524
6566
|
}
|
|
6525
|
-
var
|
|
6526
|
-
Sider:
|
|
6527
|
-
Header:
|
|
6528
|
-
Content:
|
|
6529
|
-
Footer:
|
|
6567
|
+
var AdminLayout = Object.assign(AdminLayoutRoot, {
|
|
6568
|
+
Sider: AdminLayoutSider,
|
|
6569
|
+
Header: AdminLayoutHeader,
|
|
6570
|
+
Content: AdminLayoutContent,
|
|
6571
|
+
Footer: AdminLayoutFooter
|
|
6530
6572
|
});
|
|
6531
6573
|
|
|
6532
6574
|
// src/spotlight.tsx
|
|
@@ -7436,7 +7478,7 @@ var Mentions = React26.forwardRef(
|
|
|
7436
7478
|
...native
|
|
7437
7479
|
}, forwardedRef) {
|
|
7438
7480
|
disabled = useFieldsetDisabled(disabled);
|
|
7439
|
-
const { locale, density, tokens } = useMtone();
|
|
7481
|
+
const { locale, density, theme, tokens } = useMtone();
|
|
7440
7482
|
const inputRef = React26.useRef(null), popupRef = React26.useRef(null);
|
|
7441
7483
|
const [internal, setInternal] = React26.useState(defaultValue), text = controlled ?? internal;
|
|
7442
7484
|
const [focused, setFocused] = React26.useState(false), [composing, setComposing] = React26.useState(false), [dismissed, setDismissed] = React26.useState(false);
|
|
@@ -7615,6 +7657,7 @@ var Mentions = React26.forwardRef(
|
|
|
7615
7657
|
ref: popupRef,
|
|
7616
7658
|
className: cn("mt-scope", "mt-mentions-popup", classNames?.popup),
|
|
7617
7659
|
"data-density": density,
|
|
7660
|
+
"data-mt-theme": theme,
|
|
7618
7661
|
style: {
|
|
7619
7662
|
...tokens,
|
|
7620
7663
|
...styles?.popup,
|
|
@@ -11256,7 +11299,172 @@ var TreeSelect = React41.forwardRef(
|
|
|
11256
11299
|
);
|
|
11257
11300
|
}
|
|
11258
11301
|
);
|
|
11302
|
+
|
|
11303
|
+
// src/tag-select.tsx
|
|
11304
|
+
import * as React42 from "react";
|
|
11305
|
+
import { ChevronDown as ChevronDown9 } from "lucide-react";
|
|
11306
|
+
import { jsx as jsx41, jsxs as jsxs37 } from "react/jsx-runtime";
|
|
11307
|
+
function TagSelect({
|
|
11308
|
+
options,
|
|
11309
|
+
value,
|
|
11310
|
+
defaultValue = [],
|
|
11311
|
+
onValueChange,
|
|
11312
|
+
disabled,
|
|
11313
|
+
selectAll = false,
|
|
11314
|
+
selectAllLabel = "\u5168\u9009",
|
|
11315
|
+
expandable = true,
|
|
11316
|
+
expanded,
|
|
11317
|
+
defaultExpanded = false,
|
|
11318
|
+
onExpandedChange,
|
|
11319
|
+
expandLabel = "\u5C55\u5F00",
|
|
11320
|
+
collapseLabel = "\u6536\u8D77",
|
|
11321
|
+
className,
|
|
11322
|
+
...props
|
|
11323
|
+
}) {
|
|
11324
|
+
const isDisabled = useFieldsetDisabled(disabled);
|
|
11325
|
+
const [internalValue, setInternalValue] = React42.useState(defaultValue);
|
|
11326
|
+
const [internalExpanded, setInternalExpanded] = React42.useState(defaultExpanded);
|
|
11327
|
+
const [visibleCount, setVisibleCount] = React42.useState(
|
|
11328
|
+
options.length + Number(selectAll)
|
|
11329
|
+
);
|
|
11330
|
+
const [overflow, setOverflow] = React42.useState(false);
|
|
11331
|
+
const isExpanded = expanded ?? internalExpanded;
|
|
11332
|
+
const selected = new Set(value ?? internalValue);
|
|
11333
|
+
const enabledValues = selectAll ? options.filter((option) => !option.disabled).map((option) => option.value) : [];
|
|
11334
|
+
const selectedEnabled = enabledValues.filter(
|
|
11335
|
+
(item) => selected.has(item)
|
|
11336
|
+
).length;
|
|
11337
|
+
const allSelected = enabledValues.length > 0 && selectedEnabled === enabledValues.length;
|
|
11338
|
+
const commitSelection = (next) => {
|
|
11339
|
+
if (value === void 0) setInternalValue(next);
|
|
11340
|
+
onValueChange?.(next);
|
|
11341
|
+
};
|
|
11342
|
+
const list = React42.useRef(null);
|
|
11343
|
+
const trigger = React42.useRef(null);
|
|
11344
|
+
const id = React42.useId();
|
|
11345
|
+
React42.useLayoutEffect(() => {
|
|
11346
|
+
const row = list.current;
|
|
11347
|
+
if (!row || !expandable) return;
|
|
11348
|
+
const update = () => {
|
|
11349
|
+
const first = row.firstElementChild;
|
|
11350
|
+
if (!first) {
|
|
11351
|
+
setVisibleCount(0);
|
|
11352
|
+
setOverflow(false);
|
|
11353
|
+
return;
|
|
11354
|
+
}
|
|
11355
|
+
const at = first.offsetTop;
|
|
11356
|
+
const children = Array.from(row.children);
|
|
11357
|
+
const available = row.parentElement?.parentElement?.clientWidth ?? 0;
|
|
11358
|
+
setOverflow(
|
|
11359
|
+
available > 0 && children.length > 1 && children.reduce((sum, child) => {
|
|
11360
|
+
const rectWidth = child.getBoundingClientRect().width;
|
|
11361
|
+
return sum + Math.min(
|
|
11362
|
+
available,
|
|
11363
|
+
child.scrollWidth > child.clientWidth ? child.scrollWidth + 2 : rectWidth
|
|
11364
|
+
);
|
|
11365
|
+
}, 0) + (children.length - 1) * (parseFloat(getComputedStyle(row).columnGap) || 0) > available + 0.5
|
|
11366
|
+
);
|
|
11367
|
+
const next = children.findIndex((child) => child.offsetTop > at + 1);
|
|
11368
|
+
const count = next < 0 ? children.length : next;
|
|
11369
|
+
const focused = children.indexOf(document.activeElement);
|
|
11370
|
+
if (!isExpanded && focused >= count) {
|
|
11371
|
+
if (!isDisabled) trigger.current?.focus();
|
|
11372
|
+
else children.find((child) => !child.hasAttribute("disabled"))?.focus();
|
|
11373
|
+
}
|
|
11374
|
+
setVisibleCount(count);
|
|
11375
|
+
};
|
|
11376
|
+
update();
|
|
11377
|
+
if (typeof ResizeObserver === "undefined") {
|
|
11378
|
+
window.addEventListener("resize", update);
|
|
11379
|
+
return () => window.removeEventListener("resize", update);
|
|
11380
|
+
}
|
|
11381
|
+
const observer = new ResizeObserver(update);
|
|
11382
|
+
observer.observe(row);
|
|
11383
|
+
for (const child of row.children) observer.observe(child);
|
|
11384
|
+
return () => observer.disconnect();
|
|
11385
|
+
}, [options, expandable, isExpanded, isDisabled, selectAll, selectAllLabel]);
|
|
11386
|
+
const hasOverflow = expandable && overflow;
|
|
11387
|
+
return /* @__PURE__ */ jsxs37(
|
|
11388
|
+
"div",
|
|
11389
|
+
{
|
|
11390
|
+
role: "group",
|
|
11391
|
+
...props,
|
|
11392
|
+
className: ["mt-tag-select", className].filter(Boolean).join(" "),
|
|
11393
|
+
children: [
|
|
11394
|
+
/* @__PURE__ */ jsx41(
|
|
11395
|
+
"div",
|
|
11396
|
+
{
|
|
11397
|
+
className: "mt-tag-select-viewport",
|
|
11398
|
+
"data-collapsed": hasOverflow && !isExpanded ? "" : void 0,
|
|
11399
|
+
children: /* @__PURE__ */ jsxs37("div", { className: "mt-tag-select-options", id, ref: list, children: [
|
|
11400
|
+
selectAll && /* @__PURE__ */ jsx41(
|
|
11401
|
+
"button",
|
|
11402
|
+
{
|
|
11403
|
+
type: "button",
|
|
11404
|
+
className: "mt-tag-select-option",
|
|
11405
|
+
"aria-pressed": allSelected ? true : selectedEnabled > 0 ? "mixed" : false,
|
|
11406
|
+
disabled: isDisabled || enabledValues.length === 0,
|
|
11407
|
+
onClick: () => {
|
|
11408
|
+
const enabled = new Set(enabledValues);
|
|
11409
|
+
commitSelection(
|
|
11410
|
+
allSelected ? [...selected].filter((item) => !enabled.has(item)) : [.../* @__PURE__ */ new Set([...selected, ...enabledValues])]
|
|
11411
|
+
);
|
|
11412
|
+
},
|
|
11413
|
+
children: selectAllLabel
|
|
11414
|
+
}
|
|
11415
|
+
),
|
|
11416
|
+
options.map((option, index) => {
|
|
11417
|
+
const checked = selected.has(option.value);
|
|
11418
|
+
const hidden = hasOverflow && !isExpanded && index + Number(selectAll) >= visibleCount;
|
|
11419
|
+
return /* @__PURE__ */ jsx41(
|
|
11420
|
+
"button",
|
|
11421
|
+
{
|
|
11422
|
+
type: "button",
|
|
11423
|
+
className: "mt-tag-select-option",
|
|
11424
|
+
"aria-pressed": checked,
|
|
11425
|
+
"data-overflow": hidden ? "" : void 0,
|
|
11426
|
+
tabIndex: hidden ? -1 : void 0,
|
|
11427
|
+
disabled: isDisabled || option.disabled,
|
|
11428
|
+
onClick: () => {
|
|
11429
|
+
const next = checked ? Array.from(selected).filter(
|
|
11430
|
+
(item) => item !== option.value
|
|
11431
|
+
) : [...selected, option.value];
|
|
11432
|
+
commitSelection(next);
|
|
11433
|
+
},
|
|
11434
|
+
children: option.label
|
|
11435
|
+
},
|
|
11436
|
+
option.value
|
|
11437
|
+
);
|
|
11438
|
+
})
|
|
11439
|
+
] })
|
|
11440
|
+
}
|
|
11441
|
+
),
|
|
11442
|
+
expandable && /* @__PURE__ */ jsxs37(
|
|
11443
|
+
"button",
|
|
11444
|
+
{
|
|
11445
|
+
ref: trigger,
|
|
11446
|
+
hidden: !hasOverflow,
|
|
11447
|
+
className: "mt-tag-select-trigger",
|
|
11448
|
+
type: "button",
|
|
11449
|
+
"aria-controls": id,
|
|
11450
|
+
"aria-expanded": isExpanded,
|
|
11451
|
+
disabled: isDisabled,
|
|
11452
|
+
onClick: () => {
|
|
11453
|
+
if (expanded === void 0) setInternalExpanded(!isExpanded);
|
|
11454
|
+
onExpandedChange?.(!isExpanded);
|
|
11455
|
+
},
|
|
11456
|
+
children: [
|
|
11457
|
+
isExpanded ? collapseLabel : expandLabel,
|
|
11458
|
+
/* @__PURE__ */ jsx41(ChevronDown9, { size: 14, "aria-hidden": "true" })
|
|
11459
|
+
]
|
|
11460
|
+
}
|
|
11461
|
+
)
|
|
11462
|
+
]
|
|
11463
|
+
}
|
|
11464
|
+
);
|
|
11465
|
+
}
|
|
11259
11466
|
export {
|
|
11467
|
+
AdminLayout,
|
|
11260
11468
|
Affix,
|
|
11261
11469
|
Alert,
|
|
11262
11470
|
AutoComplete,
|
|
@@ -11296,7 +11504,6 @@ export {
|
|
|
11296
11504
|
ImageGroup,
|
|
11297
11505
|
ImagePreview,
|
|
11298
11506
|
Input,
|
|
11299
|
-
Layout,
|
|
11300
11507
|
Link,
|
|
11301
11508
|
List,
|
|
11302
11509
|
ListItem,
|
|
@@ -11336,6 +11543,7 @@ export {
|
|
|
11336
11543
|
Table,
|
|
11337
11544
|
TableOfContents,
|
|
11338
11545
|
Tabs,
|
|
11546
|
+
TagSelect,
|
|
11339
11547
|
Text,
|
|
11340
11548
|
Textarea,
|
|
11341
11549
|
Timeline,
|