@k2b/ui 0.64.0 → 0.65.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/base.css +3 -6
- package/dist/browser/actions/ContextMenu.js +1 -3
- package/dist/browser/actions/ContextMenu.js.map +1 -1
- package/dist/browser/actions/Dropdown.js +15 -69
- package/dist/browser/actions/Dropdown.js.map +1 -1
- package/dist/browser/actions/SortableList.js +1 -1
- package/dist/browser/actions/SortableList.js.map +1 -1
- package/dist/browser/actions/ViewTabs.js +5 -9
- package/dist/browser/actions/ViewTabs.js.map +1 -1
- package/dist/browser/actions/drag-and-drop.js +1 -1
- package/dist/browser/actions/drag-and-drop.js.map +1 -1
- package/dist/browser/actions/index.js.map +1 -1
- package/dist/browser/actions/menu-sheet.js +18 -80
- package/dist/browser/actions/menu-sheet.js.map +1 -1
- package/dist/browser/content/DataTable.js +197 -285
- package/dist/browser/content/DataTable.js.map +1 -1
- package/dist/browser/content/MessageRow.js +139 -115
- package/dist/browser/content/MessageRow.js.map +1 -1
- package/dist/browser/content/ProgressPath.js +25 -30
- package/dist/browser/content/ProgressPath.js.map +1 -1
- package/dist/browser/content/index.js +0 -2
- package/dist/browser/content/index.js.map +1 -1
- package/dist/browser/feedback/dialog-core.js +0 -11
- package/dist/browser/feedback/dialog-core.js.map +1 -1
- package/dist/browser/internal/field.js +2 -2
- package/dist/browser/internal/field.js.map +1 -1
- package/dist/browser/intl/messages.js +1 -1
- package/dist/browser/intl/messages.js.map +1 -1
- package/dist/browser/layout/AppWorkspace.js +8 -16
- package/dist/browser/layout/AppWorkspace.js.map +1 -1
- package/dist/browser/layout/Breadcrumbs.js +42 -188
- package/dist/browser/layout/Breadcrumbs.js.map +1 -1
- package/dist/browser/layout/DetailPanel.js +205 -209
- package/dist/browser/layout/DetailPanel.js.map +1 -1
- package/dist/browser/layout/PanelDialog.js +88 -176
- package/dist/browser/layout/PanelDialog.js.map +1 -1
- package/dist/browser/layout/app-workspace-controller.js +5 -12
- package/dist/browser/layout/app-workspace-controller.js.map +1 -1
- package/dist/browser/layout/app-workspace-state.js +2 -2
- package/dist/browser/layout/app-workspace-state.js.map +1 -1
- package/dist/browser/layout/index.js +0 -2
- package/dist/browser/layout/index.js.map +1 -1
- package/dist/browser/layout/workspace-messages.js +2 -12
- package/dist/browser/layout/workspace-messages.js.map +1 -1
- package/dist/browser/surfaces/NoticeCard.js +57 -69
- package/dist/browser/surfaces/NoticeCard.js.map +1 -1
- package/dist/browser/surfaces/Placeholder.js +5 -17
- package/dist/browser/surfaces/Placeholder.js.map +1 -1
- package/dist/browser/surfaces/Section.js +7 -22
- package/dist/browser/surfaces/Section.js.map +1 -1
- package/dist/browser/surfaces/StatusBadge.js +1 -5
- package/dist/browser/surfaces/StatusBadge.js.map +1 -1
- package/dist/browser/surfaces/index.js +0 -4
- package/dist/browser/surfaces/index.js.map +1 -1
- package/dist/ssr/actions/ContextMenu.js +1 -3
- package/dist/ssr/actions/ContextMenu.js.map +1 -1
- package/dist/ssr/actions/Dropdown.js +15 -69
- package/dist/ssr/actions/Dropdown.js.map +1 -1
- package/dist/ssr/actions/SortableList.js +1 -1
- package/dist/ssr/actions/SortableList.js.map +1 -1
- package/dist/ssr/actions/ViewTabs.js +5 -9
- package/dist/ssr/actions/ViewTabs.js.map +1 -1
- package/dist/ssr/actions/drag-and-drop.js +1 -1
- package/dist/ssr/actions/drag-and-drop.js.map +1 -1
- package/dist/ssr/actions/index.js.map +1 -1
- package/dist/ssr/actions/menu-sheet.js +10 -62
- package/dist/ssr/actions/menu-sheet.js.map +1 -1
- package/dist/ssr/content/DataTable.js +54 -64
- package/dist/ssr/content/DataTable.js.map +1 -1
- package/dist/ssr/content/MessageRow.js +30 -10
- package/dist/ssr/content/MessageRow.js.map +1 -1
- package/dist/ssr/content/ProgressPath.js +8 -14
- package/dist/ssr/content/ProgressPath.js.map +1 -1
- package/dist/ssr/content/index.js +0 -2
- package/dist/ssr/content/index.js.map +1 -1
- package/dist/ssr/feedback/dialog-core.js +0 -11
- package/dist/ssr/feedback/dialog-core.js.map +1 -1
- package/dist/ssr/internal/field.js +2 -2
- package/dist/ssr/internal/field.js.map +1 -1
- package/dist/ssr/intl/messages.js +1 -1
- package/dist/ssr/intl/messages.js.map +1 -1
- package/dist/ssr/layout/AppWorkspace.js +8 -16
- package/dist/ssr/layout/AppWorkspace.js.map +1 -1
- package/dist/ssr/layout/Breadcrumbs.js +26 -140
- package/dist/ssr/layout/Breadcrumbs.js.map +1 -1
- package/dist/ssr/layout/DetailPanel.js +68 -70
- package/dist/ssr/layout/DetailPanel.js.map +1 -1
- package/dist/ssr/layout/PanelDialog.js +8 -82
- package/dist/ssr/layout/PanelDialog.js.map +1 -1
- package/dist/ssr/layout/app-workspace-controller.js +5 -12
- package/dist/ssr/layout/app-workspace-controller.js.map +1 -1
- package/dist/ssr/layout/app-workspace-state.js +2 -2
- package/dist/ssr/layout/app-workspace-state.js.map +1 -1
- package/dist/ssr/layout/index.js +0 -2
- package/dist/ssr/layout/index.js.map +1 -1
- package/dist/ssr/layout/workspace-messages.js +2 -12
- package/dist/ssr/layout/workspace-messages.js.map +1 -1
- package/dist/ssr/surfaces/NoticeCard.js +5 -7
- package/dist/ssr/surfaces/NoticeCard.js.map +1 -1
- package/dist/ssr/surfaces/Placeholder.js +4 -15
- package/dist/ssr/surfaces/Placeholder.js.map +1 -1
- package/dist/ssr/surfaces/Section.js +4 -7
- package/dist/ssr/surfaces/Section.js.map +1 -1
- package/dist/ssr/surfaces/StatusBadge.js +1 -5
- package/dist/ssr/surfaces/StatusBadge.js.map +1 -1
- package/dist/ssr/surfaces/index.js +0 -4
- package/dist/ssr/surfaces/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/actions/Dropdown.d.ts +1 -35
- package/dist/types/actions/ViewTabs.d.ts +2 -3
- package/dist/types/actions/index.d.ts +1 -1
- package/dist/types/actions/menu-sheet.d.ts +1 -3
- package/dist/types/content/DataTable.d.ts +0 -19
- package/dist/types/content/MessageRow.d.ts +11 -0
- package/dist/types/content/ProgressPath.d.ts +6 -12
- package/dist/types/content/index.d.ts +0 -2
- package/dist/types/feedback/dialog-core.d.ts +0 -5
- package/dist/types/layout/AppWorkspace.d.ts +2 -10
- package/dist/types/layout/Breadcrumbs.d.ts +5 -10
- package/dist/types/layout/PanelDialog.d.ts +0 -19
- package/dist/types/layout/app-workspace-state.d.ts +2 -2
- package/dist/types/layout/index.d.ts +1 -5
- package/dist/types/layout/workspace-messages.d.ts +0 -5
- package/dist/types/surfaces/NoticeCard.d.ts +4 -6
- package/dist/types/surfaces/Placeholder.d.ts +0 -7
- package/dist/types/surfaces/Section.d.ts +2 -8
- package/dist/types/surfaces/StatusBadge.d.ts +1 -2
- package/dist/types/surfaces/index.d.ts +1 -9
- package/package.json +2 -7
- package/dist/browser/actions/menu-sheet-messages.js +0 -26
- package/dist/browser/actions/menu-sheet-messages.js.map +0 -1
- package/dist/browser/actions/menu-submenu-panel.js +0 -392
- package/dist/browser/actions/menu-submenu-panel.js.map +0 -1
- package/dist/browser/content/FileName.js +0 -68
- package/dist/browser/content/FileName.js.map +0 -1
- package/dist/browser/content/TaskRow.js +0 -129
- package/dist/browser/content/TaskRow.js.map +0 -1
- package/dist/browser/content/progress-path-messages.js +0 -22
- package/dist/browser/content/progress-path-messages.js.map +0 -1
- package/dist/browser/feedback/dialog-foot.js +0 -45
- package/dist/browser/feedback/dialog-foot.js.map +0 -1
- package/dist/browser/internal/renders-something.js +0 -3
- package/dist/browser/internal/renders-something.js.map +0 -1
- package/dist/browser/layout/FloatingPill.js +0 -33
- package/dist/browser/layout/FloatingPill.js.map +0 -1
- package/dist/browser/layout/StatusRow.js +0 -174
- package/dist/browser/layout/StatusRow.js.map +0 -1
- package/dist/browser/layout/panel-dialog-error.js +0 -44
- package/dist/browser/layout/panel-dialog-error.js.map +0 -1
- package/dist/browser/layout/panel-sheet-handle.js +0 -86
- package/dist/browser/layout/panel-sheet-handle.js.map +0 -1
- package/dist/browser/layout-check.js +0 -232
- package/dist/browser/layout-check.js.map +0 -1
- package/dist/browser/surfaces/Area.js +0 -205
- package/dist/browser/surfaces/Area.js.map +0 -1
- package/dist/browser/surfaces/FactGroup.js +0 -148
- package/dist/browser/surfaces/FactGroup.js.map +0 -1
- package/dist/browser/surfaces/FieldGrid.js +0 -34
- package/dist/browser/surfaces/FieldGrid.js.map +0 -1
- package/dist/browser/surfaces/RowGroup.js +0 -82
- package/dist/browser/surfaces/RowGroup.js.map +0 -1
- package/dist/browser/surfaces/flat-block-messages.js +0 -37
- package/dist/browser/surfaces/flat-block-messages.js.map +0 -1
- package/dist/ssr/actions/menu-sheet-messages.js +0 -26
- package/dist/ssr/actions/menu-sheet-messages.js.map +0 -1
- package/dist/ssr/actions/menu-submenu-panel.js +0 -295
- package/dist/ssr/actions/menu-submenu-panel.js.map +0 -1
- package/dist/ssr/content/FileName.js +0 -46
- package/dist/ssr/content/FileName.js.map +0 -1
- package/dist/ssr/content/TaskRow.js +0 -95
- package/dist/ssr/content/TaskRow.js.map +0 -1
- package/dist/ssr/content/progress-path-messages.js +0 -22
- package/dist/ssr/content/progress-path-messages.js.map +0 -1
- package/dist/ssr/feedback/dialog-foot.js +0 -45
- package/dist/ssr/feedback/dialog-foot.js.map +0 -1
- package/dist/ssr/internal/renders-something.js +0 -3
- package/dist/ssr/internal/renders-something.js.map +0 -1
- package/dist/ssr/layout/FloatingPill.js +0 -16
- package/dist/ssr/layout/FloatingPill.js.map +0 -1
- package/dist/ssr/layout/StatusRow.js +0 -93
- package/dist/ssr/layout/StatusRow.js.map +0 -1
- package/dist/ssr/layout/panel-dialog-error.js +0 -28
- package/dist/ssr/layout/panel-dialog-error.js.map +0 -1
- package/dist/ssr/layout/panel-sheet-handle.js +0 -66
- package/dist/ssr/layout/panel-sheet-handle.js.map +0 -1
- package/dist/ssr/layout-check.js +0 -232
- package/dist/ssr/layout-check.js.map +0 -1
- package/dist/ssr/surfaces/Area.js +0 -147
- package/dist/ssr/surfaces/Area.js.map +0 -1
- package/dist/ssr/surfaces/FactGroup.js +0 -106
- package/dist/ssr/surfaces/FactGroup.js.map +0 -1
- package/dist/ssr/surfaces/FieldGrid.js +0 -22
- package/dist/ssr/surfaces/FieldGrid.js.map +0 -1
- package/dist/ssr/surfaces/RowGroup.js +0 -60
- package/dist/ssr/surfaces/RowGroup.js.map +0 -1
- package/dist/ssr/surfaces/flat-block-messages.js +0 -37
- package/dist/ssr/surfaces/flat-block-messages.js.map +0 -1
- package/dist/types/actions/menu-sheet-messages.d.ts +0 -11
- package/dist/types/actions/menu-submenu-panel.d.ts +0 -27
- package/dist/types/content/FileName.d.ts +0 -23
- package/dist/types/content/TaskRow.d.ts +0 -33
- package/dist/types/content/progress-path-messages.d.ts +0 -8
- package/dist/types/feedback/dialog-foot.d.ts +0 -9
- package/dist/types/internal/renders-something.d.ts +0 -2
- package/dist/types/layout/FloatingPill.d.ts +0 -20
- package/dist/types/layout/StatusRow.d.ts +0 -54
- package/dist/types/layout/panel-dialog-error.d.ts +0 -9
- package/dist/types/layout/panel-sheet-handle.d.ts +0 -8
- package/dist/types/layout-check.d.ts +0 -52
- package/dist/types/surfaces/Area.d.ts +0 -38
- package/dist/types/surfaces/FactGroup.d.ts +0 -33
- package/dist/types/surfaces/FieldGrid.d.ts +0 -14
- package/dist/types/surfaces/RowGroup.d.ts +0 -20
- package/dist/types/surfaces/flat-block-messages.d.ts +0 -16
|
@@ -7,7 +7,6 @@ import { spread as _$spread } from "solid-js/web";
|
|
|
7
7
|
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
8
8
|
import { memo as _$memo } from "solid-js/web";
|
|
9
9
|
import { className as _$className } from "solid-js/web";
|
|
10
|
-
import { style as _$style } from "solid-js/web";
|
|
11
10
|
import { effect as _$effect } from "solid-js/web";
|
|
12
11
|
import { getNextMarker as _$getNextMarker } from "solid-js/web";
|
|
13
12
|
import { setAttribute as _$setAttribute } from "solid-js/web";
|
|
@@ -40,7 +39,7 @@ import { Button } from "../actions/Button";
|
|
|
40
39
|
import { useUiMessages } from "../intl/messages";
|
|
41
40
|
import { useDetailPanelMessages } from "../layout/detail-panel-messages";
|
|
42
41
|
|
|
43
|
-
/** Named after the status tokens; a tone colours the
|
|
42
|
+
/** Named after the status tokens; a tone colours the frame, the title, and the icon, never the fill. */
|
|
44
43
|
|
|
45
44
|
/** `sm` for detail panels and other narrow columns, `md` for topics on a full page. */
|
|
46
45
|
|
|
@@ -68,7 +67,7 @@ const Heading = props => _$createComponent(Dynamic, {
|
|
|
68
67
|
}
|
|
69
68
|
});
|
|
70
69
|
const SectionRoot = props => {
|
|
71
|
-
const [local, rest] = splitProps(props, ["title", "icon", "
|
|
70
|
+
const [local, rest] = splitProps(props, ["title", "icon", "size", "frame", "tone", "restricted", "description", "count", "meta", "footer", "state", "errorMessage", "onRetry", "loadingRows", "level", "class", "children", "actions", "collapsible", "summary", "defaultOpen", "open", "onOpenChange", "disabled"]);
|
|
72
71
|
const ui = useUiMessages();
|
|
73
72
|
const counts = useDetailPanelMessages();
|
|
74
73
|
const frameDefault = useContext(SectionFrameDefault);
|
|
@@ -111,21 +110,7 @@ const SectionRoot = props => {
|
|
|
111
110
|
children: name => (() => {
|
|
112
111
|
var _el$20 = _$getNextElement(_tmpl$6),
|
|
113
112
|
_el$21 = _el$20.firstChild;
|
|
114
|
-
_$effect(
|
|
115
|
-
var _v$ = local.iconColor ? "" : undefined,
|
|
116
|
-
_v$2 = local.iconColor ? {
|
|
117
|
-
"--k2b-section-icon-color": local.iconColor
|
|
118
|
-
} : undefined,
|
|
119
|
-
_v$3 = name();
|
|
120
|
-
_v$ !== _p$.e && _$setAttribute(_el$20, "data-color", _p$.e = _v$);
|
|
121
|
-
_p$.t = _$style(_el$20, _v$2, _p$.t);
|
|
122
|
-
_v$3 !== _p$.a && _$className(_el$21, _p$.a = _v$3);
|
|
123
|
-
return _p$;
|
|
124
|
-
}, {
|
|
125
|
-
e: undefined,
|
|
126
|
-
t: undefined,
|
|
127
|
-
a: undefined
|
|
128
|
-
});
|
|
113
|
+
_$effect(() => _$className(_el$21, name()));
|
|
129
114
|
return _el$20;
|
|
130
115
|
})()
|
|
131
116
|
}), (() => {
|
|
@@ -308,10 +293,10 @@ const SectionRoot = props => {
|
|
|
308
293
|
}
|
|
309
294
|
})), _el$27, _co$8);
|
|
310
295
|
_$effect(_p$ => {
|
|
311
|
-
var _v$
|
|
312
|
-
_v$
|
|
313
|
-
_v$
|
|
314
|
-
_v$
|
|
296
|
+
var _v$ = open(),
|
|
297
|
+
_v$2 = local.disabled;
|
|
298
|
+
_v$ !== _p$.e && _$setAttribute(_el$24, "aria-expanded", _p$.e = _v$);
|
|
299
|
+
_v$2 !== _p$.t && _$setProperty(_el$24, "disabled", _p$.t = _v$2);
|
|
315
300
|
return _p$;
|
|
316
301
|
}, {
|
|
317
302
|
e: undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["surfaces/Section.tsx"],"sourcesContent":["import { children, createContext, createEffect, createSignal, createUniqueId, For, type JSX, Show, splitProps, useContext } from \"solid-js\";\nimport { Dynamic } from \"solid-js/web\";\nimport { Button } from \"../actions/Button\";\nimport { useUiMessages } from \"../intl/messages\";\nimport { useDetailPanelMessages } from \"../layout/detail-panel-messages\";\n\n/** Named after the status tokens; a tone colours the symbol tile only, never the fill or the title (K8, K17). */\nexport type SectionTone = \"neutral\" | \"success\" | \"warning\" | \"danger\" | \"info\" | \"ai\";\n/** `sm` for detail panels and other narrow columns, `md` for topics on a full page. */\nexport type SectionSize = \"sm\" | \"md\";\n/** `line` draws the light 1 px frame; inside another frame a section always stands flat. */\nexport type SectionFrame = \"line\" | \"none\";\nexport type SectionState = \"ready\" | \"loading\" | \"error\";\n\ntype SectionBaseProps = Omit<JSX.HTMLAttributes<HTMLElement>, \"title\" | \"children\" | \"class\"> & {\n title: JSX.Element;\n icon?: string;\n /**\n * The colour of the section's area as a CSS colour, such as money or goods on a dense record page (K17). It sets the\n * icon in a 20 px tile of that colour, the one place the area colour shows. Never a status hue, never near the AI\n * plum; a `tone` wins.\n */\n iconColor?: string;\n size?: SectionSize;\n frame?: SectionFrame;\n tone?: SectionTone;\n /**\n * Marks a section that only some people see, such as \"Only with permission\": a lock and these words after the\n * title. It is part of the section's accessible name and combines with any tone.\n */\n restricted?: string;\n description?: JSX.Element;\n /** How many things the section lists, as a chip after the title; `0` reads \"None yet\". */\n count?: number;\n /** Short state after the title, such as \"2 of 4 done\". */\n meta?: JSX.Element;\n /** Commands for the whole topic, as a row of buttons at the end of the body. */\n footer?: JSX.Element;\n /** `loading` and `error` take the body's place; the heading stays where it is. */\n state?: SectionState;\n /** Says what did not load; defaults to a generic sentence. */\n errorMessage?: JSX.Element;\n /** Shows \"Try again\" in the error state. */\n onRetry?: () => void;\n /** Placeholder rows while loading, the number the loaded body usually shows. Defaults to 3. */\n loadingRows?: number;\n /** Heading level; defaults to 3, or 2 for `size=\"md\"`. */\n level?: 2 | 3;\n class?: string;\n};\n\nexport type SectionProps = SectionBaseProps &\n (\n | {\n children?: JSX.Element;\n /** At most two quiet controls at the end of the heading, such as \"+\" or text buttons; they read grey. */\n actions?: JSX.Element;\n collapsible?: false;\n summary?: never;\n defaultOpen?: never;\n open?: never;\n onOpenChange?: never;\n disabled?: never;\n }\n | {\n children: JSX.Element;\n actions?: never;\n collapsible: true;\n /** One line that says what the closed section holds, such as its newest entry; hidden while open. */\n summary?: JSX.Element;\n defaultOpen?: boolean;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n disabled?: boolean;\n }\n );\n\nexport type SectionPartProps = {\n title: JSX.Element;\n children: JSX.Element;\n class?: string;\n};\n\ntype SectionComponent = ((props: SectionProps) => JSX.Element) & {\n Part: (props: SectionPartProps) => JSX.Element;\n};\n\nconst SectionLevel = createContext<number>(2);\n\n/**\n * The frame a section draws when it passes none. A host that frames its topics itself, such as a detail panel, sets\n * `none`; everywhere else a section is a card.\n */\nexport const SectionFrameDefault = createContext<SectionFrame>(\"line\");\n\nconst Heading = (props: { level: number; id?: string; class: string; children: JSX.Element }): JSX.Element => (\n <Dynamic component={`h${props.level}`} id={props.id} class={props.class}>\n {props.children}\n </Dynamic>\n);\n\nconst SectionRoot = (props: SectionProps): JSX.Element => {\n const [local, rest] = splitProps(props, [\n \"title\",\n \"icon\",\n \"iconColor\",\n \"size\",\n \"frame\",\n \"tone\",\n \"restricted\",\n \"description\",\n \"count\",\n \"meta\",\n \"footer\",\n \"state\",\n \"errorMessage\",\n \"onRetry\",\n \"loadingRows\",\n \"level\",\n \"class\",\n \"children\",\n \"actions\",\n \"collapsible\",\n \"summary\",\n \"defaultOpen\",\n \"open\",\n \"onOpenChange\",\n \"disabled\",\n ]);\n const ui = useUiMessages();\n const counts = useDetailPanelMessages();\n const frameDefault = useContext(SectionFrameDefault);\n const id = `k2b-section-${createUniqueId()}`;\n const titleId = `${id}-title`;\n const restrictedId = `${id}-restricted`;\n const bodyId = `${id}-body`;\n const level = () => local.level ?? (local.size === \"md\" ? 2 : 3);\n const state = () => local.state ?? \"ready\";\n const [internalOpen, setInternalOpen] = createSignal(local.defaultOpen ?? false);\n const open = () => !local.collapsible || (local.open ?? internalOpen());\n let toggleButton: HTMLButtonElement | undefined;\n let body: HTMLDivElement | undefined;\n\n const toggle = () => {\n if (local.disabled) return;\n const next = !open();\n if (local.open === undefined) setInternalOpen(next);\n local.onOpenChange?.(next);\n };\n // A parent may close the section while focus is inside it; focus then returns to the toggle instead of the page.\n createEffect(() => {\n if (open()) return;\n queueMicrotask(() => {\n const active = body?.ownerDocument.activeElement;\n if (!open() && active && body?.contains(active)) toggleButton?.focus();\n });\n });\n\n // Resolve once and only while ready: reading `children` twice would build the body twice.\n const resolved = children(() => (state() === \"ready\" ? local.children : undefined));\n // A JSX action must also be built once: checking the slot and then reading it again creates different hydration keys.\n const resolvedActions = children(() => local.actions);\n const hasBody = () => local.collapsible || state() !== \"ready\" || Boolean(resolved.toArray().length) || Boolean(local.footer);\n\n /** Icon, then the title with its count, state, and restricted marker in one row, then the description. */\n const headingRow = (title: JSX.Element, summary?: JSX.Element) => (\n <>\n <Show when={local.icon}>\n {(name) => (\n <span\n class=\"k2b-section__icon\"\n aria-hidden=\"true\"\n data-color={local.iconColor ? \"\" : undefined}\n style={local.iconColor ? { \"--k2b-section-icon-color\": local.iconColor } : undefined}\n >\n <i class={name()} />\n </span>\n )}\n </Show>\n <span class=\"k2b-section__copy\">\n <span class=\"k2b-section__heading\">\n {title}\n <Show when={local.count !== undefined}>\n <Show when={local.count! > 0} fallback={<span class=\"k2b-section__none\">{counts().noneYet}</span>}>\n <span class=\"k2b-count-chip\">{local.count}</span>\n </Show>\n </Show>\n <Show when={local.meta}>\n <span class=\"k2b-section__meta\">{local.meta}</span>\n </Show>\n <Show when={local.restricted}>\n <span class=\"k2b-section__restricted\" id={restrictedId}>\n <i class=\"ti ti-lock\" aria-hidden=\"true\" />\n {local.restricted}\n </span>\n </Show>\n {summary}\n </span>\n <Show when={local.description}>\n <span class=\"k2b-section__description\">{local.description}</span>\n </Show>\n </span>\n </>\n );\n\n return (\n <section\n {...rest}\n class={local.class ? `k2b-section ${local.class}` : \"k2b-section\"}\n data-size={local.size ?? \"sm\"}\n data-frame={local.frame ?? frameDefault}\n data-tone={local.tone && local.tone !== \"neutral\" ? local.tone : undefined}\n data-icon={local.icon ? \"true\" : undefined}\n data-collapsible={local.collapsible ? \"true\" : undefined}\n data-open={local.collapsible ? String(open()) : undefined}\n data-summary={local.collapsible && local.summary ? \"true\" : undefined}\n aria-labelledby={local.restricted ? `${titleId} ${restrictedId}` : titleId}\n aria-busy={state() === \"loading\" ? \"true\" : undefined}\n >\n <Show\n when={local.collapsible}\n fallback={\n <header class=\"k2b-section__header\">\n {headingRow(\n <Heading level={level()} id={titleId} class=\"k2b-section__title\">\n {local.title}\n </Heading>,\n )}\n <Show when={resolvedActions()}>\n <div class=\"k2b-section__actions\">{resolvedActions()}</div>\n </Show>\n </header>\n }\n >\n {/* The whole heading row is one disclosure button inside the heading, so the region keeps its name. */}\n <Heading level={level()} class=\"k2b-section__header\">\n <button\n ref={toggleButton}\n type=\"button\"\n class=\"k2b-section__toggle\"\n aria-expanded={open()}\n aria-controls={bodyId}\n disabled={local.disabled}\n // A native listener, not Solid's delegated `onClick`: delegation is registered once per document when\n // this module loads, so a section rendered into a later document (a test harness, an iframe) would\n // never toggle. The shared Button registers its delegation at render time and has no such gap.\n on:click={toggle}\n >\n {headingRow(\n <span id={titleId} class=\"k2b-section__title\">\n {local.title}\n </span>,\n <Show when={local.summary}>\n <span class=\"k2b-section__summary k2b-truncate-fade\">{local.summary}</span>\n </Show>,\n )}\n <span class=\"k2b-section__chevron\" aria-hidden=\"true\">\n <i class=\"ti ti-chevron-down\" />\n </span>\n </button>\n </Heading>\n </Show>\n <Show when={hasBody()}>\n <div ref={body} id={bodyId} class=\"k2b-section__body\" hidden={!open()}>\n <Show when={state() === \"loading\"}>\n {/* Placeholder rows at the height of loaded rows; their widths vary in CSS. */}\n <div role=\"status\">\n <span class=\"k2b-sr-only\">{ui().loading}</span>\n <For each={Array.from({ length: Math.max(1, local.loadingRows ?? 3) })}>\n {() => (\n <div class=\"k2b-section__skeleton-row\" aria-hidden=\"true\">\n <span />\n <span />\n </div>\n )}\n </For>\n </div>\n </Show>\n <Show when={state() === \"error\"}>\n <div class=\"k2b-section__error\" role=\"alert\">\n <i class=\"ti ti-alert-circle\" aria-hidden=\"true\" />\n <span>{local.errorMessage ?? ui().couldNotLoadData}</span>\n </div>\n <Show when={local.onRetry}>\n {(retry) => (\n <div class=\"k2b-section__footer\">\n <Button type=\"button\" size=\"sm\" variant=\"secondary\" onClick={() => retry()()}>\n <i class=\"ti ti-refresh\" aria-hidden=\"true\" />\n {ui().retry}\n </Button>\n </div>\n )}\n </Show>\n </Show>\n {resolved()}\n <Show when={state() === \"ready\" && local.footer}>\n <div class=\"k2b-section__footer\">{local.footer}</div>\n </Show>\n </div>\n </Show>\n </section>\n );\n};\n\n/** A sub-topic inside a section, such as \"Contact\" or \"Address\": a small heading, no frame of its own. */\nconst SectionPart = (props: SectionPartProps): JSX.Element => {\n const level = useContext(SectionLevel);\n const id = `k2b-section-part-${createUniqueId()}`;\n return (\n <div class={props.class ? `k2b-section__part ${props.class}` : \"k2b-section__part\"} role=\"group\" aria-labelledby={id}>\n <Heading level={Math.min(level + 1, 6)} id={id} class=\"k2b-section__part-title\">\n {props.title}\n </Heading>\n {props.children}\n </div>\n );\n};\n\n/**\n * One topic, in a detail panel or on a page: an icon, a title with its count, at most one control, and its\n * content. On a page a section is a card with the light 1 px frame; inside another frame, and in a detail panel, it\n * stands flat, so cards never nest.\n */\nconst SectionWithLevel = (props: SectionProps): JSX.Element => (\n // The level is provided before the body is built, so a part's heading sits one level below this section's.\n <SectionLevel.Provider value={props.level ?? (props.size === \"md\" ? 2 : 3)}>\n <SectionRoot {...props} />\n </SectionLevel.Provider>\n);\n\nexport const Section = SectionWithLevel as SectionComponent;\nSection.Part = SectionPart;\n\nexport default Section;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,EAAY,IAAI,EAAE,UAAU,EAAE,UAAU,QAAQ,UAAU;AAC3I,SAAS,OAAO,QAAQ,cAAc;AACtC,SAAS,MAAM,QAAQ,mBAAmB;AAC1C,SAAS,aAAa,QAAQ,kBAAkB;AAChD,SAAS,sBAAsB,QAAQ,iCAAiC;;AAExE;;AAEA;;AAEA;;AA6EA,MAAM,YAAY,GAAG,aAAa,CAAS,CAAC,CAAC;;AAE7C;AACA;AACA;AACA;AACA,OAAO,MAAM,mBAAmB,GAAG,aAAa,CAAe,MAAM,CAAC;AAEtE,MAAM,OAAO,GAAI,KAA2E,sBACzF,OAAO;EAAA,IAAC,SAAS;IAAA,OAAE,IAAI,KAAK,CAAC,KAAK,EAAE;EAAA;EAAA,IAAE,EAAE;IAAA,OAAE,KAAK,CA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ACC,YAAY,CAAC,QAAQ;EAAA,IAAC,KAAK;IAAA,OAAE,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,KAAK,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;EAAA;EAAA;IAAA,yBACvE,WAAW,EAAK,KAAK;EAAA;AAAA,EAEzB;AAED,OAAO,MAAM,OAAO,GAAG,gBAAoC;AAC3D,OAAO,CAAC,IAAI,GAAG,WAAW;AAE1B,eAAe,OAAO","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["surfaces/Section.tsx"],"sourcesContent":["import { children, createContext, createEffect, createSignal, createUniqueId, For, type JSX, Show, splitProps, useContext } from \"solid-js\";\nimport { Dynamic } from \"solid-js/web\";\nimport { Button } from \"../actions/Button\";\nimport { useUiMessages } from \"../intl/messages\";\nimport { useDetailPanelMessages } from \"../layout/detail-panel-messages\";\n\n/** Named after the status tokens; a tone colours the frame, the title, and the icon, never the fill. */\nexport type SectionTone = \"neutral\" | \"success\" | \"warning\" | \"danger\" | \"info\" | \"ai\";\n/** `sm` for detail panels and other narrow columns, `md` for topics on a full page. */\nexport type SectionSize = \"sm\" | \"md\";\n/** `line` draws the light 1 px frame; inside another frame a section always stands flat. */\nexport type SectionFrame = \"line\" | \"none\";\nexport type SectionState = \"ready\" | \"loading\" | \"error\";\n\ntype SectionBaseProps = Omit<JSX.HTMLAttributes<HTMLElement>, \"title\" | \"children\" | \"class\"> & {\n title: JSX.Element;\n icon?: string;\n size?: SectionSize;\n frame?: SectionFrame;\n tone?: SectionTone;\n /**\n * Marks a section that only some people see, such as \"Only with permission\": a lock and these words after the\n * title. It is part of the section's accessible name and combines with any tone.\n */\n restricted?: string;\n description?: JSX.Element;\n /** How many things the section lists, as a chip after the title; `0` reads \"None yet\". */\n count?: number;\n /** Short state after the title, such as \"2 of 4 done\". */\n meta?: JSX.Element;\n /** Commands for the whole topic, as a row of buttons at the end of the body. */\n footer?: JSX.Element;\n /** `loading` and `error` take the body's place; the heading stays where it is. */\n state?: SectionState;\n /** Says what did not load; defaults to a generic sentence. */\n errorMessage?: JSX.Element;\n /** Shows \"Try again\" in the error state. */\n onRetry?: () => void;\n /** Placeholder rows while loading, the number the loaded body usually shows. Defaults to 3. */\n loadingRows?: number;\n /** Heading level; defaults to 3, or 2 for `size=\"md\"`. */\n level?: 2 | 3;\n class?: string;\n};\n\nexport type SectionProps = SectionBaseProps &\n (\n | {\n children?: JSX.Element;\n /** Exactly one control at the end of the heading, such as \"+\" or one text button. */\n actions?: JSX.Element;\n collapsible?: false;\n summary?: never;\n defaultOpen?: never;\n open?: never;\n onOpenChange?: never;\n disabled?: never;\n }\n | {\n children: JSX.Element;\n actions?: never;\n collapsible: true;\n /** One line that says what the closed section holds, such as its newest entry; hidden while open. */\n summary?: JSX.Element;\n defaultOpen?: boolean;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n disabled?: boolean;\n }\n );\n\nexport type SectionPartProps = {\n title: JSX.Element;\n children: JSX.Element;\n class?: string;\n};\n\ntype SectionComponent = ((props: SectionProps) => JSX.Element) & {\n Part: (props: SectionPartProps) => JSX.Element;\n};\n\nconst SectionLevel = createContext<number>(2);\n\n/**\n * The frame a section draws when it passes none. A host that frames its topics itself, such as a detail panel, sets\n * `none`; everywhere else a section is a card.\n */\nexport const SectionFrameDefault = createContext<SectionFrame>(\"line\");\n\nconst Heading = (props: { level: number; id?: string; class: string; children: JSX.Element }): JSX.Element => (\n <Dynamic component={`h${props.level}`} id={props.id} class={props.class}>\n {props.children}\n </Dynamic>\n);\n\nconst SectionRoot = (props: SectionProps): JSX.Element => {\n const [local, rest] = splitProps(props, [\n \"title\",\n \"icon\",\n \"size\",\n \"frame\",\n \"tone\",\n \"restricted\",\n \"description\",\n \"count\",\n \"meta\",\n \"footer\",\n \"state\",\n \"errorMessage\",\n \"onRetry\",\n \"loadingRows\",\n \"level\",\n \"class\",\n \"children\",\n \"actions\",\n \"collapsible\",\n \"summary\",\n \"defaultOpen\",\n \"open\",\n \"onOpenChange\",\n \"disabled\",\n ]);\n const ui = useUiMessages();\n const counts = useDetailPanelMessages();\n const frameDefault = useContext(SectionFrameDefault);\n const id = `k2b-section-${createUniqueId()}`;\n const titleId = `${id}-title`;\n const restrictedId = `${id}-restricted`;\n const bodyId = `${id}-body`;\n const level = () => local.level ?? (local.size === \"md\" ? 2 : 3);\n const state = () => local.state ?? \"ready\";\n const [internalOpen, setInternalOpen] = createSignal(local.defaultOpen ?? false);\n const open = () => !local.collapsible || (local.open ?? internalOpen());\n let toggleButton: HTMLButtonElement | undefined;\n let body: HTMLDivElement | undefined;\n\n const toggle = () => {\n if (local.disabled) return;\n const next = !open();\n if (local.open === undefined) setInternalOpen(next);\n local.onOpenChange?.(next);\n };\n // A parent may close the section while focus is inside it; focus then returns to the toggle instead of the page.\n createEffect(() => {\n if (open()) return;\n queueMicrotask(() => {\n const active = body?.ownerDocument.activeElement;\n if (!open() && active && body?.contains(active)) toggleButton?.focus();\n });\n });\n\n // Resolve once and only while ready: reading `children` twice would build the body twice.\n const resolved = children(() => (state() === \"ready\" ? local.children : undefined));\n // A JSX action must also be built once: checking the slot and then reading it again creates different hydration keys.\n const resolvedActions = children(() => local.actions);\n const hasBody = () => local.collapsible || state() !== \"ready\" || Boolean(resolved.toArray().length) || Boolean(local.footer);\n\n /** Icon, then the title with its count, state, and restricted marker in one row, then the description. */\n const headingRow = (title: JSX.Element, summary?: JSX.Element) => (\n <>\n <Show when={local.icon}>\n {(name) => (\n <span class=\"k2b-section__icon\" aria-hidden=\"true\">\n <i class={name()} />\n </span>\n )}\n </Show>\n <span class=\"k2b-section__copy\">\n <span class=\"k2b-section__heading\">\n {title}\n <Show when={local.count !== undefined}>\n <Show when={local.count! > 0} fallback={<span class=\"k2b-section__none\">{counts().noneYet}</span>}>\n <span class=\"k2b-count-chip\">{local.count}</span>\n </Show>\n </Show>\n <Show when={local.meta}>\n <span class=\"k2b-section__meta\">{local.meta}</span>\n </Show>\n <Show when={local.restricted}>\n <span class=\"k2b-section__restricted\" id={restrictedId}>\n <i class=\"ti ti-lock\" aria-hidden=\"true\" />\n {local.restricted}\n </span>\n </Show>\n {summary}\n </span>\n <Show when={local.description}>\n <span class=\"k2b-section__description\">{local.description}</span>\n </Show>\n </span>\n </>\n );\n\n return (\n <section\n {...rest}\n class={local.class ? `k2b-section ${local.class}` : \"k2b-section\"}\n data-size={local.size ?? \"sm\"}\n data-frame={local.frame ?? frameDefault}\n data-tone={local.tone && local.tone !== \"neutral\" ? local.tone : undefined}\n data-icon={local.icon ? \"true\" : undefined}\n data-collapsible={local.collapsible ? \"true\" : undefined}\n data-open={local.collapsible ? String(open()) : undefined}\n data-summary={local.collapsible && local.summary ? \"true\" : undefined}\n aria-labelledby={local.restricted ? `${titleId} ${restrictedId}` : titleId}\n aria-busy={state() === \"loading\" ? \"true\" : undefined}\n >\n <Show\n when={local.collapsible}\n fallback={\n <header class=\"k2b-section__header\">\n {headingRow(\n <Heading level={level()} id={titleId} class=\"k2b-section__title\">\n {local.title}\n </Heading>,\n )}\n <Show when={resolvedActions()}>\n <div class=\"k2b-section__actions\">{resolvedActions()}</div>\n </Show>\n </header>\n }\n >\n {/* The whole heading row is one disclosure button inside the heading, so the region keeps its name. */}\n <Heading level={level()} class=\"k2b-section__header\">\n <button\n ref={toggleButton}\n type=\"button\"\n class=\"k2b-section__toggle\"\n aria-expanded={open()}\n aria-controls={bodyId}\n disabled={local.disabled}\n // A native listener, not Solid's delegated `onClick`: delegation is registered once per document when\n // this module loads, so a section rendered into a later document (a test harness, an iframe) would\n // never toggle. The shared Button registers its delegation at render time and has no such gap.\n on:click={toggle}\n >\n {headingRow(\n <span id={titleId} class=\"k2b-section__title\">\n {local.title}\n </span>,\n <Show when={local.summary}>\n <span class=\"k2b-section__summary k2b-truncate-fade\">{local.summary}</span>\n </Show>,\n )}\n <span class=\"k2b-section__chevron\" aria-hidden=\"true\">\n <i class=\"ti ti-chevron-down\" />\n </span>\n </button>\n </Heading>\n </Show>\n <Show when={hasBody()}>\n <div ref={body} id={bodyId} class=\"k2b-section__body\" hidden={!open()}>\n <Show when={state() === \"loading\"}>\n {/* Placeholder rows at the height of loaded rows; their widths vary in CSS. */}\n <div role=\"status\">\n <span class=\"k2b-sr-only\">{ui().loading}</span>\n <For each={Array.from({ length: Math.max(1, local.loadingRows ?? 3) })}>\n {() => (\n <div class=\"k2b-section__skeleton-row\" aria-hidden=\"true\">\n <span />\n <span />\n </div>\n )}\n </For>\n </div>\n </Show>\n <Show when={state() === \"error\"}>\n <div class=\"k2b-section__error\" role=\"alert\">\n <i class=\"ti ti-alert-circle\" aria-hidden=\"true\" />\n <span>{local.errorMessage ?? ui().couldNotLoadData}</span>\n </div>\n <Show when={local.onRetry}>\n {(retry) => (\n <div class=\"k2b-section__footer\">\n <Button type=\"button\" size=\"sm\" variant=\"secondary\" onClick={() => retry()()}>\n <i class=\"ti ti-refresh\" aria-hidden=\"true\" />\n {ui().retry}\n </Button>\n </div>\n )}\n </Show>\n </Show>\n {resolved()}\n <Show when={state() === \"ready\" && local.footer}>\n <div class=\"k2b-section__footer\">{local.footer}</div>\n </Show>\n </div>\n </Show>\n </section>\n );\n};\n\n/** A sub-topic inside a section, such as \"Contact\" or \"Address\": a small heading, no frame of its own. */\nconst SectionPart = (props: SectionPartProps): JSX.Element => {\n const level = useContext(SectionLevel);\n const id = `k2b-section-part-${createUniqueId()}`;\n return (\n <div class={props.class ? `k2b-section__part ${props.class}` : \"k2b-section__part\"} role=\"group\" aria-labelledby={id}>\n <Heading level={Math.min(level + 1, 6)} id={id} class=\"k2b-section__part-title\">\n {props.title}\n </Heading>\n {props.children}\n </div>\n );\n};\n\n/**\n * One topic, in a detail panel or on a page: an icon, a title with its count, at most one control, and its\n * content. On a page a section is a card with the light 1 px frame; inside another frame, and in a detail panel, it\n * stands flat, so cards never nest.\n */\nconst SectionWithLevel = (props: SectionProps): JSX.Element => (\n // The level is provided before the body is built, so a part's heading sits one level below this section's.\n <SectionLevel.Provider value={props.level ?? (props.size === \"md\" ? 2 : 3)}>\n <SectionRoot {...props} />\n </SectionLevel.Provider>\n);\n\nexport const Section = SectionWithLevel as SectionComponent;\nSection.Part = SectionPart;\n\nexport default Section;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,EAAY,IAAI,EAAE,UAAU,EAAE,UAAU,QAAQ,UAAU;AAC3I,SAAS,OAAO,QAAQ,cAAc;AACtC,SAAS,MAAM,QAAQ,mBAAmB;AAC1C,SAAS,aAAa,QAAQ,kBAAkB;AAChD,SAAS,sBAAsB,QAAQ,iCAAiC;;AAExE;;AAEA;;AAEA;;AAuEA,MAAM,YAAY,GAAG,aAAa,CAAS,CAAC,CAAC;;AAE7C;AACA;AACA;AACA;AACA,OAAO,MAAM,mBAAmB,GAAG,aAAa,CAAe,MAAM,CAAC;AAEtE,MAAM,OAAO,GAAI,KAA2E,sBACzF,OAAO;EAAA,IAAC,SAAS;IAAA,OAAE,IAAI,KAAK,CAAC,KAAK,EAAE;EAAA;EAAA,IAAE,EAAE;IAAA,OAAE,KAAK,CAAC,EAAE;EAAA;EAAA;IAAA,OAAS,KAAK,CAAC,KAAK;EAAA;EAAA;IAAA,OACpE,KAAK,CAAC,QAAQ;EAAA;AAAA,EAElB;AAED,MAAM,WAAW,GAAI,KAAmB,IAAkB;EACxD,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,UAAU,CAAC,KAAK,EAAE,CACtC,OAAO,EACP,MAAM,EACN,MAAM,EACN,OAAO,EACP,MAAM,EACN,YAAY,EACZ,aAAa,EACb,OAAO,EACP,MAAM,EACN,QAAQ,EACR,OAAO,EACP,cAAc,EACd,SAAS,EACT,aAAa,EACb,OAAO,EACP,OAAO,EACP,UAAU,EACV,SAAS,EACT,aAAa,EACb,SAAS,EACT,aAAa,EACb,MAAM,EACN,cAAc,EACd,UAAU,CACX,CAA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ACtC,MAAM,EAAE,GAAG,oBAAoB,cAAc,CAAC,CAAC,EAAE;EACjD;IAAA;MAAA;MAAA;MAAA;MAAA;IAAA,0CACoH,EAAE;IAAA,mCACjH,OAAO;MAAA,IAAC,KAAK;QAAA,OAAE,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC;MAAA;MAAE,EAAE,EAAE,EAAE;MAAA;MAAA;QAAA,OAC3C,KAAK,CAAC,KAAK;MAAA;IAAA;IAAA,uBAEb,KAAK,CAAC,QAAQ;IAAA,mCAJL,KAAK,CAAC,KAAK,GAAG,qBAAqB,KAAK,CAAC,KAAK,EAAE,GAAG,mBAAmB;IAAA;EAAA;AAOtF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAM,gBAAgB,GAAI,KAAmB,IAC3C;AAAA,kBACC,YAAY,CAAC,QAAQ;EAAA,IAAC,KAAK;IAAA,OAAE,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,KAAK,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;EAAA;EAAA;IAAA,yBACvE,WAAW,EAAK,KAAK;EAAA;AAAA,EAEzB;AAED,OAAO,MAAM,OAAO,GAAG,gBAAoC;AAC3D,OAAO,CAAC,IAAI,GAAG,WAAW;AAE1B,eAAe,OAAO","ignoreList":[]}
|
|
@@ -13,9 +13,6 @@ var _tmpl$ = /*#__PURE__*/_$template(`<span class=k2b-status-badge__label data-r
|
|
|
13
13
|
_tmpl$5 = /*#__PURE__*/_$template(`<span class=k2b-status-badge__label>`),
|
|
14
14
|
_tmpl$6 = /*#__PURE__*/_$template(`<span aria-hidden=true>`);
|
|
15
15
|
import { For, Show } from "solid-js";
|
|
16
|
-
|
|
17
|
-
/** `yours` is "your turn": the blue tint of an action that waits for the reader; amber `warning` is "to clarify". */
|
|
18
|
-
|
|
19
16
|
const DEFAULT_ICONS = {
|
|
20
17
|
info: "ti ti-info-circle",
|
|
21
18
|
ok: "ti ti-check",
|
|
@@ -23,8 +20,7 @@ const DEFAULT_ICONS = {
|
|
|
23
20
|
error: "ti ti-alert-circle",
|
|
24
21
|
degraded: "ti ti-plug-connected-x",
|
|
25
22
|
running: "ti ti-loader-2",
|
|
26
|
-
neutral: "ti ti-alert-square-rounded"
|
|
27
|
-
yours: "ti ti-arrow-right"
|
|
23
|
+
neutral: "ti ti-alert-square-rounded"
|
|
28
24
|
};
|
|
29
25
|
export function StatusBadge(props) {
|
|
30
26
|
const variant = () => props.variant ?? "chip";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["surfaces/StatusBadge.tsx"],"sourcesContent":["import { For, type JSX, Show } from \"solid-js\";\n\
|
|
1
|
+
{"version":3,"names":[],"sources":["surfaces/StatusBadge.tsx"],"sourcesContent":["import { For, type JSX, Show } from \"solid-js\";\n\nexport type StatusTone = \"info\" | \"ok\" | \"warning\" | \"error\" | \"degraded\" | \"running\" | \"neutral\";\n\nexport type StatusBadgeProps = {\n tone: StatusTone;\n label: JSX.Element;\n icon?: string | null;\n variant?: \"chip\" | \"dot\" | \"text\";\n /**\n * Every label this place can show, such as all states of a list's status. The badge keeps the width of the longest,\n * so in a right-aligned slot its dot starts at one x in every row and stays put when the state changes.\n */\n labels?: readonly string[];\n title?: string;\n class?: string;\n};\n\nconst DEFAULT_ICONS: Record<StatusTone, string> = {\n info: \"ti ti-info-circle\",\n ok: \"ti ti-check\",\n warning: \"ti ti-alert-triangle\",\n error: \"ti ti-alert-circle\",\n degraded: \"ti ti-plug-connected-x\",\n running: \"ti ti-loader-2\",\n neutral: \"ti ti-alert-square-rounded\",\n};\n\nexport function StatusBadge(props: StatusBadgeProps): JSX.Element {\n const variant = () => props.variant ?? \"chip\";\n const icon = () => (props.icon === null ? undefined : (props.icon ?? DEFAULT_ICONS[props.tone]));\n return (\n <span class={`k2b-status-badge ${props.class ?? \"\"}`} data-tone={props.tone} data-variant={variant()} title={props.title}>\n <Show when={variant() !== \"dot\"} fallback={<span class=\"k2b-status-badge__dot\" aria-hidden=\"true\" />}>\n <Show when={icon()}>{(glyph) => <i class={glyph()} aria-hidden=\"true\" />}</Show>\n </Show>\n <Show when={props.labels?.length} fallback={<span class=\"k2b-status-badge__label\">{props.label}</span>}>\n <span class=\"k2b-status-badge__label\" data-reserve=\"\">\n <span>{props.label}</span>\n <For each={props.labels}>{(label) => <span aria-hidden=\"true\">{label}</span>}</For>\n </span>\n </Show>\n </span>\n );\n}\n\nexport default StatusBadge;\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,GAAG,EAAY,IAAI,QAAQ,UAAU;AAkB9C,MAAM,aAAyC,GAAG;EAChD,IAAI,EAAE,mBAAmB;EACzB,EAAE,EAAE,aAAa;EACjB,OAAO,EAAE,sBAAsB;EAC/B,KAAK,EAAE,oBAAoB;EAC3B,QAAQ,EAAE,wBAAwB;EAClC,OAAO,EAAE,gBAAgB;EACzB,OAAO,EAAE;AACX,CAAC;AAED,OAAO,SAAS,WAAW,CAAC,KAAuB,EAAe;EAChE,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,OAAO,IAAI,MAAM;EAC7C,MAAM,IAAI,GAAG,MAAO,KAAK,CAAC,IAAI,KAAK,IAAI,GAAG,SAAS,GAAI,KAAK,CAAC,IAAI,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,CAAG;EAChG;IAAA;MAAA;MAAA;MAAA;MAAA;IAAA,iCAEK,IAAI;MAAA,IAAC,IAAI;QAAA,OAAE,OAAO,CAAC,CAAC,KAAK,KAAK;MAAA;MAAA,IAAE,QAAQ;QAAA;MAAA;MAAA;QAAA,yBACtC,IAAI;UAAA,IAAC,IAAI;YAAA,OAAE,IAAI,CAAC,CAAC;UAAA;UAAA,UAAI,KAAK;YAAA;YAAA,kCAAe,KAAK,CAAC,CAAC;YAAA;UAAA;QAAuB;MAAA;IAAA;IAAA,iCAEzE,IAAI;MAAA,IAAC,IAAI;QAAA,OAAE,KAAK,CAAC,MAAM,EAAE,MAAM;MAAA;MAAA,IAAE,QAAQ;QAAA;UAAA;UAAA,uBAAyC,KAAK,CAAC,KAAK;UAAA;QAAA;MAAA;MAAA;QAAA;UAAA;UAAA;UAAA;QAAA,sBAEnF,KAAK,CAAC,KAAK;QAAA,kCACjB,GAAG;UAAA,IAAC,IAAI;YAAA,OAAE,KAAK,CAAC,MAAM;UAAA;UAAA,UAAI,KAAK;YAAA;YAAA,iBAA+B,KAAK;YAAA;UAAA;QAAQ;QAAA;MAAA;IAAA;IAAA;MAAA,UAPrE,oBAAoB,KAAK,CAAC,KAAK,IAAI,EAAE,EAAE;QAAA,OAAa,KAAK,CAAC,IAAI;QAAA,OAAgB,OAAO,CAAC,CAAC;QAAA,OAAS,KAAK,CAAC,KAAK;MAAA;MAAA;MAAA;MAAA;MAAA;IAAA;MAAA;MAAA;MAAA;MAAA;IAAA;IAAA;EAAA;AAY5H;AAEA,eAAe,WAAW","ignoreList":[]}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
export { Area } from "./Area";
|
|
2
1
|
export { Avatar } from "./Avatar";
|
|
3
2
|
export { AvatarFaces, AvatarStack } from "./AvatarStack";
|
|
4
3
|
export { BudgetList, budgetState } from "./BudgetList";
|
|
5
4
|
export { ChangeList } from "./ChangeList";
|
|
6
5
|
export { DescriptionList } from "./DescriptionList";
|
|
7
6
|
export { DotStrip } from "./DotStrip";
|
|
8
|
-
export { FactGroup } from "./FactGroup";
|
|
9
7
|
export { Field } from "./Field";
|
|
10
|
-
export { FieldGrid } from "./FieldGrid";
|
|
11
8
|
export { LinkCard } from "./LinkCard";
|
|
12
9
|
export { NotFoundState } from "./NotFoundState";
|
|
13
10
|
export { NOTICE_CARD_CLASSES, NoticeCard } from "./NoticeCard";
|
|
@@ -18,7 +15,6 @@ export { ProgressBar, progressBarParts } from "./ProgressBar";
|
|
|
18
15
|
export { ProgressRing } from "./ProgressRing";
|
|
19
16
|
export { PERSON_COLORS, personColor } from "./person-color";
|
|
20
17
|
export { ResourceCard } from "./ResourceCard";
|
|
21
|
-
export { RowGroup } from "./RowGroup";
|
|
22
18
|
export { Section } from "./Section";
|
|
23
19
|
export { createDelayedLoading, Skeleton } from "./Skeleton";
|
|
24
20
|
export { StatCell } from "./StatCell";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["surfaces/index.ts"],"sourcesContent":["export type {
|
|
1
|
+
{"version":3,"names":[],"sources":["surfaces/index.ts"],"sourcesContent":["export type { AvatarProps, AvatarRing, AvatarShape, AvatarSize, AvatarTone } from \"./Avatar\";\nexport { Avatar } from \"./Avatar\";\nexport type { AvatarFacesPerson, AvatarFacesProps, AvatarStackPerson, AvatarStackProps } from \"./AvatarStack\";\nexport { AvatarFaces, AvatarStack } from \"./AvatarStack\";\nexport { type BudgetItem, type BudgetLevel, BudgetList, type BudgetListProps, budgetState } from \"./BudgetList\";\nexport type { ChangeListItem, ChangeListProps, ChangeTone } from \"./ChangeList\";\nexport { ChangeList } from \"./ChangeList\";\nexport type { DescriptionListItem, DescriptionListProps } from \"./DescriptionList\";\nexport { DescriptionList } from \"./DescriptionList\";\nexport type { DotStripProps, DotStripTone } from \"./DotStrip\";\nexport { DotStrip } from \"./DotStrip\";\nexport type { FieldRowProps } from \"./Field\";\nexport { Field } from \"./Field\";\nexport type { LinkCardColor, LinkCardProps } from \"./LinkCard\";\nexport { LinkCard } from \"./LinkCard\";\nexport type { NotFoundStateAction, NotFoundStateProps } from \"./NotFoundState\";\nexport { NotFoundState } from \"./NotFoundState\";\nexport type { NoticeCardProps, NoticeGridProps, NoticeTone } from \"./NoticeCard\";\nexport { NOTICE_CARD_CLASSES, NoticeCard } from \"./NoticeCard\";\nexport type { NoticeRowProps } from \"./NoticeRow\";\nexport { NoticeRow } from \"./NoticeRow\";\nexport type { PaperProps, PaperTag } from \"./Paper\";\nexport { Paper } from \"./Paper\";\nexport type {\n PlaceholderAlign,\n PlaceholderProps,\n PlaceholderState,\n PlaceholderSurface,\n PlaceholderVariant,\n} from \"./Placeholder\";\nexport { default as Placeholder } from \"./Placeholder\";\nexport type { ProgressBarPart, ProgressBarProps, ProgressBarSegment, ProgressBarTone } from \"./ProgressBar\";\nexport { ProgressBar, progressBarParts } from \"./ProgressBar\";\nexport type { ProgressRingProps, ProgressRingTone } from \"./ProgressRing\";\nexport { ProgressRing } from \"./ProgressRing\";\nexport { PERSON_COLORS, personColor } from \"./person-color\";\nexport type { ResourceCardColor, ResourceCardProps, ResourceCardState } from \"./ResourceCard\";\nexport { ResourceCard } from \"./ResourceCard\";\nexport type { SectionFrame, SectionPartProps, SectionProps, SectionSize, SectionState, SectionTone } from \"./Section\";\nexport { Section } from \"./Section\";\nexport { createDelayedLoading, type DelayedLoadingOptions, Skeleton, type SkeletonProps } from \"./Skeleton\";\nexport type { StatCellAccent, StatCellCompare, StatCellDelta, StatCellProps, StatCellSize, StatCellTone } from \"./StatCell\";\nexport { StatCell } from \"./StatCell\";\nexport type {\n StatGridAction,\n StatGridColumns,\n StatGridProps,\n StatGridSize,\n StatGridSurface,\n StatGridVariant,\n} from \"./StatGrid\";\nexport { StatGrid } from \"./StatGrid\";\nexport type { StatusBadgeProps, StatusTone } from \"./StatusBadge\";\nexport { StatusBadge } from \"./StatusBadge\";\nexport type { TagProps, TagSize } from \"./Tag\";\nexport { Tag } from \"./Tag\";\n"],"mappings":"AACA,SAAS,MAAM,QAAQ,UAAU;AAEjC,SAAS,WAAW,EAAE,WAAW,QAAQ,eAAe;AACxD,SAA4C,UAAU,EAAwB,WAAW,QAAQ,cAAc;AAE/G,SAAS,UAAU,QAAQ,cAAc;AAEzC,SAAS,eAAe,QAAQ,mBAAmB;AAEnD,SAAS,QAAQ,QAAQ,YAAY;AAErC,SAAS,KAAK,QAAQ,SAAS;AAE/B,SAAS,QAAQ,QAAQ,YAAY;AAErC,SAAS,aAAa,QAAQ,iBAAiB;AAE/C,SAAS,mBAAmB,EAAE,UAAU,QAAQ,cAAc;AAE9D,SAAS,SAAS,QAAQ,aAAa;AAEvC,SAAS,KAAK,QAAQ,SAAS;AAQ/B,SAAS,OAAO,IAAI,WAAW,QAAQ,eAAe;AAEtD,SAAS,WAAW,EAAE,gBAAgB,QAAQ,eAAe;AAE7D,SAAS,YAAY,QAAQ,gBAAgB;AAC7C,SAAS,aAAa,EAAE,WAAW,QAAQ,gBAAgB;AAE3D,SAAS,YAAY,QAAQ,gBAAgB;AAE7C,SAAS,OAAO,QAAQ,WAAW;AACnC,SAAS,oBAAoB,EAA8B,QAAQ,QAA4B,YAAY;AAE3G,SAAS,QAAQ,QAAQ,YAAY;AASrC,SAAS,QAAQ,QAAQ,YAAY;AAErC,SAAS,WAAW,QAAQ,eAAe;AAE3C,SAAS,GAAG,QAAQ,OAAO","ignoreList":[]}
|
|
@@ -16,9 +16,7 @@ import { DropdownItems, dropdownPosition } from "./Dropdown";
|
|
|
16
16
|
import { focusRowSegment } from "./menu-rows";
|
|
17
17
|
const NATIVE_MENU_TARGETS = "a[href], input, textarea, select, [contenteditable]:not([contenteditable='false'])";
|
|
18
18
|
let closeActiveContextMenu;
|
|
19
|
-
const focusableItems = menu => menu ? Array.from(menu.querySelectorAll(
|
|
20
|
-
// An open submenu inside the menu holds its own entries.
|
|
21
|
-
":is([role='menuitem'], [role='menuitemcheckbox'], [role='menuitemradio']):not([aria-disabled='true'], .k2b-dropdown__submenu *)")) : [];
|
|
19
|
+
const focusableItems = menu => menu ? Array.from(menu.querySelectorAll(["[role='menuitem']:not([aria-disabled='true'])", "[role='menuitemcheckbox']:not([aria-disabled='true'])", "[role='menuitemradio']:not([aria-disabled='true'])"].join(", "))) : [];
|
|
22
20
|
|
|
23
21
|
/** Right-click menu with keyboard invocation, one-open-at-a-time behavior, and viewport clamping. */
|
|
24
22
|
export function ContextMenu(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["actions/ContextMenu.tsx"],"sourcesContent":["import { createMemo, createSignal, createUniqueId, type JSX, onCleanup, onMount, Show } from \"solid-js\";\nimport { Portal } from \"solid-js/web\";\nimport { returnFocus, ringOnReturn } from \"../internal/focus-return\";\nimport { inheritUiScope } from \"../internal/portal-scope\";\nimport { useUiMessages } from \"../intl/messages\";\nimport { type DropdownItem, DropdownItems, type DropdownPosition, dropdownPosition } from \"./Dropdown\";\nimport { focusRowSegment } from \"./menu-rows\";\n\nexport type ContextMenuProps = {\n items: readonly DropdownItem[];\n children: JSX.Element;\n class?: string | ((isOpen: boolean) => string);\n /** Tab order of the context-menu host. Descendant-focused composite widgets use -1. */\n tabIndex?: number;\n disabled?: boolean;\n onClose?: () => void;\n onOpen?: () => void;\n id?: string;\n label?: string;\n /**\n * Links, form fields, editable text, and selected text inside the host keep the browser's own menu, with its Copy,\n * Paste, and Open link. Use it where the host wraps readable content rather than one row.\n */\n keepNativeMenu?: boolean;\n};\n\nconst NATIVE_MENU_TARGETS = \"a[href], input, textarea, select, [contenteditable]:not([contenteditable='false'])\";\n\nlet closeActiveContextMenu: (() => void) | undefined;\n\nconst focusableItems = (menu: HTMLElement | undefined): HTMLElement[] =>\n menu\n ? Array.from(\n menu.querySelectorAll<HTMLElement>(\n // An open submenu inside the menu holds its own entries.\n \":is([role='menuitem'], [role='menuitemcheckbox'], [role='menuitemradio']):not([aria-disabled='true'], .k2b-dropdown__submenu *)\",\n ),\n )\n : [];\n\n/** Right-click menu with keyboard invocation, one-open-at-a-time behavior, and viewport clamping. */\nexport function ContextMenu(props: ContextMenuProps): JSX.Element {\n return ContextMenuBase(props);\n}\n\n/**\n * Package-internal, not exported from the package index: `openAt` lets GestureMenu open the menu at a held finger, and\n * `title` names what was pressed above the entries, since the finger covers it.\n */\nexport function ContextMenuBase(\n props: ContextMenuProps & {\n openAt?: (open: (x: number, y: number) => void) => void;\n title?: string;\n closeWith?: (close: () => void) => void;\n },\n): JSX.Element {\n const messages = useUiMessages();\n const generatedId = `k2b-context-${createUniqueId()}`;\n const menuId = `${generatedId}-menu`;\n const [position, setPosition] = createSignal<{ x: number; y: number }>();\n let host: HTMLDivElement | undefined;\n let menu: HTMLDivElement | undefined;\n let listenersAttached = false;\n let hostRing = true;\n /** The element inside the host that had focus as the menu opened, such as a row or a day of a composite widget. */\n let opener: HTMLElement | undefined;\n let anchor = { x: 0, y: 0 };\n let viewport = { width: 0, height: 0 };\n let resizeObserver: ResizeObserver | undefined;\n\n const isOpen = () => position() !== undefined;\n const keepsNativeMenu = (target: EventTarget | null): boolean => {\n if (!props.keepNativeMenu || !(target instanceof Node)) return false;\n const element = target instanceof Element ? target : target.parentElement;\n const native = element?.closest(NATIVE_MENU_TARGETS);\n if (native && host?.contains(native)) return true;\n const selection = window.getSelection();\n return Boolean(selection && !selection.isCollapsed && selection.toString().trim() && selection.containsNode(target, true));\n };\n const hostClass = createMemo(() => (typeof props.class === \"function\" ? props.class(isOpen()) : props.class));\n const items = createMemo<readonly DropdownItem[]>(() => props.items);\n\n const dismiss = (event: PointerEvent) => {\n if (menu?.contains(event.target as Node)) return;\n close();\n };\n const closeOnScroll = (event: Event) => {\n const target = event.target;\n if (target instanceof Node && menu?.contains(target)) return;\n close();\n };\n // A resize event may leave the viewport's size unchanged; headless Chromium\n // was seen to fire one on a fresh page. The clamped menu is still in place.\n const closeOnResize = () => {\n if (window.innerWidth === viewport.width && window.innerHeight === viewport.height) return;\n close();\n };\n const attachOpenListeners = () => {\n if (listenersAttached) return;\n listenersAttached = true;\n document.addEventListener(\"pointerdown\", dismiss);\n document.addEventListener(\"keydown\", keyDown);\n window.addEventListener(\"resize\", closeOnResize);\n window.addEventListener(\"scroll\", closeOnScroll, true);\n };\n const detachOpenListeners = () => {\n if (!listenersAttached) return;\n listenersAttached = false;\n document.removeEventListener(\"pointerdown\", dismiss);\n document.removeEventListener(\"keydown\", keyDown);\n window.removeEventListener(\"resize\", closeOnResize);\n window.removeEventListener(\"scroll\", closeOnScroll, true);\n resizeObserver?.disconnect();\n };\n /** Clamps the rendered menu into the viewport beside the point that opened it. */\n const place = () => {\n if (!isOpen() || !menu?.isConnected) return;\n const point = dropdownPosition(\n new DOMRect(anchor.x, anchor.y, 0, 0),\n menu.getBoundingClientRect(),\n \"bottom-right\" satisfies DropdownPosition,\n { width: window.innerWidth, height: window.innerHeight },\n 0,\n );\n setPosition({ x: point.left, y: point.top });\n };\n const close = () => {\n detachOpenListeners();\n if (!isOpen()) return;\n // An activated entry closes the menu before its action runs: focus goes back to where the menu opened from, as\n // Escape returns it, so the keyboard never lands on the page body.\n if (menu?.contains(document.activeElement)) returnFocus(opener?.isConnected ? opener : host, hostRing);\n setPosition();\n if (closeActiveContextMenu === close) closeActiveContextMenu = undefined;\n props.onClose?.();\n };\n const focusItem = (index: number) => {\n const items = focusableItems(menu);\n if (items.length === 0) return;\n items[(index + items.length) % items.length]?.focus();\n };\n const open = (x: number, y: number) => {\n if (props.disabled) return;\n closeActiveContextMenu?.();\n // Focus may sit on a descendant of the host, as in composite widgets; Escape returns it there.\n const focused = document.activeElement;\n opener = focused instanceof HTMLElement && focused !== host && host?.contains(focused) ? focused : undefined;\n hostRing = ringOnReturn(focused);\n anchor = { x, y };\n viewport = { width: window.innerWidth, height: window.innerHeight };\n setPosition({ x, y });\n closeActiveContextMenu = close;\n attachOpenListeners();\n props.onOpen?.();\n // The menu sizes to its entries, so it is measured once rendered and\n // clamped into the viewport before the next paint, and again whenever its\n // entries change its size while it is open.\n queueMicrotask(() => {\n if (!isOpen() || !menu?.isConnected) return;\n place();\n if (typeof ResizeObserver !== \"undefined\") {\n resizeObserver ??= new ResizeObserver(place);\n resizeObserver.observe(menu);\n }\n focusItem(0);\n });\n };\n const keyDown = (event: KeyboardEvent) => {\n if (!isOpen()) return;\n const items = focusableItems(menu);\n const current = items.indexOf(document.activeElement as HTMLElement);\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n focusItem(current + (event.key === \"ArrowDown\" ? 1 : -1));\n } else if (focusRowSegment(items, event.key)) {\n event.preventDefault();\n } else if (event.key === \"Home\" || event.key === \"End\") {\n event.preventDefault();\n focusItem(event.key === \"Home\" ? 0 : -1);\n } else if (event.key === \"Escape\") {\n event.preventDefault();\n close();\n returnFocus(opener?.isConnected ? opener : host, hostRing);\n } else if (event.key === \"Tab\") {\n close();\n }\n };\n\n props.openAt?.(open);\n // A close from outside, such as a drag taking over the press, returns focus that sits in the menu to where it came from.\n props.closeWith?.(() => {\n if (isOpen() && menu?.contains(document.activeElement)) returnFocus(opener?.isConnected ? opener : host, hostRing);\n close();\n });\n\n onMount(() => {\n onCleanup(() => {\n detachOpenListeners();\n if (closeActiveContextMenu === close) closeActiveContextMenu = undefined;\n });\n });\n\n return (\n <>\n {/* biome-ignore lint/a11y/useAriaPropsSupportedByRole: the named group owns the context-menu relationship without pretending arbitrary children form one button. */}\n <div\n ref={host}\n id={props.id ?? generatedId}\n class={hostClass()}\n role=\"group\"\n tabIndex={props.disabled ? undefined : (props.tabIndex ?? 0)}\n aria-label={props.label ?? messages().contextMenu}\n aria-haspopup=\"menu\"\n aria-expanded={isOpen()}\n aria-controls={isOpen() ? menuId : undefined}\n aria-disabled={props.disabled ? \"true\" : undefined}\n onContextMenu={(event) => {\n if (props.disabled) return;\n // An enclosing context menu must not take over the browser's own either.\n if (keepsNativeMenu(event.target)) return void event.stopPropagation();\n event.preventDefault();\n event.stopPropagation();\n open(event.clientX, event.clientY);\n }}\n onKeyDown={(event) => {\n if (props.disabled || (event.key !== \"ContextMenu\" && !(event.shiftKey && event.key === \"F10\"))) return;\n // A nested context menu already opened its own; a field keeps the browser's.\n if (\n event.defaultPrevented ||\n (props.keepNativeMenu && event.target instanceof Element && event.target.closest(NATIVE_MENU_TARGETS))\n )\n return;\n event.preventDefault();\n // Beside the focused element, such as a row of a composite widget, rather than the corner of the whole host.\n const focused = document.activeElement;\n const rect = (focused instanceof HTMLElement && host?.contains(focused) ? focused : host)?.getBoundingClientRect();\n if (rect) open(rect.left + 12, rect.top + 12);\n }}\n >\n {props.children}\n </div>\n <Show when={position()}>\n {(point) => (\n // Like a dropdown's menu, it stays inside an open dialog and shows in the top layer: a modal dialog makes the\n // rest of the page inert, and the top layer keeps it at the pointer whatever the dialog's transform.\n <Portal mount={host?.closest(\"dialog[open]\") ?? undefined}>\n <div\n ref={(element) => {\n menu = element;\n inheritUiScope(element, host);\n queueMicrotask(() => {\n if (element.isConnected && typeof element.showPopover === \"function\") element.showPopover();\n });\n }}\n id={menuId}\n popover=\"manual\"\n class=\"k2b-ui k2b-context-menu\"\n role=\"menu\"\n aria-label={props.label ?? messages().contextMenu}\n style={{ left: `${point().x}px`, top: `${point().y}px` }}\n onPointerDown={(event) => event.stopPropagation()}\n >\n {/* The menu carries the same name for assistive technology. */}\n <Show when={props.title}>\n <div class=\"k2b-context-menu__title\" aria-hidden=\"true\">\n {props.title}\n </div>\n </Show>\n <DropdownItems items={items()} close={close} />\n </div>\n </Portal>\n )}\n </Show>\n </>\n );\n}\n\nexport default ContextMenu;\n"],"mappings":";;;;;;;;;AAAA,SAAS,UAAU,EAAE,YAAY,EAAE,cAAc,EAAY,SAAS,EAAE,OAAO,EAAE,IAAI,QAAQ,UAAU;AACvG,SAAS,MAAM,QAAQ,cAAc;AACrC,SAAS,WAAW,EAAE,YAAY,QAAQ,0BAA0B;AACpE,SAAS,cAAc,QAAQ,0BAA0B;AACzD,SAAS,aAAa,QAAQ,kBAAkB;AAChD,SAA4B,aAAa,EAAyB,gBAAgB,QAAQ,YAAY;AACtG,SAAS,eAAe,QAAQ,aAAa;AAoB7C,MAAM,mBAAmB,GAAG,oFAAoF;AAEhH,IAAI,sBAAgD;AAEpD,MAAM,cAAc,GAAI,IAA6B,IACnD,IAAI,GACA,KAAK,CAAC,IAAI,CACR,IAAI,CAAC,gBAAgB;AACnB;AACA,iIACF,CACF,CAAC,GACD,EAAE;;AAER;AACA,OAAO,SAAS,WAAW,CAAC,KAAuB,EAAe;EAChE,OAAO,eAAe,CAAC,KAAK,CAAC;AAC/B;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAAS,eAAe,CAC7B,KAIC,EACY;EACb,MAAM,Q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BAAsB,KAAK,KAAK,EAAE,sBAAsB,GAAG,SAAS;IAC1E,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,oDAKU,KAAK,CAAC,EAAE,IAAI,WAAW,mDACpB,SAAS,CAAC,CAAC,4CAER,KAAK,CAAC,QAAQ,YAAG,SAAS,mBAAI,KAAK,CAAC,QAAQ,IAAI,CAAC,OAAC,iDAChD,KAAK,CAAC,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,WAAW,0DAElC,MAAM,CAAC,CAAC,kDACR,MAAM,CAAC,CAAC,YAAG,MAAM,mBAAG,SAAS,kDAC7B,KAAK,CAAC,QAAQ,GAAG,MAAM,YAAG,SAAS,0BAwBjD,KAAK,CAAC,QAAQ,sBAEhB,IAAI;IAAA,IAAC,IAAI;MAAA,OAAE,QAAQ,CAAC,CAAC;IAAA;IAAA,UAClB,KAAK,IACL;IACA;IAAA,kBACC,MAAM;MAAA,IAAC,KAAK;QAAA,OAAE,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,IAAI,SAAS;MAAA;MAAA;QAAA,oDASjD,MAAM,uDAIE,KAAK,CAAC,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,WAAW,6CAClC,YAAG,KAAK,CAAC,CAAC,CAAC,CAAC,WAAI,gCAAO,YAAG,KAAK,CAAC,CAAC,CAAC,CAAC,WAAI,8BAIrD,IAAI;UAAA,IAAC,IAAI;YAAA,OAAE,KAAK,CAAC,KAAK;UAAA;UAAA;YAAA,+BAElB,KAAK,CAAC,KAAK;UAAA;QAAA,gCAGf,aAAa;UAAA,IAAC,KAAK;YAAA,OAAE,KAAK,CAAC,CAAC;UAAA;UAAE,KAAK,EAAE;QAAK;MAAA;IAAA;EAGhD;AAIT;AAEA,eAAe,WAAW","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["actions/ContextMenu.tsx"],"sourcesContent":["import { createMemo, createSignal, createUniqueId, type JSX, onCleanup, onMount, Show } from \"solid-js\";\nimport { Portal } from \"solid-js/web\";\nimport { returnFocus, ringOnReturn } from \"../internal/focus-return\";\nimport { inheritUiScope } from \"../internal/portal-scope\";\nimport { useUiMessages } from \"../intl/messages\";\nimport { type DropdownItem, DropdownItems, type DropdownPosition, dropdownPosition } from \"./Dropdown\";\nimport { focusRowSegment } from \"./menu-rows\";\n\nexport type ContextMenuProps = {\n items: readonly DropdownItem[];\n children: JSX.Element;\n class?: string | ((isOpen: boolean) => string);\n /** Tab order of the context-menu host. Descendant-focused composite widgets use -1. */\n tabIndex?: number;\n disabled?: boolean;\n onClose?: () => void;\n onOpen?: () => void;\n id?: string;\n label?: string;\n /**\n * Links, form fields, editable text, and selected text inside the host keep the browser's own menu, with its Copy,\n * Paste, and Open link. Use it where the host wraps readable content rather than one row.\n */\n keepNativeMenu?: boolean;\n};\n\nconst NATIVE_MENU_TARGETS = \"a[href], input, textarea, select, [contenteditable]:not([contenteditable='false'])\";\n\nlet closeActiveContextMenu: (() => void) | undefined;\n\nconst focusableItems = (menu: HTMLElement | undefined): HTMLElement[] =>\n menu\n ? Array.from(\n menu.querySelectorAll<HTMLElement>(\n [\n \"[role='menuitem']:not([aria-disabled='true'])\",\n \"[role='menuitemcheckbox']:not([aria-disabled='true'])\",\n \"[role='menuitemradio']:not([aria-disabled='true'])\",\n ].join(\", \"),\n ),\n )\n : [];\n\n/** Right-click menu with keyboard invocation, one-open-at-a-time behavior, and viewport clamping. */\nexport function ContextMenu(props: ContextMenuProps): JSX.Element {\n return ContextMenuBase(props);\n}\n\n/**\n * Package-internal, not exported from the package index: `openAt` lets GestureMenu open the menu at a held finger, and\n * `title` names what was pressed above the entries, since the finger covers it.\n */\nexport function ContextMenuBase(\n props: ContextMenuProps & {\n openAt?: (open: (x: number, y: number) => void) => void;\n title?: string;\n closeWith?: (close: () => void) => void;\n },\n): JSX.Element {\n const messages = useUiMessages();\n const generatedId = `k2b-context-${createUniqueId()}`;\n const menuId = `${generatedId}-menu`;\n const [position, setPosition] = createSignal<{ x: number; y: number }>();\n let host: HTMLDivElement | undefined;\n let menu: HTMLDivElement | undefined;\n let listenersAttached = false;\n let hostRing = true;\n /** The element inside the host that had focus as the menu opened, such as a row or a day of a composite widget. */\n let opener: HTMLElement | undefined;\n let anchor = { x: 0, y: 0 };\n let viewport = { width: 0, height: 0 };\n let resizeObserver: ResizeObserver | undefined;\n\n const isOpen = () => position() !== undefined;\n const keepsNativeMenu = (target: EventTarget | null): boolean => {\n if (!props.keepNativeMenu || !(target instanceof Node)) return false;\n const element = target instanceof Element ? target : target.parentElement;\n const native = element?.closest(NATIVE_MENU_TARGETS);\n if (native && host?.contains(native)) return true;\n const selection = window.getSelection();\n return Boolean(selection && !selection.isCollapsed && selection.toString().trim() && selection.containsNode(target, true));\n };\n const hostClass = createMemo(() => (typeof props.class === \"function\" ? props.class(isOpen()) : props.class));\n const items = createMemo<readonly DropdownItem[]>(() => props.items);\n\n const dismiss = (event: PointerEvent) => {\n if (menu?.contains(event.target as Node)) return;\n close();\n };\n const closeOnScroll = (event: Event) => {\n const target = event.target;\n if (target instanceof Node && menu?.contains(target)) return;\n close();\n };\n // A resize event may leave the viewport's size unchanged; headless Chromium\n // was seen to fire one on a fresh page. The clamped menu is still in place.\n const closeOnResize = () => {\n if (window.innerWidth === viewport.width && window.innerHeight === viewport.height) return;\n close();\n };\n const attachOpenListeners = () => {\n if (listenersAttached) return;\n listenersAttached = true;\n document.addEventListener(\"pointerdown\", dismiss);\n document.addEventListener(\"keydown\", keyDown);\n window.addEventListener(\"resize\", closeOnResize);\n window.addEventListener(\"scroll\", closeOnScroll, true);\n };\n const detachOpenListeners = () => {\n if (!listenersAttached) return;\n listenersAttached = false;\n document.removeEventListener(\"pointerdown\", dismiss);\n document.removeEventListener(\"keydown\", keyDown);\n window.removeEventListener(\"resize\", closeOnResize);\n window.removeEventListener(\"scroll\", closeOnScroll, true);\n resizeObserver?.disconnect();\n };\n /** Clamps the rendered menu into the viewport beside the point that opened it. */\n const place = () => {\n if (!isOpen() || !menu?.isConnected) return;\n const point = dropdownPosition(\n new DOMRect(anchor.x, anchor.y, 0, 0),\n menu.getBoundingClientRect(),\n \"bottom-right\" satisfies DropdownPosition,\n { width: window.innerWidth, height: window.innerHeight },\n 0,\n );\n setPosition({ x: point.left, y: point.top });\n };\n const close = () => {\n detachOpenListeners();\n if (!isOpen()) return;\n // An activated entry closes the menu before its action runs: focus goes back to where the menu opened from, as\n // Escape returns it, so the keyboard never lands on the page body.\n if (menu?.contains(document.activeElement)) returnFocus(opener?.isConnected ? opener : host, hostRing);\n setPosition();\n if (closeActiveContextMenu === close) closeActiveContextMenu = undefined;\n props.onClose?.();\n };\n const focusItem = (index: number) => {\n const items = focusableItems(menu);\n if (items.length === 0) return;\n items[(index + items.length) % items.length]?.focus();\n };\n const open = (x: number, y: number) => {\n if (props.disabled) return;\n closeActiveContextMenu?.();\n // Focus may sit on a descendant of the host, as in composite widgets; Escape returns it there.\n const focused = document.activeElement;\n opener = focused instanceof HTMLElement && focused !== host && host?.contains(focused) ? focused : undefined;\n hostRing = ringOnReturn(focused);\n anchor = { x, y };\n viewport = { width: window.innerWidth, height: window.innerHeight };\n setPosition({ x, y });\n closeActiveContextMenu = close;\n attachOpenListeners();\n props.onOpen?.();\n // The menu sizes to its entries, so it is measured once rendered and\n // clamped into the viewport before the next paint, and again whenever its\n // entries change its size while it is open.\n queueMicrotask(() => {\n if (!isOpen() || !menu?.isConnected) return;\n place();\n if (typeof ResizeObserver !== \"undefined\") {\n resizeObserver ??= new ResizeObserver(place);\n resizeObserver.observe(menu);\n }\n focusItem(0);\n });\n };\n const keyDown = (event: KeyboardEvent) => {\n if (!isOpen()) return;\n const items = focusableItems(menu);\n const current = items.indexOf(document.activeElement as HTMLElement);\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n focusItem(current + (event.key === \"ArrowDown\" ? 1 : -1));\n } else if (focusRowSegment(items, event.key)) {\n event.preventDefault();\n } else if (event.key === \"Home\" || event.key === \"End\") {\n event.preventDefault();\n focusItem(event.key === \"Home\" ? 0 : -1);\n } else if (event.key === \"Escape\") {\n event.preventDefault();\n close();\n returnFocus(opener?.isConnected ? opener : host, hostRing);\n } else if (event.key === \"Tab\") {\n close();\n }\n };\n\n props.openAt?.(open);\n // A close from outside, such as a drag taking over the press, returns focus that sits in the menu to where it came from.\n props.closeWith?.(() => {\n if (isOpen() && menu?.contains(document.activeElement)) returnFocus(opener?.isConnected ? opener : host, hostRing);\n close();\n });\n\n onMount(() => {\n onCleanup(() => {\n detachOpenListeners();\n if (closeActiveContextMenu === close) closeActiveContextMenu = undefined;\n });\n });\n\n return (\n <>\n {/* biome-ignore lint/a11y/useAriaPropsSupportedByRole: the named group owns the context-menu relationship without pretending arbitrary children form one button. */}\n <div\n ref={host}\n id={props.id ?? generatedId}\n class={hostClass()}\n role=\"group\"\n tabIndex={props.disabled ? undefined : (props.tabIndex ?? 0)}\n aria-label={props.label ?? messages().contextMenu}\n aria-haspopup=\"menu\"\n aria-expanded={isOpen()}\n aria-controls={isOpen() ? menuId : undefined}\n aria-disabled={props.disabled ? \"true\" : undefined}\n onContextMenu={(event) => {\n if (props.disabled) return;\n // An enclosing context menu must not take over the browser's own either.\n if (keepsNativeMenu(event.target)) return void event.stopPropagation();\n event.preventDefault();\n event.stopPropagation();\n open(event.clientX, event.clientY);\n }}\n onKeyDown={(event) => {\n if (props.disabled || (event.key !== \"ContextMenu\" && !(event.shiftKey && event.key === \"F10\"))) return;\n // A nested context menu already opened its own; a field keeps the browser's.\n if (\n event.defaultPrevented ||\n (props.keepNativeMenu && event.target instanceof Element && event.target.closest(NATIVE_MENU_TARGETS))\n )\n return;\n event.preventDefault();\n // Beside the focused element, such as a row of a composite widget, rather than the corner of the whole host.\n const focused = document.activeElement;\n const rect = (focused instanceof HTMLElement && host?.contains(focused) ? focused : host)?.getBoundingClientRect();\n if (rect) open(rect.left + 12, rect.top + 12);\n }}\n >\n {props.children}\n </div>\n <Show when={position()}>\n {(point) => (\n // Like a dropdown's menu, it stays inside an open dialog and shows in the top layer: a modal dialog makes the\n // rest of the page inert, and the top layer keeps it at the pointer whatever the dialog's transform.\n <Portal mount={host?.closest(\"dialog[open]\") ?? undefined}>\n <div\n ref={(element) => {\n menu = element;\n inheritUiScope(element, host);\n queueMicrotask(() => {\n if (element.isConnected && typeof element.showPopover === \"function\") element.showPopover();\n });\n }}\n id={menuId}\n popover=\"manual\"\n class=\"k2b-ui k2b-context-menu\"\n role=\"menu\"\n aria-label={props.label ?? messages().contextMenu}\n style={{ left: `${point().x}px`, top: `${point().y}px` }}\n onPointerDown={(event) => event.stopPropagation()}\n >\n {/* The menu carries the same name for assistive technology. */}\n <Show when={props.title}>\n <div class=\"k2b-context-menu__title\" aria-hidden=\"true\">\n {props.title}\n </div>\n </Show>\n <DropdownItems items={items()} close={close} />\n </div>\n </Portal>\n )}\n </Show>\n </>\n );\n}\n\nexport default ContextMenu;\n"],"mappings":";;;;;;;;;AAAA,SAAS,UAAU,EAAE,YAAY,EAAE,cAAc,EAAY,SAAS,EAAE,OAAO,EAAE,IAAI,QAAQ,UAAU;AACvG,SAAS,MAAM,QAAQ,cAAc;AACrC,SAAS,WAAW,EAAE,YAAY,QAAQ,0BAA0B;AACpE,SAAS,cAAc,QAAQ,0BAA0B;AACzD,SAAS,aAAa,QAAQ,kBAAkB;AAChD,SAA4B,aAAa,EAAyB,gBAAgB,QAAQ,YAAY;AACtG,SAAS,eAAe,QAAQ,aAAa;AAoB7C,MAAM,mBAAmB,GAAG,oFAAoF;AAEhH,IAAI,sBAAgD;AAEpD,MAAM,cAAc,GAAI,IAA6B,IACnD,IAAI,GACA,KAAK,CAAC,IAAI,CACR,IAAI,CAAC,gBAAgB,CACnB,CACE,+CAA+C,EAC/C,uDAAuD,EACvD,oDAAoD,CACrD,CAAC,IAAI,CAAC,IAAI,CACb,CACF,CAAC,GACD,EAAE;;AAER;AACA,OAAO,SAAS,WAAW,CAAC,KAAuB,EAAe;EAChE,OAAO,eAAe,CAAC,KAAK,CA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k2b-dropdown__copy\"><span>", "</span>", "</span>"]
|
|
|
24
24
|
_tmpl$13 = ["<div class=\"k2b-dropdown__label k2b-dropdown__label--action\"><span>", "</span>", "</div>"],
|
|
25
25
|
_tmpl$14 = ["<p id=\"", "\" class=\"k2b-dropdown__note\" aria-hidden=\"true\">", "</p>"],
|
|
26
26
|
_tmpl$15 = ["<span class=\"", "\">", "<div", " popover=\"auto\"", " class=\"", "\" style=\"", "\"", ">", "</div></span>"];
|
|
27
|
-
import { createContext, createEffect,
|
|
28
|
-
import { Dynamic
|
|
27
|
+
import { createContext, createEffect, createSignal, createUniqueId, mergeProps, onCleanup, onMount, Show, splitProps, untrack, useContext } from "solid-js";
|
|
28
|
+
import { Dynamic } from "solid-js/web";
|
|
29
29
|
import { Tooltip, useLabelTooltip } from "../feedback/Tooltip";
|
|
30
30
|
import { returnFocus, ringOnReturn } from "../internal/focus-return";
|
|
31
31
|
import { KeyedFor } from "../internal/keyed-for";
|
|
@@ -48,14 +48,6 @@ const externalOf = item => "external" in item ? item.external : undefined;
|
|
|
48
48
|
|
|
49
49
|
/** Where focus returns as a menu opened by `openAt` closes, read at that moment when it is a function. */
|
|
50
50
|
|
|
51
|
-
/**
|
|
52
|
-
* A row that opens a further menu beside it, marked with "▸" (K16). The submenu stands level with its row and turns
|
|
53
|
-
* to the other side or upwards where room ends. It opens after the pointer rests on the row for 150 ms, on click, and
|
|
54
|
-
* with Right or Enter; Left and Escape close one level. Moving the pointer towards it closes nothing. On a phone the
|
|
55
|
-
* sheet shows one level at a time, with Back at its top. A menu has at most three levels: a submenu row on the third
|
|
56
|
-
* level is not offered.
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
51
|
/** A second, smaller action at the end of a row, such as "Only" beside a checkbox; it keeps the menu open. */
|
|
60
52
|
|
|
61
53
|
/** Declarative radio or checkbox row for compact action menus. */
|
|
@@ -64,13 +56,9 @@ const externalOf = item => "external" in item ? item.external : undefined;
|
|
|
64
56
|
|
|
65
57
|
const MenuContext = createContext();
|
|
66
58
|
const DropdownContext = createContext();
|
|
67
|
-
|
|
68
|
-
/** The entries of one menu level that take focus. */
|
|
69
|
-
const menuEntries = menu => menu ? Array.from(menu.querySelectorAll(
|
|
70
|
-
// An open submenu inside the menu holds its own entries.
|
|
71
|
-
":is([role='menuitem'], [role='menuitemcheckbox'], [role='menuitemradio'], [role='option']):not([aria-disabled='true'], .k2b-dropdown__submenu *)")) : [];
|
|
59
|
+
const actionableItems = menu => menu ? Array.from(menu.querySelectorAll(["[role='menuitem']:not([aria-disabled='true'])", "[role='menuitemcheckbox']:not([aria-disabled='true'])", "[role='menuitemradio']:not([aria-disabled='true'])", "[role='option']:not([aria-disabled='true'])"].join(", "))) : [];
|
|
72
60
|
const focusMenuItem = (menu, index) => {
|
|
73
|
-
const items =
|
|
61
|
+
const items = actionableItems(menu).filter(item => !item.classList.contains("k2b-dropdown__secondary"));
|
|
74
62
|
if (items.length === 0) return;
|
|
75
63
|
items[(index + items.length) % items.length]?.focus();
|
|
76
64
|
};
|
|
@@ -88,7 +76,7 @@ export const dropdownPosition = (trigger, menu, position, viewport, gap = 4) =>
|
|
|
88
76
|
top: Math.max(8, Math.min(top, viewport.height - menu.height - 8))
|
|
89
77
|
};
|
|
90
78
|
};
|
|
91
|
-
|
|
79
|
+
const itemContent = props => [_$createComponent(Show, {
|
|
92
80
|
get when() {
|
|
93
81
|
return props.image;
|
|
94
82
|
},
|
|
@@ -234,38 +222,10 @@ function DropdownChoiceRow(props) {
|
|
|
234
222
|
}
|
|
235
223
|
export function DropdownItems(props) {
|
|
236
224
|
const messages = useUiMessages();
|
|
237
|
-
const depth = untrack(() => props.depth ?? 1);
|
|
238
|
-
// One object per level: an open submenu's code keeps the level's state under it.
|
|
239
|
-
const context = {
|
|
240
|
-
close: restoreFocus => props.close(restoreFocus),
|
|
241
|
-
role: untrack(() => props.role ?? "menuitem"),
|
|
242
|
-
depth,
|
|
243
|
-
drill: untrack(() => props.drill)
|
|
244
|
-
};
|
|
245
225
|
// Rows read their current item: a host that rebuilds equal items while the menu is open keeps each row element (#2140).
|
|
246
226
|
const renderItem = item => {
|
|
247
227
|
const initial = untrack(item);
|
|
248
228
|
if ("choice" in initial) return _$createComponent(DropdownChoiceItem, _$mergeProps(() => mergeProps(() => item())));
|
|
249
|
-
if ("submenu" in initial) {
|
|
250
|
-
const submenu = () => item();
|
|
251
|
-
loadSubmenus();
|
|
252
|
-
return _$createComponent(Show, {
|
|
253
|
-
get when() {
|
|
254
|
-
return submenuRow();
|
|
255
|
-
},
|
|
256
|
-
children: Row => _$createComponent(Dynamic, {
|
|
257
|
-
get component() {
|
|
258
|
-
return Row();
|
|
259
|
-
},
|
|
260
|
-
get item() {
|
|
261
|
-
return submenu();
|
|
262
|
-
},
|
|
263
|
-
menu: context,
|
|
264
|
-
Items: DropdownItems,
|
|
265
|
-
content: itemContent
|
|
266
|
-
})
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
229
|
const action = () => item();
|
|
270
230
|
return _$createComponent(DropdownItem, {
|
|
271
231
|
get ariaLabel() {
|
|
@@ -313,13 +273,18 @@ export function DropdownItems(props) {
|
|
|
313
273
|
});
|
|
314
274
|
};
|
|
315
275
|
return _$createComponent(MenuContext.Provider, {
|
|
316
|
-
value
|
|
276
|
+
get value() {
|
|
277
|
+
return {
|
|
278
|
+
close: props.close,
|
|
279
|
+
role: props.role ?? "menuitem"
|
|
280
|
+
};
|
|
281
|
+
},
|
|
317
282
|
get children() {
|
|
318
283
|
return _$createComponent(KeyedFor, {
|
|
319
284
|
get each() {
|
|
320
285
|
return props.items;
|
|
321
286
|
},
|
|
322
|
-
by: item => "items" in item ? `section:${item.sectionLabel ?? ""}` :
|
|
287
|
+
by: item => "items" in item ? `section:${item.sectionLabel ?? ""}` : `item:${item.label}`,
|
|
323
288
|
children: (current, index) => {
|
|
324
289
|
const item = current();
|
|
325
290
|
return _$createComponent(Show, {
|
|
@@ -354,7 +319,7 @@ export function DropdownItems(props) {
|
|
|
354
319
|
get each() {
|
|
355
320
|
return current().items;
|
|
356
321
|
},
|
|
357
|
-
by:
|
|
322
|
+
by: row => row.label,
|
|
358
323
|
children: renderItem
|
|
359
324
|
});
|
|
360
325
|
},
|
|
@@ -363,7 +328,7 @@ export function DropdownItems(props) {
|
|
|
363
328
|
get each() {
|
|
364
329
|
return current().items;
|
|
365
330
|
},
|
|
366
|
-
by:
|
|
331
|
+
by: row => row.label,
|
|
367
332
|
children: renderItem
|
|
368
333
|
})));
|
|
369
334
|
}
|
|
@@ -375,25 +340,6 @@ export function DropdownItems(props) {
|
|
|
375
340
|
}
|
|
376
341
|
});
|
|
377
342
|
}
|
|
378
|
-
|
|
379
|
-
/** A row's key names its kind too: an entry that turns from an action into a submenu row is built anew. */
|
|
380
|
-
const rowKey = item => `${"submenu" in item ? "submenu" : "choice" in item ? "choice" : "item"}:${item.label}`;
|
|
381
|
-
/**
|
|
382
|
-
* A submenu row and its menu load with the first menu that has one, so a menu without one carries none of it. A
|
|
383
|
-
* signal rather than `lazy`: the server and the first browser frame both show no row, and a Suspense boundary of the
|
|
384
|
-
* page around the menu never shows its fallback while it loads.
|
|
385
|
-
*/
|
|
386
|
-
const [submenuRow, setSubmenuRow] = createRoot(() => createSignal());
|
|
387
|
-
let submenuLoad;
|
|
388
|
-
/** Starts loading the submenu code, once, as the first submenu row renders. */
|
|
389
|
-
const loadSubmenus = () => {
|
|
390
|
-
if (isServer || submenuLoad) return;
|
|
391
|
-
submenuLoad = import("./menu-submenu-panel").then(module => setSubmenuRow(() => module.SubmenuRow), error => {
|
|
392
|
-
// The next menu tries again.
|
|
393
|
-
submenuLoad = undefined;
|
|
394
|
-
globalThis.reportError(error);
|
|
395
|
-
});
|
|
396
|
-
};
|
|
397
343
|
function DropdownTrigger(props) {
|
|
398
344
|
const context = useContext(DropdownContext);
|
|
399
345
|
if (!context) throw new Error("Dropdown.Trigger must be used inside Dropdown.Root");
|
|
@@ -684,7 +630,7 @@ function DropdownRoot(props) {
|
|
|
684
630
|
if (!next && sheet) cancelSheet();else if (next) open(focus);else close(false);
|
|
685
631
|
};
|
|
686
632
|
const handleMenuKeyDown = event => {
|
|
687
|
-
const items =
|
|
633
|
+
const items = actionableItems(menuRef);
|
|
688
634
|
// A searchable menu's field keeps the focus and moves the marked entry itself.
|
|
689
635
|
if (!props.search && !props.body && (focusMenuRow(items, event.key) || focusRowSegment(items, event.key))) {
|
|
690
636
|
event.preventDefault();
|