@k2b/ui 0.59.0 → 0.60.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/browser/actions/CommandList.js +67 -74
- package/dist/browser/actions/CommandList.js.map +1 -1
- package/dist/browser/actions/ContextMenu.js +11 -2
- package/dist/browser/actions/ContextMenu.js.map +1 -1
- package/dist/browser/actions/Dropdown.js +187 -169
- package/dist/browser/actions/Dropdown.js.map +1 -1
- package/dist/browser/actions/GestureMenu.js +18 -7
- package/dist/browser/actions/GestureMenu.js.map +1 -1
- package/dist/browser/actions/SelectionAction.js +232 -0
- package/dist/browser/actions/SelectionAction.js.map +1 -0
- package/dist/browser/actions/command-items.js.map +1 -1
- package/dist/browser/actions/index.js +1 -0
- package/dist/browser/actions/index.js.map +1 -1
- package/dist/browser/actions/menu-sheet-open.js +19 -0
- package/dist/browser/actions/menu-sheet-open.js.map +1 -0
- package/dist/browser/charts/core/line-details.js +2 -2
- package/dist/browser/charts/core/line-details.js.map +1 -1
- package/dist/browser/charts/core/render.js +2 -1
- package/dist/browser/charts/core/render.js.map +1 -1
- package/dist/browser/chat/ChatActivityWords.js +142 -0
- package/dist/browser/chat/ChatActivityWords.js.map +1 -0
- package/dist/browser/chat/ChatComposer.js +540 -515
- package/dist/browser/chat/ChatComposer.js.map +1 -1
- package/dist/browser/chat/ChatComposerQuotes.js +56 -0
- package/dist/browser/chat/ChatComposerQuotes.js.map +1 -0
- package/dist/browser/chat/ChatPrimitives.js +281 -245
- package/dist/browser/chat/ChatPrimitives.js.map +1 -1
- package/dist/browser/chat/index.js +4 -1
- package/dist/browser/chat/index.js.map +1 -1
- package/dist/browser/content/ActivityList.js +789 -0
- package/dist/browser/content/ActivityList.js.map +1 -0
- package/dist/browser/content/DataTableTools.js +3 -0
- package/dist/browser/content/DataTableTools.js.map +1 -1
- package/dist/browser/content/Lightbox.js +2 -0
- package/dist/browser/content/Lightbox.js.map +1 -1
- package/dist/browser/content/MessageQuote.js +57 -0
- package/dist/browser/content/MessageQuote.js.map +1 -0
- package/dist/browser/content/MessageRow.js +413 -391
- package/dist/browser/content/MessageRow.js.map +1 -1
- package/dist/browser/content/VirtualFeed.js +29 -2
- package/dist/browser/content/VirtualFeed.js.map +1 -1
- package/dist/browser/content/activity-messages.js +47 -0
- package/dist/browser/content/activity-messages.js.map +1 -0
- package/dist/browser/content/activity-timeline.js +144 -0
- package/dist/browser/content/activity-timeline.js.map +1 -0
- package/dist/browser/content/chart-time-calendar.js +12 -18
- package/dist/browser/content/chart-time-calendar.js.map +1 -1
- package/dist/browser/content/find-text.js +47 -0
- package/dist/browser/content/find-text.js.map +1 -0
- package/dist/browser/content/index.js +1 -0
- package/dist/browser/content/index.js.map +1 -1
- package/dist/browser/content/quote-messages.js +25 -0
- package/dist/browser/content/quote-messages.js.map +1 -0
- package/dist/browser/feedback/dialog-core.js +118 -14
- package/dist/browser/feedback/dialog-core.js.map +1 -1
- package/dist/browser/feedback/dialog-frame-motion.js +274 -0
- package/dist/browser/feedback/dialog-frame-motion.js.map +1 -0
- package/dist/browser/feedback/prompt-sheet-view.js +2 -1
- package/dist/browser/feedback/prompt-sheet-view.js.map +1 -1
- package/dist/browser/feedback/prompts.js +49 -53
- package/dist/browser/feedback/prompts.js.map +1 -1
- package/dist/browser/hover-card.js +6 -0
- package/dist/browser/hover-card.js.map +1 -0
- package/dist/browser/inputs/AutocompleteEditor.js +2 -1
- package/dist/browser/inputs/AutocompleteEditor.js.map +1 -1
- package/dist/browser/inputs/AutocompleteSelect.js +3 -12
- package/dist/browser/inputs/AutocompleteSelect.js.map +1 -1
- package/dist/browser/inputs/ChoiceList.js +131 -127
- package/dist/browser/inputs/ChoiceList.js.map +1 -1
- package/dist/browser/inputs/Combobox.js +6 -15
- package/dist/browser/inputs/Combobox.js.map +1 -1
- package/dist/browser/inputs/MultiSelectInput.js +7 -16
- package/dist/browser/inputs/MultiSelectInput.js.map +1 -1
- package/dist/browser/inputs/PeriodPicker.js +475 -252
- package/dist/browser/inputs/PeriodPicker.js.map +1 -1
- package/dist/browser/inputs/RichSelect.js +431 -431
- package/dist/browser/inputs/RichSelect.js.map +1 -1
- package/dist/browser/inputs/Select.js +3 -12
- package/dist/browser/inputs/Select.js.map +1 -1
- package/dist/browser/inputs/SelectChip.js +1 -0
- package/dist/browser/inputs/SelectChip.js.map +1 -1
- package/dist/browser/inputs/TimeInput.js +181 -0
- package/dist/browser/inputs/TimeInput.js.map +1 -0
- package/dist/browser/inputs/choice.js.map +1 -1
- package/dist/browser/inputs/date-picker.js +2 -1
- package/dist/browser/inputs/date-picker.js.map +1 -1
- package/dist/browser/inputs/file-drop.js +2 -0
- package/dist/browser/inputs/file-drop.js.map +1 -1
- package/dist/browser/inputs/index.js +1 -0
- package/dist/browser/inputs/index.js.map +1 -1
- package/dist/browser/inputs/input-messages.js +20 -2
- package/dist/browser/inputs/input-messages.js.map +1 -1
- package/dist/browser/inputs/period-picker-messages.js +20 -2
- package/dist/browser/inputs/period-picker-messages.js.map +1 -1
- package/dist/browser/inputs/period.js +83 -0
- package/dist/browser/inputs/period.js.map +1 -1
- package/dist/browser/inputs/time-input.js +93 -0
- package/dist/browser/inputs/time-input.js.map +1 -0
- package/dist/browser/internal/exit-motion.js +23 -0
- package/dist/browser/internal/exit-motion.js.map +1 -0
- package/dist/browser/internal/option-description.js +47 -0
- package/dist/browser/internal/option-description.js.map +1 -0
- package/dist/browser/internal/scroll-places.js +15 -0
- package/dist/browser/internal/scroll-places.js.map +1 -0
- package/dist/browser/layout/AppWorkspace.js +572 -495
- package/dist/browser/layout/AppWorkspace.js.map +1 -1
- package/dist/browser/layout/BottomSheet.js +2 -14
- package/dist/browser/layout/BottomSheet.js.map +1 -1
- package/dist/browser/layout/Navigation.js +7 -2
- package/dist/browser/layout/Navigation.js.map +1 -1
- package/dist/browser/layout/SidebarSwitcher.js +28 -37
- package/dist/browser/layout/SidebarSwitcher.js.map +1 -1
- package/dist/browser/layout/app-workspace-controller.js +5 -1
- package/dist/browser/layout/app-workspace-controller.js.map +1 -1
- package/dist/browser/layout/bottom-sheet-load.js +17 -0
- package/dist/browser/layout/bottom-sheet-load.js.map +1 -0
- package/dist/browser/layout/bottom-sheet-options.js +27 -0
- package/dist/browser/layout/bottom-sheet-options.js.map +1 -0
- package/dist/browser/layout/index.js +2 -1
- package/dist/browser/layout/index.js.map +1 -1
- package/dist/browser/layout/sheet-motion.js +10 -11
- package/dist/browser/layout/sheet-motion.js.map +1 -1
- package/dist/browser/layout/sidebar-scroll-memory.js +30 -0
- package/dist/browser/layout/sidebar-scroll-memory.js.map +1 -1
- package/dist/browser/surfaces/AvatarStack.js +59 -43
- package/dist/browser/surfaces/AvatarStack.js.map +1 -1
- package/dist/browser/surfaces/LinkCard.js.map +1 -1
- package/dist/browser/surfaces/Section.js +4 -2
- package/dist/browser/surfaces/Section.js.map +1 -1
- package/dist/browser/surfaces/StatCell.js +56 -28
- package/dist/browser/surfaces/StatCell.js.map +1 -1
- package/dist/browser/surfaces/StatGrid.js +17 -8
- package/dist/browser/surfaces/StatGrid.js.map +1 -1
- package/dist/browser/surfaces/index.js.map +1 -1
- package/dist/ssr/actions/CommandList.js +23 -26
- package/dist/ssr/actions/CommandList.js.map +1 -1
- package/dist/ssr/actions/ContextMenu.js +8 -2
- package/dist/ssr/actions/ContextMenu.js.map +1 -1
- package/dist/ssr/actions/Dropdown.js +79 -55
- package/dist/ssr/actions/Dropdown.js.map +1 -1
- package/dist/ssr/actions/GestureMenu.js +18 -7
- package/dist/ssr/actions/GestureMenu.js.map +1 -1
- package/dist/ssr/actions/SelectionAction.js +212 -0
- package/dist/ssr/actions/SelectionAction.js.map +1 -0
- package/dist/ssr/actions/command-items.js.map +1 -1
- package/dist/ssr/actions/index.js +1 -0
- package/dist/ssr/actions/index.js.map +1 -1
- package/dist/ssr/actions/menu-sheet-open.js +19 -0
- package/dist/ssr/actions/menu-sheet-open.js.map +1 -0
- package/dist/ssr/charts/core/line-details.js +2 -2
- package/dist/ssr/charts/core/line-details.js.map +1 -1
- package/dist/ssr/charts/core/render.js +2 -1
- package/dist/ssr/charts/core/render.js.map +1 -1
- package/dist/ssr/chat/ChatActivityWords.js +126 -0
- package/dist/ssr/chat/ChatActivityWords.js.map +1 -0
- package/dist/ssr/chat/ChatComposer.js +24 -3
- package/dist/ssr/chat/ChatComposer.js.map +1 -1
- package/dist/ssr/chat/ChatComposerQuotes.js +26 -0
- package/dist/ssr/chat/ChatComposerQuotes.js.map +1 -0
- package/dist/ssr/chat/ChatPrimitives.js +53 -47
- package/dist/ssr/chat/ChatPrimitives.js.map +1 -1
- package/dist/ssr/chat/index.js +4 -1
- package/dist/ssr/chat/index.js.map +1 -1
- package/dist/ssr/content/ActivityList.js +553 -0
- package/dist/ssr/content/ActivityList.js.map +1 -0
- package/dist/ssr/content/DataTableTools.js +3 -0
- package/dist/ssr/content/DataTableTools.js.map +1 -1
- package/dist/ssr/content/Lightbox.js +2 -0
- package/dist/ssr/content/Lightbox.js.map +1 -1
- package/dist/ssr/content/MessageQuote.js +36 -0
- package/dist/ssr/content/MessageQuote.js.map +1 -0
- package/dist/ssr/content/MessageRow.js +112 -95
- package/dist/ssr/content/MessageRow.js.map +1 -1
- package/dist/ssr/content/VirtualFeed.js +29 -2
- package/dist/ssr/content/VirtualFeed.js.map +1 -1
- package/dist/ssr/content/activity-messages.js +47 -0
- package/dist/ssr/content/activity-messages.js.map +1 -0
- package/dist/ssr/content/activity-timeline.js +144 -0
- package/dist/ssr/content/activity-timeline.js.map +1 -0
- package/dist/ssr/content/chart-time-calendar.js +12 -18
- package/dist/ssr/content/chart-time-calendar.js.map +1 -1
- package/dist/ssr/content/find-text.js +47 -0
- package/dist/ssr/content/find-text.js.map +1 -0
- package/dist/ssr/content/index.js +1 -0
- package/dist/ssr/content/index.js.map +1 -1
- package/dist/ssr/content/quote-messages.js +25 -0
- package/dist/ssr/content/quote-messages.js.map +1 -0
- package/dist/ssr/feedback/dialog-core.js +118 -14
- package/dist/ssr/feedback/dialog-core.js.map +1 -1
- package/dist/ssr/feedback/dialog-frame-motion.js +274 -0
- package/dist/ssr/feedback/dialog-frame-motion.js.map +1 -0
- package/dist/ssr/feedback/prompt-sheet-view.js +2 -1
- package/dist/ssr/feedback/prompt-sheet-view.js.map +1 -1
- package/dist/ssr/feedback/prompts.js +16 -16
- package/dist/ssr/feedback/prompts.js.map +1 -1
- package/dist/ssr/hover-card.js +6 -0
- package/dist/ssr/hover-card.js.map +1 -0
- package/dist/ssr/inputs/AutocompleteEditor.js +2 -1
- package/dist/ssr/inputs/AutocompleteEditor.js.map +1 -1
- package/dist/ssr/inputs/AutocompleteSelect.js +3 -8
- package/dist/ssr/inputs/AutocompleteSelect.js.map +1 -1
- package/dist/ssr/inputs/ChoiceList.js +25 -25
- package/dist/ssr/inputs/ChoiceList.js.map +1 -1
- package/dist/ssr/inputs/Combobox.js +4 -9
- package/dist/ssr/inputs/Combobox.js.map +1 -1
- package/dist/ssr/inputs/MultiSelectInput.js +4 -9
- package/dist/ssr/inputs/MultiSelectInput.js.map +1 -1
- package/dist/ssr/inputs/PeriodPicker.js +241 -46
- package/dist/ssr/inputs/PeriodPicker.js.map +1 -1
- package/dist/ssr/inputs/RichSelect.js +135 -121
- package/dist/ssr/inputs/RichSelect.js.map +1 -1
- package/dist/ssr/inputs/Select.js +3 -8
- package/dist/ssr/inputs/Select.js.map +1 -1
- package/dist/ssr/inputs/SelectChip.js +1 -0
- package/dist/ssr/inputs/SelectChip.js.map +1 -1
- package/dist/ssr/inputs/TimeInput.js +145 -0
- package/dist/ssr/inputs/TimeInput.js.map +1 -0
- package/dist/ssr/inputs/choice.js.map +1 -1
- package/dist/ssr/inputs/date-picker.js +2 -1
- package/dist/ssr/inputs/date-picker.js.map +1 -1
- package/dist/ssr/inputs/file-drop.js +2 -0
- package/dist/ssr/inputs/file-drop.js.map +1 -1
- package/dist/ssr/inputs/index.js +1 -0
- package/dist/ssr/inputs/index.js.map +1 -1
- package/dist/ssr/inputs/input-messages.js +20 -2
- package/dist/ssr/inputs/input-messages.js.map +1 -1
- package/dist/ssr/inputs/period-picker-messages.js +20 -2
- package/dist/ssr/inputs/period-picker-messages.js.map +1 -1
- package/dist/ssr/inputs/period.js +83 -0
- package/dist/ssr/inputs/period.js.map +1 -1
- package/dist/ssr/inputs/time-input.js +93 -0
- package/dist/ssr/inputs/time-input.js.map +1 -0
- package/dist/ssr/internal/exit-motion.js +23 -0
- package/dist/ssr/internal/exit-motion.js.map +1 -0
- package/dist/ssr/internal/option-description.js +27 -0
- package/dist/ssr/internal/option-description.js.map +1 -0
- package/dist/ssr/internal/scroll-places.js +15 -0
- package/dist/ssr/internal/scroll-places.js.map +1 -0
- package/dist/ssr/layout/AppWorkspace.js +191 -121
- package/dist/ssr/layout/AppWorkspace.js.map +1 -1
- package/dist/ssr/layout/BottomSheet.js +2 -14
- package/dist/ssr/layout/BottomSheet.js.map +1 -1
- package/dist/ssr/layout/Navigation.js +7 -2
- package/dist/ssr/layout/Navigation.js.map +1 -1
- package/dist/ssr/layout/SidebarSwitcher.js +8 -13
- package/dist/ssr/layout/SidebarSwitcher.js.map +1 -1
- package/dist/ssr/layout/app-workspace-controller.js +5 -1
- package/dist/ssr/layout/app-workspace-controller.js.map +1 -1
- package/dist/ssr/layout/bottom-sheet-load.js +17 -0
- package/dist/ssr/layout/bottom-sheet-load.js.map +1 -0
- package/dist/ssr/layout/bottom-sheet-options.js +27 -0
- package/dist/ssr/layout/bottom-sheet-options.js.map +1 -0
- package/dist/ssr/layout/index.js +2 -1
- package/dist/ssr/layout/index.js.map +1 -1
- package/dist/ssr/layout/sheet-motion.js +10 -11
- package/dist/ssr/layout/sheet-motion.js.map +1 -1
- package/dist/ssr/layout/sidebar-scroll-memory.js +30 -0
- package/dist/ssr/layout/sidebar-scroll-memory.js.map +1 -1
- package/dist/ssr/surfaces/AvatarStack.js +56 -40
- package/dist/ssr/surfaces/AvatarStack.js.map +1 -1
- package/dist/ssr/surfaces/LinkCard.js.map +1 -1
- package/dist/ssr/surfaces/Section.js +4 -2
- package/dist/ssr/surfaces/Section.js.map +1 -1
- package/dist/ssr/surfaces/StatCell.js +24 -12
- package/dist/ssr/surfaces/StatCell.js.map +1 -1
- package/dist/ssr/surfaces/StatGrid.js +12 -6
- package/dist/ssr/surfaces/StatGrid.js.map +1 -1
- package/dist/ssr/surfaces/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/actions/Dropdown.d.ts +10 -0
- package/dist/types/actions/SelectionAction.d.ts +34 -0
- package/dist/types/actions/command-items.d.ts +5 -0
- package/dist/types/actions/index.d.ts +2 -0
- package/dist/types/actions/menu-sheet-open.d.ts +13 -0
- package/dist/types/charts/core/line-details.d.ts +1 -1
- package/dist/types/chat/ChatActivityWords.d.ts +31 -0
- package/dist/types/chat/ChatComposer.d.ts +17 -1
- package/dist/types/chat/ChatComposerQuotes.d.ts +10 -0
- package/dist/types/chat/ChatPrimitives.d.ts +17 -1
- package/dist/types/chat/index.d.ts +6 -2
- package/dist/types/content/ActivityList.d.ts +166 -0
- package/dist/types/content/DataTableTools.d.ts +2 -0
- package/dist/types/content/MessageQuote.d.ts +9 -0
- package/dist/types/content/MessageRow.d.ts +5 -0
- package/dist/types/content/VirtualFeed.d.ts +6 -0
- package/dist/types/content/activity-messages.d.ts +22 -0
- package/dist/types/content/activity-timeline.d.ts +52 -0
- package/dist/types/content/chart-time-calendar.d.ts +6 -0
- package/dist/types/content/find-text.d.ts +10 -0
- package/dist/types/content/index.d.ts +1 -0
- package/dist/types/content/quote-messages.d.ts +6 -0
- package/dist/types/feedback/dialog-core.d.ts +2 -0
- package/dist/types/feedback/dialog-frame-motion.d.ts +37 -0
- package/dist/types/feedback/prompts.d.ts +5 -0
- package/dist/types/hover-card.d.ts +5 -0
- package/dist/types/inputs/ChoiceList.d.ts +12 -5
- package/dist/types/inputs/Combobox.d.ts +5 -0
- package/dist/types/inputs/MultiSelectInput.d.ts +1 -0
- package/dist/types/inputs/PeriodPicker.d.ts +10 -0
- package/dist/types/inputs/RichSelect.d.ts +5 -0
- package/dist/types/inputs/Select.d.ts +1 -0
- package/dist/types/inputs/SelectChip.d.ts +5 -0
- package/dist/types/inputs/TimeInput.d.ts +16 -0
- package/dist/types/inputs/choice.d.ts +6 -1
- package/dist/types/inputs/index.d.ts +2 -0
- package/dist/types/inputs/input-messages.d.ts +9 -0
- package/dist/types/inputs/period-picker-messages.d.ts +9 -0
- package/dist/types/inputs/period.d.ts +41 -0
- package/dist/types/inputs/time-input.d.ts +43 -0
- package/dist/types/internal/exit-motion.d.ts +10 -0
- package/dist/types/internal/option-description.d.ts +20 -0
- package/dist/types/internal/scroll-places.d.ts +2 -0
- package/dist/types/layout/AppWorkspace.d.ts +10 -0
- package/dist/types/layout/BottomSheet.d.ts +1 -14
- package/dist/types/layout/SidebarSwitcher.d.ts +5 -0
- package/dist/types/layout/bottom-sheet-load.d.ts +9 -0
- package/dist/types/layout/bottom-sheet-options.d.ts +18 -0
- package/dist/types/layout/index.d.ts +3 -2
- package/dist/types/layout/sheet-motion.d.ts +0 -5
- package/dist/types/layout/sidebar-scroll-memory.d.ts +6 -0
- package/dist/types/surfaces/LinkCard.d.ts +2 -1
- package/dist/types/surfaces/StatCell.d.ts +7 -2
- package/dist/types/surfaces/StatGrid.d.ts +15 -3
- package/dist/types/surfaces/index.d.ts +1 -1
- package/package.json +12 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["surfaces/AvatarStack.tsx"],"sourcesContent":["import { createMemo, createSignal, createUniqueId, For, type JSX, onCleanup, onMount, Show } from \"solid-js\";\nimport { dropdownPosition } from \"../actions/Dropdown\";\nimport { prefersMenuSheet } from \"../actions/menu-sheet\";\nimport { dialogCore } from \"../feedback/dialog-core\";\nimport { LocaleProvider, useLocale } from \"../intl/locale\";\nimport BottomSheet, { bottomSheetOptions } from \"../layout/BottomSheet\";\nimport { Avatar, type AvatarShape, type AvatarTone } from \"./Avatar\";\nimport { useAvatarMessages } from \"./avatar-messages\";\n\nexport type AvatarStackPerson = {\n /** Stable key, such as the account id. */\n id: string;\n name: string;\n src?: string | null;\n /** Shown instead of initials when there is no picture. */\n icon?: string;\n /** `square` for agents and service accounts. */\n shape?: AvatarShape;\n /** A short tag after the name, such as \"Agent\". */\n badge?: JSX.Element;\n /** One line below the name; it ends with an ellipsis instead of wrapping. */\n detail?: JSX.Element;\n /** Icon class before `detail`. */\n detailIcon?: string;\n /** Short text at the end of the row, such as \"2 tabs\". */\n trailing?: JSX.Element;\n /** The person viewing: listed last, below a gap, and never in the stack. */\n self?: boolean;\n /** Makes the row a button. The list closes first. */\n onSelect?: () => void;\n};\n\nexport type AvatarStackProps = {\n people: readonly AvatarStackPerson[];\n /** Title of the list that the stack opens, such as \"Here now\". */\n title: string;\n /** Accessible name of the stack button, such as \"Here now: Jana Berger and 2 more\". */\n label: string;\n /** One quiet line below the list. */\n hint?: JSX.Element;\n /** Faces before \"+n\". Defaults to 3. */\n max?: number;\n /** What the button shows instead of the faces, such as a \"+n\" chip and the viewer's own chip. */\n trigger?: JSX.Element;\n class?: string;\n};\n\nconst PersonRows = (props: { people: readonly AvatarStackPerson[]; choose: (person: AvatarStackPerson) => void }): JSX.Element => {\n let list!: HTMLUListElement;\n /**\n * A focused row that stops being a button (the person can no longer be chosen) or leaves hands focus to the nearest\n * row that still is one, else to the list, so focus never drops out of the open list.\n */\n const keepFocus = (button: HTMLButtonElement) => {\n if (!button.contains(document.activeElement)) return;\n const buttons = Array.from(list.querySelectorAll<HTMLButtonElement>(\"button.k2b-avatar-stack__row\"));\n const index = buttons.indexOf(button);\n const candidates = [...buttons.slice(index + 1), ...buttons.slice(0, Math.max(0, index)).reverse()];\n queueMicrotask(() => {\n if (!list.isConnected) return;\n (candidates.find((candidate) => candidate.isConnected) ?? list).focus();\n });\n };\n const others = () => props.people.filter((person) => !person.self);\n const selves = () => props.people.filter((person) => person.self);\n // A row reads its person through an accessor, so a live update changes the row in place and a focused row keeps focus.\n const row = (person: () => AvatarStackPerson) => {\n const content = (\n <>\n <Avatar name={person().name} src={person().src} icon={person().icon} shape={person().shape} size=\"sm\" />\n <span class=\"k2b-avatar-stack__row-copy\">\n <span class=\"k2b-avatar-stack__row-name\">\n <span>{person().name}</span>\n <Show when={person().badge}>\n <span class=\"k2b-avatar-stack__row-badge\">{person().badge}</span>\n </Show>\n </span>\n <Show when={person().detail}>\n <span class=\"k2b-avatar-stack__row-detail\">\n <Show when={person().detailIcon}>{(icon) => <i class={icon()} aria-hidden=\"true\" />}</Show>\n <span>{person().detail}</span>\n </span>\n </Show>\n </span>\n <Show when={person().trailing}>\n <span class=\"k2b-avatar-stack__row-trailing\">{person().trailing}</span>\n </Show>\n </>\n );\n return (\n <li data-self={person().self ? \"true\" : undefined}>\n <Show when={Boolean(person().onSelect)} fallback={<div class=\"k2b-avatar-stack__row\">{content}</div>}>\n {(() => {\n let button!: HTMLButtonElement;\n // Browser only: a server render never mounts the button.\n onMount(() => onCleanup(() => keepFocus(button)));\n return (\n <button ref={button} type=\"button\" class=\"k2b-avatar-stack__row\" onClick={() => props.choose(person())}>\n {content}\n </button>\n );\n })()}\n </Show>\n </li>\n );\n };\n // Rows follow each person by id: a row stays with its person when others leave or the order changes, and still\n // shows that person's latest details.\n const byId = createMemo(() => new Map(props.people.map((person) => [person.id, person])));\n const keyed = (id: string) => row(() => byId().get(id) ?? { id, name: \"\" });\n return (\n <ul ref={list} class=\"k2b-avatar-stack__rows\" tabIndex={-1}>\n <For each={others().map((person) => person.id)}>{keyed}</For>\n <For each={selves().map((person) => person.id)}>{keyed}</For>\n </ul>\n );\n};\n\nconst PeopleList = (props: {\n people: readonly AvatarStackPerson[];\n title: string;\n titleId: string;\n hint?: JSX.Element;\n choose: (person: AvatarStackPerson) => void;\n}): JSX.Element => (\n <>\n <header class=\"k2b-avatar-stack__header\">\n <h3 id={props.titleId}>{props.title}</h3>\n <span class=\"k2b-count-chip\">{props.people.length}</span>\n </header>\n <PersonRows people={props.people} choose={props.choose} />\n <Show when={props.hint}>\n <p class=\"k2b-avatar-stack__hint\">{props.hint}</p>\n </Show>\n </>\n);\n\nexport type AvatarFacesPerson = Pick<AvatarStackPerson, \"name\" | \"src\" | \"icon\" | \"shape\"> & { tone?: AvatarTone };\n\nexport type AvatarFacesProps = {\n people: readonly AvatarFacesPerson[];\n /** Faces before \"+n\". Defaults to 3. */\n max?: number;\n /** Everyone the faces stand for when `people` lists only some of them; \"+n\" counts the rest. */\n total?: number;\n /** `sm` (default) matches the stack button; `md` suits a row or table cell whose text the faces stand beside. */\n size?: \"sm\" | \"md\";\n};\n\n/**\n * The stack's faces and \"+n\" without its button or list, for a row or link that is already interactive. The faces\n * are decorative: name the people in the surrounding label or a tooltip.\n */\nexport function AvatarFaces(props: AvatarFacesProps): JSX.Element {\n const messages = useAvatarMessages();\n const max = () => Math.max(1, props.max ?? 3);\n const shown = () => props.people.slice(0, max());\n const more = () => Math.max(0, Math.max(props.total ?? 0, props.people.length) - shown().length);\n return (\n <>\n <span class=\"k2b-avatar-stack__faces\" data-faces-size={props.size === \"md\" ? \"md\" : undefined} aria-hidden=\"true\">\n <For each={shown()}>\n {(person) => (\n <Avatar name={person.name} src={person.src} icon={person.icon} shape={person.shape} tone={person.tone} size=\"xs\" alt=\"\" />\n )}\n </For>\n </span>\n <Show when={more() > 0}>\n <span class=\"k2b-avatar-stack__more\" aria-hidden=\"true\" title={messages().moreCount({ count: more() })}>\n +{more()}\n </span>\n </Show>\n </>\n );\n}\n\n/**\n * A few overlapping faces, then \"+n\", as one button. It opens the full list of people beside it, or as a bottom sheet\n * on phones. People with `self` are listed last and never shown in the stack.\n */\nexport function AvatarStack(props: AvatarStackProps): JSX.Element {\n const locale = useLocale();\n const id = createUniqueId().replace(/[^a-zA-Z0-9_-]/g, \"-\");\n const popoverId = `k2b-avatar-stack-${id}`;\n const titleId = `${popoverId}-title`;\n const [open, setOpen] = createSignal(false);\n let trigger!: HTMLButtonElement;\n let popover!: HTMLDivElement;\n let sheetOpen = false;\n const disposed = new AbortController();\n onCleanup(() => disposed.abort());\n\n const faces = () => props.people.filter((person) => !person.self);\n\n const place = () => {\n const rect = dropdownPosition(trigger.getBoundingClientRect(), popover.getBoundingClientRect(), \"bottom-left\", {\n width: window.innerWidth,\n height: window.innerHeight,\n });\n popover.style.left = `${rect.left}px`;\n popover.style.top = `${rect.top}px`;\n };\n // Like a dropdown menu, the open list follows its trigger when the window resizes or scrolls, and its own size.\n let resizeObserver: ResizeObserver | undefined;\n const follow = (on: boolean) => {\n const method = on ? \"addEventListener\" : \"removeEventListener\";\n window[method](\"resize\", place);\n window[method](\"scroll\", place, true);\n if (on && typeof ResizeObserver !== \"undefined\") {\n resizeObserver ??= new ResizeObserver(place);\n resizeObserver.observe(popover);\n } else resizeObserver?.disconnect();\n };\n // Only the browser ever follows; a server render has no window to let go of.\n onMount(() => onCleanup(() => follow(false)));\n\n const openSheet = () => {\n if (sheetOpen) return;\n sheetOpen = true;\n setOpen(true);\n let chosen: AvatarStackPerson | undefined;\n const current = locale();\n void dialogCore\n .open<void>(\n (close, context) => (\n <LocaleProvider locale={current}>\n <BottomSheet onDismiss={context.requestDismiss}>\n <BottomSheet.Body>\n <div class=\"k2b-avatar-stack__sheet\" role=\"group\" aria-labelledby={`${titleId}-sheet`}>\n <PeopleList\n people={props.people}\n title={props.title}\n titleId={`${titleId}-sheet`}\n hint={props.hint}\n choose={(person) => {\n chosen = person;\n close();\n }}\n />\n </div>\n </BottomSheet.Body>\n </BottomSheet>\n </LocaleProvider>\n ),\n { ...bottomSheetOptions, ariaLabel: props.title, history: true, signal: disposed.signal },\n )\n .then(() => chosen?.onSelect?.())\n .finally(() => {\n sheetOpen = false;\n setOpen(false);\n });\n };\n\n const toggle = () => {\n if (prefersMenuSheet()) {\n openSheet();\n return;\n }\n if (popover.matches(\":popover-open\")) {\n popover.hidePopover();\n return;\n }\n popover.showPopover();\n place();\n };\n\n return (\n <span class={`k2b-avatar-stack ${props.class ?? \"\"}`}>\n <button\n ref={trigger}\n type=\"button\"\n class=\"k2b-avatar-stack__trigger\"\n aria-label={props.label}\n aria-haspopup=\"dialog\"\n aria-expanded={open()}\n aria-controls={popoverId}\n onClick={toggle}\n >\n <Show\n when={props.trigger === undefined}\n fallback={\n <span class=\"k2b-avatar-stack__custom\" aria-hidden=\"true\">\n {props.trigger}\n </span>\n }\n >\n <AvatarFaces people={faces()} max={props.max} />\n </Show>\n </button>\n <div\n ref={popover}\n id={popoverId}\n popover=\"auto\"\n role=\"dialog\"\n aria-labelledby={titleId}\n class=\"k2b-avatar-stack__popover\"\n onToggle={(event) => {\n const next = (event as ToggleEvent).newState === \"open\";\n setOpen(next);\n follow(next);\n if (!next && document.activeElement && popover.contains(document.activeElement)) trigger.focus();\n }}\n >\n <PeopleList\n people={props.people}\n title={props.title}\n titleId={titleId}\n hint={props.hint}\n choose={(person) => {\n if (open()) popover.hidePopover();\n person.onSelect?.();\n }}\n />\n </div>\n </span>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAAS,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,EAAY,SAAS,EAAE,OAAO,EAAE,IAAI,QAAQ,UAAU;AAC5G,SAAS,gBAAgB,QAAQ,qBAAqB;AACtD,SAAS,gBAAgB,QAAQ,uBAAuB;AACxD,SAAS,UAAU,QAAQ,yBAAyB;AACpD,SAAS,cAAc,EAAE,SAAS,QAAQ,gBAAgB;AAC1D,OAAO,WAAW,IAAI,kBAAkB,QAAQ,uBAAuB;AACvE,SAAS,MAAM,QAA2C,UAAU;AACpE,SAAS,iBAAiB,QAAQ,mBAAmB;AAwCrD,MAAM,UAAU,GAAI,KAA4F,IAAkB;EAChI,IAAI,IAAuB;EAC3B;AACF;AACA;AACA;EACE,MAAM,SAAS,GAAI,MAAyB,IAAK;IAC/C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE;IAC9C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,C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AAC,2DACN,SAAS,4CAGvB,IAAI;IAAA,IACH,IAAI;MAAA,OAAE,KAAK,CAAC,OAAO,KAAK,SAAS;IAAA;IAAA,IACjC,QAAQ;MAAA,gCAEH,KAAK,CAAC,OAAO;IAAA;IAAA;MAAA,yBAIjB,WAAW;QAAA,IAAC,MAAM;UAAA,OAAE,KAAK,CAAC,CAAC;QAAA;QAAA,IAAE,GAAG;UAAA,OAAE,KAAK,CAAC,GAAG;QAAA;MAAA;IAAA;EAAA,mCAK1C,SAAS,4DAGI,OAAO,4CASvB,UAAU;IAAA,IACT,MAAM;MAAA,OAAE,KAAK,CAAC,MAAM;IAAA;IAAA,IACpB,KAAK;MAAA,OAAE,KAAK,CAAC,KAAK;IAAA;IAClB,OAAO,EAAE,OAAO;IAAA,IAChB,IAAI;MAAA,OAAE,KAAK,CAAC,IAAI;IAAA;IAChB,MAAM,EAAG,MAAM,IAAK;MAClB,IAAI,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;MACjC,MAAM,CAAC,QAAQ,GAAG,CAAC;IACrB;EAAC;AAKX","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["surfaces/AvatarStack.tsx"],"sourcesContent":["import { createMemo, createSignal, createUniqueId, For, type JSX, onCleanup, onMount, Show } from \"solid-js\";\nimport { dropdownPosition } from \"../actions/Dropdown\";\nimport { prefersMenuSheet } from \"../actions/phone-sheet\";\nimport { dialogCore } from \"../feedback/dialog-core\";\nimport { LocaleProvider, useLocale } from \"../intl/locale\";\nimport { withBottomSheet } from \"../layout/bottom-sheet-load\";\nimport { Avatar, type AvatarShape, type AvatarTone } from \"./Avatar\";\nimport { useAvatarMessages } from \"./avatar-messages\";\n\nexport type AvatarStackPerson = {\n /** Stable key, such as the account id. */\n id: string;\n name: string;\n src?: string | null;\n /** Shown instead of initials when there is no picture. */\n icon?: string;\n /** `square` for agents and service accounts. */\n shape?: AvatarShape;\n /** A short tag after the name, such as \"Agent\". */\n badge?: JSX.Element;\n /** One line below the name; it ends with an ellipsis instead of wrapping. */\n detail?: JSX.Element;\n /** Icon class before `detail`. */\n detailIcon?: string;\n /** Short text at the end of the row, such as \"2 tabs\". */\n trailing?: JSX.Element;\n /** The person viewing: listed last, below a gap, and never in the stack. */\n self?: boolean;\n /** Makes the row a button. The list closes first. */\n onSelect?: () => void;\n};\n\nexport type AvatarStackProps = {\n people: readonly AvatarStackPerson[];\n /** Title of the list that the stack opens, such as \"Here now\". */\n title: string;\n /** Accessible name of the stack button, such as \"Here now: Jana Berger and 2 more\". */\n label: string;\n /** One quiet line below the list. */\n hint?: JSX.Element;\n /** Faces before \"+n\". Defaults to 3. */\n max?: number;\n /** What the button shows instead of the faces, such as a \"+n\" chip and the viewer's own chip. */\n trigger?: JSX.Element;\n class?: string;\n};\n\nconst PersonRows = (props: { people: readonly AvatarStackPerson[]; choose: (person: AvatarStackPerson) => void }): JSX.Element => {\n let list!: HTMLUListElement;\n /**\n * A focused row that stops being a button (the person can no longer be chosen) or leaves hands focus to the nearest\n * row that still is one, else to the list, so focus never drops out of the open list.\n */\n const keepFocus = (button: HTMLButtonElement) => {\n if (!button.contains(document.activeElement)) return;\n const buttons = Array.from(list.querySelectorAll<HTMLButtonElement>(\"button.k2b-avatar-stack__row\"));\n const index = buttons.indexOf(button);\n const candidates = [...buttons.slice(index + 1), ...buttons.slice(0, Math.max(0, index)).reverse()];\n queueMicrotask(() => {\n if (!list.isConnected) return;\n (candidates.find((candidate) => candidate.isConnected) ?? list).focus();\n });\n };\n const others = () => props.people.filter((person) => !person.self);\n const selves = () => props.people.filter((person) => person.self);\n // A row reads its person through an accessor, so a live update changes the row in place and a focused row keeps focus.\n const row = (person: () => AvatarStackPerson) => {\n const content = (\n <>\n <Avatar name={person().name} src={person().src} icon={person().icon} shape={person().shape} size=\"sm\" />\n <span class=\"k2b-avatar-stack__row-copy\">\n <span class=\"k2b-avatar-stack__row-name\">\n <span>{person().name}</span>\n <Show when={person().badge}>\n <span class=\"k2b-avatar-stack__row-badge\">{person().badge}</span>\n </Show>\n </span>\n <Show when={person().detail}>\n <span class=\"k2b-avatar-stack__row-detail\">\n <Show when={person().detailIcon}>{(icon) => <i class={icon()} aria-hidden=\"true\" />}</Show>\n <span>{person().detail}</span>\n </span>\n </Show>\n </span>\n <Show when={person().trailing}>\n <span class=\"k2b-avatar-stack__row-trailing\">{person().trailing}</span>\n </Show>\n </>\n );\n return (\n <li data-self={person().self ? \"true\" : undefined}>\n <Show when={Boolean(person().onSelect)} fallback={<div class=\"k2b-avatar-stack__row\">{content}</div>}>\n {(() => {\n let button!: HTMLButtonElement;\n // Browser only: a server render never mounts the button.\n onMount(() => onCleanup(() => keepFocus(button)));\n return (\n <button ref={button} type=\"button\" class=\"k2b-avatar-stack__row\" onClick={() => props.choose(person())}>\n {content}\n </button>\n );\n })()}\n </Show>\n </li>\n );\n };\n // Rows follow each person by id: a row stays with its person when others leave or the order changes, and still\n // shows that person's latest details.\n const byId = createMemo(() => new Map(props.people.map((person) => [person.id, person])));\n const keyed = (id: string) => row(() => byId().get(id) ?? { id, name: \"\" });\n return (\n <ul ref={list} class=\"k2b-avatar-stack__rows\" tabIndex={-1}>\n <For each={others().map((person) => person.id)}>{keyed}</For>\n <For each={selves().map((person) => person.id)}>{keyed}</For>\n </ul>\n );\n};\n\nconst PeopleList = (props: {\n people: readonly AvatarStackPerson[];\n title: string;\n titleId: string;\n hint?: JSX.Element;\n choose: (person: AvatarStackPerson) => void;\n}): JSX.Element => (\n <>\n <header class=\"k2b-avatar-stack__header\">\n <h3 id={props.titleId}>{props.title}</h3>\n <span class=\"k2b-count-chip\">{props.people.length}</span>\n </header>\n <PersonRows people={props.people} choose={props.choose} />\n <Show when={props.hint}>\n <p class=\"k2b-avatar-stack__hint\">{props.hint}</p>\n </Show>\n </>\n);\n\nexport type AvatarFacesPerson = Pick<AvatarStackPerson, \"name\" | \"src\" | \"icon\" | \"shape\"> & { tone?: AvatarTone };\n\nexport type AvatarFacesProps = {\n people: readonly AvatarFacesPerson[];\n /** Faces before \"+n\". Defaults to 3. */\n max?: number;\n /** Everyone the faces stand for when `people` lists only some of them; \"+n\" counts the rest. */\n total?: number;\n /** `sm` (default) matches the stack button; `md` suits a row or table cell whose text the faces stand beside. */\n size?: \"sm\" | \"md\";\n};\n\n/**\n * The stack's faces and \"+n\" without its button or list, for a row or link that is already interactive. The faces\n * are decorative: name the people in the surrounding label or a tooltip.\n */\nexport function AvatarFaces(props: AvatarFacesProps): JSX.Element {\n const messages = useAvatarMessages();\n const max = () => Math.max(1, props.max ?? 3);\n const shown = () => props.people.slice(0, max());\n const more = () => Math.max(0, Math.max(props.total ?? 0, props.people.length) - shown().length);\n return (\n <>\n <span class=\"k2b-avatar-stack__faces\" data-faces-size={props.size === \"md\" ? \"md\" : undefined} aria-hidden=\"true\">\n <For each={shown()}>\n {(person) => (\n <Avatar name={person.name} src={person.src} icon={person.icon} shape={person.shape} tone={person.tone} size=\"xs\" alt=\"\" />\n )}\n </For>\n </span>\n <Show when={more() > 0}>\n <span class=\"k2b-avatar-stack__more\" aria-hidden=\"true\" title={messages().moreCount({ count: more() })}>\n +{more()}\n </span>\n </Show>\n </>\n );\n}\n\n/**\n * A few overlapping faces, then \"+n\", as one button. It opens the full list of people beside it, or as a bottom sheet\n * on phones. People with `self` are listed last and never shown in the stack.\n */\nexport function AvatarStack(props: AvatarStackProps): JSX.Element {\n const locale = useLocale();\n const id = createUniqueId().replace(/[^a-zA-Z0-9_-]/g, \"-\");\n const popoverId = `k2b-avatar-stack-${id}`;\n const titleId = `${popoverId}-title`;\n const [open, setOpen] = createSignal(false);\n let trigger!: HTMLButtonElement;\n let popover!: HTMLDivElement;\n let sheetOpen = false;\n const disposed = new AbortController();\n onCleanup(() => disposed.abort());\n\n const faces = () => props.people.filter((person) => !person.self);\n\n const place = () => {\n const rect = dropdownPosition(trigger.getBoundingClientRect(), popover.getBoundingClientRect(), \"bottom-left\", {\n width: window.innerWidth,\n height: window.innerHeight,\n });\n popover.style.left = `${rect.left}px`;\n popover.style.top = `${rect.top}px`;\n };\n // Like a dropdown menu, the open list follows its trigger when the window resizes or scrolls, and its own size.\n let resizeObserver: ResizeObserver | undefined;\n const follow = (on: boolean) => {\n const method = on ? \"addEventListener\" : \"removeEventListener\";\n window[method](\"resize\", place);\n window[method](\"scroll\", place, true);\n if (on && typeof ResizeObserver !== \"undefined\") {\n resizeObserver ??= new ResizeObserver(place);\n resizeObserver.observe(popover);\n } else resizeObserver?.disconnect();\n };\n // Only the browser ever follows; a server render has no window to let go of.\n onMount(() => onCleanup(() => follow(false)));\n\n const openSheet = () => {\n if (sheetOpen) return;\n sheetOpen = true;\n setOpen(true);\n let chosen: AvatarStackPerson | undefined;\n const current = locale();\n let loaded = false;\n // The sheet's code loads on a phone in the background; a wide screen never needs it.\n void withBottomSheet(({ default: BottomSheet, bottomSheetOptions }) => {\n loaded = true;\n return dialogCore.open<void>(\n (close, context) => (\n <LocaleProvider locale={current}>\n <BottomSheet onDismiss={context.requestDismiss}>\n <BottomSheet.Body>\n <div class=\"k2b-avatar-stack__sheet\" role=\"group\" aria-labelledby={`${titleId}-sheet`}>\n <PeopleList\n people={props.people}\n title={props.title}\n titleId={`${titleId}-sheet`}\n hint={props.hint}\n choose={(person) => {\n chosen = person;\n close();\n }}\n />\n </div>\n </BottomSheet.Body>\n </BottomSheet>\n </LocaleProvider>\n ),\n { ...bottomSheetOptions, ariaLabel: props.title, history: true, signal: disposed.signal },\n );\n })\n .then(\n () => chosen?.onSelect?.(),\n (error: unknown) => {\n if (loaded) throw error;\n globalThis.reportError(error);\n // The sheet's code did not load: the same list opens beside the stack, and the next tap tries the sheet again.\n if (disposed.signal.aborted || !trigger.isConnected) return;\n popover.showPopover();\n place();\n },\n )\n .finally(() => {\n sheetOpen = false;\n // The popover that opened in place of a sheet reports its own state.\n if (!popover.matches(\":popover-open\")) setOpen(false);\n });\n };\n\n const toggle = () => {\n if (prefersMenuSheet()) {\n openSheet();\n return;\n }\n if (popover.matches(\":popover-open\")) {\n popover.hidePopover();\n return;\n }\n popover.showPopover();\n place();\n };\n\n return (\n <span class={`k2b-avatar-stack ${props.class ?? \"\"}`}>\n <button\n ref={trigger}\n type=\"button\"\n class=\"k2b-avatar-stack__trigger\"\n aria-label={props.label}\n aria-haspopup=\"dialog\"\n aria-expanded={open()}\n aria-controls={popoverId}\n onClick={toggle}\n >\n <Show\n when={props.trigger === undefined}\n fallback={\n <span class=\"k2b-avatar-stack__custom\" aria-hidden=\"true\">\n {props.trigger}\n </span>\n }\n >\n <AvatarFaces people={faces()} max={props.max} />\n </Show>\n </button>\n <div\n ref={popover}\n id={popoverId}\n popover=\"auto\"\n role=\"dialog\"\n aria-labelledby={titleId}\n class=\"k2b-avatar-stack__popover\"\n onToggle={(event) => {\n const next = (event as ToggleEvent).newState === \"open\";\n setOpen(next);\n follow(next);\n if (!next && document.activeElement && popover.contains(document.activeElement)) trigger.focus();\n }}\n >\n <PeopleList\n people={props.people}\n title={props.title}\n titleId={titleId}\n hint={props.hint}\n choose={(person) => {\n if (open()) popover.hidePopover();\n person.onSelect?.();\n }}\n />\n </div>\n </span>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAAS,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,EAAY,SAAS,EAAE,OAAO,EAAE,IAAI,QAAQ,UAAU;AAC5G,SAAS,gBAAgB,QAAQ,qBAAqB;AACtD,SAAS,gBAAgB,QAAQ,wBAAwB;AACzD,SAAS,UAAU,QAAQ,yBAAyB;AACpD,SAAS,cAAc,EAAE,SAAS,QAAQ,gBAAgB;AAC1D,SAAS,eAAe,QAAQ,6BAA6B;AAC7D,SAAS,MAAM,QAA2C,UAAU;AACpE,SAAS,iBAAiB,QAAQ,mBAAmB;AAwCrD,MAAM,UAAU,GAAI,KAA4F,IAAkB;EAChI,IAAI,IAAuB;EAC3B;AACF;AACA;AACA;EACE,MAAM,SAAS,GAAI,MAAyB,IAAK;IAC/C,IAAI,CA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AC;IACrB;EAAC;AAKX","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["surfaces/LinkCard.tsx"],"sourcesContent":["import { Link, type LinkNavigateEvent } from \"@k2b/ssr/nav\";\nimport { type JSX, Show } from \"solid-js\";\nimport { Paper } from \"./Paper\";\n\nexport type LinkCardColor = \"blue\" | \"emerald\" | \"violet\" | \"orange\" | \"red\" | \"amber\" | \"zinc\" | \"cyan\" | \"rose\";\n\nexport type LinkCardProps = {\n href: string;\n navigation?: \"document\" | \"enhanced\";\n onNavigate?: (event: LinkNavigateEvent) => void | Promise<void>;\n title: string;\n description: string;\n /** Tabler icon class of the icon tile. Omit it only together with `media`. */\n icon?: string;\n /** Replaces the icon tile, for example with a `FileTypeIcon` for a file. */\n media?: JSX.Element;\n /** Glyph color. Omit it to use the host application's accent. */\n color?: LinkCardColor;\n /** One trailing fact, such as a count or a badge. */\n meta?: JSX.Element;\n /**\n * `paper` (default) is a framed card. `plain` is a flat entry for a quiet overview: no frame and no surface until\n * hover, no chevron. Put plain cards in `AppOverview.Cards surface=\"plain\"`.\n */\n surface?: \"paper\" | \"plain\";\n /**\n * The card as a small overview of one thing, as on \"My apps & automations\": `aside` stands top right beside the\n * title, such as a strip of the last runs; `body` is a line under the head, such as what it did last; `footer` is\n * the last line, `start` (a state with its sign) and `end` (a quiet time). Any of them stacks the card: head, body,\n * and footer one below the other, the footer on the card's bottom edge, a 10 px radius, and no chevron. The whole\n * card stays one link, so these places hold text and marks, never links or buttons.\n */\n aside?: JSX.Element;\n body?: JSX.Element;\n footer?: { start?: JSX.Element; end?: JSX.Element };\n};\n\nexport function LinkCard(props: LinkCardProps): JSX.Element {\n const plain = () => props.surface === \"plain\";\n const stacked = () => Boolean(props.aside || props.body || props.footer);\n const content = (\n <>\n <Show\n when={props.media}\n fallback={\n <Show when={props.icon}>\n {(icon) => (\n <div class=\"k2b-link-card__icon k2b-icon-tile\">\n <i class={`${icon()} k2b-link-card__glyph`} aria-hidden=\"true\" />\n </div>\n )}\n </Show>\n }\n >\n <div class=\"k2b-link-card__media\">{props.media}</div>\n </Show>\n <div class=\"k2b-link-card__copy\">\n <span class=\"k2b-link-card__title\">{props.title}</span>\n <p class=\"k2b-link-card__description\">{props.description}</p>\n </div>\n <Show when={props.meta}>\n <span class=\"k2b-link-card__meta\">{props.meta}</span>\n </Show>\n {/* One insertion for the chevron or every stacked place, so a classic card renders exactly as before. */}\n <Show\n when={stacked()}\n fallback={\n <Show when={!plain()}>\n <i class=\"ti ti-chevron-right k2b-link-card__chevron\" aria-hidden=\"true\" />\n </Show>\n }\n >\n <Show when={props.aside}>\n <span class=\"k2b-link-card__aside\">{props.aside}</span>\n </Show>\n <Show when={props.body}>\n <span class=\"k2b-link-card__body\">{props.body}</span>\n </Show>\n <Show when={props.footer}>\n {(footer) => (\n <span class=\"k2b-link-card__footer\">\n <span class=\"k2b-link-card__footer-start\">{footer().start}</span>\n <span class=\"k2b-link-card__footer-end\">{footer().end}</span>\n </span>\n )}\n </Show>\n </Show>\n </>\n );\n if (props.navigation === \"enhanced\" && props.onNavigate) {\n return (\n <Link\n href={props.href}\n onNavigate={props.onNavigate}\n class={plain() ? \"k2b-link-card\" : \"k2b-paper k2b-link-card\"}\n data-color={props.color}\n data-surface={plain() ? \"plain\" : undefined}\n data-layout={stacked() ? \"stacked\" : undefined}\n data-interactive=\"true\"\n >\n {content}\n </Link>\n );\n }\n if (plain())\n return (\n <a\n href={props.href}\n class=\"k2b-link-card\"\n data-color={props.color}\n data-surface=\"plain\"\n data-layout={stacked() ? \"stacked\" : undefined}\n data-interactive=\"true\"\n >\n {content}\n </a>\n );\n return (\n <Paper\n as=\"a\"\n href={props.href}\n class=\"k2b-link-card\"\n data-color={props.color}\n data-layout={stacked() ? \"stacked\" : undefined}\n interactive\n >\n {content}\n </Paper>\n );\n}\n\nexport default LinkCard;\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,IAAI,QAAgC,cAAc;AAC3D,SAAmB,IAAI,QAAQ,UAAU;AACzC,SAAS,KAAK,QAAQ,SAAS;
|
|
1
|
+
{"version":3,"names":[],"sources":["surfaces/LinkCard.tsx"],"sourcesContent":["import { Link, type LinkNavigateEvent } from \"@k2b/ssr/nav\";\nimport { type JSX, Show } from \"solid-js\";\nimport { Paper } from \"./Paper\";\n\nexport type LinkCardColor = \"blue\" | \"emerald\" | \"violet\" | \"orange\" | \"red\" | \"amber\" | \"zinc\" | \"cyan\" | \"rose\";\n\nexport type LinkCardProps = {\n href: string;\n navigation?: \"document\" | \"enhanced\";\n onNavigate?: (event: LinkNavigateEvent) => void | Promise<void>;\n title: string;\n description: string;\n /** Tabler icon class of the icon tile. Omit it only together with `media`. */\n icon?: string;\n /** Replaces the icon tile, for example with a `FileTypeIcon` for a file. */\n media?: JSX.Element;\n /** Glyph color. Omit it to use the host application's accent. */\n color?: LinkCardColor;\n /** One trailing fact, such as a count or a badge. */\n meta?: JSX.Element;\n /**\n * `paper` (default) is a framed card. `plain` is a flat entry for a quiet overview: no frame and no surface until\n * hover, no chevron. Put plain cards in `AppOverview.Cards surface=\"plain\"`.\n */\n surface?: \"paper\" | \"plain\";\n /**\n * The card as a small overview of one thing, as on \"My apps & automations\": `aside` stands top right beside the\n * title, such as a strip of the last runs; `body` is a line under the head, such as what it did last; `footer` is\n * the last line, `start` (a state with its sign) and `end` (a quiet time). Any of them stacks the card: head, body,\n * and footer one below the other, the footer on the card's bottom edge, a 10 px radius, and no chevron. Its title and\n * description wrap instead of ending in \"…\". The whole\n * card stays one link, so these places hold text and marks, never links or buttons.\n */\n aside?: JSX.Element;\n body?: JSX.Element;\n footer?: { start?: JSX.Element; end?: JSX.Element };\n};\n\nexport function LinkCard(props: LinkCardProps): JSX.Element {\n const plain = () => props.surface === \"plain\";\n const stacked = () => Boolean(props.aside || props.body || props.footer);\n const content = (\n <>\n <Show\n when={props.media}\n fallback={\n <Show when={props.icon}>\n {(icon) => (\n <div class=\"k2b-link-card__icon k2b-icon-tile\">\n <i class={`${icon()} k2b-link-card__glyph`} aria-hidden=\"true\" />\n </div>\n )}\n </Show>\n }\n >\n <div class=\"k2b-link-card__media\">{props.media}</div>\n </Show>\n <div class=\"k2b-link-card__copy\">\n <span class=\"k2b-link-card__title\">{props.title}</span>\n <p class=\"k2b-link-card__description\">{props.description}</p>\n </div>\n <Show when={props.meta}>\n <span class=\"k2b-link-card__meta\">{props.meta}</span>\n </Show>\n {/* One insertion for the chevron or every stacked place, so a classic card renders exactly as before. */}\n <Show\n when={stacked()}\n fallback={\n <Show when={!plain()}>\n <i class=\"ti ti-chevron-right k2b-link-card__chevron\" aria-hidden=\"true\" />\n </Show>\n }\n >\n <Show when={props.aside}>\n <span class=\"k2b-link-card__aside\">{props.aside}</span>\n </Show>\n <Show when={props.body}>\n <span class=\"k2b-link-card__body\">{props.body}</span>\n </Show>\n <Show when={props.footer}>\n {(footer) => (\n <span class=\"k2b-link-card__footer\">\n <span class=\"k2b-link-card__footer-start\">{footer().start}</span>\n <span class=\"k2b-link-card__footer-end\">{footer().end}</span>\n </span>\n )}\n </Show>\n </Show>\n </>\n );\n if (props.navigation === \"enhanced\" && props.onNavigate) {\n return (\n <Link\n href={props.href}\n onNavigate={props.onNavigate}\n class={plain() ? \"k2b-link-card\" : \"k2b-paper k2b-link-card\"}\n data-color={props.color}\n data-surface={plain() ? \"plain\" : undefined}\n data-layout={stacked() ? \"stacked\" : undefined}\n data-interactive=\"true\"\n >\n {content}\n </Link>\n );\n }\n if (plain())\n return (\n <a\n href={props.href}\n class=\"k2b-link-card\"\n data-color={props.color}\n data-surface=\"plain\"\n data-layout={stacked() ? \"stacked\" : undefined}\n data-interactive=\"true\"\n >\n {content}\n </a>\n );\n return (\n <Paper\n as=\"a\"\n href={props.href}\n class=\"k2b-link-card\"\n data-color={props.color}\n data-layout={stacked() ? \"stacked\" : undefined}\n interactive\n >\n {content}\n </Paper>\n );\n}\n\nexport default LinkCard;\n"],"mappings":";;;;;;;;;;;;;;AAAA,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AA,IAAC,IAAI;UAAA,OAAE,KAAK,CAAC,MAAM;QAAA;QAAA,UACpB,MAAM,4BAEuC,MAAM,CAAC,CAAC,CAAC,KAAK,YAChB,MAAM,CAAC,CAAC,CAAC,GAAG;MAExD;IAAA;EAAA,GAIR;EACD,IAAI,KAAK,CAAC,UAAU,KAAK,UAAU,IAAI,KAAK,CAAC,UAAU,EAAE;IACvD,yBACG,IAAI;MAAA,IACH,IAAI;QAAA,OAAE,KAAK,CAAC,IAAI;MAAA;MAAA,IAChB,UAAU;QAAA,OAAE,KAAK,CAAC,UAAU;MAAA;MAAA;QAAA,OACrB,KAAK,CAAC,CAAC,GAAG,eAAe,GAAG,yBAAyB;MAAA;MAAA;QAAA,OAChD,KAAK,CAAC,KAAK;MAAA;MAAA;QAAA,OACT,KAAK,CAAC,CAAC,GAAG,OAAO,GAAG,SAAS;MAAA;MAAA;QAAA,OAC9B,OAAO,CAAC,CAAC,GAAG,SAAS,GAAG,SAAS;MAAA;MAAA;MAAA,UAG7C;IAAO;EAGd;EACA,IAAI,KAAK,CAAC,CAAC,EACT,sDAEU,KAAK,CAAC,IAAI,uDAEJ,KAAK,CAAC,KAAK,+CAEV,OAAO,CAAC,CAAC,GAAG,SAAS,YAAG,SAAS,0BAG7C,OAAO;EAGd,yBACG,KAAK;IACJ,EAAE;IAAA,IACF,IAAI;MAAA,OAAE,KAAK,CAAC,IAAI;IAAA;IAAA;IAAA;MAAA,OAEJ,KAAK,CAAC,KAAK;IAAA;IAAA;MAAA,OACV,OAAO,CAAC,CAAC,GAAG,SAAS,GAAG,SAAS;IAAA;IAC9C,WAAW;IAAA,UAEV;EAAO;AAGd;AAEA,eAAe,QAAQ","ignoreList":[]}
|
|
@@ -89,6 +89,8 @@ const SectionRoot = props => {
|
|
|
89
89
|
|
|
90
90
|
// Resolve once and only while ready: reading `children` twice would build the body twice.
|
|
91
91
|
const resolved = children(() => state() === "ready" ? local.children : undefined);
|
|
92
|
+
// A JSX action must also be built once: checking the slot and then reading it again creates different hydration keys.
|
|
93
|
+
const resolvedActions = children(() => local.actions);
|
|
92
94
|
const hasBody = () => local.collapsible || state() !== "ready" || Boolean(resolved.toArray().length) || Boolean(local.footer);
|
|
93
95
|
|
|
94
96
|
/** Icon, then the title with its count, state, and restricted marker in one row, then the description. */
|
|
@@ -183,10 +185,10 @@ const SectionRoot = props => {
|
|
|
183
185
|
}
|
|
184
186
|
}))), _$escape(_$createComponent(Show, {
|
|
185
187
|
get when() {
|
|
186
|
-
return
|
|
188
|
+
return resolvedActions();
|
|
187
189
|
},
|
|
188
190
|
get children() {
|
|
189
|
-
return _$ssr(_tmpl$11, _$escape(
|
|
191
|
+
return _$ssr(_tmpl$11, _$escape(resolvedActions()));
|
|
190
192
|
}
|
|
191
193
|
})));
|
|
192
194
|
},
|
|
@@ -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 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 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={local.actions}>\n <div class=\"k2b-section__actions\">{local.actions}</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,E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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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AuB,IAAkB;EAC5D,MAAM,KAAK,GAAG,UAAU,CAAC,YAAY,CAAC;EACtC,MAAM,EAAE,GAAG,oBAAoB,cAAc,CAAC,CAAC,EAAE;EACjD,+CACc,KAAK,CAAC,KAAK,GAAG,8BAAqB,KAAK,CAAC,KAAK,SAAE,GAAG,mBAAmB,qDAAgC,EAAE,4CACjH,OAAO;IAAA,IAAC,KAAK;MAAA,OAAE,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC;IAAA;IAAE,EAAE,EAAE,EAAE;IAAA;IAAA;MAAA,OAC3C,KAAK,CAAC,KAAK;IAAA;EAAA,cAEb,KAAK,CAAC,QAAQ;AAGrB,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":[]}
|
|
@@ -38,6 +38,15 @@ import { useStatCellMessages } from "./stat-cell-messages";
|
|
|
38
38
|
|
|
39
39
|
function Body(props) {
|
|
40
40
|
const gridSize = useStatGridSize();
|
|
41
|
+
// A plain figure keeps its change off the figure's line: the third line holds it with the comparison.
|
|
42
|
+
const surface = useStatGridSurface();
|
|
43
|
+
const plain = () => surface() === "plain";
|
|
44
|
+
const badge = delta => _$createComponent(DeltaBadge, {
|
|
45
|
+
delta: delta,
|
|
46
|
+
get compare() {
|
|
47
|
+
return props.compare;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
41
50
|
const size = () => props.size ?? gridSize;
|
|
42
51
|
const accent = () => props.accent;
|
|
43
52
|
const locale = useLocale();
|
|
@@ -79,16 +88,9 @@ function Body(props) {
|
|
|
79
88
|
}
|
|
80
89
|
}))), _$createComponent(Show, {
|
|
81
90
|
get when() {
|
|
82
|
-
return _$memo(() =>
|
|
91
|
+
return _$memo(() => !!(!plain() && !empty()))() && props.delta;
|
|
83
92
|
},
|
|
84
|
-
children: delta =>
|
|
85
|
-
get delta() {
|
|
86
|
-
return delta();
|
|
87
|
-
},
|
|
88
|
-
get compare() {
|
|
89
|
-
return props.compare;
|
|
90
|
-
}
|
|
91
|
-
})
|
|
93
|
+
children: delta => badge(delta())
|
|
92
94
|
})];
|
|
93
95
|
},
|
|
94
96
|
get children() {
|
|
@@ -116,6 +118,11 @@ function Body(props) {
|
|
|
116
118
|
},
|
|
117
119
|
get fallback() {
|
|
118
120
|
return [_$createComponent(Show, {
|
|
121
|
+
get when() {
|
|
122
|
+
return _$memo(() => !!(plain() && !empty()))() && props.delta;
|
|
123
|
+
},
|
|
124
|
+
children: delta => badge(delta())
|
|
125
|
+
}), _$createComponent(Show, {
|
|
119
126
|
get when() {
|
|
120
127
|
return props.compare;
|
|
121
128
|
},
|
|
@@ -196,12 +203,17 @@ function Body(props) {
|
|
|
196
203
|
|
|
197
204
|
/**
|
|
198
205
|
* One key figure as a framed tile: icon and label, the figure with its change, and a support line with the comparison
|
|
199
|
-
* and the trend. Each state (loading, error, stale, empty)
|
|
206
|
+
* and the trend. In a `plain` grid the same three rows stand without a frame. Each state (loading, error, stale, empty)
|
|
207
|
+
* keeps the tile's place and size.
|
|
200
208
|
*/
|
|
201
209
|
export function StatCell(props) {
|
|
202
210
|
const gridSize = useStatGridSize();
|
|
203
211
|
const size = () => props.size ?? gridSize;
|
|
212
|
+
// A plain figure has no surface; its tone colours the figure instead of only the icon chip.
|
|
204
213
|
const surface = useStatGridSurface();
|
|
214
|
+
const plain = () => surface() === "plain";
|
|
215
|
+
const variant = () => plain() ? "plain" : undefined;
|
|
216
|
+
const tone = () => plain() ? props.tone : undefined;
|
|
205
217
|
return _$createComponent(Show
|
|
206
218
|
// A tile that offers a retry is no link: the button must not sit inside it.
|
|
207
219
|
, {
|
|
@@ -209,10 +221,10 @@ export function StatCell(props) {
|
|
|
209
221
|
return _$memo(() => !!(props.href && !props.status))() && !(props.stale && props.onRetry);
|
|
210
222
|
},
|
|
211
223
|
get fallback() {
|
|
212
|
-
return _$ssr(_tmpl$16, _$ssrAttribute("data-size", _$escape(size(), true), false) + _$ssrAttribute("data-surface", _$escape(surface, true), false) + _$ssrAttribute("data-wrap", _$escape(props.wrap || undefined, true), false) + _$ssrAttribute("data-delta-placement", _$escape(props.deltaPlacement, true), false) + _$ssrAttribute("data-status", _$escape(props.status, true), false) + _$ssrAttribute("aria-busy", _$escape(props.status === "loading" || undefined, true), false), _$escape(_$createComponent(Body, props)));
|
|
224
|
+
return _$ssr(_tmpl$16, _$ssrAttribute("data-size", _$escape(size(), true), false) + _$ssrAttribute("data-surface", plain() ? _$escape(undefined, true) : _$escape(surface(), true), false) + _$ssrAttribute("data-variant", _$escape(variant(), true), false) + _$ssrAttribute("data-tone", _$escape(tone(), true), false) + _$ssrAttribute("data-wrap", _$escape(props.wrap || undefined, true), false) + _$ssrAttribute("data-delta-placement", _$escape(props.deltaPlacement, true), false) + _$ssrAttribute("data-status", _$escape(props.status, true), false) + _$ssrAttribute("aria-busy", _$escape(props.status === "loading" || undefined, true), false), _$escape(_$createComponent(Body, props)));
|
|
213
225
|
},
|
|
214
226
|
get children() {
|
|
215
|
-
return _$ssr(_tmpl$15, _$ssrAttribute("href", _$escape(props.href, true), false), _$ssrAttribute("data-size", _$escape(size(), true), false) + _$ssrAttribute("data-surface", _$escape(surface, true), false) + _$ssrAttribute("data-wrap", _$escape(props.wrap || undefined, true), false) + _$ssrAttribute("data-delta-placement", _$escape(props.deltaPlacement, true), false), _$escape(_$createComponent(Body, props)));
|
|
227
|
+
return _$ssr(_tmpl$15, _$ssrAttribute("href", _$escape(props.href, true), false), _$ssrAttribute("data-size", _$escape(size(), true), false) + _$ssrAttribute("data-surface", plain() ? _$escape(undefined, true) : _$escape(surface(), true), false) + _$ssrAttribute("data-variant", _$escape(variant(), true), false) + _$ssrAttribute("data-tone", _$escape(tone(), true), false) + _$ssrAttribute("data-wrap", _$escape(props.wrap || undefined, true), false) + _$ssrAttribute("data-delta-placement", _$escape(props.deltaPlacement, true), false), _$escape(_$createComponent(Body, props)));
|
|
216
228
|
}
|
|
217
229
|
});
|
|
218
230
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["surfaces/StatCell.tsx"],"sourcesContent":["import { type JSX, Match, Show, Switch } from \"solid-js\";\nimport type { ChartNumberFormat } from \"../charts/description\";\nimport { ChartSparkline } from \"../content/ChartSparkline\";\nimport type { ChartTooltipFormatter } from \"../content/chart-inspection-core\";\nimport { useLocale } from \"../intl/locale\";\nimport type { AccentColor } from \"../semantics\";\nimport { DeltaBadge } from \"./delta-badge\";\nimport { type StatGridSize, useStatGridSize, useStatGridSurface } from \"./StatGrid\";\nimport { useStatCellMessages } from \"./stat-cell-messages\";\n\nexport type StatCellTone = AccentColor;\n\nexport type StatCellAccent = {\n tone: StatCellTone;\n icon: string;\n text?: string;\n};\n\n/**\n * The change against a comparison period. `unit: \"ratio\"` (default) reads `0.082` as `+8.2 %`; `\"points\"` is the\n * difference of two shares in ratio units, so `0.031` reads `+3.1 pts`. Only with `better` does the badge carry a tone\n * and say \"better\" or \"worse\"; without it the change stays unrated.\n */\nexport type StatCellDelta = {\n value: number;\n unit?: \"ratio\" | \"points\" | \"absolute\";\n /** Existing measures can express a change in their own unit instead of a ratio. */\n format?: ChartNumberFormat;\n better?: \"up\" | \"down\";\n};\n\n/** The value the change compares against, shown under the figure, such as \"Last month 44,560\". */\nexport type StatCellCompare = {\n label: string;\n value: string | number;\n};\n\nexport type StatCellSize = StatGridSize;\n\nexport type StatCellProps = {\n label: string;\n /** The figure. `null` shows the empty dash; `sub` then says why. */\n value: string | number | JSX.Element | null;\n sub?: string;\n valueClass?: string;\n /** An icon in a chip before the label, in `tone`. `\"in\"` and `\"out\"` are the money colours of `FlowAmount`. */\n icon?: string;\n /** The chip colour of `icon`. Defaults to zinc. */\n tone?: StatCellTone | \"in\" | \"out\";\n accent?: StatCellAccent;\n delta?: StatCellDelta;\n /** Keep the figure and change on separate rows, including while loading. Defaults to beside the figure. */\n deltaPlacement?: \"below\";\n compare?: StatCellCompare;\n href?: string;\n title?: string;\n trend?: readonly number[];\n /**\n * Replaces the default trend tooltip in browser code, for example with a period title or a unit.\n * `selection.datum.index` is the source index into `trend`.\n */\n trendTooltip?: ChartTooltipFormatter;\n size?: StatCellSize;\n /**\n * Wraps the label, value and support line instead of truncating them. Use it for a cell whose height nothing\n * reserves, such as one figure on its own; cells compared in a row keep one line each.\n */\n wrap?: boolean;\n /** `\"loading\"` keeps the tile's size with placeholders; `\"error\"` says the figure did not load. */\n status?: \"loading\" | \"error\";\n /** Offers \"Try again\" after an error and \"Reload\" beside `stale`. */\n onRetry?: () => void;\n /** The figure is not current: a short note such as \"As of 09:12 · not current\" replaces the support line. */\n stale?: string;\n};\n\nfunction Body(props: StatCellProps): JSX.Element {\n const gridSize = useStatGridSize();\n const size = () => props.size ?? gridSize;\n const accent = () => props.accent;\n const locale = useLocale();\n const t = useStatCellMessages();\n const defaultTrendTooltip: ChartTooltipFormatter = ({ datum }) => {\n const y = datum.values.find((field) => field.key === \"y\")?.value ?? \"\";\n return {\n rows: [\n { label: props.label, value: typeof y === \"number\" ? new Intl.NumberFormat(locale(), { maximumFractionDigits: 6 }).format(y) : y },\n ],\n };\n };\n const compareValue = () => {\n const value = props.compare?.value;\n return typeof value === \"number\" ? new Intl.NumberFormat(locale()).format(value) : value;\n };\n const empty = () => props.value === null || props.value === undefined || props.value === \"\";\n return (\n <>\n <div class=\"k2b-stat-cell__head\">\n <Show when={props.icon}>\n {(icon) => (\n <span class=\"k2b-stat-cell__icon k2b-icon-tile\" data-tone={props.tone ?? \"zinc\"} aria-hidden=\"true\">\n <i class={icon()} />\n </span>\n )}\n </Show>\n <span class=\"k2b-stat-cell__label\" data-size={size()}>\n {props.label}\n </span>\n </div>\n <div class=\"k2b-stat-cell__main\">\n <Switch\n fallback={\n <>\n <span\n class={`k2b-stat-cell__value ${props.valueClass ?? \"\"}`}\n data-size={size()}\n data-empty={empty() || undefined}\n title={props.title}\n >\n {/* A missing figure is the shared empty dash, named for screen readers instead of read as a dash. */}\n <Show\n when={!empty()}\n fallback={\n <span role=\"img\" aria-label={t().noValue}>\n —\n </span>\n }\n >\n {props.value}\n </Show>\n </span>\n <Show when={!empty() && props.delta}>{(delta) => <DeltaBadge delta={delta()} compare={props.compare} />}</Show>\n </>\n }\n >\n <Match when={props.status === \"loading\"}>\n <span class=\"k2b-stat-cell__skeleton k2b-skeleton\" data-part=\"value\" aria-hidden=\"true\" />\n <span class=\"k2b-sr-only\">{t().loading}</span>\n </Match>\n <Match when={props.status === \"error\"}>\n <span class=\"k2b-stat-cell__error\">\n <i class=\"ti ti-alert-circle\" aria-hidden=\"true\" />\n {t().notLoaded}\n </span>\n </Match>\n </Switch>\n </div>\n <div class=\"k2b-stat-cell__support\">\n <Switch\n fallback={\n <Show\n when={props.stale}\n fallback={\n <>\n <Show when={props.compare}>\n {(compare) => (\n <span class=\"k2b-stat-cell__sub\">\n {compare().label} {compareValue()}\n </span>\n )}\n </Show>\n <Show when={props.sub}>{(sub) => <span class=\"k2b-stat-cell__sub\">{sub()}</span>}</Show>\n <Show when={accent()}>\n {(value) => (\n <Show\n when={value().text}\n fallback={<i class={`${value().icon} k2b-stat-cell__accent-icon`} data-tone={value().tone} aria-hidden=\"true\" />}\n >\n {(text) => (\n <span class=\"k2b-stat-cell__accent\" data-tone={value().tone}>\n <i class={value().icon} aria-hidden=\"true\" />\n {text()}\n </span>\n )}\n </Show>\n )}\n </Show>\n {/* No figure, no trend: an empty tile says why in `sub` and keeps the size of its other states. */}\n <Show when={!empty() && props.trend && props.trend.length > 1}>\n <ChartSparkline\n labels={{ interactiveChart: props.label }}\n tooltip={props.trendTooltip ?? defaultTrendTooltip}\n class=\"k2b-stat-cell__trend\"\n data={Array.from(props.trend ?? [])}\n showLast\n />\n </Show>\n </>\n }\n >\n {(stale) => (\n <>\n <span class=\"k2b-stat-cell__stale\">\n <i class=\"ti ti-clock-exclamation\" aria-hidden=\"true\" />\n {stale()}\n </span>\n <Show when={props.onRetry}>\n {(retry) => (\n <button type=\"button\" class=\"k2b-stat-cell__retry\" onClick={() => retry()()}>\n {t().reload}\n </button>\n )}\n </Show>\n </>\n )}\n </Show>\n }\n >\n <Match when={props.status === \"loading\"}>\n <span class=\"k2b-stat-cell__skeleton k2b-skeleton\" data-part=\"support\" aria-hidden=\"true\" />\n </Match>\n <Match when={props.status === \"error\"}>\n <Show when={props.onRetry}>\n {(retry) => (\n <button type=\"button\" class=\"k2b-stat-cell__retry\" onClick={() => retry()()}>\n {t().retry}\n </button>\n )}\n </Show>\n </Match>\n </Switch>\n </div>\n </>\n );\n}\n\n/**\n * One key figure as a framed tile: icon and label, the figure with its change, and a support line with the comparison\n * and the trend. Each state (loading, error, stale, empty) keeps the tile's place and size.\n */\nexport function StatCell(props: StatCellProps): JSX.Element {\n const gridSize = useStatGridSize();\n const size = () => props.size ?? gridSize;\n const surface = useStatGridSurface();\n return (\n <Show\n // A tile that offers a retry is no link: the button must not sit inside it.\n when={props.href && !props.status && !(props.stale && props.onRetry)}\n fallback={\n <div\n class=\"k2b-stat-cell\"\n data-size={size()}\n data-surface={surface}\n data-wrap={props.wrap || undefined}\n data-delta-placement={props.deltaPlacement}\n data-status={props.status}\n aria-busy={props.status === \"loading\" || undefined}\n >\n <Body {...props} />\n </div>\n }\n >\n <a\n href={props.href}\n class=\"k2b-stat-cell k2b-stat-cell--link\"\n data-size={size()}\n data-surface={surface}\n data-wrap={props.wrap || undefined}\n data-delta-placement={props.deltaPlacement}\n >\n <i class=\"ti ti-external-link k2b-stat-cell__link-icon\" aria-hidden=\"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OAAO,uDACV,KAAK,CAAC,IAAI,IAAI,SAAS,kEACZ,KAAK,CAAC,cAAc,yDAC7B,KAAK,CAAC,MAAM,uDACd,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,SAAS,4CAEjD,IAAI,EAAK,KAAK;IAAA;IAAA;MAAA,uDAKX,KAAK,CAAC,IAAI,sDAEL,IAAI,CAAC,CAAC,0DACH,OAAO,uDACV,KAAK,CAAC,IAAI,IAAI,SAAS,kEACZ,KAAK,CAAC,cAAc,4CAGzC,IAAI,EAAK,KAAK;IAAA;EAAA;AAIvB;AAEA,eAAe,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["surfaces/StatCell.tsx"],"sourcesContent":["import { type JSX, Match, Show, Switch } from \"solid-js\";\nimport type { ChartNumberFormat } from \"../charts/description\";\nimport { ChartSparkline } from \"../content/ChartSparkline\";\nimport type { ChartTooltipFormatter } from \"../content/chart-inspection-core\";\nimport { useLocale } from \"../intl/locale\";\nimport type { AccentColor } from \"../semantics\";\nimport { DeltaBadge } from \"./delta-badge\";\nimport { type StatGridSize, useStatGridSize, useStatGridSurface } from \"./StatGrid\";\nimport { useStatCellMessages } from \"./stat-cell-messages\";\n\nexport type StatCellTone = AccentColor;\n\nexport type StatCellAccent = {\n tone: StatCellTone;\n icon: string;\n text?: string;\n};\n\n/**\n * The change against a comparison period. `unit: \"ratio\"` (default) reads `0.082` as `+8.2 %`; `\"points\"` is the\n * difference of two shares in ratio units, so `0.031` reads `+3.1 pts`. Only with `better` does the badge carry a tone\n * and say \"better\" or \"worse\"; without it the change stays unrated.\n */\nexport type StatCellDelta = {\n value: number;\n unit?: \"ratio\" | \"points\" | \"absolute\";\n /** Existing measures can express a change in their own unit instead of a ratio. */\n format?: ChartNumberFormat;\n better?: \"up\" | \"down\";\n};\n\n/** The value the change compares against, shown under the figure, such as \"Last month 44,560\". */\nexport type StatCellCompare = {\n label: string;\n value: string | number;\n};\n\nexport type StatCellSize = StatGridSize;\n\nexport type StatCellProps = {\n label: string;\n /** The figure. `null` shows the empty dash; `sub` then says why. */\n value: string | number | JSX.Element | null;\n sub?: string;\n valueClass?: string;\n /** An icon in a chip before the label, in `tone`. `\"in\"` and `\"out\"` are the money colours of `FlowAmount`. */\n icon?: string;\n /**\n * The chip colour of `icon`. Defaults to zinc. In a `plain` grid, `amber` (a warning) and `red` (a problem) also\n * colour the figure and its third line; say what is wrong there with `accent` (icon and word).\n */\n tone?: StatCellTone | \"in\" | \"out\";\n accent?: StatCellAccent;\n /** The change against `compare`; beside the figure, and always on the third line in a `plain` grid. */\n delta?: StatCellDelta;\n /** Keep the figure and change on separate rows, including while loading. Defaults to beside the figure. */\n deltaPlacement?: \"below\";\n compare?: StatCellCompare;\n href?: string;\n title?: string;\n trend?: readonly number[];\n /**\n * Replaces the default trend tooltip in browser code, for example with a period title or a unit.\n * `selection.datum.index` is the source index into `trend`.\n */\n trendTooltip?: ChartTooltipFormatter;\n size?: StatCellSize;\n /**\n * Wraps the label, value and support line instead of truncating them. Use it for a cell whose height nothing\n * reserves, such as one figure on its own; cells compared in a row keep one line each.\n */\n wrap?: boolean;\n /** `\"loading\"` keeps the tile's size with placeholders; `\"error\"` says the figure did not load. */\n status?: \"loading\" | \"error\";\n /** Offers \"Try again\" after an error and \"Reload\" beside `stale`. */\n onRetry?: () => void;\n /** The figure is not current: a short note such as \"As of 09:12 · not current\" replaces the support line. */\n stale?: string;\n};\n\nfunction Body(props: StatCellProps): JSX.Element {\n const gridSize = useStatGridSize();\n // A plain figure keeps its change off the figure's line: the third line holds it with the comparison.\n const surface = useStatGridSurface();\n const plain = () => surface() === \"plain\";\n const badge = (delta: StatCellDelta) => <DeltaBadge delta={delta} compare={props.compare} />;\n const size = () => props.size ?? gridSize;\n const accent = () => props.accent;\n const locale = useLocale();\n const t = useStatCellMessages();\n const defaultTrendTooltip: ChartTooltipFormatter = ({ datum }) => {\n const y = datum.values.find((field) => field.key === \"y\")?.value ?? \"\";\n return {\n rows: [\n { label: props.label, value: typeof y === \"number\" ? new Intl.NumberFormat(locale(), { maximumFractionDigits: 6 }).format(y) : y },\n ],\n };\n };\n const compareValue = () => {\n const value = props.compare?.value;\n return typeof value === \"number\" ? new Intl.NumberFormat(locale()).format(value) : value;\n };\n const empty = () => props.value === null || props.value === undefined || props.value === \"\";\n return (\n <>\n <div class=\"k2b-stat-cell__head\">\n <Show when={props.icon}>\n {(icon) => (\n <span class=\"k2b-stat-cell__icon k2b-icon-tile\" data-tone={props.tone ?? \"zinc\"} aria-hidden=\"true\">\n <i class={icon()} />\n </span>\n )}\n </Show>\n <span class=\"k2b-stat-cell__label\" data-size={size()}>\n {props.label}\n </span>\n </div>\n <div class=\"k2b-stat-cell__main\">\n <Switch\n fallback={\n <>\n <span\n class={`k2b-stat-cell__value ${props.valueClass ?? \"\"}`}\n data-size={size()}\n data-empty={empty() || undefined}\n title={props.title}\n >\n {/* A missing figure is the shared empty dash, named for screen readers instead of read as a dash. */}\n <Show\n when={!empty()}\n fallback={\n <span role=\"img\" aria-label={t().noValue}>\n —\n </span>\n }\n >\n {props.value}\n </Show>\n </span>\n <Show when={!plain() && !empty() && props.delta}>{(delta) => badge(delta())}</Show>\n </>\n }\n >\n <Match when={props.status === \"loading\"}>\n <span class=\"k2b-stat-cell__skeleton k2b-skeleton\" data-part=\"value\" aria-hidden=\"true\" />\n <span class=\"k2b-sr-only\">{t().loading}</span>\n </Match>\n <Match when={props.status === \"error\"}>\n <span class=\"k2b-stat-cell__error\">\n <i class=\"ti ti-alert-circle\" aria-hidden=\"true\" />\n {t().notLoaded}\n </span>\n </Match>\n </Switch>\n </div>\n <div class=\"k2b-stat-cell__support\">\n <Switch\n fallback={\n <Show\n when={props.stale}\n fallback={\n <>\n <Show when={plain() && !empty() && props.delta}>{(delta) => badge(delta())}</Show>\n <Show when={props.compare}>\n {(compare) => (\n <span class=\"k2b-stat-cell__sub\">\n {compare().label} {compareValue()}\n </span>\n )}\n </Show>\n <Show when={props.sub}>{(sub) => <span class=\"k2b-stat-cell__sub\">{sub()}</span>}</Show>\n <Show when={accent()}>\n {(value) => (\n <Show\n when={value().text}\n fallback={<i class={`${value().icon} k2b-stat-cell__accent-icon`} data-tone={value().tone} aria-hidden=\"true\" />}\n >\n {(text) => (\n <span class=\"k2b-stat-cell__accent\" data-tone={value().tone}>\n <i class={value().icon} aria-hidden=\"true\" />\n {text()}\n </span>\n )}\n </Show>\n )}\n </Show>\n {/* No figure, no trend: an empty tile says why in `sub` and keeps the size of its other states. */}\n <Show when={!empty() && props.trend && props.trend.length > 1}>\n <ChartSparkline\n labels={{ interactiveChart: props.label }}\n tooltip={props.trendTooltip ?? defaultTrendTooltip}\n class=\"k2b-stat-cell__trend\"\n data={Array.from(props.trend ?? [])}\n showLast\n />\n </Show>\n </>\n }\n >\n {(stale) => (\n <>\n <span class=\"k2b-stat-cell__stale\">\n <i class=\"ti ti-clock-exclamation\" aria-hidden=\"true\" />\n {stale()}\n </span>\n <Show when={props.onRetry}>\n {(retry) => (\n <button type=\"button\" class=\"k2b-stat-cell__retry\" onClick={() => retry()()}>\n {t().reload}\n </button>\n )}\n </Show>\n </>\n )}\n </Show>\n }\n >\n <Match when={props.status === \"loading\"}>\n <span class=\"k2b-stat-cell__skeleton k2b-skeleton\" data-part=\"support\" aria-hidden=\"true\" />\n </Match>\n <Match when={props.status === \"error\"}>\n <Show when={props.onRetry}>\n {(retry) => (\n <button type=\"button\" class=\"k2b-stat-cell__retry\" onClick={() => retry()()}>\n {t().retry}\n </button>\n )}\n </Show>\n </Match>\n </Switch>\n </div>\n </>\n );\n}\n\n/**\n * One key figure as a framed tile: icon and label, the figure with its change, and a support line with the comparison\n * and the trend. In a `plain` grid the same three rows stand without a frame. Each state (loading, error, stale, empty)\n * keeps the tile's place and size.\n */\nexport function StatCell(props: StatCellProps): JSX.Element {\n const gridSize = useStatGridSize();\n const size = () => props.size ?? gridSize;\n // A plain figure has no surface; its tone colours the figure instead of only the icon chip.\n const surface = useStatGridSurface();\n const plain = () => surface() === \"plain\";\n const variant = () => (plain() ? \"plain\" : undefined);\n const tone = () => (plain() ? props.tone : undefined);\n return (\n <Show\n // A tile that offers a retry is no link: the button must not sit inside it.\n when={props.href && !props.status && !(props.stale && props.onRetry)}\n fallback={\n <div\n class=\"k2b-stat-cell\"\n data-size={size()}\n data-surface={plain() ? undefined : surface()}\n data-variant={variant()}\n data-tone={tone()}\n data-wrap={props.wrap || undefined}\n data-delta-placement={props.deltaPlacement}\n data-status={props.status}\n aria-busy={props.status === \"loading\" || undefined}\n >\n <Body {...props} />\n </div>\n }\n >\n <a\n href={props.href}\n class=\"k2b-stat-cell k2b-stat-cell--link\"\n data-size={size()}\n data-surface={plain() ? undefined : surface()}\n data-variant={variant()}\n data-tone={tone()}\n data-wrap={props.wrap || undefined}\n data-delta-placement={props.deltaPlacement}\n >\n <i class=\"ti ti-external-link k2b-stat-cell__link-icon\" aria-hidden=\"true\" />\n <Body {...props} />\n </a>\n </Show>\n );\n}\n\nexport default StatCell;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAmB,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,UAAU;AAExD,SAAS,cAAc,QAAQ,2BAA2B;AAE1D,SAAS,SAAS,QAAQ,gBAAgB;AAE1C,SAAS,UAAU,QAAQ,eAAe;AAC1C,SAA4B,eAAe,EAAE,kBAAkB,QAAQ,YAAY;AACnF,SAAS,mBAAmB,QAAQ,sBAAsB;;AAU1D;AACA;AACA;AACA;AACA;;AASA;;AAiDA,SAAS,IAAI,CAAC,KAAoB,EAAe;EAC/C,MAAM,QAAQ,GAAG,eAAe,CAAC,CAAC;EAClC;EACA,MAAM,OAAO,GAAG,kBAAkB,CAAC,CAAC;EACpC,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,CAAC,KAAK,OAAO;EACzC,MAAM,KAAK,GAAI,KAAoB,sBAAM,UAAU;IAAC,KAAK,EAAE,KAAK;IAAA,IAAE,OAAO;MAAA,OAAE,KAAK,CAAC,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AAC,uDACZ,IAAI,CAAC,CAAC,uDACN,KAAK,CAAC,IAAI,IAAI,SAAS,kEACZ,KAAK,CAAC,cAAc,yDAC7B,KAAK,CAAC,MAAM,uDACd,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,SAAS,4CAEjD,IAAI,EAAK,KAAK;IAAA;IAAA;MAAA,uDAKX,KAAK,CAAC,IAAI,sDAEL,IAAI,CAAC,CAAC,iDACH,KAAK,CAAC,CAAC,YAAG,SAAS,mBAAG,OAAO,CAAC,CAAC,0DAC/B,OAAO,CAAC,CAAC,uDACZ,IAAI,CAAC,CAAC,uDACN,KAAK,CAAC,IAAI,IAAI,SAAS,kEACZ,KAAK,CAAC,cAAc,4CAGzC,IAAI,EAAK,KAAK;IAAA;EAAA;AAIvB;AAEA,eAAe,QAAQ","ignoreList":[]}
|
|
@@ -8,8 +8,12 @@ var _tmpl$ = ["<header class=\"k2b-stat-grid__header\"><span class=\"k2b-stat-gr
|
|
|
8
8
|
_tmpl$3 = ["<section class=\"", "\"", ">", "", "</section>"],
|
|
9
9
|
_tmpl$4 = ["<a", " class=\"k2b-stat-grid__action\"><span>", "</span><i class=\"ti ti-arrow-up-right\" aria-hidden=\"true\"></i></a>"];
|
|
10
10
|
import { createContext, Show, useContext } from "solid-js";
|
|
11
|
+
|
|
12
|
+
/** `tiles` frames each figure; `plain` sets the figures in equal columns with a thin line between, for a page head. */
|
|
13
|
+
|
|
11
14
|
const StatGridSizeContext = createContext("md");
|
|
12
|
-
|
|
15
|
+
// A plain grid has no surface, so the surface context carries "plain" to its cells; a cell outside a grid stays a tile.
|
|
16
|
+
const StatGridSurfaceContext = createContext(() => "white");
|
|
13
17
|
export const useStatGridSize = () => useContext(StatGridSizeContext);
|
|
14
18
|
export const useStatGridSurface = () => useContext(StatGridSurfaceContext);
|
|
15
19
|
const columnValue = columns => {
|
|
@@ -17,10 +21,14 @@ const columnValue = columns => {
|
|
|
17
21
|
return 4;
|
|
18
22
|
};
|
|
19
23
|
|
|
20
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* A row of key figures, each a framed tile of its own or, with `variant="plain"`, flat figures in equal columns; the
|
|
26
|
+
* optional title and action sit above the row.
|
|
27
|
+
*/
|
|
21
28
|
export function StatGrid(props) {
|
|
22
29
|
const surface = () => props.surface ?? "white";
|
|
23
|
-
|
|
30
|
+
const plain = () => props.variant === "plain";
|
|
31
|
+
return _$ssr(_tmpl$3, `k2b-stat-grid ${_$escape(props.class ?? "", true)}`, _$ssrAttribute("data-columns", _$escape(columnValue(props.columns), true), false) + _$ssrAttribute("data-size", _$escape(props.size ?? "md", true), false) + _$ssrAttribute("data-surface", _$escape(surface(), true), false) + _$ssrAttribute("data-variant", plain() ? "plain" : "tiles", false) + _$ssrAttribute("aria-label", _$escape(props.title, true), false), _$escape(_$createComponent(Show, {
|
|
24
32
|
get when() {
|
|
25
33
|
return props.title;
|
|
26
34
|
},
|
|
@@ -38,9 +46,7 @@ export function StatGrid(props) {
|
|
|
38
46
|
},
|
|
39
47
|
get children() {
|
|
40
48
|
return _$createComponent(StatGridSurfaceContext.Provider, {
|
|
41
|
-
|
|
42
|
-
return surface();
|
|
43
|
-
},
|
|
49
|
+
value: () => plain() ? "plain" : surface(),
|
|
44
50
|
get children() {
|
|
45
51
|
return _$ssr(_tmpl$2, _$escape(props.children));
|
|
46
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["surfaces/StatGrid.tsx"],"sourcesContent":["import { createContext, type JSX, Show, useContext } from \"solid-js\";\n\nexport type StatGridSize = \"lg\" | \"md\" | \"sm\";\nexport type StatGridSurface = \"white\" | \"muted\";\nexport type StatGridColumns = 1 | 2 | 3 | 4 | 5 | 6;\nexport type StatGridAction = { label: string; href: string };\n\nexport type StatGridProps = {\n children: JSX.Element;\n title?: string;\n action?: StatGridAction;\n /** Tiles per row on a wide container. Defaults to 4; at 600 px or less two share a row, and five or six take three up to 900 px. */\n columns?: StatGridColumns;\n size?: StatGridSize;\n surface?: StatGridSurface;\n class?: string;\n};\n\nconst StatGridSizeContext = createContext<StatGridSize>(\"md\");\nconst StatGridSurfaceContext = createContext<StatGridSurface
|
|
1
|
+
{"version":3,"names":[],"sources":["surfaces/StatGrid.tsx"],"sourcesContent":["import { type Accessor, createContext, type JSX, Show, useContext } from \"solid-js\";\n\nexport type StatGridSize = \"lg\" | \"md\" | \"sm\";\nexport type StatGridSurface = \"white\" | \"muted\";\nexport type StatGridColumns = 1 | 2 | 3 | 4 | 5 | 6;\nexport type StatGridAction = { label: string; href: string };\n/** `tiles` frames each figure; `plain` sets the figures in equal columns with a thin line between, for a page head. */\nexport type StatGridVariant = \"tiles\" | \"plain\";\n\nexport type StatGridProps = {\n children: JSX.Element;\n title?: string;\n action?: StatGridAction;\n /** Tiles per row on a wide container. Defaults to 4; at 600 px or less two share a row, and five or six take three up to 900 px. */\n columns?: StatGridColumns;\n size?: StatGridSize;\n /** Applies to `tiles` only: a `plain` row has no surface. */\n surface?: StatGridSurface;\n /**\n * `tiles` (default) frames each figure. `plain` drops frame, surface and shadow: equal columns with a 1 px line\n * between them, two columns below a 34rem container. Every figure keeps three rows (label, figure, a reserved third\n * line for `sub`, the change or the comparison), so all figures stand on one line.\n */\n variant?: StatGridVariant;\n class?: string;\n};\n\nconst StatGridSizeContext = createContext<StatGridSize>(\"md\");\n// A plain grid has no surface, so the surface context carries \"plain\" to its cells; a cell outside a grid stays a tile.\nconst StatGridSurfaceContext = createContext<Accessor<StatGridSurface | \"plain\">>((): StatGridSurface | \"plain\" => \"white\");\n\nexport const useStatGridSize = (): StatGridSize => useContext(StatGridSizeContext);\nexport const useStatGridSurface = (): Accessor<StatGridSurface | \"plain\"> => useContext(StatGridSurfaceContext);\n\nconst columnValue = (columns?: StatGridColumns): StatGridColumns => {\n if (columns && Number.isInteger(columns) && columns >= 1 && columns <= 6) return columns;\n return 4;\n};\n\n/**\n * A row of key figures, each a framed tile of its own or, with `variant=\"plain\"`, flat figures in equal columns; the\n * optional title and action sit above the row.\n */\nexport function StatGrid(props: StatGridProps): JSX.Element {\n const surface = () => props.surface ?? \"white\";\n const plain = () => props.variant === \"plain\";\n return (\n <section\n class={`k2b-stat-grid ${props.class ?? \"\"}`}\n data-columns={columnValue(props.columns)}\n data-size={props.size ?? \"md\"}\n data-surface={surface()}\n data-variant={plain() ? \"plain\" : \"tiles\"}\n aria-label={props.title}\n >\n <Show when={props.title}>\n <header class=\"k2b-stat-grid__header\">\n <span class=\"k2b-stat-grid__title\">{props.title}</span>\n <Show when={props.action}>\n {(action) => (\n <a href={action().href} class=\"k2b-stat-grid__action\">\n <span>{action().label}</span>\n <i class=\"ti ti-arrow-up-right\" aria-hidden=\"true\" />\n </a>\n )}\n </Show>\n </header>\n </Show>\n <StatGridSizeContext.Provider value={props.size ?? \"md\"}>\n <StatGridSurfaceContext.Provider value={() => (plain() ? \"plain\" : surface())}>\n <div class=\"k2b-stat-grid__body\">{props.children}</div>\n </StatGridSurfaceContext.Provider>\n </StatGridSizeContext.Provider>\n </section>\n );\n}\n\nexport default StatGrid;\n"],"mappings":";;;;;;;;;AAAA,SAAwB,aAAa,EAAY,IAAI,EAAE,UAAU,QAAQ,UAAU;;AAMnF;;AAqBA,MAAM,mBAAmB,GAAG,aAAa,CAAe,IAAI,CAAC;AAC7D;AACA,MAAM,sBAAsB,GAAG,aAAa,CAAsC,MAAiC,OAAO,CAAC;AAE3H,OAAO,MAAM,eAAe,GAAG,MAAoB,UAAU,CAAC,mBAAmB,CAAC;AAClF,OAAO,MAAM,kBAAkB,GAAG,MAA2C,UAAU,CAAC,sBAAsB,CAAC;AAE/G,MAAM,WAAW,GAAI,OAAyB,IAAsB;EAClE,IAAI,OAAO,IAAI,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,OAAO,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,EAAE,OAAO,OAAO;EACxF,OAAO,CAAC;AACV,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,SAAS,QAAQ,CAAC,KAAoB,EAAe;EAC1D,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,OAAO,IAAI,OAAO;EAC9C,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,OAAO,KAAK,OAAO;EAC7C,sBAEW,0BAAiB,KAAK,CAAC,KAAK,IAAI,EAAE,SAAE,0CAC7B,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,uDAC7B,KAAK,CAAC,IAAI,IAAI,IAAI,0DACf,OAAO,CAAC,CAAC,iDACT,KAAK,CAAC,CAAC,GAAG,OAAO,GAAG,OAAO,iDAC7B,KAAK,CAAC,KAAK,4CAEtB,IAAI;IAAA,IAAC,IAAI;MAAA,OAAE,KAAK,CAAC,KAAK;IAAA;IAAA;MAAA,8BAEiB,KAAK,CAAC,KAAK,8BAC9C,IAAI;QAAA,IAAC,IAAI;UAAA,OAAE,KAAK,CAAC,MAAM;QAAA;QAAA,UACpB,MAAM,mDACG,MAAM,CAAC,CAAC,CAAC,IAAI,0BACb,MAAM,CAAC,CAAC,CAAC,KAAK;MAGxB;IAAA;EAAA,gCAIN,mBAAmB,CAAC,QAAQ;IAAA,IAAC,KAAK;MAAA,OAAE,KAAK,CAAC,IAAI,IAAI,IAAI;IAAA;IAAA;MAAA,yBACpD,sBAAsB,CAAC,QAAQ;QAAC,KAAK,EAAE,MAAO,KAAK,CAAC,CAAC,GAAG,OAAO,GAAG,OAAO,CAAC,CAAE;QAAA;UAAA,+BACzC,KAAK,CAAC,QAAQ;QAAA;MAAA;IAAA;EAAA;AAK1D;AAEA,eAAe,QAAQ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
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} 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;
|
|
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":[]}
|