@momoi-labs/kiso-react 0.26.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.
@@ -1,4 +1,4 @@
1
- export declare const accents: readonly ["violet", "terracotta", "teal", "cobalt", "nocturne", "tangerine", "red", "gold", "lime", "plum", "stone", "steel"];
1
+ export declare const accents: readonly ["violet", "terracotta", "teal", "cobalt", "nocturne", "tangerine", "red", "gold", "lime", "plum", "stone", "steel", "snes"];
2
2
  export type Accent = (typeof accents)[number];
3
3
  export declare function AccentSelector({ accent, onChange, options, preview, }: {
4
4
  accent: string;
@@ -13,6 +13,7 @@ export const accents = [
13
13
  "plum",
14
14
  "stone",
15
15
  "steel",
16
+ "snes",
16
17
  ];
17
18
  const label = (accent) => `${accent[0].toUpperCase()}${accent.slice(1)}`;
18
19
  export function AccentSelector({ accent, onChange, options = accents, preview = true, }) {
@@ -29,6 +29,7 @@ type ApplicationShellSharedProps = Omit<React.ComponentProps<typeof AppShell>, "
29
29
  primaryAction?: React.ReactNode;
30
30
  header?: React.ReactNode;
31
31
  headerVariant?: React.ComponentProps<typeof Header>["variant"];
32
+ headerSize?: React.ComponentProps<typeof Header>["size"];
32
33
  panel?: React.ReactNode;
33
34
  children: React.ReactNode;
34
35
  };
package/dist/app-shell.js CHANGED
@@ -37,12 +37,12 @@ function ApplicationShellNavigation({ navigation, navigationLabel, collapsible =
37
37
  }
38
38
  function ApplicationShell(props) {
39
39
  if (props.layout === "topbar") {
40
- const { brand, primaryAction, header, headerVariant, panel, bottomNav, children, layout: _layout, ...shellProps } = props;
41
- return (_jsxs(AppShell, { ...shellProps, "data-layout": "topbar", children: [_jsxs(AppShellMain, { children: [_jsxs(Header, { variant: headerVariant, children: [brand, primaryAction, header] }), children] }), panel, bottomNav] }));
40
+ const { brand, primaryAction, header, headerVariant, headerSize, panel, bottomNav, children, layout: _layout, ...shellProps } = props;
41
+ return (_jsxs(AppShell, { ...shellProps, "data-layout": "topbar", children: [_jsxs(AppShellMain, { children: [_jsxs(Header, { variant: headerVariant, size: headerSize, children: [brand, primaryAction, header] }), children] }), panel, bottomNav] }));
42
42
  }
43
43
  return _jsx(ApplicationShellSidebar, { ...props });
44
44
  }
45
- function ApplicationShellSidebar({ brand, primaryAction, navigation, navigationLabel = "Primary", footer, header, headerVariant, panel, children, layout: _layout, collapsible = false, togglePlacement = "sidebar", collapsed, defaultCollapsed = false, onCollapsedChange, drawerOpen: controlledDrawer, onDrawerOpenChange, phoneNavigation = "drawer", ...shellProps }) {
45
+ function ApplicationShellSidebar({ brand, primaryAction, navigation, navigationLabel = "Primary", footer, header, headerVariant, headerSize, panel, children, layout: _layout, collapsible = false, togglePlacement = "sidebar", collapsed, defaultCollapsed = false, onCollapsedChange, drawerOpen: controlledDrawer, onDrawerOpenChange, phoneNavigation = "drawer", ...shellProps }) {
46
46
  const [internalCollapsed, setInternalCollapsed] = React.useState(defaultCollapsed);
47
47
  // Below 1024px the sidebar is not in the page; the same brand, action,
48
48
  // navigation and footer open in a drawer from the header instead.
@@ -73,7 +73,7 @@ function ApplicationShellSidebar({ brand, primaryAction, navigation, navigationL
73
73
  }
74
74
  const toggle = collapsible ? (_jsx(Button, { ref: toggleRef, variant: "ghost", size: "sm", className: "sidebar-toggle btn-icon", "aria-controls": sidebarId, "aria-expanded": !isCollapsed, "aria-label": isCollapsed ? "Expand sidebar" : "Collapse sidebar", title: isCollapsed ? "Expand sidebar" : "Collapse sidebar", onClick: toggleSidebar, children: isCollapsed ? _jsx(PanelLeftOpen, { className: "icon", "aria-hidden": "true" }) : _jsx(PanelLeftClose, { className: "icon", "aria-hidden": "true" }) })) : null;
75
75
  const menu = (_jsx(Button, { ref: menuRef, variant: "ghost", size: "sm", className: "app-shell-menu btn-icon", "aria-expanded": drawerOpen, "aria-label": "Open navigation", title: "Navigation", onClick: () => setDrawerOpen(true), children: _jsx(Menu, { className: "icon", "aria-hidden": "true" }) }));
76
- return (_jsxs(AppShell, { ...shellProps, "data-phone-drawer": "true", "data-phone-navigation": phoneNavigation, children: [_jsxs(Sidebar, { ref: sidebarRef, id: sidebarId, collapsed: isCollapsed, children: [_jsx(SidebarHeader, { className: collapsible && togglePlacement === "sidebar" ? "sidebar-header-collapsible" : undefined, children: collapsible ? _jsxs(_Fragment, { children: [_jsxs("div", { className: "sidebar-expanded-content", children: [brand, primaryAction] }), togglePlacement === "sidebar" && toggle] }) : _jsxs(_Fragment, { children: [brand, primaryAction] }) }), _jsx(SidebarBody, { children: _jsx(ApplicationShellNavigation, { navigation: navigation, navigationLabel: navigationLabel, collapsible: collapsible }) }), footer && _jsx(SidebarFooter, { className: collapsible ? "sidebar-expanded-content" : undefined, children: footer })] }), _jsxs(AppShellMain, { children: [_jsxs(Header, { variant: headerVariant, "data-phone-only": header || (collapsible && togglePlacement === "header") ? undefined : "true", children: [menu, phoneNavigation === "bottom" && _jsx("div", { className: "app-shell-phone-brand", children: brand }), phoneNavigation === "bottom" && primaryAction && _jsx("div", { className: "app-shell-phone-action", children: primaryAction }), togglePlacement === "header" && toggle, header] }), children] }), panel, _jsx(Drawer, { open: drawerOpen, onOpenChange: setDrawerOpen, children: _jsxs(DrawerContent, { placement: "side", className: "app-shell-drawer", onCloseAutoFocus: (event) => {
76
+ return (_jsxs(AppShell, { ...shellProps, "data-phone-drawer": "true", "data-phone-navigation": phoneNavigation, children: [_jsxs(Sidebar, { ref: sidebarRef, id: sidebarId, collapsed: isCollapsed, children: [_jsx(SidebarHeader, { className: collapsible && togglePlacement === "sidebar" ? "sidebar-header-collapsible" : undefined, children: collapsible ? _jsxs(_Fragment, { children: [_jsxs("div", { className: "sidebar-expanded-content", children: [brand, primaryAction] }), togglePlacement === "sidebar" && toggle] }) : _jsxs(_Fragment, { children: [brand, primaryAction] }) }), _jsx(SidebarBody, { children: _jsx(ApplicationShellNavigation, { navigation: navigation, navigationLabel: navigationLabel, collapsible: collapsible }) }), footer && _jsx(SidebarFooter, { className: collapsible ? "sidebar-expanded-content" : undefined, children: footer })] }), _jsxs(AppShellMain, { children: [_jsxs(Header, { variant: headerVariant, size: headerSize, "data-phone-only": header || (collapsible && togglePlacement === "header") ? undefined : "true", children: [menu, phoneNavigation === "bottom" && _jsx("div", { className: "app-shell-phone-brand", children: brand }), phoneNavigation === "bottom" && primaryAction && _jsx("div", { className: "app-shell-phone-action", children: primaryAction }), togglePlacement === "header" && toggle, header] }), children] }), panel, _jsx(Drawer, { open: drawerOpen, onOpenChange: setDrawerOpen, children: _jsxs(DrawerContent, { placement: "side", className: "app-shell-drawer", onCloseAutoFocus: (event) => {
77
77
  event.preventDefault();
78
78
  menuRef.current?.focus();
79
79
  }, children: [_jsxs(DrawerHeader, { children: [_jsx(VisuallyHidden.Root, { asChild: true, children: _jsx(DrawerTitle, { children: "Navigation" }) }), brand] }), _jsxs(DrawerBody, { onClick: (event) => {
@@ -1,6 +1,7 @@
1
1
  export type DiagramEdgeLine = "solid" | "dashed" | "dotted";
2
2
  export type DiagramEdgeTone = "neutral" | "success" | "danger";
3
3
  export type DiagramEdgeRoute = "side" | "down" | "drop";
4
+ export type DiagramEdgeSide = "top" | "right" | "bottom" | "left";
4
5
  export type DiagramCrossings = "none" | "hop" | "gap";
5
6
  export type DiagramLabels = "auto" | "horizontal" | "vertical";
6
7
  export type DiagramEdgeShape = "orthogonal" | "curve" | "straight" | "sketch";
@@ -19,6 +20,8 @@ export type EdgeSpec = EdgeLook & {
19
20
  to: string;
20
21
  label?: string;
21
22
  route?: DiagramEdgeRoute;
23
+ fromSide?: DiagramEdgeSide;
24
+ toSide?: DiagramEdgeSide;
22
25
  };
23
26
  export type Pt = [number, number];
24
27
  export type Box = {
@@ -48,7 +51,7 @@ type RouteLabel = {
48
51
  text: string;
49
52
  /** The segment the label belongs to. */
50
53
  run: number;
51
- /** Where along a horizontal run the label centres, 0 to 1. */
54
+ /** Where along its run the label centres, 0 to 1. */
52
55
  along?: number;
53
56
  /** Width a flat label may take before it stacks. */
54
57
  room?: number;
@@ -63,6 +66,7 @@ export type Route = {
63
66
  ends?: [string, string];
64
67
  label?: RouteLabel;
65
68
  dot?: Pt;
69
+ pinned?: boolean;
66
70
  };
67
71
  export type Rect = {
68
72
  key: string;
@@ -103,11 +107,13 @@ export declare const RADIUS = 8;
103
107
  export declare const TRACK = 6;
104
108
  export declare const look: (edge: EdgeSpec) => EdgeLook;
105
109
  export type DiagramFlow = "right" | "down" | "grid";
106
- export declare function route(measured: Measured[], nodes: Box[], flow: DiagramFlow, frames?: Box[]): Route[];
110
+ export declare function anchorOf(box: Box, side: DiagramEdgeSide): Pt;
111
+ export declare function route(measured: Measured[], nodes: Box[], flow: DiagramFlow, frames?: Box[], titles?: Box[]): Route[];
107
112
  export type DrawStyle = {
108
113
  shape?: DiagramEdgeShape;
109
114
  arrow?: DiagramArrow;
110
115
  boxes?: Map<string, Box>;
116
+ blocks?: Box[];
111
117
  };
112
118
  export declare function draw(routes: Route[], frames: Frame[], crossings: DiagramCrossings, labels: DiagramLabels, measure: (text: string) => {
113
119
  width: number;