@cratis/components 4.42.2 → 4.42.3
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/compat-manifest.json +11 -11
- package/dist/esm/Chat/ChatTopicEmptyMessage.d.ts +9 -0
- package/dist/esm/Chat/ChatTopicEmptyMessage.d.ts.map +1 -0
- package/dist/esm/Chat/ChatTopicEmptyMessage.js +19 -0
- package/dist/esm/Chat/ChatTopicEmptyMessage.js.map +1 -0
- package/dist/esm/Chat/ChatTopicList.d.ts +2 -2
- package/dist/esm/Chat/ChatTopicList.d.ts.map +1 -1
- package/dist/esm/Chat/ChatTopicList.js +5 -20
- package/dist/esm/Chat/ChatTopicList.js.map +1 -1
- package/dist/esm/Chat/ChatTopicRow.d.ts +22 -0
- package/dist/esm/Chat/ChatTopicRow.d.ts.map +1 -0
- package/dist/esm/Chat/ChatTopicRow.js +23 -0
- package/dist/esm/Chat/ChatTopicRow.js.map +1 -0
- package/dist/esm/Chat/ChatTopicStartButton.d.ts +8 -0
- package/dist/esm/Chat/ChatTopicStartButton.d.ts.map +1 -0
- package/dist/esm/Chat/ChatTopicStartButton.js +7 -0
- package/dist/esm/Chat/ChatTopicStartButton.js.map +1 -0
- package/dist/esm/CommandForm/fields/ChipsField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/ChipsField.js +2 -6
- package/dist/esm/CommandForm/fields/ChipsField.js.map +1 -1
- package/dist/esm/CommandForm/fields/ChipsRoot.d.ts +15 -0
- package/dist/esm/CommandForm/fields/ChipsRoot.d.ts.map +1 -0
- package/dist/esm/CommandForm/fields/ChipsRoot.js +11 -0
- package/dist/esm/CommandForm/fields/ChipsRoot.js.map +1 -0
- package/dist/esm/CommandForm/fields/PasswordField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/PasswordField.js +4 -14
- package/dist/esm/CommandForm/fields/PasswordField.js.map +1 -1
- package/dist/esm/CommandForm/fields/PasswordInput.d.ts +17 -0
- package/dist/esm/CommandForm/fields/PasswordInput.d.ts.map +1 -0
- package/dist/esm/CommandForm/fields/PasswordInput.js +7 -0
- package/dist/esm/CommandForm/fields/PasswordInput.js.map +1 -0
- package/dist/esm/CommandForm/fields/PasswordRoot.d.ts +15 -0
- package/dist/esm/CommandForm/fields/PasswordRoot.d.ts.map +1 -0
- package/dist/esm/CommandForm/fields/PasswordRoot.js +7 -0
- package/dist/esm/CommandForm/fields/PasswordRoot.js.map +1 -0
- package/dist/esm/CommandForm/fields/PasswordToggle.d.ts +13 -0
- package/dist/esm/CommandForm/fields/PasswordToggle.d.ts.map +1 -0
- package/dist/esm/CommandForm/fields/PasswordToggle.js +9 -0
- package/dist/esm/CommandForm/fields/PasswordToggle.js.map +1 -0
- package/dist/esm/DataTables/TablePaginatorImplementation.js +1 -1
- package/dist/esm/Dialogs/DialogImplementation.js +1 -1
- package/dist/esm/Dropdown/useDropdownState.js +1 -1
- package/dist/esm/Filter/FilterPanel.d.ts +69 -0
- package/dist/esm/Filter/FilterPanel.d.ts.map +1 -1
- package/dist/esm/Filter/FilterPanel.js +6 -21
- package/dist/esm/Filter/FilterPanel.js.map +1 -1
- package/dist/esm/Filter/FilterPanelContent.d.ts +14 -0
- package/dist/esm/Filter/FilterPanelContent.d.ts.map +1 -0
- package/dist/esm/Filter/FilterPanelContent.js +8 -0
- package/dist/esm/Filter/FilterPanelContent.js.map +1 -0
- package/dist/esm/Filter/usePortalTarget.d.ts +13 -0
- package/dist/esm/Filter/usePortalTarget.d.ts.map +1 -0
- package/dist/esm/Filter/usePortalTarget.js +24 -0
- package/dist/esm/Filter/usePortalTarget.js.map +1 -0
- package/dist/esm/Notifications/ToastCloseButton.d.ts +11 -0
- package/dist/esm/Notifications/ToastCloseButton.d.ts.map +1 -0
- package/dist/esm/Notifications/ToastCloseButton.js +14 -0
- package/dist/esm/Notifications/ToastCloseButton.js.map +1 -0
- package/dist/esm/Notifications/ToastContent.d.ts +10 -0
- package/dist/esm/Notifications/ToastContent.d.ts.map +1 -0
- package/dist/esm/Notifications/ToastContent.js +7 -0
- package/dist/esm/Notifications/ToastContent.js.map +1 -0
- package/dist/esm/Notifications/Toaster.d.ts.map +1 -1
- package/dist/esm/Notifications/Toaster.js +8 -17
- package/dist/esm/Notifications/Toaster.js.map +1 -1
- package/dist/esm/Notifications/useToastAutoDismiss.d.ts +4 -0
- package/dist/esm/Notifications/useToastAutoDismiss.d.ts.map +1 -0
- package/dist/esm/Notifications/useToastAutoDismiss.js +20 -0
- package/dist/esm/Notifications/useToastAutoDismiss.js.map +1 -0
- package/dist/esm/PivotViewer/PivotViewer.d.ts +1 -1
- package/dist/esm/PivotViewer/PivotViewer.d.ts.map +1 -1
- package/dist/esm/PivotViewer/PivotViewer.js +24 -31
- package/dist/esm/PivotViewer/PivotViewer.js.map +1 -1
- package/dist/esm/PivotViewer/components/PivotViewerContent.d.ts +40 -0
- package/dist/esm/PivotViewer/components/PivotViewerContent.d.ts.map +1 -0
- package/dist/esm/PivotViewer/components/PivotViewerContent.js +13 -0
- package/dist/esm/PivotViewer/components/PivotViewerContent.js.map +1 -0
- package/dist/esm/PivotViewer/hooks/usePivotViewerViewState.d.ts +37 -0
- package/dist/esm/PivotViewer/hooks/usePivotViewerViewState.d.ts.map +1 -0
- package/dist/esm/PivotViewer/hooks/usePivotViewerViewState.js +35 -0
- package/dist/esm/PivotViewer/hooks/usePivotViewerViewState.js.map +1 -0
- package/dist/esm/TimeMachine/EventCard.d.ts +9 -0
- package/dist/esm/TimeMachine/EventCard.d.ts.map +1 -0
- package/dist/esm/TimeMachine/EventCard.js +8 -0
- package/dist/esm/TimeMachine/EventCard.js.map +1 -0
- package/dist/esm/TimeMachine/EventSeparator.d.ts +11 -0
- package/dist/esm/TimeMachine/EventSeparator.d.ts.map +1 -0
- package/dist/esm/TimeMachine/EventSeparator.js +7 -0
- package/dist/esm/TimeMachine/EventSeparator.js.map +1 -0
- package/dist/esm/TimeMachine/EventTimelineItem.d.ts +14 -0
- package/dist/esm/TimeMachine/EventTimelineItem.d.ts.map +1 -0
- package/dist/esm/TimeMachine/EventTimelineItem.js +9 -0
- package/dist/esm/TimeMachine/EventTimelineItem.js.map +1 -0
- package/dist/esm/TimeMachine/EventsScrollButton.d.ts +10 -0
- package/dist/esm/TimeMachine/EventsScrollButton.d.ts.map +1 -0
- package/dist/esm/TimeMachine/EventsScrollButton.js +6 -0
- package/dist/esm/TimeMachine/EventsScrollButton.js.map +1 -0
- package/dist/esm/TimeMachine/EventsView.d.ts +1 -1
- package/dist/esm/TimeMachine/EventsView.d.ts.map +1 -1
- package/dist/esm/TimeMachine/EventsView.js +6 -39
- package/dist/esm/TimeMachine/EventsView.js.map +1 -1
- package/dist/esm/TimeMachine/useScrollEdges.d.ts +13 -0
- package/dist/esm/TimeMachine/useScrollEdges.d.ts.map +1 -0
- package/dist/esm/TimeMachine/useScrollEdges.js +40 -0
- package/dist/esm/TimeMachine/useScrollEdges.js.map +1 -0
- package/dist/esm/Toolbar/ToolbarFolder.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toaster.js","sources":["../../../Notifications/Toaster.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport {\n useEffect,\n useState,\n useSyncExternalStore,\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { useCratisComponentsConfig } from '../configuration/CratisComponentsContext';\nimport { useCratisIcon } from '../configuration/useCratisIcon';\nimport {\n getToastSnapshot,\n subscribeToToasts,\n toast,\n type ToastRecord,\n type ToastSeverity,\n} from './toast';\nimport type { ExactPartKeys } from '../types/ExactPartKeys';\nimport type { PartsOf } from '../types/parts';\nimport { classNames } from '../ClassNames/classNames';\n\n/** Supported viewport positions for the global toast region. */\nexport type ToasterPosition =\n | 'top-left'\n | 'top-center'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-center'\n | 'bottom-right';\n\n/** Stable part attributes for {@link Toaster}. */\nexport interface ToasterPassThrough {\n /** Accessible toast region. */\n region?: HTMLAttributes<HTMLDivElement>;\n /** One toast article. */\n toast?: HTMLAttributes<HTMLElement>;\n /** Severity/custom icon wrapper. */\n icon?: HTMLAttributes<HTMLSpanElement>;\n /** Toast content wrapper. */\n content?: HTMLAttributes<HTMLDivElement>;\n /** Toast title. */\n title?: HTMLAttributes<HTMLDivElement>;\n /** Toast description. */\n description?: HTMLAttributes<HTMLDivElement>;\n /** Dismiss button. */\n close?: ButtonHTMLAttributes<HTMLButtonElement>;\n /** Optional toast action button. */\n action?: ButtonHTMLAttributes<HTMLButtonElement>;\n}\n\nconst toasterPartsMatchManifest: ExactPartKeys<\n ToasterPassThrough,\n PartsOf<'Toaster'>\n> = true;\nvoid toasterPartsMatchManifest;\n\n/** Props for the global accessible toast region. */\nexport interface ToasterProps {\n /** Viewport position. */\n position?: ToasterPosition;\n /** Maximum visible toast count. */\n limit?: number;\n /** Default timeout in milliseconds. */\n timeout?: number;\n /** Accessible label for dismiss buttons. Falls back to the provider's `notifications.dismiss` message, then `'Dismiss'`. */\n dismissAriaLabel?: string;\n /** Accessible name for the toast region. Falls back to the provider's `notifications.region` message, then `'Notifications'`. */\n regionAriaLabel?: string;\n /** Stable part attributes. */\n pt?: ToasterPassThrough;\n}\n\nconst severitySymbol: Record<ToastSeverity, string> = {\n normal: '●',\n success: '✓',\n info: 'ⓘ',\n warn: '⚠',\n error: '⨯',\n secondary: '●',\n contrast: '●',\n};\n\nconst emptyToasts: ToastRecord[] = [];\n\ninterface ToastFrameProps {\n item: ToastRecord;\n timeout: number;\n dismissAriaLabel: string;\n pt?: ToasterPassThrough;\n}\n\nconst ToastFrame = ({ item, timeout, dismissAriaLabel, pt }: ToastFrameProps) => {\n const [paused, setPaused] = useState(false);\n const icon = useCratisIcon();\n\n useEffect(() => {\n if (paused || item.loading || item.duration === 0) return;\n const duration = item.duration ?? timeout;\n const timer = window.setTimeout(\n () => {\n item.onTimeout?.(item);\n toast.dismiss(item.id);\n },\n Math.max(duration, 5000),\n );\n return () => window.clearTimeout(timer);\n }, [item, paused, timeout]);\n\n const severity = item.severity ?? 'normal';\n const content = item.render ?? (\n <>\n {item.title && (\n <div\n {...pt?.title}\n className={classNames('cratis-toast__title', pt?.title?.className)}\n data-cratis-part='title'\n >\n {item.title}\n </div>\n )}\n {item.description && (\n <div\n {...pt?.description}\n className={classNames(\n 'cratis-toast__description',\n pt?.description?.className,\n )}\n data-cratis-part='description'\n >\n {item.description}\n </div>\n )}\n {item.action && (\n <button\n {...item.action}\n {...pt?.action}\n type='button'\n className={classNames(\n 'cratis-toast__action',\n item.action.className,\n pt?.action?.className,\n )}\n data-cratis-part='action'\n />\n )}\n </>\n );\n\n return (\n <article\n {...pt?.toast}\n className={classNames('cratis-toast', pt?.toast?.className)}\n data-cratis-part='toast'\n data-severity={severity}\n data-loading={item.loading || undefined}\n data-busy={item.loading || undefined}\n role={severity === 'error' ? 'alert' : 'status'}\n onMouseEnter={() => setPaused(true)}\n onMouseLeave={() => setPaused(false)}\n onFocusCapture={() => setPaused(true)}\n onBlurCapture={(event) => {\n if (!event.currentTarget.contains(event.relatedTarget)) setPaused(false);\n }}\n >\n <span\n {...pt?.icon}\n className={classNames('cratis-toast__icon', pt?.icon?.className)}\n data-cratis-part='icon'\n aria-hidden='true'\n >\n {item.loading\n ? '◌'\n : (item.icon ?? severitySymbol[severity])}\n </span>\n <div\n {...pt?.content}\n className={classNames('cratis-toast__content', pt?.content?.className)}\n data-cratis-part='content'\n data-loading={item.loading || undefined}\n data-busy={item.loading || undefined}\n >\n {content}\n </div>\n {item.dismissible !== false && (\n <button\n {...pt?.close}\n type='button'\n className={classNames('cratis-toast__close', pt?.close?.className)}\n data-cratis-part='close'\n aria-label={pt?.close?.['aria-label'] ?? dismissAriaLabel}\n onClick={() => toast.dismiss(item.id)}\n >\n <span aria-hidden='true'>{icon('close', '×')}</span>\n </button>\n )}\n </article>\n );\n};\n\n/** App-wide accessible toast region backed by the Cratis-owned toast queue. */\nexport const Toaster = ({\n position = 'top-right',\n limit = 3,\n timeout = 6000,\n dismissAriaLabel,\n regionAriaLabel,\n pt,\n}: ToasterProps) => {\n const { messages } = useCratisComponentsConfig();\n const notificationsMessages = messages?.notifications;\n const resolvedDismissAriaLabel =\n dismissAriaLabel ?? notificationsMessages?.dismiss ?? 'Dismiss';\n const resolvedRegionAriaLabel =\n regionAriaLabel ?? notificationsMessages?.region ?? 'Notifications';\n const items = useSyncExternalStore(\n subscribeToToasts,\n getToastSnapshot,\n () => emptyToasts,\n );\n if (typeof document === 'undefined') return null;\n\n return createPortal(\n <div\n {...pt?.region}\n className={classNames('cratis-toaster', pt?.region?.className)}\n data-cratis-part='region'\n data-position={position}\n role='region'\n aria-label={resolvedRegionAriaLabel}\n aria-live='polite'\n >\n {items.slice(-limit).map((item) => (\n <ToastFrame\n key={item.id}\n item={item}\n timeout={timeout}\n dismissAriaLabel={resolvedDismissAriaLabel}\n pt={pt}\n />\n ))}\n </div>,\n document.body,\n );\n};\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;;;;AA2EA,MAAM,cAAc,GAAkC;AAClD,IAAA,MAAM,EAAE,GAAG;AACX,IAAA,OAAO,EAAE,GAAG;AACZ,IAAA,IAAI,EAAE,GAAG;AACT,IAAA,IAAI,EAAE,GAAG;AACT,IAAA,KAAK,EAAE,GAAG;AACV,IAAA,SAAS,EAAE,GAAG;AACd,IAAA,QAAQ,EAAE,GAAG;CAChB;AAED,MAAM,WAAW,GAAkB,EAAE;AASrC,MAAM,UAAU,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,EAAmB,KAAI;IAC5E,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AAC3C,IAAA,MAAM,IAAI,GAAG,aAAa,EAAE;IAE5B,SAAS,CAAC,MAAK;QACX,IAAI,MAAM,IAAI,IAAI,CA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M,WAAW,CACpB;IACD,IAAI,OAAO,QAAQ,KAAK,WAAW;AAAE,QAAA,OAAO,IAAI;AAEhD,IAAA,OAAO,YAAY,CACfA,GAAA,CAAA,KAAA,EAAA,EAAA,GACQ,EAAE,EAAE,MAAM,EACd,SAAS,EAAE,UAAU,CAAC,gBAAgB,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,EAAA,kBAAA,EAC7C,QAAQ,EAAA,eAAA,EACV,QAAQ,EACvB,IAAI,EAAC,QAAQ,EAAA,YAAA,EACD,uBAAuB,EAAA,WAAA,EACzB,QAAQ,EAAA,QAAA,EAEjB,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,MAC1BA,GAAA,CAAC,UAAU,EAAA,EAEP,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,wBAAwB,EAC1C,EAAE,EAAE,EAAE,EAAA,EAJD,IAAI,CAAC,EAAE,CAKd,CACL,CAAC,EAAA,CACA,EACN,QAAQ,CAAC,IAAI,CAChB;AACL;;"}
|
|
1
|
+
{"version":3,"file":"Toaster.js","sources":["../../../Notifications/Toaster.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport {\n useState,\n useSyncExternalStore,\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { useCratisComponentsConfig } from '../configuration/CratisComponentsContext';\nimport {\n getToastSnapshot,\n subscribeToToasts,\n type ToastRecord,\n type ToastSeverity,\n} from './toast';\nimport { ToastCloseButton } from './ToastCloseButton';\nimport { ToastContent } from './ToastContent';\nimport { useToastAutoDismiss } from './useToastAutoDismiss';\nimport type { ExactPartKeys } from '../types/ExactPartKeys';\nimport type { PartsOf } from '../types/parts';\nimport { classNames } from '../ClassNames/classNames';\n\n/** Supported viewport positions for the global toast region. */\nexport type ToasterPosition =\n | 'top-left'\n | 'top-center'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-center'\n | 'bottom-right';\n\n/** Stable part attributes for {@link Toaster}. */\nexport interface ToasterPassThrough {\n /** Accessible toast region. */\n region?: HTMLAttributes<HTMLDivElement>;\n /** One toast article. */\n toast?: HTMLAttributes<HTMLElement>;\n /** Severity/custom icon wrapper. */\n icon?: HTMLAttributes<HTMLSpanElement>;\n /** Toast content wrapper. */\n content?: HTMLAttributes<HTMLDivElement>;\n /** Toast title. */\n title?: HTMLAttributes<HTMLDivElement>;\n /** Toast description. */\n description?: HTMLAttributes<HTMLDivElement>;\n /** Dismiss button. */\n close?: ButtonHTMLAttributes<HTMLButtonElement>;\n /** Optional toast action button. */\n action?: ButtonHTMLAttributes<HTMLButtonElement>;\n}\n\nconst toasterPartsMatchManifest: ExactPartKeys<\n ToasterPassThrough,\n PartsOf<'Toaster'>\n> = true;\nvoid toasterPartsMatchManifest;\n\n/** Props for the global accessible toast region. */\nexport interface ToasterProps {\n /** Viewport position. */\n position?: ToasterPosition;\n /** Maximum visible toast count. */\n limit?: number;\n /** Default timeout in milliseconds. */\n timeout?: number;\n /** Accessible label for dismiss buttons. Falls back to the provider's `notifications.dismiss` message, then `'Dismiss'`. */\n dismissAriaLabel?: string;\n /** Accessible name for the toast region. Falls back to the provider's `notifications.region` message, then `'Notifications'`. */\n regionAriaLabel?: string;\n /** Stable part attributes. */\n pt?: ToasterPassThrough;\n}\n\nconst severitySymbol: Record<ToastSeverity, string> = {\n normal: '●',\n success: '✓',\n info: 'ⓘ',\n warn: '⚠',\n error: '⨯',\n secondary: '●',\n contrast: '●',\n};\n\nconst emptyToasts: ToastRecord[] = [];\n\ninterface ToastFrameProps {\n item: ToastRecord;\n timeout: number;\n dismissAriaLabel: string;\n pt?: ToasterPassThrough;\n}\n\nconst ToastFrame = ({ item, timeout, dismissAriaLabel, pt }: ToastFrameProps) => {\n const [paused, setPaused] = useState(false);\n\n useToastAutoDismiss(item, paused, timeout);\n\n const severity = item.severity ?? 'normal';\n return (\n <article\n {...pt?.toast}\n className={classNames('cratis-toast', pt?.toast?.className)}\n data-cratis-part='toast'\n data-severity={severity}\n data-loading={item.loading || undefined}\n data-busy={item.loading || undefined}\n role={severity === 'error' ? 'alert' : 'status'}\n onMouseEnter={() => setPaused(true)}\n onMouseLeave={() => setPaused(false)}\n onFocusCapture={() => setPaused(true)}\n onBlurCapture={(event) => {\n if (!event.currentTarget.contains(event.relatedTarget)) setPaused(false);\n }}\n >\n <span\n {...pt?.icon}\n className={classNames('cratis-toast__icon', pt?.icon?.className)}\n data-cratis-part='icon'\n aria-hidden='true'\n >\n {item.loading\n ? '◌'\n : (item.icon ?? severitySymbol[severity])}\n </span>\n <div\n {...pt?.content}\n className={classNames('cratis-toast__content', pt?.content?.className)}\n data-cratis-part='content'\n data-loading={item.loading || undefined}\n data-busy={item.loading || undefined}\n >\n <ToastContent item={item} pt={pt} />\n </div>\n <ToastCloseButton item={item} dismissAriaLabel={dismissAriaLabel} pt={pt} />\n </article>\n );\n};\n\n/** App-wide accessible toast region backed by the Cratis-owned toast queue. */\nexport const Toaster = ({\n position = 'top-right',\n limit = 3,\n timeout = 6000,\n dismissAriaLabel,\n regionAriaLabel,\n pt,\n}: ToasterProps) => {\n const { messages } = useCratisComponentsConfig();\n const notificationsMessages = messages?.notifications;\n const resolvedDismissAriaLabel =\n dismissAriaLabel ?? notificationsMessages?.dismiss ?? 'Dismiss';\n const resolvedRegionAriaLabel =\n regionAriaLabel ?? notificationsMessages?.region ?? 'Notifications';\n const items = useSyncExternalStore(\n subscribeToToasts,\n getToastSnapshot,\n () => emptyToasts,\n );\n if (typeof document === 'undefined') return null;\n\n return createPortal(\n <div\n {...pt?.region}\n className={classNames('cratis-toaster', pt?.region?.className)}\n data-cratis-part='region'\n data-position={position}\n role='region'\n aria-label={resolvedRegionAriaLabel}\n aria-live='polite'\n >\n {items.slice(-limit).map((item) => (\n <ToastFrame\n key={item.id}\n item={item}\n timeout={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gBAAgB,IAAI,qBAAqB,EAAE,OAAO,IAAI,SAAS;IACnE,MAAM,uBAAuB,GACzB,eAAe,IAAI,qBAAqB,EAAE,MAAM,IAAI,eAAe;AACvE,IAAA,MAAM,KAAK,GAAG,oBAAoB,CAC9B,iBAAiB,EACjB,gBAAgB,EAChB,MAAM,WAAW,CACpB;IACD,IAAI,OAAO,QAAQ,KAAK,WAAW;AAAE,QAAA,OAAO,IAAI;AAEhD,IAAA,OAAO,YAAY,CACfA,GAAA,CAAA,KAAA,EAAA,EAAA,GACQ,EAAE,EAAE,MAAM,EACd,SAAS,EAAE,UAAU,CAAC,gBAAgB,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,EAAA,kBAAA,EAC7C,QAAQ,EAAA,eAAA,EACV,QAAQ,EACvB,IAAI,EAAC,QAAQ,EAAA,YAAA,EACD,uBAAuB,EAAA,WAAA,EACzB,QAAQ,EAAA,QAAA,EAEjB,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,MAC1BA,GAAA,CAAC,UAAU,EAAA,EAEP,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,wBAAwB,EAC1C,EAAE,EAAE,EAAE,EAAA,EAJD,IAAI,CAAC,EAAE,CAKd,CACL,CAAC,EAAA,CACA,EACN,QAAQ,CAAC,IAAI,CAChB;AACL;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type ToastRecord } from './toast.js';
|
|
2
|
+
/** Dismisses a toast after its duration, unless it is paused, loading or has a zero duration. */
|
|
3
|
+
export declare const useToastAutoDismiss: (item: ToastRecord, paused: boolean, timeout: number) => void;
|
|
4
|
+
//# sourceMappingURL=useToastAutoDismiss.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useToastAutoDismiss.d.ts","sourceRoot":"","sources":["../../../Notifications/useToastAutoDismiss.ts"],"names":[],"mappings":"AAIA,OAAO,EAAS,KAAK,WAAW,EAAE,MAAM,YAAS,CAAC;AAMlD,iGAAiG;AACjG,eAAO,MAAM,mBAAmB,SAAU,WAAW,UAAU,OAAO,WAAW,MAAM,SAatF,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { toast } from './toast.js';
|
|
3
|
+
|
|
4
|
+
const minimumDuration = 5000;
|
|
5
|
+
const isTimedToast = (item) => !item.loading && item.duration !== 0;
|
|
6
|
+
const useToastAutoDismiss = (item, paused, timeout) => {
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (paused || !isTimedToast(item))
|
|
9
|
+
return;
|
|
10
|
+
const duration = item.duration ?? timeout;
|
|
11
|
+
const timer = window.setTimeout(() => {
|
|
12
|
+
item.onTimeout?.(item);
|
|
13
|
+
toast.dismiss(item.id);
|
|
14
|
+
}, Math.max(duration, minimumDuration));
|
|
15
|
+
return () => window.clearTimeout(timer);
|
|
16
|
+
}, [item, paused, timeout]);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { useToastAutoDismiss };
|
|
20
|
+
//# sourceMappingURL=useToastAutoDismiss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useToastAutoDismiss.js","sources":["../../../Notifications/useToastAutoDismiss.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useEffect } from 'react';\nimport { toast, type ToastRecord } from './toast';\n\nconst minimumDuration = 5000;\n\nconst isTimedToast = (item: ToastRecord) => !item.loading && item.duration !== 0;\n\n/** Dismisses a toast after its duration, unless it is paused, loading or has a zero duration. */\nexport const useToastAutoDismiss = (item: ToastRecord, paused: boolean, timeout: number) => {\n useEffect(() => {\n if (paused || !isTimedToast(item)) return;\n const duration = item.duration ?? timeout;\n const timer = window.setTimeout(\n () => {\n item.onTimeout?.(item);\n toast.dismiss(item.id);\n },\n Math.max(duration, minimumDuration),\n );\n return () => window.clearTimeout(timer);\n }, [item, paused, timeout]);\n};\n"],"names":[],"mappings":";;;AAMA,MAAM,eAAe,GAAG,IAAI;AAE5B,MAAM,YAAY,GAAG,CAAC,IAAiB,KAAK,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC;AAGzE,MAAM,mBAAmB,GAAG,CAAC,IAAiB,EAAE,MAAe,EAAE,OAAe,KAAI;IACvF,SAAS,CAAC,MAAK;AACX,QAAA,IAAI,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;YAAE;AACnC,QAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,OAAO;AACzC,QAAA,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAC3B,MAAK;AACD,YAAA,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;AACtB,YAAA,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,CAAC,EACD,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,eAAe,CAAC,CACtC;QACD,OAAO,MAAM,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC;IAC3C,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAC/B;;"}
|
|
@@ -18,5 +18,5 @@ import type { PivotViewerProps } from './types.js';
|
|
|
18
18
|
* @typeParam TItem - The item type contained in {@link PivotViewerProps.data}.
|
|
19
19
|
* @param props - {@link PivotViewerProps}.
|
|
20
20
|
*/
|
|
21
|
-
export declare function PivotViewer<TItem extends object>(
|
|
21
|
+
export declare function PivotViewer<TItem extends object>(props: PivotViewerProps<TItem>): import("react").JSX.Element;
|
|
22
22
|
//# sourceMappingURL=PivotViewer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PivotViewer.d.ts","sourceRoot":"","sources":["../../../PivotViewer/PivotViewer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PivotViewer.d.ts","sourceRoot":"","sources":["../../../PivotViewer/PivotViewer.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAS,CAAC;AA+ChD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,KAAK,SAAS,MAAM,EAAE,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC,+BAiH/E"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useRef,
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useRef, useEffect } from 'react';
|
|
3
3
|
import { useFilterState } from './hooks/useFilterState.js';
|
|
4
4
|
import { useDimensionState } from './hooks/useDimensionState.js';
|
|
5
5
|
import { useZoomState } from './hooks/useZoomState.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { FilterPanelContainer } from './components/FilterPanelContainer.js';
|
|
9
|
-
import { ToolbarContainer } from './components/ToolbarContainer.js';
|
|
6
|
+
import { PivotViewerContent } from './components/PivotViewerContent.js';
|
|
7
|
+
import { usePivotViewerViewState } from './hooks/usePivotViewerViewState.js';
|
|
10
8
|
import { useFilterOptions } from './hooks/useFilterOptions.js';
|
|
11
9
|
import { usePanning } from './hooks/usePanning.js';
|
|
12
10
|
import { useWheelZoom } from './hooks/useWheelZoom.js';
|
|
@@ -38,28 +36,25 @@ function buildViewerClassName(className, hasFilters, filtersOpen, viewMode) {
|
|
|
38
36
|
.filter(Boolean)
|
|
39
37
|
.join(' ');
|
|
40
38
|
}
|
|
41
|
-
function PivotViewer(
|
|
39
|
+
function PivotViewer(props) {
|
|
40
|
+
const { data, dimensions, filters, defaultDimensionKey, getItemId, searchFields, className, isLoading = false, colors } = props;
|
|
42
41
|
const containerRef = useRef(null);
|
|
43
42
|
const filterButtonRef = useRef(null);
|
|
44
43
|
const axisLabelsRef = useRef(null);
|
|
45
44
|
const spacerRef = useRef(null);
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const { filterState, rangeFilterState, expandedFilterKey, setExpandedFilterKey, handleToggleFilter, handleClearFilter, handleRangeChange, } = useFilterState(filters);
|
|
56
|
-
const { activeDimensionKey, setActiveDimensionKey, activeDimension, dimensionFilter, handleAxisLabelClick, } = useDimensionState(dimensions, defaultDimensionKey);
|
|
57
|
-
const { zoomLevel, setZoomLevel, handleZoomIn, handleZoomOut, handleZoomSlider, handleZoomReset, handleZoomChange, } = useZoomState(1);
|
|
58
|
-
const { isPanning, handlePanStart, handlePanMove, handlePanEnd } = usePanning(containerRef, undefined, setScrollPosition);
|
|
45
|
+
const view = usePivotViewerViewState();
|
|
46
|
+
const { search, viewMode, selectedItem, preSelectionState, scrollPosition } = view;
|
|
47
|
+
const filter = useFilterState(filters);
|
|
48
|
+
const { filterState, rangeFilterState } = filter;
|
|
49
|
+
const dimension = useDimensionState(dimensions, defaultDimensionKey);
|
|
50
|
+
const { activeDimensionKey, activeDimension, dimensionFilter } = dimension;
|
|
51
|
+
const zoom = useZoomState(1);
|
|
52
|
+
const { zoomLevel, setZoomLevel } = zoom;
|
|
53
|
+
const pan = usePanning(containerRef, undefined, view.setScrollPosition);
|
|
59
54
|
useWheelZoom(containerRef, zoomLevel, setZoomLevel);
|
|
60
55
|
useZoomScrollAnchor(containerRef, spacerRef, viewMode);
|
|
61
56
|
const containerDimensions = useContainerDimensions(containerRef, isLoading);
|
|
62
|
-
useScrollPositionTracking(containerRef, setScrollPosition);
|
|
57
|
+
useScrollPositionTracking(containerRef, view.setScrollPosition);
|
|
63
58
|
const { ready, visibleIds, grouping } = usePivotViewerGrouping({
|
|
64
59
|
data,
|
|
65
60
|
dimensions,
|
|
@@ -76,7 +71,7 @@ function PivotViewer({ data, dimensions, filters, defaultDimensionKey, cardRende
|
|
|
76
71
|
const layout = useViewerLayout(grouping, viewMode, zoomLevel, containerDimensions);
|
|
77
72
|
const { resolveId, handleCardClick, closeDetail } = usePivotViewerInteractions({
|
|
78
73
|
data,
|
|
79
|
-
isPanning,
|
|
74
|
+
isPanning: pan.isPanning,
|
|
80
75
|
selectedItem,
|
|
81
76
|
zoomLevel,
|
|
82
77
|
viewMode,
|
|
@@ -93,23 +88,21 @@ function PivotViewer({ data, dimensions, filters, defaultDimensionKey, cardRende
|
|
|
93
88
|
rangeFilterState,
|
|
94
89
|
search,
|
|
95
90
|
activeDimensionKey,
|
|
96
|
-
setAnimationMode,
|
|
91
|
+
setAnimationMode: view.setAnimationMode,
|
|
97
92
|
setZoomLevel,
|
|
98
|
-
setIsZooming,
|
|
99
|
-
setSelectedItem,
|
|
100
|
-
setPreSelectionState,
|
|
93
|
+
setIsZooming: view.setIsZooming,
|
|
94
|
+
setSelectedItem: view.setSelectedItem,
|
|
95
|
+
setPreSelectionState: view.setPreSelectionState,
|
|
101
96
|
});
|
|
102
|
-
const cardWidth = BASE_CARD_WIDTH;
|
|
103
|
-
const cardHeight = BASE_CARD_HEIGHT;
|
|
104
97
|
const filterOptions = useFilterOptions(data, filters, filterState, rangeFilterState);
|
|
105
98
|
const hasFilters = Boolean(filters && filters.length > 0);
|
|
106
99
|
const activeFilterCount = countActiveFilters(filterState, rangeFilterState);
|
|
107
|
-
const viewerClassName = buildViewerClassName(className, hasFilters, filtersOpen, viewMode);
|
|
100
|
+
const viewerClassName = buildViewerClassName(className, hasFilters, view.filtersOpen, viewMode);
|
|
108
101
|
useEffect(() => {
|
|
109
|
-
setSelectedItem(null);
|
|
102
|
+
view.setSelectedItem(null);
|
|
110
103
|
}, [viewMode]);
|
|
111
104
|
const cssVariables = useColorCssVariables(colors);
|
|
112
|
-
return (
|
|
105
|
+
return (jsx(PivotViewerContent, { viewer: props, isLoading: isLoading, viewerClassName: viewerClassName, cssVariables: cssVariables, hasFilters: hasFilters, activeFilterCount: activeFilterCount, filterOptions: filterOptions, view: view, filter: filter, dimension: dimension, zoom: zoom, pan: pan, ready: ready, visibleIds: visibleIds, grouping: grouping, layout: layout, containerDimensions: containerDimensions, resolveId: resolveId, onCardClick: handleCardClick, onCloseDetail: closeDetail, containerRef: containerRef, filterButtonRef: filterButtonRef, axisLabelsRef: axisLabelsRef, spacerRef: spacerRef }));
|
|
113
106
|
}
|
|
114
107
|
|
|
115
108
|
export { PivotViewer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PivotViewer.js","sources":["../../../PivotViewer/PivotViewer.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useEffect, useRef, useState } from 'react';\nimport type { PivotViewerProps } from './types';\nimport { useFilterState } from './hooks/useFilterState';\nimport { useDimensionState } from './hooks/useDimensionState';\nimport { useZoomState } from './hooks/useZoomState';\nimport { BASE_CARD_WIDTH, BASE_CARD_HEIGHT } from './constants';\nimport { PivotViewerMain } from './components/PivotViewerMain';\nimport { FilterPanelContainer } from './components/FilterPanelContainer';\nimport { ToolbarContainer } from './components/ToolbarContainer';\nimport { usePanning, useWheelZoom, useZoomScrollAnchor, useFilterOptions } from './hooks';\nimport { useContainerDimensions } from './hooks/useContainerDimensions';\nimport type { ViewMode } from './components/Toolbar';\nimport { useColorCssVariables } from './hooks/useColorCssVariables';\nimport { useViewerLayout } from './hooks/useViewerLayout';\nimport { useScrollPositionTracking } from './hooks/useScrollPositionTracking';\nimport { usePivotViewerGrouping } from './hooks/usePivotViewerGrouping';\nimport { usePivotViewerInteractions } from './hooks/usePivotViewerInteractions';\n\nfunction countActiveFilters(\n filterState: Record<string, unknown>,\n rangeFilterState: Record<string, unknown>,\n): number {\n const selectionCount = Object.values(filterState).reduce(\n (sum: number, vals) => sum + (vals as Set<string>).size,\n 0,\n );\n return selectionCount + Object.values(rangeFilterState).filter((r) => r !== null).length;\n}\n\nfunction filtersClassName(hasFilters: boolean, filtersOpen: boolean): string {\n if (!hasFilters) return 'no-filters';\n return filtersOpen ? 'filters-open' : 'filters-closed';\n}\n\nfunction buildViewerClassName(\n className: string | undefined,\n hasFilters: boolean,\n filtersOpen: boolean,\n viewMode: ViewMode,\n): string {\n return [\n 'pivot-viewer',\n className,\n filtersClassName(hasFilters, filtersOpen),\n viewMode === 'grouped' ? 'grouped-mode' : 'collection-mode',\n ]\n .filter(Boolean)\n .join(' ');\n}\n\n/**\n * A faceted, zoomable card-grid visualization inspired by Microsoft's PivotViewer.\n * Renders a large set of items as cards that can be grouped by any of a set of\n * declared dimensions, filtered through faceted panels, searched by text, and\n * zoomed/panned around freely. A detail pane shows the selected card's full\n * information.\n *\n * Backed by PIXI.js for high-performance rendering, so it gracefully handles\n * thousands of items. Consumers supply their own `cardRenderer` and\n * `detailRenderer` to control card and detail content; the component handles\n * grouping, filtering, panning, zooming, and selection internally.\n *\n * Use this for exploratory data analysis UIs over large collections (catalogs,\n * inventories, telemetry samples). For tabular display, use {@link DataPage}\n * or {@link DataTableForQuery}.\n *\n * @typeParam TItem - The item type contained in {@link PivotViewerProps.data}.\n * @param props - {@link PivotViewerProps}.\n */\nexport function PivotViewer<TItem extends object>({\n data,\n dimensions,\n filters,\n defaultDimensionKey,\n cardRenderer,\n detailRenderer,\n getItemId,\n searchFields,\n title,\n className,\n emptyContent,\n isLoading = false,\n loadingLabel,\n labels,\n colors,\n}: PivotViewerProps<TItem>) {\n // Refs\n const containerRef = useRef<HTMLDivElement>(null!);\n const filterButtonRef = useRef<HTMLButtonElement>(null!);\n const axisLabelsRef = useRef<HTMLDivElement>(null!);\n const spacerRef = useRef<HTMLDivElement>(null!);\n\n // State\n const [search, setSearch] = useState('');\n const [viewMode, setViewMode] = useState<ViewMode>('collection');\n const [filtersOpen, setFiltersOpen] = useState(false);\n const [selectedItem, setSelectedItem] = useState<TItem | null>(null);\n const [isZooming, setIsZooming] = useState(false);\n const [hoveredGroupIndex, setHoveredGroupIndex] = useState<number | null>(null);\n const [preSelectionState, setPreSelectionState] = useState<{\n zoom: number;\n scrollLeft: number;\n scrollTop: number;\n } | null>(null);\n const [, setAnimationMode] = useState<'layout' | 'filter'>('layout');\n const [scrollPosition, setScrollPosition] = useState({ x: 0, y: 0 });\n\n // Filter hooks\n const {\n filterState,\n rangeFilterState,\n expandedFilterKey,\n setExpandedFilterKey,\n handleToggleFilter,\n handleClearFilter,\n handleRangeChange,\n } = useFilterState(filters);\n\n // Dimension hooks\n const {\n activeDimensionKey,\n setActiveDimensionKey,\n activeDimension,\n dimensionFilter,\n handleAxisLabelClick,\n } = useDimensionState(dimensions, defaultDimensionKey);\n\n // Zoom and pan hooks\n const {\n zoomLevel,\n setZoomLevel,\n handleZoomIn,\n handleZoomOut,\n handleZoomSlider,\n handleZoomReset,\n handleZoomChange,\n } = useZoomState(1);\n\n const { isPanning, handlePanStart, handlePanMove, handlePanEnd } = usePanning(\n containerRef,\n undefined,\n setScrollPosition,\n );\n\n useWheelZoom(containerRef, zoomLevel, setZoomLevel);\n useZoomScrollAnchor(containerRef, spacerRef, viewMode);\n\n // Track container dimensions for responsive layout\n const containerDimensions = useContainerDimensions(containerRef, isLoading);\n\n useScrollPositionTracking(containerRef, setScrollPosition);\n\n const { ready, visibleIds, grouping } = usePivotViewerGrouping({\n data,\n dimensions,\n filters,\n filterState,\n rangeFilterState,\n dimensionFilter,\n activeDimension,\n activeDimensionKey,\n searchFields,\n search,\n viewMode,\n });\n\n const layout = useViewerLayout(grouping, viewMode, zoomLevel, containerDimensions);\n\n const { resolveId, handleCardClick, closeDetail } = usePivotViewerInteractions({\n data,\n isPanning,\n selectedItem,\n zoomLevel,\n viewMode,\n layout,\n containerRef,\n axisLabelsRef,\n spacerRef,\n containerDimensions,\n scrollPosition,\n preSelectionState,\n grouping,\n getItemId,\n filterState,\n rangeFilterState,\n search,\n activeDimensionKey,\n setAnimationMode,\n setZoomLevel,\n setIsZooming,\n setSelectedItem,\n setPreSelectionState,\n });\n\n // Use base card dimensions - zoom is applied as transform in canvas\n const cardWidth = BASE_CARD_WIDTH;\n const cardHeight = BASE_CARD_HEIGHT;\n\n // Calculate filter options\n const filterOptions = useFilterOptions(data, filters, filterState, rangeFilterState);\n\n const hasFilters = Boolean(filters && filters.length > 0);\n const activeFilterCount = countActiveFilters(filterState, rangeFilterState);\n const viewerClassName = buildViewerClassName(className, hasFilters, filtersOpen, viewMode);\n\n // Deselect any selected card when switching between view modes\n useEffect(() => {\n setSelectedItem(null);\n }, [viewMode]);\n\n const cssVariables = useColorCssVariables(colors);\n\n return (\n <div className={viewerClassName} style={cssVariables as React.CSSProperties}>\n <FilterPanelContainer\n isOpen={filtersOpen && hasFilters}\n filterLabel={labels?.filters}\n searchPlaceholder={labels?.search}\n searchGroup={labels?.searchGroup}\n search={search}\n filterState={filterState}\n rangeFilterState={rangeFilterState}\n expandedFilterKey={expandedFilterKey}\n filterOptions={filterOptions}\n anchorRef={filterButtonRef}\n onClose={() => setFiltersOpen(false)}\n onSearchChange={setSearch}\n onFilterToggle={handleToggleFilter}\n onFilterClear={handleClearFilter}\n onRangeChange={handleRangeChange}\n onExpandedFilterChange={setExpandedFilterKey}\n />\n\n <main className='pv-main'>\n <ToolbarContainer\n hasFilters={hasFilters}\n filtersOpen={filtersOpen}\n filteredCount={visibleIds.length}\n viewMode={viewMode}\n zoomLevel={zoomLevel}\n activeDimensionKey={activeDimensionKey}\n dimensions={dimensions}\n activeFilterCount={activeFilterCount}\n title={title}\n labels={labels}\n onFiltersToggle={() => setFiltersOpen((prev) => !prev)}\n onViewModeChange={setViewMode}\n onZoomIn={handleZoomIn}\n onZoomOut={handleZoomOut}\n onZoomSlider={handleZoomSlider}\n onZoomReset={handleZoomReset}\n onZoomChange={handleZoomChange}\n onDimensionChange={setActiveDimensionKey}\n filterButtonRef={filterButtonRef}\n />\n\n <PivotViewerMain\n data={data}\n ready={ready}\n isLoading={isLoading}\n loadingLabel={loadingLabel ?? labels?.loading ?? 'Loading…'}\n viewportLabel={labels?.viewport ?? 'Card area'}\n visibleIds={visibleIds}\n grouping={grouping}\n layout={layout}\n cardWidth={cardWidth}\n cardHeight={cardHeight}\n zoomLevel={zoomLevel}\n scrollPosition={scrollPosition}\n containerDimensions={containerDimensions}\n selectedItem={selectedItem}\n hoveredGroupIndex={hoveredGroupIndex}\n isZooming={isZooming}\n viewMode={viewMode}\n cardRenderer={cardRenderer}\n colorOverrides={colors}\n detailRenderer={detailRenderer}\n resolveId={resolveId}\n emptyContent={emptyContent}\n dimensionFilter={dimensionFilter}\n onCardClick={handleCardClick}\n onPanStart={handlePanStart as (e: React.MouseEvent) => void}\n onPanMove={handlePanMove as (e: React.MouseEvent) => void}\n onPanEnd={handlePanEnd}\n onGroupHover={setHoveredGroupIndex}\n onAxisLabelClick={handleAxisLabelClick}\n onCloseDetail={closeDetail}\n containerRef={containerRef}\n axisLabelsRef={axisLabelsRef}\n spacerRef={spacerRef}\n />\n </main>\n </div>\n );\n}\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,SAAS,kBAAkB,CACvB,WAAoC,EACpC,gBAAyC,EAAA;IAEzC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,CACpD,CAAC,GAAW,EAAE,IAAI,KAAK,GAAG,GAAI,IAAoB,CAAC,IAAI,EACvD,CAAC,CACJ;IACD,OAAO,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM;AAC5F;AAEA,SAAS,gBAAgB,CAAC,UAAmB,EAAE,WAAoB,EAAA;AAC/D,IAAA,IAAI,CAAC,UAAU;AAAE,QAAA,OAAO,YAAY;IACpC,OAAO,WAAW,GAAG,cAAc,GAAG,gBAAgB;AAC1D;AAEA,SAAS,oBAAoB,CACzB,SAA6B,EAC7B,UAAmB,EACnB,WAAoB,EAC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E,QAAQ,IAAI,WAAW,EAC9C,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,mBAAmB,EAAE,mBAAmB,EACxC,YAAY,EAAE,YAAY,EAC1B,iBAAiB,EAAE,iBAAiB,EACpC,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,cAAc,EAC9B,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,eAAe,EAC5B,UAAU,EAAE,cAA+C,EAC3D,SAAS,EAAE,aAA8C,EACzD,QAAQ,EAAE,YAAY,EACtB,YAAY,EAAE,oBAAoB,EAClC,gBAAgB,EAAE,oBAAoB,EACtC,aAAa,EAAE,WAAW,EAC1B,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,SAAS,GACtB,CAAA,EAAA,CACC,CAAA,EAAA,CACL;AAEd;;"}
|
|
1
|
+
{"version":3,"file":"PivotViewer.js","sources":["../../../PivotViewer/PivotViewer.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useEffect, useRef } from 'react';\nimport type { CSSProperties } from 'react';\nimport type { PivotViewerProps } from './types';\nimport { useFilterState } from './hooks/useFilterState';\nimport { useDimensionState } from './hooks/useDimensionState';\nimport { useZoomState } from './hooks/useZoomState';\nimport { PivotViewerContent } from './components/PivotViewerContent';\nimport { usePivotViewerViewState } from './hooks/usePivotViewerViewState';\nimport { usePanning, useWheelZoom, useZoomScrollAnchor, useFilterOptions } from './hooks';\nimport { useContainerDimensions } from './hooks/useContainerDimensions';\nimport type { ViewMode } from './components/Toolbar';\nimport { useColorCssVariables } from './hooks/useColorCssVariables';\nimport { useViewerLayout } from './hooks/useViewerLayout';\nimport { useScrollPositionTracking } from './hooks/useScrollPositionTracking';\nimport { usePivotViewerGrouping } from './hooks/usePivotViewerGrouping';\nimport { usePivotViewerInteractions } from './hooks/usePivotViewerInteractions';\n\nfunction countActiveFilters(\n filterState: Record<string, unknown>,\n rangeFilterState: Record<string, unknown>,\n): number {\n const selectionCount = Object.values(filterState).reduce(\n (sum: number, vals) => sum + (vals as Set<string>).size,\n 0,\n );\n return selectionCount + Object.values(rangeFilterState).filter((r) => r !== null).length;\n}\n\nfunction filtersClassName(hasFilters: boolean, filtersOpen: boolean): string {\n if (!hasFilters) return 'no-filters';\n return filtersOpen ? 'filters-open' : 'filters-closed';\n}\n\nfunction buildViewerClassName(\n className: string | undefined,\n hasFilters: boolean,\n filtersOpen: boolean,\n viewMode: ViewMode,\n): string {\n return [\n 'pivot-viewer',\n className,\n filtersClassName(hasFilters, filtersOpen),\n viewMode === 'grouped' ? 'grouped-mode' : 'collection-mode',\n ]\n .filter(Boolean)\n .join(' ');\n}\n\n/**\n * A faceted, zoomable card-grid visualization inspired by Microsoft's PivotViewer.\n * Renders a large set of items as cards that can be grouped by any of a set of\n * declared dimensions, filtered through faceted panels, searched by text, and\n * zoomed/panned around freely. A detail pane shows the selected card's full\n * information.\n *\n * Backed by PIXI.js for high-performance rendering, so it gracefully handles\n * thousands of items. Consumers supply their own `cardRenderer` and\n * `detailRenderer` to control card and detail content; the component handles\n * grouping, filtering, panning, zooming, and selection internally.\n *\n * Use this for exploratory data analysis UIs over large collections (catalogs,\n * inventories, telemetry samples). For tabular display, use {@link DataPage}\n * or {@link DataTableForQuery}.\n *\n * @typeParam TItem - The item type contained in {@link PivotViewerProps.data}.\n * @param props - {@link PivotViewerProps}.\n */\nexport function PivotViewer<TItem extends object>(props: PivotViewerProps<TItem>) {\n const { data, dimensions, filters, defaultDimensionKey, getItemId, searchFields, className, isLoading = false, colors } = props;\n\n // Refs\n const containerRef = useRef<HTMLDivElement>(null!);\n const filterButtonRef = useRef<HTMLButtonElement>(null!);\n const axisLabelsRef = useRef<HTMLDivElement>(null!);\n const spacerRef = useRef<HTMLDivElement>(null!);\n\n const view = usePivotViewerViewState<TItem>();\n const { search, viewMode, selectedItem, preSelectionState, scrollPosition } = view;\n\n const filter = useFilterState(filters);\n const { filterState, rangeFilterState } = filter;\n const dimension = useDimensionState(dimensions, defaultDimensionKey);\n const { activeDimensionKey, activeDimension, dimensionFilter } = dimension;\n const zoom = useZoomState(1);\n const { zoomLevel, setZoomLevel } = zoom;\n\n const pan = usePanning(containerRef, undefined, view.setScrollPosition);\n\n useWheelZoom(containerRef, zoomLevel, setZoomLevel);\n useZoomScrollAnchor(containerRef, spacerRef, viewMode);\n\n // Track container dimensions for responsive layout\n const containerDimensions = useContainerDimensions(containerRef, isLoading);\n\n useScrollPositionTracking(containerRef, view.setScrollPosition);\n\n const { ready, visibleIds, grouping } = usePivotViewerGrouping({\n data,\n dimensions,\n filters,\n filterState,\n rangeFilterState,\n dimensionFilter,\n activeDimension,\n activeDimensionKey,\n searchFields,\n search,\n viewMode,\n });\n\n const layout = useViewerLayout(grouping, viewMode, zoomLevel, containerDimensions);\n\n const { resolveId, handleCardClick, closeDetail } = usePivotViewerInteractions({\n data,\n isPanning: pan.isPanning,\n selectedItem,\n zoomLevel,\n viewMode,\n layout,\n containerRef,\n axisLabelsRef,\n spacerRef,\n containerDimensions,\n scrollPosition,\n preSelectionState,\n grouping,\n getItemId,\n filterState,\n rangeFilterState,\n search,\n activeDimensionKey,\n setAnimationMode: view.setAnimationMode,\n setZoomLevel,\n setIsZooming: view.setIsZooming,\n setSelectedItem: view.setSelectedItem,\n setPreSelectionState: view.setPreSelectionState,\n });\n\n // Calculate filter options\n const filterOptions = useFilterOptions(data, filters, filterState, rangeFilterState);\n\n const hasFilters = Boolean(filters && filters.length > 0);\n const activeFilterCount = countActiveFilters(filterState, rangeFilterState);\n const viewerClassName = buildViewerClassName(className, hasFilters, view.filtersOpen, viewMode);\n\n // Deselect any selected card when switching between view modes\n useEffect(() => {\n view.setSelectedItem(null);\n }, [viewMode]);\n\n const cssVariables = useColorCssVariables(colors);\n\n return (\n <PivotViewerContent<TItem>\n viewer={props}\n isLoading={isLoading}\n viewerClassName={viewerClassName}\n cssVariables={cssVariables as CSSProperties}\n hasFilters={hasFilters}\n activeFilterCount={activeFilterCount}\n filterOptions={filterOptions}\n view={view}\n filter={filter}\n dimension={dimension}\n zoom={zoom}\n pan={pan}\n ready={ready}\n visibleIds={visibleIds}\n grouping={grouping}\n layout={layout}\n containerDimensions={containerDimensions}\n resolveId={resolveId}\n onCardClick={handleCardClick}\n onCloseDetail={closeDetail}\n containerRef={containerRef}\n filterButtonRef={filterButtonRef}\n axisLabelsRef={axisLabelsRef}\n spacerRef={spacerRef}\n />\n );\n}\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,SAAS,kBAAkB,CACvB,WAAoC,EACpC,gBAAyC,EAAA;IAEzC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,CACpD,CAAC,GAAW,EAAE,IAAI,KAAK,GAAG,GAAI,IAAoB,CAAC,IAAI,EACvD,CAAC,CACJ;IACD,OAAO,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM;AAC5F;AAEA,SAAS,gBAAgB,CAAC,UAAmB,EAAE,WAAoB,EAAA;AAC/D,IAAA,IAAI,CAAC,UAAU;AAAE,QAAA,OAAO,YAAY;IACpC,OAAO,WAAW,GAAG,cAAc,GAAG,gBAAgB;AAC1D;AAEA,SAAS,oBAAoB,CACzB,SAA6B,EAC7B,UAAmB,EACnB,WAAoB,EACpB,QAAkB,EAAA;IAElB,OAAO;QACH,cAAc;QACd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ACzD,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,WAAW,EAAE,gBAAgB,CAAC;AAC3E,IAAA,MAAM,eAAe,GAAG,oBAAoB,CAAC,SAAS,EAAE,UAAU,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC;IAG/F,SAAS,CAAC,MAAK;AACX,QAAA,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;AAC9B,IAAA,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;AAEd,IAAA,MAAM,YAAY,GAAG,oBAAoB,CAAC,MAAM,CAAC;IAEjD,QACIA,IAAC,kBAAkB,EAAA,EACf,MAAM,EAAE,KAAK,EACb,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAA6B,EAC3C,UAAU,EAAE,UAAU,EACtB,iBAAiB,EAAE,iBAAiB,EACpC,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,mBAAmB,EACxC,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,eAAe,EAC5B,aAAa,EAAE,WAAW,EAC1B,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,SAAS,EAAA,CACtB;AAEV;;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { CSSProperties, RefObject } from 'react';
|
|
2
|
+
import type { GroupingResult, ItemId, LayoutResult } from '../engine/types.js';
|
|
3
|
+
import type { PivotViewerProps } from '../types.js';
|
|
4
|
+
import type { useDimensionState } from '../hooks/useDimensionState.js';
|
|
5
|
+
import type { useFilterOptions } from '../hooks/useFilterOptions.js';
|
|
6
|
+
import type { useFilterState } from '../hooks/useFilterState.js';
|
|
7
|
+
import type { usePanning } from '../hooks/usePanning.js';
|
|
8
|
+
import type { usePivotViewerViewState } from '../hooks/usePivotViewerViewState.js';
|
|
9
|
+
import type { useZoomState } from '../hooks/useZoomState.js';
|
|
10
|
+
export interface PivotViewerContentProps<TItem extends object> {
|
|
11
|
+
viewer: PivotViewerProps<TItem>;
|
|
12
|
+
isLoading: boolean;
|
|
13
|
+
viewerClassName: string;
|
|
14
|
+
cssVariables: CSSProperties;
|
|
15
|
+
hasFilters: boolean;
|
|
16
|
+
activeFilterCount: number;
|
|
17
|
+
filterOptions: ReturnType<typeof useFilterOptions<TItem>>;
|
|
18
|
+
view: ReturnType<typeof usePivotViewerViewState<TItem>>;
|
|
19
|
+
filter: ReturnType<typeof useFilterState>;
|
|
20
|
+
dimension: ReturnType<typeof useDimensionState<TItem>>;
|
|
21
|
+
zoom: ReturnType<typeof useZoomState>;
|
|
22
|
+
pan: ReturnType<typeof usePanning>;
|
|
23
|
+
ready: boolean;
|
|
24
|
+
visibleIds: Uint32Array;
|
|
25
|
+
grouping: GroupingResult;
|
|
26
|
+
layout: LayoutResult;
|
|
27
|
+
containerDimensions: {
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
};
|
|
31
|
+
resolveId: (item: TItem, index: number) => ItemId;
|
|
32
|
+
onCardClick: (item: TItem, e: globalThis.MouseEvent, id: number | string) => void;
|
|
33
|
+
onCloseDetail: () => void;
|
|
34
|
+
containerRef: RefObject<HTMLDivElement>;
|
|
35
|
+
filterButtonRef: RefObject<HTMLButtonElement>;
|
|
36
|
+
axisLabelsRef: RefObject<HTMLDivElement>;
|
|
37
|
+
spacerRef: RefObject<HTMLDivElement>;
|
|
38
|
+
}
|
|
39
|
+
export declare function PivotViewerContent<TItem extends object>({ viewer, isLoading, viewerClassName, cssVariables, hasFilters, activeFilterCount, filterOptions, view, filter, dimension, zoom, pan, ready, visibleIds, grouping, layout, containerDimensions, resolveId, onCardClick, onCloseDetail, containerRef, filterButtonRef, axisLabelsRef, spacerRef, }: PivotViewerContentProps<TItem>): import("react").JSX.Element;
|
|
40
|
+
//# sourceMappingURL=PivotViewerContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PivotViewerContent.d.ts","sourceRoot":"","sources":["../../../../PivotViewer/components/PivotViewerContent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAc,SAAS,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,oBAAiB,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAU,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAkC,CAAC;AAChF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAAuB,CAAC;AAM1D,MAAM,WAAW,uBAAuB,CAAC,KAAK,SAAS,MAAM;IACzD,MAAM,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAChC,SAAS,EAAE,OAAO,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,aAAa,CAAC;IAC5B,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC1D,IAAI,EAAE,UAAU,CAAC,OAAO,uBAAuB,CAAC,KAAK,CAAC,CAAC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b,SAAS,GACZ,EAAE,uBAAuB,CAAC,KAAK,CAAC,+BAqFhC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { BASE_CARD_HEIGHT, BASE_CARD_WIDTH } from '../constants.js';
|
|
3
|
+
import { FilterPanelContainer } from './FilterPanelContainer.js';
|
|
4
|
+
import { PivotViewerMain } from './PivotViewerMain.js';
|
|
5
|
+
import { ToolbarContainer } from './ToolbarContainer.js';
|
|
6
|
+
|
|
7
|
+
function PivotViewerContent({ viewer, isLoading, viewerClassName, cssVariables, hasFilters, activeFilterCount, filterOptions, view, filter, dimension, zoom, pan, ready, visibleIds, grouping, layout, containerDimensions, resolveId, onCardClick, onCloseDetail, containerRef, filterButtonRef, axisLabelsRef, spacerRef, }) {
|
|
8
|
+
const { labels } = viewer;
|
|
9
|
+
return (jsxs("div", { className: viewerClassName, style: cssVariables, children: [jsx(FilterPanelContainer, { isOpen: view.filtersOpen && hasFilters, filterLabel: labels?.filters, searchPlaceholder: labels?.search, searchGroup: labels?.searchGroup, search: view.search, filterState: filter.filterState, rangeFilterState: filter.rangeFilterState, expandedFilterKey: filter.expandedFilterKey, filterOptions: filterOptions, anchorRef: filterButtonRef, onClose: () => view.setFiltersOpen(false), onSearchChange: view.setSearch, onFilterToggle: filter.handleToggleFilter, onFilterClear: filter.handleClearFilter, onRangeChange: filter.handleRangeChange, onExpandedFilterChange: filter.setExpandedFilterKey }), jsxs("main", { className: 'pv-main', children: [jsx(ToolbarContainer, { hasFilters: hasFilters, filtersOpen: view.filtersOpen, filteredCount: visibleIds.length, viewMode: view.viewMode, zoomLevel: zoom.zoomLevel, activeDimensionKey: dimension.activeDimensionKey, dimensions: viewer.dimensions, activeFilterCount: activeFilterCount, title: viewer.title, labels: labels, onFiltersToggle: () => view.setFiltersOpen((prev) => !prev), onViewModeChange: view.setViewMode, onZoomIn: zoom.handleZoomIn, onZoomOut: zoom.handleZoomOut, onZoomSlider: zoom.handleZoomSlider, onZoomReset: zoom.handleZoomReset, onZoomChange: zoom.handleZoomChange, onDimensionChange: dimension.setActiveDimensionKey, filterButtonRef: filterButtonRef }), jsx(PivotViewerMain, { data: viewer.data, ready: ready, isLoading: isLoading, loadingLabel: viewer.loadingLabel ?? labels?.loading ?? 'Loading…', viewportLabel: labels?.viewport ?? 'Card area', visibleIds: visibleIds, grouping: grouping, layout: layout, cardWidth: BASE_CARD_WIDTH, cardHeight: BASE_CARD_HEIGHT, zoomLevel: zoom.zoomLevel, scrollPosition: view.scrollPosition, containerDimensions: containerDimensions, selectedItem: view.selectedItem, hoveredGroupIndex: view.hoveredGroupIndex, isZooming: view.isZooming, viewMode: view.viewMode, cardRenderer: viewer.cardRenderer, colorOverrides: viewer.colors, detailRenderer: viewer.detailRenderer, resolveId: resolveId, emptyContent: viewer.emptyContent, dimensionFilter: dimension.dimensionFilter, onCardClick: onCardClick, onPanStart: pan.handlePanStart, onPanMove: pan.handlePanMove, onPanEnd: pan.handlePanEnd, onGroupHover: view.setHoveredGroupIndex, onAxisLabelClick: dimension.handleAxisLabelClick, onCloseDetail: onCloseDetail, containerRef: containerRef, axisLabelsRef: axisLabelsRef, spacerRef: spacerRef })] })] }));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { PivotViewerContent };
|
|
13
|
+
//# sourceMappingURL=PivotViewerContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PivotViewerContent.js","sources":["../../../../PivotViewer/components/PivotViewerContent.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { CSSProperties, MouseEvent, RefObject } from 'react';\nimport type { GroupingResult, ItemId, LayoutResult } from '../engine/types';\nimport type { PivotViewerProps } from '../types';\nimport type { useDimensionState } from '../hooks/useDimensionState';\nimport type { useFilterOptions } from '../hooks/useFilterOptions';\nimport type { useFilterState } from '../hooks/useFilterState';\nimport type { usePanning } from '../hooks/usePanning';\nimport type { usePivotViewerViewState } from '../hooks/usePivotViewerViewState';\nimport type { useZoomState } from '../hooks/useZoomState';\nimport { BASE_CARD_HEIGHT, BASE_CARD_WIDTH } from '../constants';\nimport { FilterPanelContainer } from './FilterPanelContainer';\nimport { PivotViewerMain } from './PivotViewerMain';\nimport { ToolbarContainer } from './ToolbarContainer';\n\nexport interface PivotViewerContentProps<TItem extends object> {\n viewer: PivotViewerProps<TItem>;\n isLoading: boolean;\n viewerClassName: string;\n cssVariables: CSSProperties;\n hasFilters: boolean;\n activeFilterCount: number;\n filterOptions: ReturnType<typeof useFilterOptions<TItem>>;\n view: ReturnType<typeof usePivotViewerViewState<TItem>>;\n filter: ReturnType<typeof useFilterState>;\n dimension: ReturnType<typeof useDimensionState<TItem>>;\n zoom: ReturnType<typeof useZoomState>;\n pan: ReturnType<typeof usePanning>;\n ready: boolean;\n visibleIds: Uint32Array;\n grouping: GroupingResult;\n layout: LayoutResult;\n containerDimensions: { width: number; height: number };\n resolveId: (item: TItem, index: number) => ItemId;\n onCardClick: (item: TItem, e: globalThis.MouseEvent, id: number | string) => void;\n onCloseDetail: () => void;\n containerRef: RefObject<HTMLDivElement>;\n filterButtonRef: RefObject<HTMLButtonElement>;\n axisLabelsRef: RefObject<HTMLDivElement>;\n spacerRef: RefObject<HTMLDivElement>;\n}\n\nexport function PivotViewerContent<TItem extends object>({\n viewer,\n isLoading,\n viewerClassName,\n cssVariables,\n hasFilters,\n activeFilterCount,\n filterOptions,\n view,\n filter,\n dimension,\n zoom,\n pan,\n ready,\n visibleIds,\n grouping,\n layout,\n containerDimensions,\n resolveId,\n onCardClick,\n onCloseDetail,\n containerRef,\n filterButtonRef,\n axisLabelsRef,\n spacerRef,\n}: PivotViewerContentProps<TItem>) {\n const { labels } = viewer;\n\n return (\n <div className={viewerClassName} style={cssVariables}>\n <FilterPanelContainer\n isOpen={view.filtersOpen && hasFilters}\n filterLabel={labels?.filters}\n searchPlaceholder={labels?.search}\n searchGroup={labels?.searchGroup}\n search={view.search}\n filterState={filter.filterState}\n rangeFilterState={filter.rangeFilterState}\n expandedFilterKey={filter.expandedFilterKey}\n filterOptions={filterOptions}\n anchorRef={filterButtonRef}\n onClose={() => view.setFiltersOpen(false)}\n onSearchChange={view.setSearch}\n onFilterToggle={filter.handleToggleFilter}\n onFilterClear={filter.handleClearFilter}\n onRangeChange={filter.handleRangeChange}\n onExpandedFilterChange={filter.setExpandedFilterKey}\n />\n\n <main className='pv-main'>\n <ToolbarContainer\n hasFilters={hasFilters}\n filtersOpen={view.filtersOpen}\n filteredCount={visibleIds.length}\n viewMode={view.viewMode}\n zoomLevel={zoom.zoomLevel}\n activeDimensionKey={dimension.activeDimensionKey}\n dimensions={viewer.dimensions}\n activeFilterCount={activeFilterCount}\n title={viewer.title}\n labels={labels}\n onFiltersToggle={() => view.setFiltersOpen((prev) => !prev)}\n onViewModeChange={view.setViewMode}\n onZoomIn={zoom.handleZoomIn}\n onZoomOut={zoom.handleZoomOut}\n onZoomSlider={zoom.handleZoomSlider}\n onZoomReset={zoom.handleZoomReset}\n onZoomChange={zoom.handleZoomChange}\n onDimensionChange={dimension.setActiveDimensionKey}\n filterButtonRef={filterButtonRef}\n />\n\n <PivotViewerMain\n data={viewer.data}\n ready={ready}\n isLoading={isLoading}\n loadingLabel={viewer.loadingLabel ?? labels?.loading ?? 'Loading…'}\n viewportLabel={labels?.viewport ?? 'Card area'}\n visibleIds={visibleIds}\n grouping={grouping}\n layout={layout}\n cardWidth={BASE_CARD_WIDTH}\n cardHeight={BASE_CARD_HEIGHT}\n zoomLevel={zoom.zoomLevel}\n scrollPosition={view.scrollPosition}\n containerDimensions={containerDimensions}\n selectedItem={view.selectedItem}\n hoveredGroupIndex={view.hoveredGroupIndex}\n isZooming={view.isZooming}\n viewMode={view.viewMode}\n cardRenderer={viewer.cardRenderer}\n colorOverrides={viewer.colors}\n detailRenderer={viewer.detailRenderer}\n resolveId={resolveId}\n emptyContent={viewer.emptyContent}\n dimensionFilter={dimension.dimensionFilter}\n onCardClick={onCardClick}\n onPanStart={pan.handlePanStart as (e: MouseEvent) => void}\n onPanMove={pan.handlePanMove as (e: MouseEvent) => void}\n onPanEnd={pan.handlePanEnd}\n onGroupHover={view.setHoveredGroupIndex}\n onAxisLabelClick={dimension.handleAxisLabelClick}\n onCloseDetail={onCloseDetail}\n containerRef={containerRef}\n axisLabelsRef={axisLabelsRef}\n spacerRef={spacerRef}\n />\n </main>\n </div>\n );\n}\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;AA4CM,SAAU,kBAAkB,CAAuB,EACrD,MAAM,EACN,SAAS,EACT,eAAe,EACf,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,IAAI,EACJ,MAAM,EACN,SAAS,EACT,IAAI,EACJ,GAAG,EACH,KAAK,EACL,UAAU,EACV,QAAQ,EACR,MAAM,EACN,mBAAmB,EACnB,SAAS,EACT,WAAW,EACX,aAAa,EACb,YAAY,EACZ,eAAe,EACf,aAAa,EACb,SAAS,GACoB,EAAA;AAC7B,IAAA,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM;IAEzB,QACIA,cAAK,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,YAAY,EAAA,QAAA,EAAA,CAChDC,GAAA,CAAC,oBAAoB,EAAA,EACjB,MAAM,EAAE,IAAI,CAAC,WAAW,IAAI,UAAU,EACtC,WAAW,EAAE,MAAM,EAAE,OAAO,EAC5B,iBAAiB,EAAE,MAAM,EAAE,MAAM,EACjC,WAAW,EAAE,MAAM,EAAE,WAAW,EAChC,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,WAAW,EAAE,MAAM,CAAC,WAAW,EAC/B,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,EACzC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,EAC3C,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,eAAe,EAC1B,OAAO,EAAE,MAAM,IAAI,CAAC,cAAc,CA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AAM,EAAE,QAAQ,IAAI,WAAW,EAC9C,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,eAAe,EAC1B,UAAU,EAAE,gBAAgB,EAC5B,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,cAAc,EAAE,IAAI,CAAC,cAAc,EACnC,mBAAmB,EAAE,mBAAmB,EACxC,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EACzC,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,YAAY,EAAE,MAAM,CAAC,YAAY,EACjC,cAAc,EAAE,MAAM,CAAC,MAAM,EAC7B,cAAc,EAAE,MAAM,CAAC,cAAc,EACrC,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,MAAM,CAAC,YAAY,EACjC,eAAe,EAAE,SAAS,CAAC,eAAe,EAC1C,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,GAAG,CAAC,cAAyC,EACzD,SAAS,EAAE,GAAG,CAAC,aAAwC,EACvD,QAAQ,EAAE,GAAG,CAAC,YAAY,EAC1B,YAAY,EAAE,IAAI,CAAC,oBAAoB,EACvC,gBAAgB,EAAE,SAAS,CAAC,oBAAoB,EAChD,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,SAAS,EAAA,CACtB,CAAA,EAAA,CACC,CAAA,EAAA,CACL;AAEd;;"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ViewMode } from '../components/Toolbar.js';
|
|
2
|
+
export interface PreSelectionState {
|
|
3
|
+
zoom: number;
|
|
4
|
+
scrollLeft: number;
|
|
5
|
+
scrollTop: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Holds the transient UI state of a PivotViewer: search text, view mode, panel visibility,
|
|
9
|
+
* selection, zoom/hover flags and scroll position.
|
|
10
|
+
* @returns The state values with their setters.
|
|
11
|
+
*/
|
|
12
|
+
export declare function usePivotViewerViewState<TItem extends object>(): {
|
|
13
|
+
search: string;
|
|
14
|
+
setSearch: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
15
|
+
viewMode: ViewMode;
|
|
16
|
+
setViewMode: import("react").Dispatch<import("react").SetStateAction<ViewMode>>;
|
|
17
|
+
filtersOpen: boolean;
|
|
18
|
+
setFiltersOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
19
|
+
selectedItem: TItem | null;
|
|
20
|
+
setSelectedItem: import("react").Dispatch<import("react").SetStateAction<TItem | null>>;
|
|
21
|
+
isZooming: boolean;
|
|
22
|
+
setIsZooming: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
23
|
+
hoveredGroupIndex: number | null;
|
|
24
|
+
setHoveredGroupIndex: import("react").Dispatch<import("react").SetStateAction<number | null>>;
|
|
25
|
+
preSelectionState: PreSelectionState | null;
|
|
26
|
+
setPreSelectionState: import("react").Dispatch<import("react").SetStateAction<PreSelectionState | null>>;
|
|
27
|
+
setAnimationMode: import("react").Dispatch<import("react").SetStateAction<"filter" | "layout">>;
|
|
28
|
+
scrollPosition: {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
};
|
|
32
|
+
setScrollPosition: import("react").Dispatch<import("react").SetStateAction<{
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
}>>;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=usePivotViewerViewState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePivotViewerViewState.d.ts","sourceRoot":"","sources":["../../../../PivotViewer/hooks/usePivotViewerViewState.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAAuB,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,SAAS,MAAM;;;;;;;;;;;;;;;;;;;;;;;;EA8B3D"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
function usePivotViewerViewState() {
|
|
4
|
+
const [search, setSearch] = useState('');
|
|
5
|
+
const [viewMode, setViewMode] = useState('collection');
|
|
6
|
+
const [filtersOpen, setFiltersOpen] = useState(false);
|
|
7
|
+
const [selectedItem, setSelectedItem] = useState(null);
|
|
8
|
+
const [isZooming, setIsZooming] = useState(false);
|
|
9
|
+
const [hoveredGroupIndex, setHoveredGroupIndex] = useState(null);
|
|
10
|
+
const [preSelectionState, setPreSelectionState] = useState(null);
|
|
11
|
+
const [, setAnimationMode] = useState('layout');
|
|
12
|
+
const [scrollPosition, setScrollPosition] = useState({ x: 0, y: 0 });
|
|
13
|
+
return {
|
|
14
|
+
search,
|
|
15
|
+
setSearch,
|
|
16
|
+
viewMode,
|
|
17
|
+
setViewMode,
|
|
18
|
+
filtersOpen,
|
|
19
|
+
setFiltersOpen,
|
|
20
|
+
selectedItem,
|
|
21
|
+
setSelectedItem,
|
|
22
|
+
isZooming,
|
|
23
|
+
setIsZooming,
|
|
24
|
+
hoveredGroupIndex,
|
|
25
|
+
setHoveredGroupIndex,
|
|
26
|
+
preSelectionState,
|
|
27
|
+
setPreSelectionState,
|
|
28
|
+
setAnimationMode,
|
|
29
|
+
scrollPosition,
|
|
30
|
+
setScrollPosition,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { usePivotViewerViewState };
|
|
35
|
+
//# sourceMappingURL=usePivotViewerViewState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePivotViewerViewState.js","sources":["../../../../PivotViewer/hooks/usePivotViewerViewState.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useState } from 'react';\nimport type { ViewMode } from '../components/Toolbar';\n\nexport interface PreSelectionState {\n zoom: number;\n scrollLeft: number;\n scrollTop: number;\n}\n\n/**\n * Holds the transient UI state of a PivotViewer: search text, view mode, panel visibility,\n * selection, zoom/hover flags and scroll position.\n * @returns The state values with their setters.\n */\nexport function usePivotViewerViewState<TItem extends object>() {\n const [search, setSearch] = useState('');\n const [viewMode, setViewMode] = useState<ViewMode>('collection');\n const [filtersOpen, setFiltersOpen] = useState(false);\n const [selectedItem, setSelectedItem] = useState<TItem | null>(null);\n const [isZooming, setIsZooming] = useState(false);\n const [hoveredGroupIndex, setHoveredGroupIndex] = useState<number | null>(null);\n const [preSelectionState, setPreSelectionState] = useState<PreSelectionState | null>(null);\n const [, setAnimationMode] = useState<'layout' | 'filter'>('layout');\n const [scrollPosition, setScrollPosition] = useState({ x: 0, y: 0 });\n\n return {\n search,\n setSearch,\n viewMode,\n setViewMode,\n filtersOpen,\n setFiltersOpen,\n selectedItem,\n setSelectedItem,\n isZooming,\n setIsZooming,\n hoveredGroupIndex,\n setHoveredGroupIndex,\n preSelectionState,\n setPreSelectionState,\n setAnimationMode,\n scrollPosition,\n setScrollPosition,\n };\n}\n"],"names":[],"mappings":";;SAiBgB,uBAAuB,GAAA;IACnC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC;IACxC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAW,YAAY,CAAC;IAChE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IACrD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC;IACpE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IACjD,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC;IAC/E,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,QAAQ,CAA2B,IAAI,CAAC;IAC1F,MAAM,GAAG,gBAAgB,CAAC,GAAG,QAAQ,CAAsB,QAAQ,CAAC;AACpE,IAAA,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAEpE,OAAO;QACH,MAAM;QACN,SAAS;QACT,QAAQ;QACR,WAAW;QACX,WAAW;QACX,cAAc;QACd,YAAY;QACZ,eAAe;QACf,SAAS;QACT,YAAY;QACZ,iBAAiB;QACjB,oBAAoB;QACpB,iBAAiB;QACjB,oBAAoB;QACpB,gBAAgB;QAChB,cAAc;QACd,iBAAiB;KACpB;AACL;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Event } from './types.js';
|
|
2
|
+
/** Props for {@link EventCard}. */
|
|
3
|
+
export interface EventCardProps {
|
|
4
|
+
event: Event;
|
|
5
|
+
position: 'left' | 'right';
|
|
6
|
+
}
|
|
7
|
+
/** The card of one timeline event: type, timestamp and properties. */
|
|
8
|
+
export declare const EventCard: ({ event, position }: EventCardProps) => import("react").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=EventCard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventCard.d.ts","sourceRoot":"","sources":["../../../TimeMachine/EventCard.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAS,CAAC;AAErC,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC3B,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC9B;AAKD,sEAAsE;AACtE,eAAO,MAAM,SAAS,wBAAyB,cAAc,gCAc5D,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Properties } from './Properties.js';
|
|
3
|
+
|
|
4
|
+
const alignedClass = (base, position) => `${base} ${position === 'left' ? `${base}--right` : ''}`;
|
|
5
|
+
const EventCard = ({ event, position }) => (jsxs("div", { className: `events-view-event-card events-view-event-card--${position}`, children: [jsxs("div", { className: alignedClass('events-view-event-header', position), children: [jsx("h3", { className: alignedClass('events-view-event-name', position), children: event.type }), jsx("div", { className: alignedClass('events-view-event-timestamp', position), children: event.occurred.toLocaleString() })] }), jsx("div", { className: 'events-view-event-properties', children: jsx(Properties, { data: event.content || {}, align: 'left' }) })] }));
|
|
6
|
+
|
|
7
|
+
export { EventCard };
|
|
8
|
+
//# sourceMappingURL=EventCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventCard.js","sources":["../../../TimeMachine/EventCard.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Properties } from './Properties';\nimport type { Event } from './types';\n\n/** Props for {@link EventCard}. */\nexport interface EventCardProps {\n event: Event;\n position: 'left' | 'right';\n}\n\nconst alignedClass = (base: string, position: 'left' | 'right') =>\n `${base} ${position === 'left' ? `${base}--right` : ''}`;\n\n/** The card of one timeline event: type, timestamp and properties. */\nexport const EventCard = ({ event, position }: EventCardProps) => (\n <div className={`events-view-event-card events-view-event-card--${position}`}>\n <div className={alignedClass('events-view-event-header', position)}>\n <h3 className={alignedClass('events-view-event-name', position)}>\n {event.type}\n </h3>\n <div className={alignedClass('events-view-event-timestamp', position)}>\n {event.occurred.toLocaleString()}\n </div>\n </div>\n <div className='events-view-event-properties'>\n <Properties data={event.content || {}} align='left' />\n </div>\n </div>\n);\n"],"names":["_jsxs","_jsx"],"mappings":";;;AAYA,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,QAA0B,KAC1D,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,QAAQ,KAAK,MAAM,GAAG,CAAA,EAAG,IAAI,CAAA,OAAA,CAAS,GAAG,EAAE,CAAA,CAAE;AAGrD,MAAM,SAAS,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAkB,MACzDA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,CAAA,+CAAA,EAAkD,QAAQ,CAAA,CAAE,EAAA,QAAA,EAAA,CACxEA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,YAAY,CAAC,0BAA0B,EAAE,QAAQ,CAAC,EAAA,QAAA,EAAA,CAC9DC,GAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAE,YAAY,CAAC,wBAAwB,EAAE,QAAQ,CAAC,EAAA,QAAA,EAC1D,KAAK,CAAC,IAAI,EAAA,CACV,EACLA,aAAK,SAAS,EAAE,YAAY,CAAC,6BAA6B,EAAE,QAAQ,CAAC,YAChE,KAAK,CAAC,QAAQ,CAAC,cAAc,EAAE,EAAA,CAC9B,CAAA,EAAA,CACJ,EACNA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,8BAA8B,YACzCA,GAAA,CAAC,UAAU,IAAC,IAAI,EAAE,KAAK,CAAC,OAAO,IAAI,EAAE,EAAE,KAAK,EAAC,MAAM,GAAG,EAAA,CACpD,CAAA,EAAA,CACJ;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EventsViewParts } from './EventsView.js';
|
|
2
|
+
/** Props for {@link EventSeparator}. */
|
|
3
|
+
export interface EventSeparatorProps {
|
|
4
|
+
isSelected: boolean | undefined;
|
|
5
|
+
/** Whether a connector line follows the marker. */
|
|
6
|
+
hasConnector: boolean;
|
|
7
|
+
pt?: EventsViewParts;
|
|
8
|
+
}
|
|
9
|
+
/** The timeline spine segment of one event: its marker and the connector to the next event. */
|
|
10
|
+
export declare const EventSeparator: ({ isSelected, hasConnector, pt }: EventSeparatorProps) => import("react").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=EventSeparator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventSeparator.d.ts","sourceRoot":"","sources":["../../../TimeMachine/EventSeparator.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAc,CAAC;AAEpD,wCAAwC;AACxC,MAAM,WAAW,mBAAmB;IAChC,UAAU,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,mDAAmD;IACnD,YAAY,EAAE,OAAO,CAAC;IACtB,EAAE,CAAC,EAAE,eAAe,CAAC;CACxB;AAED,+FAA+F;AAC/F,eAAO,MAAM,cAAc,qCAAsC,mBAAmB,gCAsBnF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { classNames } from '../ClassNames/classNames.js';
|
|
3
|
+
|
|
4
|
+
const EventSeparator = ({ isSelected, hasConnector, pt }) => (jsxs("div", { ...pt?.separator, className: classNames('events-view-timeline-separator', pt?.separator?.className), "data-cratis-part": 'separator', children: [jsx("div", { ...pt?.marker, className: classNames('events-view-marker', pt?.marker?.className), "data-cratis-part": 'marker', "data-selected": isSelected || undefined, children: jsx("div", { className: 'events-view-marker-dot' }) }), hasConnector && (jsx("div", { ...pt?.connector, className: classNames('events-view-timeline-connector', pt?.connector?.className), "data-cratis-part": 'connector' }))] }));
|
|
5
|
+
|
|
6
|
+
export { EventSeparator };
|
|
7
|
+
//# sourceMappingURL=EventSeparator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventSeparator.js","sources":["../../../TimeMachine/EventSeparator.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { classNames } from '../ClassNames/classNames';\nimport type { EventsViewParts } from './EventsView';\n\n/** Props for {@link EventSeparator}. */\nexport interface EventSeparatorProps {\n isSelected: boolean | undefined;\n /** Whether a connector line follows the marker. */\n hasConnector: boolean;\n pt?: EventsViewParts;\n}\n\n/** The timeline spine segment of one event: its marker and the connector to the next event. */\nexport const EventSeparator = ({ isSelected, hasConnector, pt }: EventSeparatorProps) => (\n <div\n {...pt?.separator}\n className={classNames('events-view-timeline-separator', pt?.separator?.className)}\n data-cratis-part='separator'\n >\n <div\n {...pt?.marker}\n className={classNames('events-view-marker', pt?.marker?.className)}\n data-cratis-part='marker'\n data-selected={isSelected || undefined}\n >\n <div className='events-view-marker-dot' />\n </div>\n {hasConnector && (\n <div\n {...pt?.connector}\n className={classNames('events-view-timeline-connector', pt?.connector?.className)}\n data-cratis-part='connector'\n />\n )}\n </div>\n);\n"],"names":["_jsxs","_jsx"],"mappings":";;;MAea,cAAc,GAAG,CAAC,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,EAAuB,MAChFA,iBACQ,EAAE,EAAE,SAAS,EACjB,SAAS,EAAE,UAAU,CAAC,gCAAgC,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,EAAA,kBAAA,EAChE,WAAW,EAAA,QAAA,EAAA,CAE5BC,GAAA,CAAA,KAAA,EAAA,EAAA,GACQ,EAAE,EAAE,MAAM,EACd,SAAS,EAAE,UAAU,CAAC,oBAAoB,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,EAAA,kBAAA,EACjD,QAAQ,mBACV,UAAU,IAAI,SAAS,EAAA,QAAA,EAEtCA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,wBAAwB,GAAG,EAAA,CACxC,EACL,YAAY,KACTA,gBACQ,EAAE,EAAE,SAAS,EACjB,SAAS,EAAE,UAAU,CAAC,gCAAgC,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,EAAA,kBAAA,EAChE,WAAW,EAAA,CAC9B,CACL,CAAA,EAAA,CACC;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EventsViewParts } from './EventsView.js';
|
|
2
|
+
import type { Event } from './types.js';
|
|
3
|
+
/** Props for {@link EventTimelineItem}. */
|
|
4
|
+
export interface EventTimelineItemProps {
|
|
5
|
+
event: Event;
|
|
6
|
+
position: 'left' | 'right';
|
|
7
|
+
isSelected: boolean | undefined;
|
|
8
|
+
/** Whether a connector line follows this event. */
|
|
9
|
+
hasConnector: boolean;
|
|
10
|
+
pt?: EventsViewParts;
|
|
11
|
+
}
|
|
12
|
+
/** One event on the timeline: separator with marker and connector, and the event card. */
|
|
13
|
+
export declare const EventTimelineItem: ({ event, position, isSelected, hasConnector, pt }: EventTimelineItemProps) => import("react").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=EventTimelineItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventTimelineItem.d.ts","sourceRoot":"","sources":["../../../TimeMachine/EventTimelineItem.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAc,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAS,CAAC;AAErC,2CAA2C;AAC3C,MAAM,WAAW,sBAAsB;IACnC,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,UAAU,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,mDAAmD;IACnD,YAAY,EAAE,OAAO,CAAC;IACtB,EAAE,CAAC,EAAE,eAAe,CAAC;CACxB;AAED,0FAA0F;AAC1F,eAAO,MAAM,iBAAiB,sDAAuD,sBAAsB,gCAiB1G,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { classNames } from '../ClassNames/classNames.js';
|
|
3
|
+
import { EventCard } from './EventCard.js';
|
|
4
|
+
import { EventSeparator } from './EventSeparator.js';
|
|
5
|
+
|
|
6
|
+
const EventTimelineItem = ({ event, position, isSelected, hasConnector, pt }) => (jsxs("article", { ...pt?.event, className: classNames('events-view-timeline-event', pt?.event?.className), "data-cratis-part": 'event', "data-position": position, "data-selected": isSelected || undefined, children: [jsx(EventSeparator, { isSelected: isSelected, hasConnector: hasConnector, pt: pt }), jsx("div", { ...pt?.content, className: classNames('events-view-timeline-content', pt?.content?.className), "data-cratis-part": 'content', children: jsx(EventCard, { event: event, position: position }) })] }));
|
|
7
|
+
|
|
8
|
+
export { EventTimelineItem };
|
|
9
|
+
//# sourceMappingURL=EventTimelineItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventTimelineItem.js","sources":["../../../TimeMachine/EventTimelineItem.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { classNames } from '../ClassNames/classNames';\nimport { EventCard } from './EventCard';\nimport { EventSeparator } from './EventSeparator';\nimport type { EventsViewParts } from './EventsView';\nimport type { Event } from './types';\n\n/** Props for {@link EventTimelineItem}. */\nexport interface EventTimelineItemProps {\n event: Event;\n position: 'left' | 'right';\n isSelected: boolean | undefined;\n /** Whether a connector line follows this event. */\n hasConnector: boolean;\n pt?: EventsViewParts;\n}\n\n/** One event on the timeline: separator with marker and connector, and the event card. */\nexport const EventTimelineItem = ({ event, position, isSelected, hasConnector, pt }: EventTimelineItemProps) => (\n <article\n {...pt?.event}\n className={classNames('events-view-timeline-event', pt?.event?.className)}\n data-cratis-part='event'\n data-position={position}\n data-selected={isSelected || undefined}\n >\n <EventSeparator isSelected={isSelected} hasConnector={hasConnector} pt={pt} />\n <div\n {...pt?.content}\n className={classNames('events-view-timeline-content', pt?.content?.className)}\n data-cratis-part='content'\n >\n <EventCard event={event} position={position} />\n </div>\n </article>\n);\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;MAoBa,iBAAiB,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,EAA0B,MACvGA,IAAA,CAAA,SAAA,EAAA,EAAA,GACQ,EAAE,EAAE,KAAK,EACb,SAAS,EAAE,UAAU,CAAC,4BAA4B,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,EAAA,kBAAA,EACxD,OAAO,EAAA,eAAA,EACT,QAAQ,mBACR,UAAU,IAAI,SAAS,EAAA,QAAA,EAAA,CAEtCC,GAAA,CAAC,cAAc,IAAC,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,EAAE,EAAE,EAAE,GAAI,EAC9EA,GAAA,CAAA,KAAA,EAAA,EAAA,GACQ,EAAE,EAAE,OAAO,EACf,SAAS,EAAE,UAAU,CAAC,8BAA8B,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,CAAC,sBAC5D,SAAS,EAAA,QAAA,EAE1BA,IAAC,SAAS,EAAA,EAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAA,CAAI,EAAA,CAC7C,CAAA,EAAA,CACA;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Props for {@link EventsScrollButton}. */
|
|
2
|
+
export interface EventsScrollButtonProps {
|
|
3
|
+
/** Which edge of the timeline the button scrolls to. */
|
|
4
|
+
edge: 'top' | 'bottom';
|
|
5
|
+
label: string;
|
|
6
|
+
onClick: () => void;
|
|
7
|
+
}
|
|
8
|
+
/** A button floating at one edge of the events timeline that scrolls to that edge. */
|
|
9
|
+
export declare const EventsScrollButton: ({ edge, label, onClick }: EventsScrollButtonProps) => import("react").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=EventsScrollButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventsScrollButton.d.ts","sourceRoot":"","sources":["../../../TimeMachine/EventsScrollButton.tsx"],"names":[],"mappings":"AAGA,4CAA4C;AAC5C,MAAM,WAAW,uBAAuB;IACpC,wDAAwD;IACxD,IAAI,EAAE,KAAK,GAAG,QAAQ,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,sFAAsF;AACtF,eAAO,MAAM,kBAAkB,6BAA8B,uBAAuB,gCAWnF,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
const EventsScrollButton = ({ edge, label, onClick }) => (jsx("div", { className: `events-view-scroll-button-wrapper events-view-scroll-button-wrapper--${edge}`, children: jsx("button", { type: 'button', className: `events-view-scroll-button events-view-scroll-button--${edge}`, onClick: onClick, "aria-label": label, children: edge === 'top' ? '↑' : '↓' }) }));
|
|
4
|
+
|
|
5
|
+
export { EventsScrollButton };
|
|
6
|
+
//# sourceMappingURL=EventsScrollButton.js.map
|