@seanyeh77/ui 0.45.0 → 0.47.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/bundle.js +19 -19
- package/dist/components/Alert/Alert.d.ts +2 -1
- package/dist/components/Alert/Alert.js +15 -17
- package/dist/components/Alert/Alert.js.map +1 -1
- package/dist/components/AppShell/AppShell.d.ts +3 -3
- package/dist/components/AppShell/AppShell.js +9 -10
- package/dist/components/AppShell/AppShell.js.map +1 -1
- package/dist/components/Badge/Badge.d.ts +4 -4
- package/dist/components/Badge/Badge.js +7 -1
- package/dist/components/Badge/Badge.js.map +1 -1
- package/dist/components/Breadcrumb/Breadcrumb.js +1 -0
- package/dist/components/Breadcrumb/Breadcrumb.js.map +1 -1
- package/dist/components/Calendar/Calendar.js +6 -2
- package/dist/components/Calendar/Calendar.js.map +1 -1
- package/dist/components/ConsoleLayout/ConsoleLayout.js +15 -12
- package/dist/components/ConsoleLayout/ConsoleLayout.js.map +1 -1
- package/dist/components/DataTable/DataTable.d.ts +8 -0
- package/dist/components/DataTable/DataTable.js +188 -34
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/DataTable/filters.js +10 -4
- package/dist/components/DataTable/filters.js.map +1 -1
- package/dist/components/DatePicker/DatePicker.js +1 -0
- package/dist/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.js +1 -0
- package/dist/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/components/DetailList/DetailList.d.ts +8 -1
- package/dist/components/DetailList/DetailList.js +16 -2
- package/dist/components/DetailList/DetailList.js.map +1 -1
- package/dist/components/EmptyState/EmptyState.js +19 -1
- package/dist/components/EmptyState/EmptyState.js.map +1 -1
- package/dist/components/EventTimeline/EventTimeline.js +6 -3
- package/dist/components/EventTimeline/EventTimeline.js.map +1 -1
- package/dist/components/FileUpload/FileUpload.js +2 -2
- package/dist/components/FileUpload/FileUpload.js.map +1 -1
- package/dist/components/Grid/Grid.d.ts +5 -2
- package/dist/components/Grid/Grid.js +4 -3
- package/dist/components/Grid/Grid.js.map +1 -1
- package/dist/components/InlineCode/InlineCode.js +7 -6
- package/dist/components/InlineCode/InlineCode.js.map +1 -1
- package/dist/components/KpiCard/KpiCard.d.ts +6 -4
- package/dist/components/KpiCard/KpiCard.js +6 -12
- package/dist/components/KpiCard/KpiCard.js.map +1 -1
- package/dist/components/LayerGraph/LayerGraph.js +47 -13
- package/dist/components/LayerGraph/LayerGraph.js.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.js +73 -45
- package/dist/components/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/components/NotificationBell/NotificationBell.d.ts +6 -3
- package/dist/components/NotificationBell/NotificationBell.js +14 -3
- package/dist/components/NotificationBell/NotificationBell.js.map +1 -1
- package/dist/components/PageHeader/PageHeader.d.ts +3 -2
- package/dist/components/PageHeader/PageHeader.js +10 -1
- package/dist/components/PageHeader/PageHeader.js.map +1 -1
- package/dist/components/RelativeTime/RelativeTime.js +4 -3
- package/dist/components/RelativeTime/RelativeTime.js.map +1 -1
- package/dist/components/Select/Select.js +1 -1
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/SettingsLayout/SettingsLayout.d.ts +6 -4
- package/dist/components/SettingsLayout/SettingsLayout.js +38 -11
- package/dist/components/SettingsLayout/SettingsLayout.js.map +1 -1
- package/dist/components/SideNav/SideNav.d.ts +10 -5
- package/dist/components/SideNav/SideNav.js +10 -6
- package/dist/components/SideNav/SideNav.js.map +1 -1
- package/dist/components/SplitPane/SplitPane.d.ts +2 -2
- package/dist/components/SplitPane/SplitPane.js +29 -9
- package/dist/components/SplitPane/SplitPane.js.map +1 -1
- package/dist/components/TextField/TextField.d.ts +8 -2
- package/dist/components/TextField/TextField.js +59 -13
- package/dist/components/TextField/TextField.js.map +1 -1
- package/dist/components/TopBar/TopBar.d.ts +2 -2
- package/dist/components/TopBar/TopBar.js.map +1 -1
- package/dist/components/Workbench/Workbench.d.ts +8 -5
- package/dist/components/Workbench/Workbench.js +184 -157
- package/dist/components/Workbench/Workbench.js.map +1 -1
- package/dist/components/ZoneMap/ZoneMap.js +4 -4
- package/dist/components/ZoneMap/ZoneMap.js.map +1 -1
- package/dist/components/useFormErrors/useFormErrors.d.ts +5 -2
- package/dist/components/useFormErrors/useFormErrors.js +10 -4
- package/dist/components/useFormErrors/useFormErrors.js.map +1 -1
- package/dist/css/AccentPicker.css +19 -0
- package/dist/css/Alert.css +30 -7
- package/dist/css/AppShell.css +12 -0
- package/dist/css/Calendar.css +7 -0
- package/dist/css/ConsoleLayout.css +3 -0
- package/dist/css/DataTable.css +70 -8
- package/dist/css/DetailList.css +11 -0
- package/dist/css/EmptyState.css +8 -0
- package/dist/css/EventTimeline.css +11 -4
- package/dist/css/Grid.css +15 -0
- package/dist/css/KpiCard.css +1 -0
- package/dist/css/LayerGraph.css +1 -1
- package/dist/css/LoadingBar.css +4 -1
- package/dist/css/LoginCard.css +1 -1
- package/dist/css/MobileTabBar.css +6 -4
- package/dist/css/MultiSelect.css +23 -3
- package/dist/css/Select.css +9 -0
- package/dist/css/SettingsLayout.css +29 -14
- package/dist/css/Tabs.css +36 -17
- package/dist/css/Toast.css +7 -0
- package/dist/css/TopBar.css +6 -3
- package/dist/css/Workbench.css +10 -5
- package/dist/css/base.css +90 -3
- package/dist/css/end.css +5 -2
- package/dist/fonts-latin.css +2 -0
- package/dist/fonts-tc.css +2 -0
- package/dist/format.d.ts +4 -3
- package/dist/format.js +13 -12
- package/dist/format.js.map +1 -1
- package/dist/i18n.js +17 -6
- package/dist/i18n.js.map +1 -1
- package/dist/icons/Icon.d.ts +2 -1
- package/dist/icons/Icon.js +4 -3
- package/dist/icons/Icon.js.map +1 -1
- package/dist/icons/all.js +23 -1
- package/dist/icons/all.js.map +1 -1
- package/dist/icons/names.d.ts +22 -0
- package/dist/icons/names.js +11 -0
- package/dist/icons/names.js.map +1 -1
- package/dist/icons/ph/credit-card.d.ts +10 -0
- package/dist/icons/ph/credit-card.js +11 -0
- package/dist/icons/ph/credit-card.js.map +1 -0
- package/dist/icons/ph/map-pin.d.ts +10 -0
- package/dist/icons/ph/map-pin.js +11 -0
- package/dist/icons/ph/map-pin.js.map +1 -0
- package/dist/icons/ph/package.d.ts +10 -0
- package/dist/icons/ph/package.js +11 -0
- package/dist/icons/ph/package.js.map +1 -0
- package/dist/icons/ph/pause.d.ts +10 -0
- package/dist/icons/ph/pause.js +11 -0
- package/dist/icons/ph/pause.js.map +1 -0
- package/dist/icons/ph/phone.d.ts +10 -0
- package/dist/icons/ph/phone.js +11 -0
- package/dist/icons/ph/phone.js.map +1 -0
- package/dist/icons/ph/play.d.ts +10 -0
- package/dist/icons/ph/play.js +11 -0
- package/dist/icons/ph/play.js.map +1 -0
- package/dist/icons/ph/prohibit.d.ts +10 -0
- package/dist/icons/ph/prohibit.js +11 -0
- package/dist/icons/ph/prohibit.js.map +1 -0
- package/dist/icons/ph/receipt.d.ts +10 -0
- package/dist/icons/ph/receipt.js +11 -0
- package/dist/icons/ph/receipt.js.map +1 -0
- package/dist/icons/ph/shopping-cart.d.ts +10 -0
- package/dist/icons/ph/shopping-cart.js +11 -0
- package/dist/icons/ph/shopping-cart.js.map +1 -0
- package/dist/icons/ph/storefront.d.ts +10 -0
- package/dist/icons/ph/storefront.js +11 -0
- package/dist/icons/ph/storefront.js.map +1 -0
- package/dist/icons/ph/truck.d.ts +10 -0
- package/dist/icons/ph/truck.js +11 -0
- package/dist/icons/ph/truck.js.map +1 -0
- package/dist/icons/store.d.ts +3 -1
- package/dist/icons/store.js +17 -12
- package/dist/icons/store.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/internal/FloatingPanel.js +5 -2
- package/dist/internal/FloatingPanel.js.map +1 -1
- package/dist/internal/clickSteps.js +11 -0
- package/dist/internal/clickSteps.js.map +1 -0
- package/dist/internal/util.js +7 -1
- package/dist/internal/util.js.map +1 -1
- package/dist/styles.css +499 -162
- package/dist/theme.d.ts +7 -0
- package/dist/theme.js +39 -15
- package/dist/theme.js.map +1 -1
- package/docs/Alert.md +1 -1
- package/docs/AppShell.md +4 -4
- package/docs/Badge.md +2 -1
- package/docs/BarChart.md +1 -1
- package/docs/Checkbox.md +2 -2
- package/docs/CodeView.md +12 -22
- package/docs/ConsoleLayout.md +1 -0
- package/docs/DataTable.md +16 -11
- package/docs/DatePicker.md +1 -1
- package/docs/DateRangePicker.md +1 -0
- package/docs/DetailList.md +12 -1
- package/docs/Drawer.md +1 -1
- package/docs/EmptyState.md +1 -0
- package/docs/EventTimeline.md +1 -1
- package/docs/Format.md +2 -1
- package/docs/Graph.md +1 -0
- package/docs/Grid.md +9 -0
- package/docs/KpiCard.md +5 -4
- package/docs/LoadingBar.md +1 -1
- package/docs/LoginCard.md +1 -1
- package/docs/Markdown.md +4 -37
- package/docs/MobileTabBar.md +1 -1
- package/docs/MultiSelect.md +3 -2
- package/docs/NotificationBell.md +2 -2
- package/docs/PageHeader.md +2 -1
- package/docs/RadioGroup.md +1 -1
- package/docs/RelativeTime.md +2 -2
- package/docs/SettingsLayout.md +5 -4
- package/docs/SideNav.md +2 -1
- package/docs/Skeleton.md +2 -2
- package/docs/SplitPane.md +3 -9
- package/docs/Tabs.md +14 -11
- package/docs/Tag.md +4 -3
- package/docs/TextField.md +2 -0
- package/docs/Toast.md +1 -1
- package/docs/TopBar.md +2 -2
- package/docs/Workbench.md +9 -6
- package/docs/agents.md +13 -13
- package/docs/data.md +2 -1
- package/docs/guidelines.md +4 -4
- package/docs/icons.md +2 -2
- package/docs/layout.md +3 -3
- package/docs/theme.md +6 -3
- package/docs/useFormErrors.md +2 -1
- package/package.json +4 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineCode.js","names":[],"sources":["../../../src/components/InlineCode/InlineCode.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cx } from '../../internal/util';\nimport { codeSpans, hasCodeSpan } from '../../internal/codeSpans';\n\ninterface InlineCodeBase {\n /** The code, path or ID. */\n children?: React.ReactNode;\n /** Extra class on the root element. */\n className?: string;\n}\ntype Target =\n | { /** Makes it a link. */ href: string; onClick?: (e: React.MouseEvent<HTMLElement>) => void }\n | { href?: undefined; onClick: (e: React.MouseEvent<HTMLElement>) => void };\n\nexport type InlineCodeProps = InlineCodeBase &\n (\n | {\n /** 'chip' (default): monospace on a light gray chip; with href or onClick an underlined accent link. */\n look?: 'chip';\n /** Makes it a link. */\n href?: string;\n /** Makes it a button-like link that runs this. */\n onClick?: (e: React.MouseEvent<HTMLElement>) => void;\n }\n | ({\n /** 'name': a function, class or variable that opens its definition. Accent monospace without a chip, underlined\n * on hover and keyboard focus. 'location': a file and line (src/app.c:86), gray and one step smaller, accent\n * and underlined on hover and focus. Both need href or onClick: text that points nowhere keeps the chip. */\n look: 'name' | 'location';\n } & Target)\n );\n\n/** Code inside a sentence: monospace on a light gray chip. A span that points somewhere is a link; `look` turns a\n * link into a name or a location. */\nexport function InlineCode({ children, href, onClick, className, look = 'chip' }: InlineCodeProps) {\n // Like Term: a link inside a sentence (text beside it) keeps its line height; on its own it gets the 48 px touch area.\n const [inline, setInline] = React.useState(false);\n const link = React.useCallback((el: HTMLElement | null) => {\n const par = el?.parentNode;\n setInline(!!par && Array.from(par.childNodes).some((n) => n.nodeType === 3 && !!n.textContent?.trim()));\n }, []);\n const isLink = !!(href || onClick);\n const cls = cx(\n 'ui-code',\n isLink && 'is-link',\n isLink && inline && 'is-inline',\n isLink && look !== 'chip' && `is-${look}`,\n typeof children === 'string' && children.length <= 24 && 'is-short',\n className,\n );\n if (href)\n return (\n <a ref={link} className={cls} href={href} onClick={onClick}>\n {children}\n </a>\n );\n if (onClick)\n return (\n <button ref={link} type=\"button\" className={cls} onClick={onClick}>\n {children}\n </button>\n );\n return <code className={cls}>{children}</code>;\n}\n\n/** Returns the link of a reference such as src/app.c:86, or undefined when it has no target. */\nexport type RefHref = (ref: string) => string | undefined | null;\n/** Called on a plain click on a reference; the default navigation is prevented. */\nexport type OnRef = (ref: string, e: React.MouseEvent<HTMLElement>) => void;\n\n/** A file and line, such as src/app.c:86 or main.py:12-20. */\nconst CODE_REF = /^[\\w./-]+\\.[A-Za-z0-9]+:\\d+(-\\d+)?$/;\nexport const isCodeRef = (span: string): boolean => CODE_REF.test(span);\n\nexport interface CodeTextProps {\n /** Text with `backtick` spans, as written in Markdown. */\n text: string;\n /** Spans that look like file.c:86 become links; return undefined when the reference has no target. */\n refHref?: RefHref;\n /** Called when a reference is pressed, for apps that open it themselves. */\n onRef?: OnRef;\n /** Which spans are references. Default: a file name with a line number. */\n isRef?: (span: string) => boolean;\n /** The element to render. Default span. */\n as?: 'span' | 'p' | 'div' | 'li';\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** Text with `backtick` spans: renders them as InlineCode, never as raw backticks. */\nexport function CodeText({ text, refHref, onRef, isRef = isCodeRef, as: Tag = 'span', className }: CodeTextProps) {\n return (\n <Tag className={className}>\n {codeSpans(text).map(({ code, text: v }, i) => {\n if (!code) return v;\n const href = refHref && isRef(v) ? refHref(v) || undefined : undefined;\n const link = isRef(v) && (refHref ? !!href : !!onRef);\n if (!link) return <InlineCode key={i}>{v}</InlineCode>;\n // A reference that points somewhere is a location: gray, one step smaller.\n const click = onRef\n ? (e: React.MouseEvent<HTMLElement>) => {\n // A plain click goes to onRef; Ctrl, ⌘, Shift or the middle button still opens href in a new tab.\n if (href && (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1)) return;\n e.preventDefault();\n onRef(v, e);\n }\n : undefined;\n if (href)\n return (\n <InlineCode key={i} look=\"location\" href={href} onClick={click}>\n {v}\n </InlineCode>\n );\n if (click)\n return (\n <InlineCode key={i} look=\"location\" onClick={click}>\n {v}\n </InlineCode>\n );\n return <InlineCode key={i}>{v}</InlineCode>;\n })}\n </Tag>\n );\n}\n\n/** A sentence prop that takes a string: `backtick` spans become InlineCode, the backticks are not shown
|
|
1
|
+
{"version":3,"file":"InlineCode.js","names":[],"sources":["../../../src/components/InlineCode/InlineCode.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cx, keepUnits } from '../../internal/util';\nimport { codeSpans, hasCodeSpan } from '../../internal/codeSpans';\n\ninterface InlineCodeBase {\n /** The code, path or ID. */\n children?: React.ReactNode;\n /** Extra class on the root element. */\n className?: string;\n}\ntype Target =\n | { /** Makes it a link. */ href: string; onClick?: (e: React.MouseEvent<HTMLElement>) => void }\n | { href?: undefined; onClick: (e: React.MouseEvent<HTMLElement>) => void };\n\nexport type InlineCodeProps = InlineCodeBase &\n (\n | {\n /** 'chip' (default): monospace on a light gray chip; with href or onClick an underlined accent link. */\n look?: 'chip';\n /** Makes it a link. */\n href?: string;\n /** Makes it a button-like link that runs this. */\n onClick?: (e: React.MouseEvent<HTMLElement>) => void;\n }\n | ({\n /** 'name': a function, class or variable that opens its definition. Accent monospace without a chip, underlined\n * on hover and keyboard focus. 'location': a file and line (src/app.c:86), gray and one step smaller, accent\n * and underlined on hover and focus. Both need href or onClick: text that points nowhere keeps the chip. */\n look: 'name' | 'location';\n } & Target)\n );\n\n/** Code inside a sentence: monospace on a light gray chip. A span that points somewhere is a link; `look` turns a\n * link into a name or a location. */\nexport function InlineCode({ children, href, onClick, className, look = 'chip' }: InlineCodeProps) {\n // Like Term: a link inside a sentence (text beside it) keeps its line height; on its own it gets the 48 px touch area.\n const [inline, setInline] = React.useState(false);\n const link = React.useCallback((el: HTMLElement | null) => {\n const par = el?.parentNode;\n setInline(!!par && Array.from(par.childNodes).some((n) => n.nodeType === 3 && !!n.textContent?.trim()));\n }, []);\n const isLink = !!(href || onClick);\n const cls = cx(\n 'ui-code',\n isLink && 'is-link',\n isLink && inline && 'is-inline',\n isLink && look !== 'chip' && `is-${look}`,\n typeof children === 'string' && children.length <= 24 && 'is-short',\n className,\n );\n if (href)\n return (\n <a ref={link} className={cls} href={href} onClick={onClick}>\n {children}\n </a>\n );\n if (onClick)\n return (\n <button ref={link} type=\"button\" className={cls} onClick={onClick}>\n {children}\n </button>\n );\n return <code className={cls}>{children}</code>;\n}\n\n/** Returns the link of a reference such as src/app.c:86, or undefined when it has no target. */\nexport type RefHref = (ref: string) => string | undefined | null;\n/** Called on a plain click on a reference; the default navigation is prevented. */\nexport type OnRef = (ref: string, e: React.MouseEvent<HTMLElement>) => void;\n\n/** A file and line, such as src/app.c:86 or main.py:12-20. */\nconst CODE_REF = /^[\\w./-]+\\.[A-Za-z0-9]+:\\d+(-\\d+)?$/;\nexport const isCodeRef = (span: string): boolean => CODE_REF.test(span);\n\nexport interface CodeTextProps {\n /** Text with `backtick` spans, as written in Markdown. */\n text: string;\n /** Spans that look like file.c:86 become links; return undefined when the reference has no target. */\n refHref?: RefHref;\n /** Called when a reference is pressed, for apps that open it themselves. */\n onRef?: OnRef;\n /** Which spans are references. Default: a file name with a line number. */\n isRef?: (span: string) => boolean;\n /** The element to render. Default span. */\n as?: 'span' | 'p' | 'div' | 'li';\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** Text with `backtick` spans: renders them as InlineCode, never as raw backticks. */\nexport function CodeText({ text, refHref, onRef, isRef = isCodeRef, as: Tag = 'span', className }: CodeTextProps) {\n return (\n <Tag className={className}>\n {codeSpans(text).map(({ code, text: v }, i) => {\n if (!code) return keepUnits(v);\n const href = refHref && isRef(v) ? refHref(v) || undefined : undefined;\n const link = isRef(v) && (refHref ? !!href : !!onRef);\n if (!link) return <InlineCode key={i}>{v}</InlineCode>;\n // A reference that points somewhere is a location: gray, one step smaller.\n const click = onRef\n ? (e: React.MouseEvent<HTMLElement>) => {\n // A plain click goes to onRef; Ctrl, ⌘, Shift or the middle button still opens href in a new tab.\n if (href && (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1)) return;\n e.preventDefault();\n onRef(v, e);\n }\n : undefined;\n if (href)\n return (\n <InlineCode key={i} look=\"location\" href={href} onClick={click}>\n {v}\n </InlineCode>\n );\n if (click)\n return (\n <InlineCode key={i} look=\"location\" onClick={click}>\n {v}\n </InlineCode>\n );\n return <InlineCode key={i}>{v}</InlineCode>;\n })}\n </Tag>\n );\n}\n\n/** A sentence prop that takes a string: `backtick` spans become InlineCode, the backticks are not shown; a number and its\n * unit outside them never break apart (「100 MB」). Anything that is not a string (an element) is left alone. */\nexport function codeText(text: React.ReactNode): React.ReactNode {\n if (typeof text !== 'string') return text;\n if (!hasCodeSpan(text)) return keepUnits(text);\n return codeSpans(text).map((s, i) => (s.code ? <InlineCode key={i}>{s.text}</InlineCode> : keepUnits(s.text)));\n}\n"],"mappings":";;;;;;;;AAkCA,SAAgB,WAAW,EAAE,UAAU,MAAM,SAAS,WAAW,OAAO,UAA2B;CAEjG,MAAM,CAAC,QAAQ,aAAa,MAAM,SAAS,KAAK;CAChD,MAAM,OAAO,MAAM,aAAa,OAA2B;EACzD,MAAM,MAAM,IAAI;EAChB,UAAU,CAAC,CAAC,OAAO,MAAM,KAAK,IAAI,UAAU,CAAC,CAAC,MAAM,MAAM,EAAE,aAAa,KAAK,CAAC,CAAC,EAAE,aAAa,KAAK,CAAC,CAAC;CACxG,GAAG,CAAC,CAAC;CACL,MAAM,SAAS,CAAC,EAAE,QAAQ;CAC1B,MAAM,MAAM,GACV,WACA,UAAU,WACV,UAAU,UAAU,aACpB,UAAU,SAAS,UAAU,MAAM,QACnC,OAAO,aAAa,YAAY,SAAS,UAAU,MAAM,YACzD,SACF;CACA,IAAI,MACF,OACE,oBAAC,KAAD;EAAG,KAAK;EAAM,WAAW;EAAW;EAAe;EAChD;CACA,CAAA;CAEP,IAAI,SACF,OACE,oBAAC,UAAD;EAAQ,KAAK;EAAM,MAAK;EAAS,WAAW;EAAc;EACvD;CACK,CAAA;CAEZ,OAAO,oBAAC,QAAD;EAAM,WAAW;EAAM;CAAe,CAAA;AAC/C;;AAQA,MAAM,WAAW;AACjB,MAAa,aAAa,SAA0B,SAAS,KAAK,IAAI;;AAkBtE,SAAgB,SAAS,EAAE,MAAM,SAAS,OAAO,QAAQ,WAAW,IAAI,MAAM,QAAQ,aAA4B;CAChH,OACE,oBAAC,KAAD;EAAgB;EACb,UAAA,UAAU,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,MAAM,KAAK,MAAM;GAC7C,IAAI,CAAC,MAAM,OAAO,UAAU,CAAC;GAC7B,MAAM,OAAO,WAAW,MAAM,CAAC,IAAI,QAAQ,CAAC,KAAK,KAAA,IAAY,KAAA;GAE7D,IAAI,EADS,MAAM,CAAC,MAAM,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,SACpC,OAAO,oBAAC,YAAD,EAAA,UAAqB,EAAc,GAAlB,CAAkB;GAErD,MAAM,QAAQ,SACT,MAAqC;IAEpC,IAAI,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,IAAI;IACtE,EAAE,eAAe;IACjB,MAAM,GAAG,CAAC;GACZ,IACA,KAAA;GACJ,IAAI,MACF,OACE,oBAAC,YAAD;IAAoB,MAAK;IAAiB;IAAM,SAAS;IACtD,UAAA;GACS,GAFK,CAEL;GAEhB,IAAI,OACF,OACE,oBAAC,YAAD;IAAoB,MAAK;IAAW,SAAS;IAC1C,UAAA;GACS,GAFK,CAEL;GAEhB,OAAO,oBAAC,YAAD,EAAA,UAAqB,EAAc,GAAlB,CAAkB;EAC5C,CAAC;CACE,CAAA;AAET;;;AAIA,SAAgB,SAAS,MAAwC;CAC/D,IAAI,OAAO,SAAS,UAAU,OAAO;CACrC,IAAI,CAAC,YAAY,IAAI,GAAG,OAAO,UAAU,IAAI;CAC7C,OAAO,UAAU,IAAI,CAAC,CAAC,KAAK,GAAG,MAAO,EAAE,OAAO,oBAAC,YAAD,EAAA,UAAqB,EAAE,KAAiB,GAAvB,CAAuB,IAAI,UAAU,EAAE,IAAI,CAAE;AAC/G"}
|
|
@@ -12,18 +12,20 @@ export interface KpiCardProps {
|
|
|
12
12
|
compact?: boolean;
|
|
13
13
|
/** Written after the number: 元, 人, ms, %. */
|
|
14
14
|
unit?: string;
|
|
15
|
-
/** Digits after the decimal point, for the figure and its change (delta). Default 0 for the figure
|
|
16
|
-
* keeps 1 (%) or 2 (pt). */
|
|
15
|
+
/** Digits after the decimal point, for the figure and its change (delta). Default 0 for the figure, 1 with unit="%"
|
|
16
|
+
* (a percentage has 1 decimal); the change then keeps 1 (%) or 2 (pt). */
|
|
17
17
|
decimals?: number;
|
|
18
18
|
/** Change versus the comparison period. */
|
|
19
19
|
delta?: number;
|
|
20
20
|
/** '%' (default) or 'pt' for percentage points. */
|
|
21
21
|
deltaUnit?: '%' | 'pt';
|
|
22
|
-
/**
|
|
22
|
+
/** Which way is better: 'up' (default; revenue, users) or 'down' (error rate, response time, cost). Sets good or bad from delta's sign. */
|
|
23
|
+
direction?: 'up' | 'down';
|
|
24
|
+
/** Overrides direction: whether this change is good (true) or bad (false), whatever its sign. */
|
|
23
25
|
good?: boolean;
|
|
24
26
|
/** Recent values for the sparkline. */
|
|
25
27
|
spark?: number[];
|
|
26
|
-
/** Default 「較上週」. */
|
|
28
|
+
/** The comparison period after the change. Default 「較上週」. */
|
|
27
29
|
compareLabel?: string;
|
|
28
30
|
/** Its own class names. */
|
|
29
31
|
className?: string;
|
|
@@ -18,7 +18,7 @@ function sansCjk(text) {
|
|
|
18
18
|
}
|
|
19
19
|
/** One figure with its change and a sparkline. It is a card: put several in a grid, not inside another Card. */
|
|
20
20
|
function KpiCard(props) {
|
|
21
|
-
const { label, value, unit, decimals = 0, delta, deltaUnit, good, spark, compareLabel, size = "default", verdict, target, className } = props;
|
|
21
|
+
const { label, value, unit, decimals = unit === "%" ? 1 : 0, delta, deltaUnit, direction = "up", good, spark, compareLabel, size = "default", verdict, target, className } = props;
|
|
22
22
|
const compact = size === "compact";
|
|
23
23
|
devWarn(compact && !!spark, "KpiCard", "size=\"compact\" draws no sparkline, so spark is ignored. Drop spark, or use the default size.");
|
|
24
24
|
devWarn(props.format === "percent" && !unit, "KpiCard", "format='percent' shows the number only; pass unit=\"%\" for the smaller % after it.");
|
|
@@ -35,7 +35,8 @@ function KpiCard(props) {
|
|
|
35
35
|
]);
|
|
36
36
|
const hasDelta = typeof delta === "number";
|
|
37
37
|
const up = hasDelta && delta > 0;
|
|
38
|
-
const
|
|
38
|
+
const flat = hasDelta && delta === 0;
|
|
39
|
+
const isGood = good ?? (direction === "down" ? hasDelta && delta < 0 : up);
|
|
39
40
|
const dTxt = hasDelta ? deltaUnit === "pt" ? tr("{n} 個百分點", { n: format.number(Math.abs(delta), props.decimals ?? 2) }) : format.percent(Math.abs(delta), props.decimals ?? 1) : "";
|
|
40
41
|
let sparkD = null;
|
|
41
42
|
if (!compact && spark && spark.length > 1) {
|
|
@@ -96,18 +97,11 @@ function KpiCard(props) {
|
|
|
96
97
|
hasDelta ? /* @__PURE__ */ jsxs("div", {
|
|
97
98
|
className: "ui-kpi-delta",
|
|
98
99
|
children: [/* @__PURE__ */ jsxs("span", {
|
|
99
|
-
className: cx("ui-kpi-change", isGood ? "is-good" : "is-bad"),
|
|
100
|
-
children: [
|
|
101
|
-
up ? "▲ " : "▼ ",
|
|
102
|
-
digits(dTxt),
|
|
103
|
-
/* @__PURE__ */ jsx("span", {
|
|
104
|
-
className: "ui-visually-hidden",
|
|
105
|
-
children: isGood ? tr(",改善") : tr(",變差")
|
|
106
|
-
})
|
|
107
|
-
]
|
|
100
|
+
className: cx("ui-kpi-change", flat ? "is-flat" : isGood ? "is-good" : "is-bad"),
|
|
101
|
+
children: [flat ? "" : up ? "▲ " : "▼ ", digits(dTxt)]
|
|
108
102
|
}), /* @__PURE__ */ jsx("span", {
|
|
109
103
|
className: "ui-kpi-note",
|
|
110
|
-
children: compareLabel || tr("較上週")
|
|
104
|
+
children: (compareLabel || tr("較上週")) + (flat ? "" : isGood ? tr("(改善)") : tr("(變差)"))
|
|
111
105
|
})]
|
|
112
106
|
}) : null,
|
|
113
107
|
verdict || target ? verdict && verdict.tone !== "success" ? /* @__PURE__ */ jsx("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KpiCard.js","names":[],"sources":["../../../src/components/KpiCard/KpiCard.tsx"],"sourcesContent":["import * as React from 'react';\nimport { format } from '../../format';\nimport { devWarn } from '../../internal/dev';\nimport { I18N, tr } from '../../i18n';\nimport { kpiText, smoothPath, useCountUp, useFitText, type Point } from '../../internal/chart';\nimport { cx, digits } from '../../internal/util';\nimport { codeText } from '../InlineCode/InlineCode';\n\nexport interface KpiCardProps {\n /** What is measured: 「本月營收」. */\n label: string;\n /** The figure, as a number (counts up from 0 when it appears). */\n value: number;\n /** 'money' shows NT$ 1,280; 'percent' 1 decimal without the % sign: pass unit=\"%\" (same as DataTable). Default 'number'. */\n format?: 'number' | 'money' | 'percent';\n /** For money. Default: the locale's currency (TWD). */\n currency?: string;\n /** Abbreviate from 1 萬 (default true). The only place numbers are abbreviated. */\n compact?: boolean;\n /** Written after the number: 元, 人, ms, %. */\n unit?: string;\n /** Digits after the decimal point, for the figure and its change (delta). Default 0 for the figure
|
|
1
|
+
{"version":3,"file":"KpiCard.js","names":[],"sources":["../../../src/components/KpiCard/KpiCard.tsx"],"sourcesContent":["import * as React from 'react';\nimport { format } from '../../format';\nimport { devWarn } from '../../internal/dev';\nimport { I18N, tr } from '../../i18n';\nimport { kpiText, smoothPath, useCountUp, useFitText, type Point } from '../../internal/chart';\nimport { cx, digits } from '../../internal/util';\nimport { codeText } from '../InlineCode/InlineCode';\n\nexport interface KpiCardProps {\n /** What is measured: 「本月營收」. */\n label: string;\n /** The figure, as a number (counts up from 0 when it appears). */\n value: number;\n /** 'money' shows NT$ 1,280; 'percent' 1 decimal without the % sign: pass unit=\"%\" (same as DataTable). Default 'number'. */\n format?: 'number' | 'money' | 'percent';\n /** For money. Default: the locale's currency (TWD). */\n currency?: string;\n /** Abbreviate from 1 萬 (default true). The only place numbers are abbreviated. */\n compact?: boolean;\n /** Written after the number: 元, 人, ms, %. */\n unit?: string;\n /** Digits after the decimal point, for the figure and its change (delta). Default 0 for the figure, 1 with unit=\"%\"\n * (a percentage has 1 decimal); the change then keeps 1 (%) or 2 (pt). */\n decimals?: number;\n /** Change versus the comparison period. */\n delta?: number;\n /** '%' (default) or 'pt' for percentage points. */\n deltaUnit?: '%' | 'pt';\n /** Which way is better: 'up' (default; revenue, users) or 'down' (error rate, response time, cost). Sets good or bad from delta's sign. */\n direction?: 'up' | 'down';\n /** Overrides direction: whether this change is good (true) or bad (false), whatever its sign. */\n good?: boolean;\n /** Recent values for the sparkline. */\n spark?: number[];\n /** The comparison period after the change. Default 「較上週」. */\n compareLabel?: string;\n /** Its own class names. */\n className?: string;\n /** `compact`: a 22 px number for a top bar, no sparkline; with verdict and target below. Default 'default' (31 px). */\n size?: 'default' | 'compact';\n /** How the figure is judged, in words: 「預測準確」(success), 「偏差變大」(warning), 「需要校正」(danger). Shown only\n * when it is not success, in place of the target line and in its color; screen readers always hear it. `backticks` are code. */\n verdict?: { tone: 'success' | 'warning' | 'danger'; text: string };\n /** One gray line under the number, e.g. 「目標 ≤ 0.5 °C(示意)」; `backticks` are code. */\n target?: string;\n}\n\n/** Chinese in a figure (the 萬 and 億 of an abbreviated number) in the text font and drawn like the unit (smaller,\n * muted); Geist Mono stays on the digits. */\nfunction sansCjk(text: string): React.ReactNode[] {\n // The space before 萬 is the unit's margin (CSS), not a space as wide as a Geist Mono digit.\n return text.split(/\\s*([\\u2e80-\\u9fff\\uff00-\\uffef]+)/).map((t, i) =>\n i % 2 ? (\n <span key={i} className=\"ui-kpi-cjk\">\n {t}\n </span>\n ) : (\n t\n ),\n );\n}\n\n/** One figure with its change and a sparkline. It is a card: put several in a grid, not inside another Card. */\nexport function KpiCard(props: KpiCardProps) {\n const {\n label,\n value,\n unit,\n decimals = unit === '%' ? 1 : 0,\n delta,\n deltaUnit,\n direction = 'up',\n good,\n spark,\n compareLabel,\n size = 'default',\n verdict,\n target,\n className,\n } = props;\n const compact = size === 'compact';\n devWarn(compact && !!spark, 'KpiCard', 'size=\"compact\" draws no sparkline, so spark is ignored. Drop spark, or use the default size.');\n devWarn(props.format === 'percent' && !unit, 'KpiCard', 'format=\\'percent\\' shows the number only; pass unit=\"%\" for the smaller % after it.');\n const t = useCountUp(value, 900);\n const valRef = React.useRef<HTMLDivElement>(null);\n useFitText(valRef, [value, props.format, unit, decimals, props.compact, props.currency, I18N.locale]);\n const hasDelta = typeof delta === 'number';\n const up = hasDelta && delta > 0;\n const flat = hasDelta && delta === 0;\n // No change is neither good nor bad: no arrow, no word, muted.\n const isGood = good ?? (direction === 'down' ? hasDelta && delta < 0 : up);\n // The change follows decimals when it is given (decimals={1}: 「0.4 個百分點」, not 「0.40」).\n const dTxt = hasDelta\n ? deltaUnit === 'pt'\n ? tr('{n} 個百分點', { n: format.number(Math.abs(delta), props.decimals ?? 2) })\n : format.percent(Math.abs(delta), props.decimals ?? 1)\n : '';\n let sparkD: string | null = null;\n if (!compact && spark && spark.length > 1) {\n const mx = Math.max(...spark);\n const mn = Math.min(...spark);\n sparkD = smoothPath(spark.map((v, i): Point => [(i * 160) / (spark.length - 1), 32 - ((v - mn) / (mx - mn || 1)) * 28]));\n }\n const showUnit = unit && props.format !== 'money';\n return (\n <section className={cx('ui-kpi', compact && 'is-compact', className)}>\n <div className=\"ui-kpi-label\">{label}</div>\n <div ref={valRef} className=\"ui-kpi-value\">\n {/* The final figure for screen readers, as text (an aria-label on a div without a role is not read); the\n counting figure is hidden from them. */}\n <span className=\"ui-visually-hidden\">{kpiText(value, props, decimals) + (showUnit ? ' ' + unit : '')}</span>\n <span className=\"ui-kpi-num\" aria-hidden=\"true\">\n <span className=\"ui-kpi-sizer\">{sansCjk(kpiText(value, props, decimals))}</span>\n <span className=\"ui-kpi-live\">{sansCjk(kpiText(value * t, props, decimals))}</span>\n </span>\n {showUnit ? (\n <span className=\"ui-kpi-unit\" aria-hidden=\"true\">\n {unit}\n </span>\n ) : null}\n </div>\n {sparkD ? (\n <svg className=\"ui-kpi-spark\" width=\"100%\" height={36} viewBox=\"0 0 160 36\" preserveAspectRatio=\"none\" aria-hidden=\"true\">\n <path d={sparkD} fill=\"none\" stroke=\"var(--chart-1)\" strokeWidth={2} strokeLinecap=\"round\" vectorEffect=\"non-scaling-stroke\" />\n </svg>\n ) : null}\n {hasDelta ? (\n <div className=\"ui-kpi-delta\">\n <span className={cx('ui-kpi-change', flat ? 'is-flat' : isGood ? 'is-good' : 'is-bad')}>\n {flat ? '' : up ? '▲ ' : '▼ '}\n {digits(dTxt)}\n </span>\n {/* Good or bad is not only a colour (WCAG 1.4.1): the word follows the comparison period, muted. */}\n <span className=\"ui-kpi-note\">{(compareLabel || tr('較上週')) + (flat ? '' : isGood ? tr('(改善)') : tr('(變差)'))}</span>\n </div>\n ) : null}\n {verdict || target ? (\n verdict && verdict.tone !== 'success' ? (\n <div className={'ui-kpi-target ui-kpi-verdict is-' + verdict.tone}>\n {codeText(target ? tr('{v}({t})', { v: verdict.text, t: target }) : verdict.text)}\n </div>\n ) : (\n <div className=\"ui-kpi-target\">\n {verdict ? <span className=\"ui-visually-hidden\">{codeText(verdict.text + tr(','))}</span> : null}\n {codeText(target)}\n </div>\n )\n ) : null}\n </section>\n );\n}\n"],"mappings":"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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { GraphLegend } from "../Graph/Graph.js";
|
|
3
|
-
import {
|
|
3
|
+
import { SegmentedControl } from "../SegmentedControl/SegmentedControl.js";
|
|
4
4
|
import { IconButton } from "../IconButton/IconButton.js";
|
|
5
5
|
import { Switch } from "../Switch/Switch.js";
|
|
6
6
|
import { tr } from "../../i18n.js";
|
|
@@ -9,6 +9,8 @@ import { cx, monoNums, resizeObserver } from "../../internal/util.js";
|
|
|
9
9
|
import { ScrollHint, useScrollHint } from "../../internal/scrollHint.js";
|
|
10
10
|
import { codeSpans } from "../../internal/codeSpans.js";
|
|
11
11
|
import { devWarn } from "../../internal/dev.js";
|
|
12
|
+
import { announce } from "../../announce.js";
|
|
13
|
+
import { nextPreset } from "../../internal/clickSteps.js";
|
|
12
14
|
import { useStored } from "../../internal/stored.js";
|
|
13
15
|
import { Icon } from "../../icons/Icon.js";
|
|
14
16
|
import { includeIcons } from "../../icons/store.js";
|
|
@@ -64,6 +66,21 @@ function resolveProps(q) {
|
|
|
64
66
|
};
|
|
65
67
|
}
|
|
66
68
|
const scrollMemory = /* @__PURE__ */ new Map();
|
|
69
|
+
const MEMORY = 50;
|
|
70
|
+
function remember(key, x) {
|
|
71
|
+
scrollMemory.delete(key);
|
|
72
|
+
scrollMemory.set(key, x);
|
|
73
|
+
if (scrollMemory.size > MEMORY) scrollMemory.delete(scrollMemory.keys().next().value);
|
|
74
|
+
}
|
|
75
|
+
/** A short key for a list of ids (FNV-1a, 32 bit, plus the count): the same diagram gets the same key. */
|
|
76
|
+
function idsKey(ids) {
|
|
77
|
+
let h = 2166136261;
|
|
78
|
+
for (const id of ids) {
|
|
79
|
+
for (let i = 0; i < id.length; i++) h = Math.imul(h ^ id.charCodeAt(i), 16777619);
|
|
80
|
+
h = Math.imul(h ^ 124, 16777619);
|
|
81
|
+
}
|
|
82
|
+
return ids.length + ":" + (h >>> 0).toString(36);
|
|
83
|
+
}
|
|
67
84
|
let measure;
|
|
68
85
|
const NUM = /(\d[\d,.]*)/;
|
|
69
86
|
/** A label in pieces: `code` (read the same way as CodeText, by codeSpans) and numbers are mono, the rest sans. */
|
|
@@ -114,12 +131,14 @@ function textWidth(text, size, code) {
|
|
|
114
131
|
const TAG_KEEP = 8;
|
|
115
132
|
const MIN_FRAME = 160;
|
|
116
133
|
const MAX_EXTRA = 200;
|
|
117
|
-
/** HC: the bar under the diagram: drag it, ↑↓ 16 px, Enter or a double-click back to the drawn height.
|
|
134
|
+
/** HC: the bar under the diagram: drag it, ↑↓ 16 px, Enter or a double-click back to the drawn height. A click without
|
|
135
|
+
* dragging (WCAG 2.5.7) steps through the shortest frame, the drawn height and the widest gaps. */
|
|
118
136
|
function HeightHandle(p) {
|
|
119
137
|
const [dragging, setDragging] = React.useState(false);
|
|
120
138
|
const from = React.useRef(null);
|
|
121
139
|
return /* @__PURE__ */ jsx("div", {
|
|
122
140
|
className: cx("ui-lg-resize", dragging && "is-dragging"),
|
|
141
|
+
"aria-description": tr("拖曳或按 ↑ ↓ 調整;按一下切換預設高度,按 Enter 還原"),
|
|
123
142
|
role: "separator",
|
|
124
143
|
"aria-orientation": "horizontal",
|
|
125
144
|
"aria-label": tr("調整架構圖高度"),
|
|
@@ -134,17 +153,22 @@ function HeightHandle(p) {
|
|
|
134
153
|
e.currentTarget.setPointerCapture?.(e.pointerId);
|
|
135
154
|
from.current = {
|
|
136
155
|
y: e.clientY,
|
|
137
|
-
d: p.start()
|
|
156
|
+
d: p.start(),
|
|
157
|
+
moved: false
|
|
138
158
|
};
|
|
139
159
|
setDragging(true);
|
|
140
160
|
},
|
|
141
161
|
onPointerMove: (e) => {
|
|
142
|
-
|
|
143
|
-
|
|
162
|
+
const f = from.current;
|
|
163
|
+
if (!f || !f.moved && Math.abs(e.clientY - f.y) < 4) return;
|
|
164
|
+
f.moved = true;
|
|
165
|
+
p.onDrag(f.d + e.clientY - f.y);
|
|
144
166
|
},
|
|
145
167
|
onPointerUp: () => {
|
|
168
|
+
const f = from.current;
|
|
146
169
|
from.current = null;
|
|
147
170
|
setDragging(false);
|
|
171
|
+
if (f && !f.moved) p.onStep(nextPreset(f.d, p.presets));
|
|
148
172
|
},
|
|
149
173
|
onPointerCancel: () => {
|
|
150
174
|
from.current = null;
|
|
@@ -407,7 +431,7 @@ function LayerGraph(props) {
|
|
|
407
431
|
const { ref: scrollRef, more: scrollMore, overflows, scrolled, onScroll } = useScrollHint();
|
|
408
432
|
const uid = React.useId().replace(/:/g, "");
|
|
409
433
|
const [view, setView] = React.useState("graph");
|
|
410
|
-
const memKey = p.scrollKey ?? all.map((n) => n.id)
|
|
434
|
+
const memKey = p.scrollKey ?? idsKey(all.map((n) => n.id));
|
|
411
435
|
React.useLayoutEffect(() => {
|
|
412
436
|
const el = scrollRef.current;
|
|
413
437
|
const x = scrollMemory.get(memKey);
|
|
@@ -419,7 +443,7 @@ function LayerGraph(props) {
|
|
|
419
443
|
]);
|
|
420
444
|
const onScrollKeep = () => {
|
|
421
445
|
const el = scrollRef.current;
|
|
422
|
-
if (el)
|
|
446
|
+
if (el) remember(memKey, el.scrollLeft);
|
|
423
447
|
onScroll();
|
|
424
448
|
};
|
|
425
449
|
const selEdge = pickEdge && edges.find((e) => edgeId(e) === p.selectedEdge) || null;
|
|
@@ -1600,15 +1624,15 @@ function LayerGraph(props) {
|
|
|
1600
1624
|
children: tr("線上文字")
|
|
1601
1625
|
})]
|
|
1602
1626
|
}) : null,
|
|
1603
|
-
p.listView === false ? null : /* @__PURE__ */ jsx(
|
|
1627
|
+
p.listView === false ? null : /* @__PURE__ */ jsx(SegmentedControl, {
|
|
1604
1628
|
label: tr("顯示方式"),
|
|
1605
1629
|
value: view,
|
|
1606
1630
|
onChange: setView,
|
|
1607
|
-
|
|
1608
|
-
|
|
1631
|
+
options: [{
|
|
1632
|
+
value: "graph",
|
|
1609
1633
|
label: tr("圖")
|
|
1610
1634
|
}, {
|
|
1611
|
-
|
|
1635
|
+
value: "list",
|
|
1612
1636
|
label: tr("清單")
|
|
1613
1637
|
}]
|
|
1614
1638
|
})
|
|
@@ -1681,7 +1705,17 @@ function LayerGraph(props) {
|
|
|
1681
1705
|
onDrag: (d) => setDh(dragTo(d)),
|
|
1682
1706
|
onKey: (step) => setDh(dragTo(dh + step)),
|
|
1683
1707
|
onReset: () => setDh(0),
|
|
1684
|
-
start: () => dh
|
|
1708
|
+
start: () => dh,
|
|
1709
|
+
presets: [
|
|
1710
|
+
dragTo(-Infinity),
|
|
1711
|
+
0,
|
|
1712
|
+
dragTo(Infinity)
|
|
1713
|
+
],
|
|
1714
|
+
onStep: (d) => {
|
|
1715
|
+
const next = dragTo(d);
|
|
1716
|
+
setDh(next);
|
|
1717
|
+
announce(tr("架構圖高度 {n} px", { n: Math.round(naturalH + next) }));
|
|
1718
|
+
}
|
|
1685
1719
|
}) : null,
|
|
1686
1720
|
showList ? null : /* @__PURE__ */ jsx(ScrollHint, {
|
|
1687
1721
|
show: overflows,
|
|
@@ -1728,6 +1762,6 @@ function LayerGraph(props) {
|
|
|
1728
1762
|
]
|
|
1729
1763
|
});
|
|
1730
1764
|
}
|
|
1731
|
-
export { LayerGraph };
|
|
1765
|
+
export { LayerGraph, idsKey };
|
|
1732
1766
|
|
|
1733
1767
|
//# sourceMappingURL=LayerGraph.js.map
|