@seanyeh77/ui 0.43.1 → 0.44.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 +14 -14
- package/dist/bundle.js.map +1 -1
- package/dist/components/Alert/Alert.d.ts +1 -1
- package/dist/components/Alert/Alert.js +2 -1
- package/dist/components/Alert/Alert.js.map +1 -1
- package/dist/components/DangerZone/DangerZone.d.ts +1 -1
- package/dist/components/DangerZone/DangerZone.js +2 -1
- package/dist/components/DangerZone/DangerZone.js.map +1 -1
- package/dist/components/DataTable/DataTable.d.ts +8 -3
- package/dist/components/DataTable/DataTable.js +155 -63
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/DatePicker/DatePicker.d.ts +2 -2
- package/dist/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/Dialog/Dialog.d.ts +1 -1
- package/dist/components/Dialog/Dialog.js +2 -1
- package/dist/components/Dialog/Dialog.js.map +1 -1
- package/dist/components/Drawer/Drawer.d.ts +1 -0
- package/dist/components/Drawer/Drawer.js +2 -1
- package/dist/components/Drawer/Drawer.js.map +1 -1
- package/dist/components/EmptyState/EmptyState.d.ts +2 -2
- package/dist/components/EmptyState/EmptyState.js +3 -2
- package/dist/components/EmptyState/EmptyState.js.map +1 -1
- package/dist/components/ErrorPage/ErrorPage.d.ts +1 -0
- package/dist/components/ErrorPage/ErrorPage.js +2 -1
- package/dist/components/ErrorPage/ErrorPage.js.map +1 -1
- package/dist/components/EventTimeline/EventTimeline.d.ts +1 -1
- package/dist/components/EventTimeline/EventTimeline.js +2 -1
- package/dist/components/EventTimeline/EventTimeline.js.map +1 -1
- package/dist/components/FileUpload/FileUpload.d.ts +1 -1
- package/dist/components/FileUpload/FileUpload.js +2 -1
- package/dist/components/FileUpload/FileUpload.js.map +1 -1
- package/dist/components/InlineCode/InlineCode.js +10 -6
- package/dist/components/InlineCode/InlineCode.js.map +1 -1
- package/dist/components/KpiCard/KpiCard.d.ts +2 -2
- package/dist/components/KpiCard/KpiCard.js +5 -4
- package/dist/components/KpiCard/KpiCard.js.map +1 -1
- package/dist/components/LayerGraph/LayerGraph.js +19 -9
- package/dist/components/LayerGraph/LayerGraph.js.map +1 -1
- package/dist/components/LoginCard/LoginCard.d.ts +1 -1
- package/dist/components/LoginCard/LoginCard.js.map +1 -1
- package/dist/components/Markdown/Markdown.js +19 -1
- package/dist/components/Markdown/Markdown.js.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/dist/components/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/components/NotificationBell/NotificationBell.d.ts +1 -0
- package/dist/components/NotificationBell/NotificationBell.js +2 -1
- package/dist/components/NotificationBell/NotificationBell.js.map +1 -1
- package/dist/components/Select/Select.d.ts +1 -1
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/SettingsLayout/SettingsLayout.d.ts +1 -1
- package/dist/components/SettingsLayout/SettingsLayout.js +2 -1
- package/dist/components/SettingsLayout/SettingsLayout.js.map +1 -1
- package/dist/components/Tabs/Tabs.d.ts +4 -1
- package/dist/components/Tabs/Tabs.js +5 -2
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/TextArea/TextArea.d.ts +2 -1
- package/dist/components/TextArea/TextArea.js +3 -2
- package/dist/components/TextArea/TextArea.js.map +1 -1
- package/dist/components/TextField/TextField.d.ts +2 -2
- package/dist/components/TextField/TextField.js.map +1 -1
- package/dist/components/Toast/Toast.d.ts +1 -1
- package/dist/components/Toast/Toast.js +2 -1
- package/dist/components/Toast/Toast.js.map +1 -1
- package/dist/css/Alert.css +1 -0
- package/dist/css/Button.css +1 -0
- package/dist/css/Checkbox.css +1 -0
- package/dist/css/CodeView.css +1 -1
- package/dist/css/DangerZone.css +1 -0
- package/dist/css/DataTable.css +177 -38
- package/dist/css/DatePicker.css +1 -0
- package/dist/css/DateRangePicker.css +1 -0
- package/dist/css/Drawer.css +1 -0
- package/dist/css/EmptyState.css +1 -0
- package/dist/css/ErrorPage.css +1 -0
- package/dist/css/EventTimeline.css +1 -0
- package/dist/css/FileUpload.css +1 -0
- package/dist/css/KpiCard.css +1 -0
- package/dist/css/LoginCard.css +1 -0
- package/dist/css/Markdown.css +29 -1
- package/dist/css/MultiSelect.css +1 -0
- package/dist/css/NotificationBell.css +1 -0
- package/dist/css/ProjectSwitcher.css +6 -1
- package/dist/css/Select.css +1 -0
- package/dist/css/SettingsLayout.css +1 -0
- package/dist/css/Suggestion.css +1 -1
- package/dist/css/Tabs.css +6 -6
- package/dist/css/Term.css +1 -1
- package/dist/css/TextArea.css +1 -0
- package/dist/css/TextField.css +1 -0
- package/dist/css/Toast.css +1 -0
- package/dist/css/Tour.css +1 -1
- package/dist/css/TreeList.css +1 -0
- package/dist/css/Workbench.css +12 -0
- package/dist/format.js +3 -1
- package/dist/format.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/internal/Field.js +3 -2
- package/dist/internal/Field.js.map +1 -1
- package/dist/internal/codeSpans.js +20 -0
- package/dist/internal/codeSpans.js.map +1 -0
- package/dist/styles.css +316 -133
- package/docs/Alert.md +1 -0
- package/docs/Card.md +3 -3
- package/docs/DangerZone.md +1 -0
- package/docs/DataTable.md +29 -19
- package/docs/DatePicker.md +1 -0
- package/docs/Dialog.md +1 -0
- package/docs/Drawer.md +1 -0
- package/docs/EmptyState.md +1 -0
- package/docs/ErrorPage.md +1 -0
- package/docs/EventTimeline.md +1 -0
- package/docs/FileUpload.md +1 -0
- package/docs/Format.md +1 -1
- package/docs/KpiCard.md +1 -0
- package/docs/LoginCard.md +1 -0
- package/docs/Markdown.md +3 -0
- package/docs/MultiSelect.md +1 -0
- package/docs/NotificationBell.md +1 -0
- package/docs/Select.md +1 -0
- package/docs/SettingsLayout.md +1 -0
- package/docs/Tabs.md +2 -2
- package/docs/Term.md +1 -0
- package/docs/TextArea.md +1 -0
- package/docs/TextField.md +1 -0
- package/docs/Toast.md +1 -0
- package/docs/data.md +4 -3
- package/docs/guidelines.md +4 -4
- package/docs/layout.md +1 -1
- package/package.json +2 -2
|
@@ -7,7 +7,7 @@ export interface DialogProps {
|
|
|
7
7
|
onClose?: () => void;
|
|
8
8
|
/** States the decision; may be a question: 「刪除 api-gateway?」. */
|
|
9
9
|
title: string;
|
|
10
|
-
/** What happens and whether it can be undone, at most 2 short sentences. */
|
|
10
|
+
/** What happens and whether it can be undone, at most 2 short sentences; in a string, `backticks` are code. */
|
|
11
11
|
children?: React.ReactNode;
|
|
12
12
|
/** The confirming button's label, a verb: 刪除, 發布. With onConfirm, the dialog draws its own buttons. */
|
|
13
13
|
confirmLabel?: string;
|
|
@@ -6,6 +6,7 @@ import { devWarn } from "../../internal/dev.js";
|
|
|
6
6
|
import { Button } from "../Button/Button.js";
|
|
7
7
|
import { includeIcons } from "../../icons/store.js";
|
|
8
8
|
import x_default from "../../icons/ph/x.js";
|
|
9
|
+
import { codeText } from "../InlineCode/InlineCode.js";
|
|
9
10
|
import * as React from "react";
|
|
10
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
12
|
import { Dialog } from "@base-ui/react/dialog";
|
|
@@ -60,7 +61,7 @@ function Dialog$1(props) {
|
|
|
60
61
|
head,
|
|
61
62
|
children ? /* @__PURE__ */ jsx("div", {
|
|
62
63
|
className: "ui-dialog-body",
|
|
63
|
-
children
|
|
64
|
+
children: codeText(children)
|
|
64
65
|
}) : null,
|
|
65
66
|
footer ? /* @__PURE__ */ jsx("div", {
|
|
66
67
|
className: "ui-dialog-actions",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","names":["phX","Dialog","Base"],"sources":["../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Dialog as Base } from '@base-ui/react/dialog';\nimport { tr } from '../../i18n';\nimport { Icon } from '../../icons/Icon';\nimport { cx } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { Button } from '../Button/Button';\nimport { includeIcons } from '../../icons/store';\nimport phX from '../../icons/ph/x';\n\nincludeIcons(phX);\n\nexport interface DialogProps {\n /** Shows the dialog over a blurred backdrop, with focus trapped inside and Esc to close.\n * Required unless modal={false}. */\n open?: boolean;\n /** Called on Esc, a press on the backdrop, × and the cancel button. */\n onClose?: () => void;\n /** States the decision; may be a question: 「刪除 api-gateway?」. */\n title: string;\n /** What happens and whether it can be undone, at most 2 short sentences. */\n children?: React.ReactNode;\n /** The confirming button's label, a verb: 刪除, 發布. With onConfirm, the dialog draws its own buttons. */\n confirmLabel?: string;\n onConfirm?: () => void;\n /** Default 「取消」. */\n cancelLabel?: string;\n /** danger: the confirming button is red. */\n tone?: 'default' | 'danger';\n /** Spinner on the confirming button while the action runs. */\n confirmLoading?: boolean;\n /** Your own buttons instead of confirmLabel: secondary first, primary last. */\n actions?: React.ReactNode;\n className?: string;\n /** @deprecated the id is generated. */\n titleId?: string;\n /** false: draw the panel inline, as a static preview in docs. Without it, pass open. */\n modal?: false;\n}\n\n/** A centered 400 px dialog for a decision. Secondary button left, primary right. */\nexport function Dialog(props: DialogProps) {\n const { open, onClose, title, children, confirmLabel, onConfirm, cancelLabel, tone = 'default', confirmLoading, actions, className } = props;\n devWarn((confirmLabel !== undefined) !== !!onConfirm, 'Dialog', 'confirmLabel and onConfirm go together; pass both, or pass actions.');\n devWarn(\n open === undefined && props.modal !== false,\n 'Dialog',\n 'pass open={…} (and onClose) to show a dialog; rendering it conditionally without open draws a static panel with no focus trap or Esc. Use modal={false} for a static preview.',\n );\n devWarn(open !== undefined && !onClose, 'Dialog', 'an open dialog needs onClose, or Esc and the backdrop cannot close it.');\n const footer =\n actions ??\n (confirmLabel && onConfirm ? (\n <>\n <Button onClick={onClose}>{cancelLabel ?? tr('取消')}</Button>\n {tone === 'danger' ? (\n <Button variant=\"danger\" confirmed loading={confirmLoading} onClick={onConfirm}>\n {confirmLabel}\n </Button>\n ) : (\n <Button variant=\"primary\" loading={confirmLoading} onClick={onConfirm}>\n {confirmLabel}\n </Button>\n )}\n </>\n ) : null);\n const id = React.useId();\n const inline = open === undefined;\n const closeIcon = <Icon name=\"x\" />;\n const head = (\n <div className=\"ui-dialog-head\">\n {inline ? (\n <div id={id} className=\"ui-dialog-title\">\n {title}\n </div>\n ) : (\n <Base.Title className=\"ui-dialog-title\">{title}</Base.Title>\n )}\n {onClose && inline ? (\n <button type=\"button\" className=\"ui-dialog-close\" aria-label={tr('關閉')} onClick={onClose}>\n {closeIcon}\n </button>\n ) : onClose ? (\n <Base.Close className=\"ui-dialog-close\" aria-label={tr('關閉')}>\n {closeIcon}\n </Base.Close>\n ) : null}\n </div>\n );\n const content = (\n <>\n {head}\n {children ? <div className=\"ui-dialog-body\">{children}</div> : null}\n {footer ? <div className=\"ui-dialog-actions\">{footer}</div> : null}\n </>\n );\n\n if (inline) {\n // A static panel for previews and docs: no backdrop, no focus handling.\n return (\n <div className={cx('ui-dialog', className)} role=\"dialog\" aria-labelledby={id}>\n {content}\n </div>\n );\n }\n return (\n <Base.Root open={open} onOpenChange={(next) => !next && onClose?.()}>\n <Base.Portal>\n <Base.Backdrop className=\"ui-backdrop\" />\n <Base.Viewport className=\"ui-dialog-viewport\">\n <Base.Popup className={cx('ui-dialog', className)}>{content}</Base.Popup>\n </Base.Viewport>\n </Base.Portal>\n </Base.Root>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Dialog.js","names":["phX","Dialog","Base"],"sources":["../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Dialog as Base } from '@base-ui/react/dialog';\nimport { tr } from '../../i18n';\nimport { Icon } from '../../icons/Icon';\nimport { cx } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { Button } from '../Button/Button';\nimport { includeIcons } from '../../icons/store';\nimport phX from '../../icons/ph/x';\nimport { codeText } from '../InlineCode/InlineCode';\n\nincludeIcons(phX);\n\nexport interface DialogProps {\n /** Shows the dialog over a blurred backdrop, with focus trapped inside and Esc to close.\n * Required unless modal={false}. */\n open?: boolean;\n /** Called on Esc, a press on the backdrop, × and the cancel button. */\n onClose?: () => void;\n /** States the decision; may be a question: 「刪除 api-gateway?」. */\n title: string;\n /** What happens and whether it can be undone, at most 2 short sentences; in a string, `backticks` are code. */\n children?: React.ReactNode;\n /** The confirming button's label, a verb: 刪除, 發布. With onConfirm, the dialog draws its own buttons. */\n confirmLabel?: string;\n onConfirm?: () => void;\n /** Default 「取消」. */\n cancelLabel?: string;\n /** danger: the confirming button is red. */\n tone?: 'default' | 'danger';\n /** Spinner on the confirming button while the action runs. */\n confirmLoading?: boolean;\n /** Your own buttons instead of confirmLabel: secondary first, primary last. */\n actions?: React.ReactNode;\n className?: string;\n /** @deprecated the id is generated. */\n titleId?: string;\n /** false: draw the panel inline, as a static preview in docs. Without it, pass open. */\n modal?: false;\n}\n\n/** A centered 400 px dialog for a decision. Secondary button left, primary right. */\nexport function Dialog(props: DialogProps) {\n const { open, onClose, title, children, confirmLabel, onConfirm, cancelLabel, tone = 'default', confirmLoading, actions, className } = props;\n devWarn((confirmLabel !== undefined) !== !!onConfirm, 'Dialog', 'confirmLabel and onConfirm go together; pass both, or pass actions.');\n devWarn(\n open === undefined && props.modal !== false,\n 'Dialog',\n 'pass open={…} (and onClose) to show a dialog; rendering it conditionally without open draws a static panel with no focus trap or Esc. Use modal={false} for a static preview.',\n );\n devWarn(open !== undefined && !onClose, 'Dialog', 'an open dialog needs onClose, or Esc and the backdrop cannot close it.');\n const footer =\n actions ??\n (confirmLabel && onConfirm ? (\n <>\n <Button onClick={onClose}>{cancelLabel ?? tr('取消')}</Button>\n {tone === 'danger' ? (\n <Button variant=\"danger\" confirmed loading={confirmLoading} onClick={onConfirm}>\n {confirmLabel}\n </Button>\n ) : (\n <Button variant=\"primary\" loading={confirmLoading} onClick={onConfirm}>\n {confirmLabel}\n </Button>\n )}\n </>\n ) : null);\n const id = React.useId();\n const inline = open === undefined;\n const closeIcon = <Icon name=\"x\" />;\n const head = (\n <div className=\"ui-dialog-head\">\n {inline ? (\n <div id={id} className=\"ui-dialog-title\">\n {title}\n </div>\n ) : (\n <Base.Title className=\"ui-dialog-title\">{title}</Base.Title>\n )}\n {onClose && inline ? (\n <button type=\"button\" className=\"ui-dialog-close\" aria-label={tr('關閉')} onClick={onClose}>\n {closeIcon}\n </button>\n ) : onClose ? (\n <Base.Close className=\"ui-dialog-close\" aria-label={tr('關閉')}>\n {closeIcon}\n </Base.Close>\n ) : null}\n </div>\n );\n const content = (\n <>\n {head}\n {children ? <div className=\"ui-dialog-body\">{codeText(children)}</div> : null}\n {footer ? <div className=\"ui-dialog-actions\">{footer}</div> : null}\n </>\n );\n\n if (inline) {\n // A static panel for previews and docs: no backdrop, no focus handling.\n return (\n <div className={cx('ui-dialog', className)} role=\"dialog\" aria-labelledby={id}>\n {content}\n </div>\n );\n }\n return (\n <Base.Root open={open} onOpenChange={(next) => !next && onClose?.()}>\n <Base.Portal>\n <Base.Backdrop className=\"ui-backdrop\" />\n <Base.Viewport className=\"ui-dialog-viewport\">\n <Base.Popup className={cx('ui-dialog', className)}>{content}</Base.Popup>\n </Base.Viewport>\n </Base.Portal>\n </Base.Root>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAWA,aAAaA,SAAG;;AA+BhB,SAAgBC,SAAO,OAAoB;CACzC,MAAM,EAAE,MAAM,SAAS,OAAO,UAAU,cAAc,WAAW,aAAa,OAAO,WAAW,gBAAgB,SAAS,cAAc;CACvI,QAAS,iBAAiB,KAAA,MAAe,CAAC,CAAC,WAAW,UAAU,qEAAqE;CACrI,QACE,SAAS,KAAA,KAAa,MAAM,UAAU,OACtC,UACA,+KACF;CACA,QAAQ,SAAS,KAAA,KAAa,CAAC,SAAS,UAAU,wEAAwE;CAC1H,MAAM,SACJ,YACC,gBAAgB,YACf,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,QAAD;EAAQ,SAAS;EAAU,UAAA,eAAe,GAAG,IAAI;CAAU,CAAA,GAC1D,SAAS,WACR,oBAAC,QAAD;EAAQ,S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,oBAACA,OAAK,OAAN;IAAY,WAAW,GAAG,aAAa,SAAS;IAAI,UAAA;GAAoB,CAAA;EAC3D,CAAA,CACJ,EAAA,CAAA;CACJ,CAAA;AAEf"}
|
|
@@ -13,6 +13,7 @@ export interface DrawerProps {
|
|
|
13
13
|
/** Which edge it slides in from. Default 'right'; 'left' for navigation opened from a menu button at the left. */
|
|
14
14
|
side?: 'right' | 'left';
|
|
15
15
|
confirmTitle?: string;
|
|
16
|
+
/** The sentence of the close confirmation; `backticks` are code. */
|
|
16
17
|
confirmText?: string;
|
|
17
18
|
children?: React.ReactNode;
|
|
18
19
|
}
|
|
@@ -4,6 +4,7 @@ import { Icon } from "../../icons/Icon.js";
|
|
|
4
4
|
import { Dialog as Dialog$1 } from "../Dialog/Dialog.js";
|
|
5
5
|
import { includeIcons } from "../../icons/store.js";
|
|
6
6
|
import x_default from "../../icons/ph/x.js";
|
|
7
|
+
import { codeText } from "../InlineCode/InlineCode.js";
|
|
7
8
|
import * as React from "react";
|
|
8
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
import { Dialog } from "@base-ui/react/dialog";
|
|
@@ -56,7 +57,7 @@ function Drawer({ open, onClose, title, actions, dirty, width, side = "right", c
|
|
|
56
57
|
setAsking(false);
|
|
57
58
|
onClose();
|
|
58
59
|
},
|
|
59
|
-
children: confirmText || tr("關閉後,剛才的修改不會保留。")
|
|
60
|
+
children: codeText(confirmText || tr("關閉後,剛才的修改不會保留。"))
|
|
60
61
|
})
|
|
61
62
|
]
|
|
62
63
|
})] })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.js","names":["phX","Base","Dialog"],"sources":["../../../src/components/Drawer/Drawer.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Dialog as Base } from '@base-ui/react/dialog';\nimport { tr } from '../../i18n';\nimport { Icon } from '../../icons/Icon';\nimport { Dialog } from '../Dialog/Dialog';\nimport { includeIcons } from '../../icons/store';\nimport phX from '../../icons/ph/x';\n\nincludeIcons(phX);\n\nexport interface DrawerProps {\n open: boolean;\n onClose: () => void;\n title: string;\n /** Footer buttons: secondary first, primary last. Pass a function to get requestClose for your 取消 button: it\n * asks before discarding unsaved changes, like ✕ and Esc. */\n actions?: React.ReactNode | ((requestClose: () => void) => React.ReactNode);\n /** Unsaved changes: closing asks 「放棄未儲存的變更?」 first. */\n dirty?: boolean;\n /** px. Default 400. */\n width?: number;\n /** Which edge it slides in from. Default 'right'; 'left' for navigation opened from a menu button at the left. */\n side?: 'right' | 'left';\n confirmTitle?: string;\n confirmText?: string;\n children?: React.ReactNode;\n}\n\n/** A 400 px panel from the right for editing one item without leaving the page. */\nexport function Drawer({ open, onClose, title, actions, dirty, width, side = 'right', confirmTitle, confirmText, children }: DrawerProps) {\n const [asking, setAsking] = React.useState(false);\n const request = () => (dirty ? setAsking(true) : onClose());\n const panel = React.useRef<HTMLDivElement>(null);\n // Focus the first field (or action), not the close button.\n const firstField = () =>\n panel.current?.querySelector<HTMLElement>(\n '.ui-drawer-body :is(input, textarea, select, button, [tabindex]):not([disabled], [tabindex=\"-1\"]), .ui-drawer-foot button:not([disabled])',\n ) ?? true;\n return (\n <Base.Root open={open} onOpenChange={(next) => !next && request()}>\n <Base.Portal>\n <Base.Backdrop className=\"ui-drawer-backdrop\" />\n <Base.Popup ref={panel} initialFocus={firstField} className={side === 'left' ? 'ui-drawer is-left' : 'ui-drawer'} style={width ? { width } : undefined}>\n <div className=\"ui-drawer-head\">\n <Base.Title className=\"ui-drawer-title\">{title}</Base.Title>\n <button type=\"button\" className=\"ui-drawer-close ui-dialog-close\" aria-label={tr('關閉')} onClick={request}>\n <Icon name=\"x\" />\n </button>\n </div>\n <div className=\"ui-drawer-body\">{children}</div>\n {actions ? <div className=\"ui-drawer-foot\">{typeof actions === 'function' ? actions(request) : actions}</div> : null}\n <Dialog\n open={asking}\n onClose={() => setAsking(false)}\n title={confirmTitle || tr('放棄未儲存的變更?')}\n tone=\"danger\"\n cancelLabel={tr('繼續編輯')}\n confirmLabel={tr('放棄')}\n onConfirm={() => {\n setAsking(false);\n onClose();\n }}\n >\n {confirmText || tr('關閉後,剛才的修改不會保留。')}\n </Dialog>\n </Base.Popup>\n </Base.Portal>\n </Base.Root>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Drawer.js","names":["phX","Base","Dialog"],"sources":["../../../src/components/Drawer/Drawer.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Dialog as Base } from '@base-ui/react/dialog';\nimport { tr } from '../../i18n';\nimport { Icon } from '../../icons/Icon';\nimport { Dialog } from '../Dialog/Dialog';\nimport { includeIcons } from '../../icons/store';\nimport phX from '../../icons/ph/x';\nimport { codeText } from '../InlineCode/InlineCode';\n\nincludeIcons(phX);\n\nexport interface DrawerProps {\n open: boolean;\n onClose: () => void;\n title: string;\n /** Footer buttons: secondary first, primary last. Pass a function to get requestClose for your 取消 button: it\n * asks before discarding unsaved changes, like ✕ and Esc. */\n actions?: React.ReactNode | ((requestClose: () => void) => React.ReactNode);\n /** Unsaved changes: closing asks 「放棄未儲存的變更?」 first. */\n dirty?: boolean;\n /** px. Default 400. */\n width?: number;\n /** Which edge it slides in from. Default 'right'; 'left' for navigation opened from a menu button at the left. */\n side?: 'right' | 'left';\n confirmTitle?: string;\n /** The sentence of the close confirmation; `backticks` are code. */\n confirmText?: string;\n children?: React.ReactNode;\n}\n\n/** A 400 px panel from the right for editing one item without leaving the page. */\nexport function Drawer({ open, onClose, title, actions, dirty, width, side = 'right', confirmTitle, confirmText, children }: DrawerProps) {\n const [asking, setAsking] = React.useState(false);\n const request = () => (dirty ? setAsking(true) : onClose());\n const panel = React.useRef<HTMLDivElement>(null);\n // Focus the first field (or action), not the close button.\n const firstField = () =>\n panel.current?.querySelector<HTMLElement>(\n '.ui-drawer-body :is(input, textarea, select, button, [tabindex]):not([disabled], [tabindex=\"-1\"]), .ui-drawer-foot button:not([disabled])',\n ) ?? true;\n return (\n <Base.Root open={open} onOpenChange={(next) => !next && request()}>\n <Base.Portal>\n <Base.Backdrop className=\"ui-drawer-backdrop\" />\n <Base.Popup ref={panel} initialFocus={firstField} className={side === 'left' ? 'ui-drawer is-left' : 'ui-drawer'} style={width ? { width } : undefined}>\n <div className=\"ui-drawer-head\">\n <Base.Title className=\"ui-drawer-title\">{title}</Base.Title>\n <button type=\"button\" className=\"ui-drawer-close ui-dialog-close\" aria-label={tr('關閉')} onClick={request}>\n <Icon name=\"x\" />\n </button>\n </div>\n <div className=\"ui-drawer-body\">{children}</div>\n {actions ? <div className=\"ui-drawer-foot\">{typeof actions === 'function' ? actions(request) : actions}</div> : null}\n <Dialog\n open={asking}\n onClose={() => setAsking(false)}\n title={confirmTitle || tr('放棄未儲存的變更?')}\n tone=\"danger\"\n cancelLabel={tr('繼續編輯')}\n confirmLabel={tr('放棄')}\n onConfirm={() => {\n setAsking(false);\n onClose();\n }}\n >\n {codeText(confirmText || tr('關閉後,剛才的修改不會保留。'))}\n </Dialog>\n </Base.Popup>\n </Base.Portal>\n </Base.Root>\n );\n}\n"],"mappings":";;;;;;;;;;;AASA,aAAaA,SAAG;;AAsBhB,SAAgB,OAAO,EAAE,MAAM,SAAS,OAAO,SAAS,OAAO,OAAO,OAAO,SAAS,cAAc,aAAa,YAAyB;CACxI,MAAM,CAAC,QAAQ,aAAa,MAAM,SAAS,KAAK;CAChD,MAAM,gBAAiB,QAAQ,UAAU,IAAI,IAAI,QAAQ;CACzD,MAAM,QAAQ,MAAM,OAAuB,IAAI;CAE/C,MAAM,mBACJ,MAAM,SAAS,cACb,6IACF,KAAK;CACP,OACE,oBAACC,OAAK,MAAN;EAAiB;EAAM,eAAe,SAAS,CAAC,QAAQ,QAAQ;EAC9D,UAAA,qBAACA,OAAK,QAAN,EAAA,UAAA,CACE,oBAACA,OAAK,UAAN,EAAe,WAAU,qBAAsB,CAAA,GAC/C,qBAACA,OAAK,OAAN;GAAY,KAAK;GAAO,cAAc;GAAY,WAAW,SAAS,SAAS,sBAAsB;GAAa,OAAO,QAAQ,EAAE,MAAM,IAAI,KAAA;GAA7I,UAAA;IACE,qBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACE,oBAACA,OAAK,OAAN;MAAY,WAAU;MAAmB,UAAA;KAAkB,CAAA,GAC3D,oBAAC,UAAD;MAAQ,MAAK;MAAS,WAAU;MAAkC,cAAY,GAAG,IAAI;MAAG,SAAS;MAC/F,UAAA,oBAAC,MAAD,EAAM,MAAK,IAAK,CAAA;KACV,CAAA,CACL;;IACL,oBAAC,OAAD;KAAK,WAAU;KAAkB;IAAc,CAAA;IAC9C,UAAU,oBAAC,OAAD;KAAK,WAAU;KAAkB,UAAA,OAAO,YAAY,aAAa,QAAQ,OAAO,IAAI;IAAa,CAAA,IAAI;IAChH,oBAACC,UAAD;KACE,MAAM;KACN,eAAe,UAAU,KAAK;KAC9B,OAAO,gBAAgB,GAAG,WAAW;KACrC,MAAK;KACL,aAAa,GAAG,MAAM;KACtB,cAAc,GAAG,IAAI;KACrB,iBAAiB;MACf,UAAU,KAAK;MACf,QAAQ;KACV;KAEC,UAAA,SAAS,eAAe,GAAG,gBAAgB,CAAC;IACvC,CAAA;GACE;EACD,CAAA,CAAA,EAAA,CAAA;CACJ,CAAA;AAEf"}
|
|
@@ -2,9 +2,9 @@ import * as React from "react";
|
|
|
2
2
|
export interface EmptyStateProps {
|
|
3
3
|
/** What is empty, stated: 「還沒有專案」. */
|
|
4
4
|
title: string;
|
|
5
|
-
/** One sentence on what to do. */
|
|
5
|
+
/** One sentence on what to do; `backticks` are code. */
|
|
6
6
|
description?: string;
|
|
7
|
-
/** Numbered first steps. */
|
|
7
|
+
/** Numbered first steps; `backticks` are code. */
|
|
8
8
|
steps?: string[];
|
|
9
9
|
/** Index of the current step. Default 0. */
|
|
10
10
|
current?: number;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { codeText } from "../InlineCode/InlineCode.js";
|
|
2
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
4
|
// src/components/EmptyState/EmptyState.tsx
|
|
4
5
|
/** What a list or page shows when it has nothing yet: what is missing and the first step. */
|
|
@@ -12,7 +13,7 @@ function EmptyState({ title, description, steps = [], current = 0, action }) {
|
|
|
12
13
|
}),
|
|
13
14
|
description ? /* @__PURE__ */ jsx("p", {
|
|
14
15
|
className: "ui-empty-desc",
|
|
15
|
-
children: description
|
|
16
|
+
children: codeText(description)
|
|
16
17
|
}) : null,
|
|
17
18
|
steps.length ? /* @__PURE__ */ jsx("ol", {
|
|
18
19
|
className: "ui-steps",
|
|
@@ -22,7 +23,7 @@ function EmptyState({ title, description, steps = [], current = 0, action }) {
|
|
|
22
23
|
children: [/* @__PURE__ */ jsx("span", {
|
|
23
24
|
className: "ui-step-num",
|
|
24
25
|
children: i + 1
|
|
25
|
-
}), /* @__PURE__ */ jsx("span", { children: s })]
|
|
26
|
+
}), /* @__PURE__ */ jsx("span", { children: codeText(s) })]
|
|
26
27
|
}, i))
|
|
27
28
|
}) : null,
|
|
28
29
|
action ?? null
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmptyState.js","names":[],"sources":["../../../src/components/EmptyState/EmptyState.tsx"],"sourcesContent":["import type * as React from 'react';\n\nexport interface EmptyStateProps {\n /** What is empty, stated: 「還沒有專案」. */\n title: string;\n /** One sentence on what to do. */\n description?: string;\n /** Numbered first steps. */\n steps?: string[];\n /** Index of the current step. Default 0. */\n current?: number;\n /** The one button that starts the first step. */\n action?: React.ReactNode;\n}\n\n/** What a list or page shows when it has nothing yet: what is missing and the first step. */\nexport function EmptyState({ title, description, steps = [], current = 0, action }: EmptyStateProps) {\n return (\n <div className=\"ui-empty\">\n <div className=\"ui-empty-title\">{title}</div>\n {description ? <p className=\"ui-empty-desc\">{description}</p> : null}\n {steps.length ? (\n <ol className=\"ui-steps\">\n {steps.map((s, i) => (\n <li key={i} className={i === current ? 'is-current' : undefined} aria-current={i === current ? 'step' : undefined}>\n <span className=\"ui-step-num\">{i + 1}</span>\n <span>{s}</span>\n </li>\n ))}\n </ol>\n ) : null}\n {action ?? null}\n </div>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EmptyState.js","names":[],"sources":["../../../src/components/EmptyState/EmptyState.tsx"],"sourcesContent":["import type * as React from 'react';\nimport { codeText } from '../InlineCode/InlineCode';\n\nexport interface EmptyStateProps {\n /** What is empty, stated: 「還沒有專案」. */\n title: string;\n /** One sentence on what to do; `backticks` are code. */\n description?: string;\n /** Numbered first steps; `backticks` are code. */\n steps?: string[];\n /** Index of the current step. Default 0. */\n current?: number;\n /** The one button that starts the first step. */\n action?: React.ReactNode;\n}\n\n/** What a list or page shows when it has nothing yet: what is missing and the first step. */\nexport function EmptyState({ title, description, steps = [], current = 0, action }: EmptyStateProps) {\n return (\n <div className=\"ui-empty\">\n <div className=\"ui-empty-title\">{title}</div>\n {description ? <p className=\"ui-empty-desc\">{codeText(description)}</p> : null}\n {steps.length ? (\n <ol className=\"ui-steps\">\n {steps.map((s, i) => (\n <li key={i} className={i === current ? 'is-current' : undefined} aria-current={i === current ? 'step' : undefined}>\n <span className=\"ui-step-num\">{i + 1}</span>\n <span>{codeText(s)}</span>\n </li>\n ))}\n </ol>\n ) : null}\n {action ?? null}\n </div>\n );\n}\n"],"mappings":";;;;;AAiBA,SAAgB,WAAW,EAAE,OAAO,aAAa,QAAQ,CAAC,GAAG,UAAU,GAAG,UAA2B;CACnG,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA;GACE,oBAAC,OAAD;IAAK,WAAU;IAAkB,UAAA;GAAW,CAAA;GAC3C,cAAc,oBAAC,KAAD;IAAG,WAAU;IAAiB,UAAA,SAAS,WAAW;GAAK,CAAA,IAAI;GACzE,MAAM,SACL,oBAAC,MAAD;IAAI,WAAU;IACX,UAAA,MAAM,KAAK,GAAG,MACb,qBAAC,MAAD;KAAY,WAAW,MAAM,UAAU,eAAe,KAAA;KAAW,gBAAc,MAAM,UAAU,SAAS,KAAA;KAAxG,UAAA,CACE,oBAAC,QAAD;MAAM,WAAU;MAAe,UAAA,IAAI;KAAQ,CAAA,GAC3C,oBAAC,QAAD,EAAA,UAAO,SAAS,CAAC,EAAQ,CAAA,CACvB;IAHK,GAAA,CAGL,CACL;GACC,CAAA,IACF;GACH,UAAU;EACR;;AAET"}
|
|
@@ -2,6 +2,7 @@ export interface ErrorPageProps {
|
|
|
2
2
|
/** 404, 403 and 500 come with their own title and sentence. */
|
|
3
3
|
code: number;
|
|
4
4
|
title?: string;
|
|
5
|
+
/** One sentence on what happened and what to do; `backticks` are code. */
|
|
5
6
|
description?: string;
|
|
6
7
|
/** Default: history.back(). */
|
|
7
8
|
onBack?: () => void;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { tr } from "../../i18n.js";
|
|
3
3
|
import { cx } from "../../internal/util.js";
|
|
4
4
|
import { Button } from "../Button/Button.js";
|
|
5
|
+
import { codeText } from "../InlineCode/InlineCode.js";
|
|
5
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
// src/components/ErrorPage/ErrorPage.tsx
|
|
7
8
|
const ERR_COPY = {
|
|
@@ -26,7 +27,7 @@ function ErrorPage({ code, title, description, onBack, onHome, homeHref = "/", c
|
|
|
26
27
|
}),
|
|
27
28
|
/* @__PURE__ */ jsx("p", {
|
|
28
29
|
className: "ui-errorpage-desc",
|
|
29
|
-
children: description || (copy ? tr(copy[1]) : "")
|
|
30
|
+
children: codeText(description || (copy ? tr(copy[1]) : ""))
|
|
30
31
|
}),
|
|
31
32
|
/* @__PURE__ */ jsxs("div", {
|
|
32
33
|
className: "ui-errorpage-actions",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorPage.js","names":[],"sources":["../../../src/components/ErrorPage/ErrorPage.tsx"],"sourcesContent":["import { tr } from '../../i18n';\nimport { cx } from '../../internal/util';\nimport { Button } from '../Button/Button';\n\nconst ERR_COPY: Record<number, [string, string]> = {\n 404: ['找不到這個頁面', '網址可能打錯了,或這個頁面已經移除。'],\n 500: ['伺服器暫時無法回應', '這個問題已經記錄下來,請稍後重新整理再試。'],\n 403: ['沒有權限查看這個頁面', '請向管理員申請權限,或切換成有權限的帳號。'],\n};\n\nexport interface ErrorPageProps {\n /** 404, 403 and 500 come with their own title and sentence. */\n code: number;\n title?: string;\n description?: string;\n /** Default: history.back(). */\n onBack?: () => void;\n onHome?: () => void;\n /** Default '/'. */\n homeHref?: string;\n className?: string;\n}\n\n/** A whole page for 404, 403 and 500: the code, a title, one sentence, then 「回上一頁」 and 「回首頁」. */\nexport function ErrorPage({ code, title, description, onBack, onHome, homeHref = '/', className }: ErrorPageProps) {\n const copy = ERR_COPY[code];\n return (\n <main className={cx('ui-errorpage', className)}>\n <div className=\"ui-errorpage-code\" aria-hidden=\"true\">\n {code}\n </div>\n <h1 className=\"ui-errorpage-title\">{title || (copy ? tr(copy[0]) : tr('發生錯誤'))}</h1>\n <p className=\"ui-errorpage-desc\">{description || (copy ? tr(copy[1]) : '')}</p>\n <div className=\"ui-errorpage-actions\">\n <Button onClick={onBack ?? (() => history.back())}>{tr('回上一頁')}</Button>\n <Button variant=\"primary\" onClick={onHome ?? (() => (location.href = homeHref))}>\n {tr('回首頁')}\n </Button>\n </div>\n </main>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ErrorPage.js","names":[],"sources":["../../../src/components/ErrorPage/ErrorPage.tsx"],"sourcesContent":["import { tr } from '../../i18n';\nimport { cx } from '../../internal/util';\nimport { Button } from '../Button/Button';\nimport { codeText } from '../InlineCode/InlineCode';\n\nconst ERR_COPY: Record<number, [string, string]> = {\n 404: ['找不到這個頁面', '網址可能打錯了,或這個頁面已經移除。'],\n 500: ['伺服器暫時無法回應', '這個問題已經記錄下來,請稍後重新整理再試。'],\n 403: ['沒有權限查看這個頁面', '請向管理員申請權限,或切換成有權限的帳號。'],\n};\n\nexport interface ErrorPageProps {\n /** 404, 403 and 500 come with their own title and sentence. */\n code: number;\n title?: string;\n /** One sentence on what happened and what to do; `backticks` are code. */\n description?: string;\n /** Default: history.back(). */\n onBack?: () => void;\n onHome?: () => void;\n /** Default '/'. */\n homeHref?: string;\n className?: string;\n}\n\n/** A whole page for 404, 403 and 500: the code, a title, one sentence, then 「回上一頁」 and 「回首頁」. */\nexport function ErrorPage({ code, title, description, onBack, onHome, homeHref = '/', className }: ErrorPageProps) {\n const copy = ERR_COPY[code];\n return (\n <main className={cx('ui-errorpage', className)}>\n <div className=\"ui-errorpage-code\" aria-hidden=\"true\">\n {code}\n </div>\n <h1 className=\"ui-errorpage-title\">{title || (copy ? tr(copy[0]) : tr('發生錯誤'))}</h1>\n <p className=\"ui-errorpage-desc\">{codeText(description || (copy ? tr(copy[1]) : ''))}</p>\n <div className=\"ui-errorpage-actions\">\n <Button onClick={onBack ?? (() => history.back())}>{tr('回上一頁')}</Button>\n <Button variant=\"primary\" onClick={onHome ?? (() => (location.href = homeHref))}>\n {tr('回首頁')}\n </Button>\n </div>\n </main>\n );\n}\n"],"mappings":";;;;;;;AAKA,MAAM,WAA6C;CACjD,KAAK,CAAC,WAAW,oBAAoB;CACrC,KAAK,CAAC,aAAa,uBAAuB;CAC1C,KAAK,CAAC,cAAc,uBAAuB;AAC7C;;AAiBA,SAAgB,UAAU,EAAE,MAAM,OAAO,aAAa,QAAQ,QAAQ,WAAW,KAAK,aAA6B;CACjH,MAAM,OAAO,SAAS;CACtB,OACE,qBAAC,QAAD;EAAM,WAAW,GAAG,gBAAgB,SAAS;EAA7C,UAAA;GACE,oBAAC,OAAD;IAAK,WAAU;IAAoB,eAAY;IAC5C,UAAA;GACE,CAAA;GACL,oBAAC,MAAD;IAAI,WAAU;IAAsB,UAAA,UAAU,OAAO,GAAG,KAAK,EAAE,IAAI,GAAG,MAAM;GAAO,CAAA;GACnF,oBAAC,KAAD;IAAG,WAAU;IAAqB,UAAA,SAAS,gBAAgB,OAAO,GAAG,KAAK,EAAE,IAAI,GAAG;GAAK,CAAA;GACxF,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,oBAAC,QAAD;KAAQ,SAAS,iBAAiB,QAAQ,KAAK;KAAK,UAAA,GAAG,MAAM;IAAU,CAAA,GACvE,oBAAC,QAAD;KAAQ,SAAQ;KAAU,SAAS,iBAAkB,SAAS,OAAO;KAClE,UAAA,GAAG,KAAK;IACH,CAAA,CACL;;EACD;;AAEV"}
|
|
@@ -4,7 +4,7 @@ export interface TimelineEvent {
|
|
|
4
4
|
time: Date;
|
|
5
5
|
/** alert 告警, switch 切換, ai AI, manual 人工: an icon in front, read aloud as the kind's name. */
|
|
6
6
|
kind: EventKind;
|
|
7
|
-
/** What happened, one short sentence: 「F 區進氣溫度超過上限 29 °C
|
|
7
|
+
/** What happened, one short sentence: 「F 區進氣溫度超過上限 29 °C」; `backticks` are code. */
|
|
8
8
|
text: string;
|
|
9
9
|
}
|
|
10
10
|
export interface EventTimelineProps {
|
|
@@ -8,6 +8,7 @@ import arrows_left_right_default from "../../icons/ph/arrows-left-right.js";
|
|
|
8
8
|
import sparkle_default from "../../icons/ph/sparkle.js";
|
|
9
9
|
import user_default from "../../icons/ph/user.js";
|
|
10
10
|
import warning_default from "../../icons/ph/warning.js";
|
|
11
|
+
import { codeText } from "../InlineCode/InlineCode.js";
|
|
11
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
13
|
// src/components/EventTimeline/EventTimeline.tsx
|
|
13
14
|
includeIcons(arrows_left_right_default, sparkle_default, user_default, warning_default);
|
|
@@ -58,7 +59,7 @@ function EventTimeline({ events, label, empty, className }) {
|
|
|
58
59
|
}),
|
|
59
60
|
/* @__PURE__ */ jsx("span", {
|
|
60
61
|
className: "ui-events-text",
|
|
61
|
-
children: e.text
|
|
62
|
+
children: codeText(e.text)
|
|
62
63
|
})
|
|
63
64
|
]
|
|
64
65
|
}, e.id ?? i))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventTimeline.js","names":["phArrowsLeftRight","phSparkle","phUser","phWarning"],"sources":["../../../src/components/EventTimeline/EventTimeline.tsx"],"sourcesContent":["import { cx } from '../../internal/util';\nimport { format } from '../../format';\nimport { tr } from '../../i18n';\nimport { Icon, type IconName } from '../../icons/Icon';\nimport { includeIcons } from '../../icons/store';\nimport phArrowsLeftRight from '../../icons/ph/arrows-left-right';\nimport phSparkle from '../../icons/ph/sparkle';\nimport phUser from '../../icons/ph/user';\nimport phWarning from '../../icons/ph/warning';\n\nincludeIcons(phArrowsLeftRight, phSparkle, phUser, phWarning);\n\nexport type EventKind = 'alert' | 'switch' | 'ai' | 'manual';\n\nexport interface TimelineEvent {\n id?: string;\n time: Date;\n /** alert 告警, switch 切換, ai AI, manual 人工: an icon in front, read aloud as the kind's name. */\n kind: EventKind;\n /** What happened, one short sentence: 「F 區進氣溫度超過上限 29 °C
|
|
1
|
+
{"version":3,"file":"EventTimeline.js","names":["phArrowsLeftRight","phSparkle","phUser","phWarning"],"sources":["../../../src/components/EventTimeline/EventTimeline.tsx"],"sourcesContent":["import { cx } from '../../internal/util';\nimport { format } from '../../format';\nimport { tr } from '../../i18n';\nimport { Icon, type IconName } from '../../icons/Icon';\nimport { includeIcons } from '../../icons/store';\nimport phArrowsLeftRight from '../../icons/ph/arrows-left-right';\nimport phSparkle from '../../icons/ph/sparkle';\nimport phUser from '../../icons/ph/user';\nimport phWarning from '../../icons/ph/warning';\nimport { codeText } from '../InlineCode/InlineCode';\n\nincludeIcons(phArrowsLeftRight, phSparkle, phUser, phWarning);\n\nexport type EventKind = 'alert' | 'switch' | 'ai' | 'manual';\n\nexport interface TimelineEvent {\n id?: string;\n time: Date;\n /** alert 告警, switch 切換, ai AI, manual 人工: an icon in front, read aloud as the kind's name. */\n kind: EventKind;\n /** What happened, one short sentence: 「F 區進氣溫度超過上限 29 °C」; `backticks` are code. */\n text: string;\n}\n\nexport interface EventTimelineProps {\n events: TimelineEvent[];\n /** What the list is, for screen readers, e.g. 「近 4 小時的事件」. */\n label: string;\n /** Shown when there are no events, e.g. 「近 4 小時沒有事件」. Default 「沒有事件」. */\n empty?: string;\n className?: string;\n}\n\nconst KIND: Record<EventKind, { icon: IconName; name: string }> = {\n alert: { icon: 'warning', name: '告警' },\n switch: { icon: 'arrows-left-right', name: '切換' },\n ai: { icon: 'sparkle', name: 'AI' },\n manual: { icon: 'user', name: '人工' },\n};\n\n/** Events newest first, one row each: the time (Geist Mono), an icon for the kind, and what happened. */\nexport function EventTimeline({ events, label, empty, className }: EventTimelineProps) {\n const list = [...events].sort((a, b) => b.time.getTime() - a.time.getTime());\n if (!list.length) return <p className={cx('ui-events-empty', className)}>{empty ?? tr('沒有事件')}</p>;\n return (\n <ol className={cx('ui-events', className)} aria-label={label}>\n {list.map((e, i) => (\n <li key={e.id ?? i} className={'is-' + e.kind}>\n <time className=\"ui-events-time\" dateTime={e.time.toISOString()}>\n {format.time(e.time)}\n </time>\n <span className=\"ui-events-kind\" role=\"img\" aria-label={tr(KIND[e.kind].name)}>\n <Icon name={KIND[e.kind].icon} size={20} />\n </span>\n <span className=\"ui-events-text\">{codeText(e.text)}</span>\n </li>\n ))}\n </ol>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAWA,aAAaA,2BAAmBC,iBAAWC,cAAQC,eAAS;AAsB5D,MAAM,OAA4D;CAChE,OAAO;EAAE,MAAM;EAAW,MAAM;CAAK;CACrC,QAAQ;EAAE,MAAM;EAAqB,MAAM;CAAK;CAChD,IAAI;EAAE,MAAM;EAAW,MAAM;CAAK;CAClC,QAAQ;EAAE,MAAM;EAAQ,MAAM;CAAK;AACrC;;AAGA,SAAgB,cAAc,EAAE,QAAQ,OAAO,OAAO,aAAiC;CACrF,MAAM,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,KAAK,QAAQ,IAAI,EAAE,KAAK,QAAQ,CAAC;CAC3E,IAAI,CAAC,KAAK,QAAQ,OAAO,oBAAC,KAAD;EAAG,WAAW,GAAG,mBAAmB,SAAS;EAAI,UAAA,SAAS,GAAG,MAAM;CAAK,CAAA;CACjG,OACE,oBAAC,MAAD;EAAI,WAAW,GAAG,aAAa,SAAS;EAAG,cAAY;EACpD,UAAA,KAAK,KAAK,GAAG,MACZ,qBAAC,MAAD;GAAoB,WAAW,QAAQ,EAAE;GAAzC,UAAA;IACE,oBAAC,QAAD;KAAM,WAAU;KAAiB,UAAU,EAAE,KAAK,YAAY;KAC3D,UAAA,OAAO,KAAK,EAAE,IAAI;IACf,CAAA;IACN,oBAAC,QAAD;KAAM,WAAU;KAAiB,MAAK;KAAM,cAAY,GAAG,KAAK,EAAE,KAAK,CAAC,IAAI;KAC1E,UAAA,oBAAC,MAAD;MAAM,MAAM,KAAK,EAAE,KAAK,CAAC;MAAM,MAAM;KAAK,CAAA;IACtC,CAAA;IACN,oBAAC,QAAD;KAAM,WAAU;KAAkB,UAAA,SAAS,EAAE,IAAI;IAAQ,CAAA;GACvD;EARK,GAAA,EAAE,MAAM,CAQb,CACL;CACC,CAAA;AAER"}
|
|
@@ -7,7 +7,7 @@ export interface UploadFile {
|
|
|
7
7
|
/** 0 to 100 while uploading. */
|
|
8
8
|
progress?: number;
|
|
9
9
|
status?: 'uploading' | 'done' | 'error';
|
|
10
|
-
/** The cause and the fix, shown in red. */
|
|
10
|
+
/** The cause and the fix, shown in red; `backticks` are code. */
|
|
11
11
|
error?: string;
|
|
12
12
|
}
|
|
13
13
|
export interface FileUploadProps {
|
|
@@ -8,6 +8,7 @@ import { includeIcons } from "../../icons/store.js";
|
|
|
8
8
|
import file_default from "../../icons/ph/file.js";
|
|
9
9
|
import upload_simple_default from "../../icons/ph/upload-simple.js";
|
|
10
10
|
import x_default from "../../icons/ph/x.js";
|
|
11
|
+
import { codeText } from "../InlineCode/InlineCode.js";
|
|
11
12
|
import * as React from "react";
|
|
12
13
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
14
|
// src/components/FileUpload/FileUpload.tsx
|
|
@@ -96,7 +97,7 @@ function FileUpload({ label, files = [], onAdd, onRemove, onRetry, limitText, ac
|
|
|
96
97
|
}) : /* @__PURE__ */ jsxs("div", {
|
|
97
98
|
className: "ui-upload-error",
|
|
98
99
|
role: "alert",
|
|
99
|
-
children: [fl.error || tr("上傳失敗,請再試一次。"), onRetry ? /* @__PURE__ */ jsx("button", {
|
|
100
|
+
children: [codeText(fl.error || tr("上傳失敗,請再試一次。")), onRetry ? /* @__PURE__ */ jsx("button", {
|
|
100
101
|
type: "button",
|
|
101
102
|
className: "ui-link-btn",
|
|
102
103
|
onClick: () => onRetry(fl),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileUpload.js","names":["phFile","phUploadSimple","phX"],"sources":["../../../src/components/FileUpload/FileUpload.tsx"],"sourcesContent":["import * as React from 'react';\nimport { tr } from '../../i18n';\nimport { Icon } from '../../icons/Icon';\nimport { cx } from '../../internal/util';\nimport { FieldLabel } from '../../internal/Field';\nimport { ProgressBar } from '../ProgressBar/ProgressBar';\nimport { includeIcons } from '../../icons/store';\nimport phFile from '../../icons/ph/file';\nimport phUploadSimple from '../../icons/ph/upload-simple';\nimport phX from '../../icons/ph/x';\n\nincludeIcons(phFile, phUploadSimple, phX);\n\nexport interface UploadFile {\n id?: string | number;\n name: string;\n /** format.fileSize(bytes), e.g. 「1.2 MB」. */\n size?: string;\n /** 0 to 100 while uploading. */\n progress?: number;\n status?: 'uploading' | 'done' | 'error';\n /** The cause and the fix, shown in red. */\n error?: string;\n}\n\nexport interface FileUploadProps {\n label?: string;\n files?: UploadFile[];\n onAdd?: (files: File[]) => void;\n onRemove?: (file: UploadFile) => void;\n onRetry?: (file: UploadFile) => void;\n /** Written inside the drop zone, e.g. 「每個最大 100 MB」. */\n limitText?: string;\n accept?: string;\n /** Default true. */\n multiple?: boolean;\n className?: string;\n}\n\n/** A one-line drop zone and a list of files with progress. The upload itself is yours: pass files with progress and status. */\nexport function FileUpload({ label, files = [], onAdd, onRemove, onRetry, limitText, accept, multiple = true, className }: FileUploadProps) {\n const [drag, setDrag] = React.useState(false);\n const input = React.useRef<HTMLInputElement>(null);\n const add = (list: FileList | null) => {\n const arr = Array.from(list ?? []);\n if (arr.length) onAdd?.(arr);\n };\n return (\n <div className={cx('ui-upload', className)}>\n {label ? <FieldLabel>{label}</FieldLabel> : null}\n <div\n className={cx('ui-dropline', drag && 'is-drag')}\n onDragOver={(e) => {\n e.preventDefault();\n setDrag(true);\n }}\n onDragLeave={() => setDrag(false)}\n onDrop={(e) => {\n e.preventDefault();\n setDrag(false);\n add(e.dataTransfer.files);\n }}\n >\n <Icon name=\"upload-simple\" size={18} />\n <span className=\"ui-dropline-text\">\n {tr('拖放檔案,或 ')}\n <button type=\"button\" className=\"ui-link-btn\" onClick={() => input.current?.click()}>\n {tr('選擇檔案')}\n </button>\n </span>\n {limitText ? <span className=\"ui-dropline-limit\">{limitText}</span> : null}\n <input\n ref={input}\n type=\"file\"\n multiple={multiple}\n accept={accept}\n hidden\n onChange={(e) => {\n add(e.target.files);\n e.target.value = '';\n }}\n />\n </div>\n {files.length ? (\n <ul className=\"ui-upload-list\">\n {files.map((fl) => {\n const fail = fl.status === 'error';\n return (\n <li key={fl.id ?? fl.name} className={cx('ui-upload-item', fail && 'is-error')}>\n <Icon name=\"file\" size={20} className=\"ui-upload-icon\" />\n <div className=\"ui-upload-body\">\n <div className=\"ui-upload-row\">\n <span className=\"ui-upload-name\">{fl.name}</span>\n {fl.size ? <span className=\"ui-upload-size\">{fl.size}</span> : null}\n </div>\n {!fail ? (\n <ProgressBar value={fl.status === 'done' ? 100 : fl.progress || 0} aria-label={tr('{name} 上傳進度', { name: fl.name })} />\n ) : (\n <div className=\"ui-upload-error\" role=\"alert\">\n {fl.error || tr('上傳失敗,請再試一次。')}\n {onRetry ? (\n <button type=\"button\" className=\"ui-link-btn\" onClick={() => onRetry(fl)}>\n {tr('重試')}\n </button>\n ) : null}\n </div>\n )}\n </div>\n {onRemove ? (\n <button type=\"button\" className=\"ui-dialog-close\" aria-label={tr('移除 {name}', { name: fl.name })} onClick={() => onRemove(fl)}>\n <Icon name=\"x\" size={16} />\n </button>\n ) : null}\n </li>\n );\n })}\n </ul>\n ) : null}\n </div>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileUpload.js","names":["phFile","phUploadSimple","phX"],"sources":["../../../src/components/FileUpload/FileUpload.tsx"],"sourcesContent":["import * as React from 'react';\nimport { tr } from '../../i18n';\nimport { Icon } from '../../icons/Icon';\nimport { cx } from '../../internal/util';\nimport { FieldLabel } from '../../internal/Field';\nimport { ProgressBar } from '../ProgressBar/ProgressBar';\nimport { includeIcons } from '../../icons/store';\nimport phFile from '../../icons/ph/file';\nimport phUploadSimple from '../../icons/ph/upload-simple';\nimport phX from '../../icons/ph/x';\nimport { codeText } from '../InlineCode/InlineCode';\n\nincludeIcons(phFile, phUploadSimple, phX);\n\nexport interface UploadFile {\n id?: string | number;\n name: string;\n /** format.fileSize(bytes), e.g. 「1.2 MB」. */\n size?: string;\n /** 0 to 100 while uploading. */\n progress?: number;\n status?: 'uploading' | 'done' | 'error';\n /** The cause and the fix, shown in red; `backticks` are code. */\n error?: string;\n}\n\nexport interface FileUploadProps {\n label?: string;\n files?: UploadFile[];\n onAdd?: (files: File[]) => void;\n onRemove?: (file: UploadFile) => void;\n onRetry?: (file: UploadFile) => void;\n /** Written inside the drop zone, e.g. 「每個最大 100 MB」. */\n limitText?: string;\n accept?: string;\n /** Default true. */\n multiple?: boolean;\n className?: string;\n}\n\n/** A one-line drop zone and a list of files with progress. The upload itself is yours: pass files with progress and status. */\nexport function FileUpload({ label, files = [], onAdd, onRemove, onRetry, limitText, accept, multiple = true, className }: FileUploadProps) {\n const [drag, setDrag] = React.useState(false);\n const input = React.useRef<HTMLInputElement>(null);\n const add = (list: FileList | null) => {\n const arr = Array.from(list ?? []);\n if (arr.length) onAdd?.(arr);\n };\n return (\n <div className={cx('ui-upload', className)}>\n {label ? <FieldLabel>{label}</FieldLabel> : null}\n <div\n className={cx('ui-dropline', drag && 'is-drag')}\n onDragOver={(e) => {\n e.preventDefault();\n setDrag(true);\n }}\n onDragLeave={() => setDrag(false)}\n onDrop={(e) => {\n e.preventDefault();\n setDrag(false);\n add(e.dataTransfer.files);\n }}\n >\n <Icon name=\"upload-simple\" size={18} />\n <span className=\"ui-dropline-text\">\n {tr('拖放檔案,或 ')}\n <button type=\"button\" className=\"ui-link-btn\" onClick={() => input.current?.click()}>\n {tr('選擇檔案')}\n </button>\n </span>\n {limitText ? <span className=\"ui-dropline-limit\">{limitText}</span> : null}\n <input\n ref={input}\n type=\"file\"\n multiple={multiple}\n accept={accept}\n hidden\n onChange={(e) => {\n add(e.target.files);\n e.target.value = '';\n }}\n />\n </div>\n {files.length ? (\n <ul className=\"ui-upload-list\">\n {files.map((fl) => {\n const fail = fl.status === 'error';\n return (\n <li key={fl.id ?? fl.name} className={cx('ui-upload-item', fail && 'is-error')}>\n <Icon name=\"file\" size={20} className=\"ui-upload-icon\" />\n <div className=\"ui-upload-body\">\n <div className=\"ui-upload-row\">\n <span className=\"ui-upload-name\">{fl.name}</span>\n {fl.size ? <span className=\"ui-upload-size\">{fl.size}</span> : null}\n </div>\n {!fail ? (\n <ProgressBar value={fl.status === 'done' ? 100 : fl.progress || 0} aria-label={tr('{name} 上傳進度', { name: fl.name })} />\n ) : (\n <div className=\"ui-upload-error\" role=\"alert\">\n {codeText(fl.error || tr('上傳失敗,請再試一次。'))}\n {onRetry ? (\n <button type=\"button\" className=\"ui-link-btn\" onClick={() => onRetry(fl)}>\n {tr('重試')}\n </button>\n ) : null}\n </div>\n )}\n </div>\n {onRemove ? (\n <button type=\"button\" className=\"ui-dialog-close\" aria-label={tr('移除 {name}', { name: fl.name })} onClick={() => onRemove(fl)}>\n <Icon name=\"x\" size={16} />\n </button>\n ) : null}\n </li>\n );\n })}\n </ul>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,aAAaA,cAAQC,uBAAgBC,SAAG;;AA6BxC,SAAgB,WAAW,EAAE,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C,MAAD;MAA2B,WAAW,GAAG,kBAAkB,QAAQ,UAAU;MAA7E,UAAA;OACE,oBAAC,MAAD;QAAM,MAAK;QAAO,MAAM;QAAI,WAAU;OAAkB,CAAA;OACxD,qBAAC,OAAD;QAAK,WAAU;QAAf,UAAA,CACE,qBAAC,OAAD;SAAK,WAAU;SAAf,UAAA,CACE,oBAAC,QAAD;UAAM,WAAU;UAAkB,UAAA,GAAG;SAAW,CAAA,GAC/C,GAAG,OAAO,oBAAC,QAAD;UAAM,WAAU;UAAkB,UAAA,GAAG;SAAW,CAAA,IAAI,IAC5D;QACJ,CAAA,GAAA,CAAC,OACA,oBAAC,aAAD;SAAa,OAAO,GAAG,WAAW,SAAS,MAAM,GAAG,YAAY;SAAG,cAAY,GAAG,eAAe,EAAE,MAAM,GAAG,KAAK,CAAC;QAAI,CAAA,IAEtH,qBAAC,OAAD;SAAK,WAAU;SAAkB,MAAK;SAAtC,UAAA,CACG,SAAS,GAAG,SAAS,GAAG,aAAa,CAAC,GACtC,UACC,oBAAC,UAAD;UAAQ,MAAK;UAAS,WAAU;UAAc,eAAe,QAAQ,EAAE;UACpE,UAAA,GAAG,IAAI;SACF,CAAA,IACN,IACD;QAEJ,CAAA,CAAA;;OACJ,WACC,oBAAC,UAAD;QAAQ,MAAK;QAAS,WAAU;QAAkB,cAAY,GAAG,aAAa,EAAE,MAAM,GAAG,KAAK,CAAC;QAAG,eAAe,SAAS,EAAE;QAC1H,UAAA,oBAAC,MAAD;SAAM,MAAK;SAAI,MAAM;QAAK,CAAA;OACpB,CAAA,IACN;MACF;KAzBK,GAAA,GAAG,MAAM,GAAG,IAyBjB;IAER,CAAC;GACC,CAAA,IACF;EACD;;AAET"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cx } from "../../internal/util.js";
|
|
3
|
+
import { codeSpans, hasCodeSpan } from "../../internal/codeSpans.js";
|
|
3
4
|
import * as React from "react";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
// src/components/InlineCode/InlineCode.tsx
|
|
@@ -37,13 +38,10 @@ const CODE_REF = /^[\w./-]+\.[A-Za-z0-9]+:\d+(-\d+)?$/;
|
|
|
37
38
|
const isCodeRef = (span) => CODE_REF.test(span);
|
|
38
39
|
/** Text with `backtick` spans: renders them as InlineCode, never as raw backticks. */
|
|
39
40
|
function CodeText({ text, refHref, onRef, isRef = isCodeRef, as: Tag = "span", className }) {
|
|
40
|
-
const parts = String(text || "").split(/(`[^`]+`)/);
|
|
41
41
|
return /* @__PURE__ */ jsx(Tag, {
|
|
42
42
|
className,
|
|
43
|
-
children:
|
|
44
|
-
if (!
|
|
45
|
-
if (t[0] !== "`" || t.length < 2) return t;
|
|
46
|
-
const v = t.slice(1, -1);
|
|
43
|
+
children: codeSpans(text).map(({ code, text: v }, i) => {
|
|
44
|
+
if (!code) return v;
|
|
47
45
|
const href = refHref && isRef(v) ? refHref(v) || void 0 : void 0;
|
|
48
46
|
if (!(isRef(v) && (refHref ? !!href : !!onRef))) return /* @__PURE__ */ jsx(InlineCode, { children: v }, i);
|
|
49
47
|
const click = onRef ? (e) => {
|
|
@@ -66,6 +64,12 @@ function CodeText({ text, refHref, onRef, isRef = isCodeRef, as: Tag = "span", c
|
|
|
66
64
|
})
|
|
67
65
|
});
|
|
68
66
|
}
|
|
69
|
-
|
|
67
|
+
/** A sentence prop that takes a string: `backtick` spans become InlineCode, the backticks are not shown. Text without a
|
|
68
|
+
* pair of backticks comes back as it is, and anything that is not a string (an element) is left alone. */
|
|
69
|
+
function codeText(text) {
|
|
70
|
+
if (typeof text !== "string" || !hasCodeSpan(text)) return text;
|
|
71
|
+
return codeSpans(text).map((s, i) => s.code ? /* @__PURE__ */ jsx(InlineCode, { children: s.text }, i) : s.text);
|
|
72
|
+
}
|
|
73
|
+
export { CodeText, InlineCode, codeText, isCodeRef };
|
|
70
74
|
|
|
71
75
|
//# sourceMappingURL=InlineCode.js.map
|
|
@@ -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';\n\ninterface InlineCodeBase {\n children?: React.ReactNode;\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 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 onRef?: OnRef;\n /** Which spans are references. Default: a file name with a line number. */\n isRef?: (span: string) => boolean;\n as?: 'span' | 'p' | 'div' | 'li';\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
|
|
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 children?: React.ReactNode;\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 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 onRef?: OnRef;\n /** Which spans are references. Default: a file name with a line number. */\n isRef?: (span: string) => boolean;\n as?: 'span' | 'p' | 'div' | 'li';\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. Text without a\n * pair of backticks comes back as it is, and anything that is not a string (an element) is left alone. */\nexport function codeText(text: React.ReactNode): React.ReactNode {\n if (typeof text !== 'string' || !hasCodeSpan(text)) return text;\n return codeSpans(text).map((s, i) => (s.code ? <InlineCode key={i}>{s.text}</InlineCode> : s.text));\n}\n"],"mappings":";;;;;;;;AA+BA,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,SA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E,CAAA;AAET;;;AAIA,SAAgB,SAAS,MAAwC;CAC/D,IAAI,OAAO,SAAS,YAAY,CAAC,YAAY,IAAI,GAAG,OAAO;CAC3D,OAAO,UAAU,IAAI,CAAC,CAAC,KAAK,GAAG,MAAO,EAAE,OAAO,oBAAC,YAAD,EAAA,UAAqB,EAAE,KAAiB,GAAvB,CAAuB,IAAI,EAAE,IAAK;AACpG"}
|
|
@@ -25,12 +25,12 @@ export interface KpiCardProps {
|
|
|
25
25
|
/** `compact`: a 22 px number for a top bar, no sparkline; with verdict and target below. Default 'default' (31 px). */
|
|
26
26
|
size?: 'default' | 'compact';
|
|
27
27
|
/** How the figure is judged, in words: 「預測準確」(success), 「偏差變大」(warning), 「需要校正」(danger). Shown only
|
|
28
|
-
* when it is not success, in place of the target line and in its color; screen readers always hear it. */
|
|
28
|
+
* when it is not success, in place of the target line and in its color; screen readers always hear it. `backticks` are code. */
|
|
29
29
|
verdict?: {
|
|
30
30
|
tone: 'success' | 'warning' | 'danger';
|
|
31
31
|
text: string;
|
|
32
32
|
};
|
|
33
|
-
/** One gray line under the number, e.g. 「目標 ≤ 0.5 °C
|
|
33
|
+
/** One gray line under the number, e.g. 「目標 ≤ 0.5 °C(示意)」; `backticks` are code. */
|
|
34
34
|
target?: string;
|
|
35
35
|
className?: string;
|
|
36
36
|
}
|
|
@@ -4,6 +4,7 @@ import { devWarn } from "../../internal/dev.js";
|
|
|
4
4
|
import { I18N, tr } from "../../i18n.js";
|
|
5
5
|
import { kpiText, smoothPath, useCountUp, useFitText } from "../../internal/chart.js";
|
|
6
6
|
import { cx, digits } from "../../internal/util.js";
|
|
7
|
+
import { codeText } from "../InlineCode/InlineCode.js";
|
|
7
8
|
import * as React from "react";
|
|
8
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
// src/components/KpiCard/KpiCard.tsx
|
|
@@ -97,16 +98,16 @@ function KpiCard(props) {
|
|
|
97
98
|
}) : null,
|
|
98
99
|
verdict || target ? verdict && verdict.tone !== "success" ? /* @__PURE__ */ jsx("div", {
|
|
99
100
|
className: "ui-kpi-target ui-kpi-verdict is-" + verdict.tone,
|
|
100
|
-
children: target ? tr("{v}({t})", {
|
|
101
|
+
children: codeText(target ? tr("{v}({t})", {
|
|
101
102
|
v: verdict.text,
|
|
102
103
|
t: target
|
|
103
|
-
}) : verdict.text
|
|
104
|
+
}) : verdict.text)
|
|
104
105
|
}) : /* @__PURE__ */ jsxs("div", {
|
|
105
106
|
className: "ui-kpi-target",
|
|
106
107
|
children: [verdict ? /* @__PURE__ */ jsx("span", {
|
|
107
108
|
className: "ui-visually-hidden",
|
|
108
|
-
children: verdict.text + tr(",")
|
|
109
|
-
}) : null, target]
|
|
109
|
+
children: codeText(verdict.text + tr(","))
|
|
110
|
+
}) : null, codeText(target)]
|
|
110
111
|
}) : null
|
|
111
112
|
]
|
|
112
113
|
});
|
|
@@ -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';\n\nexport interface KpiCardProps {\n /** What is measured: 「本月營收」. */\n label: string;\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 decimals?: number;\n /** Change versus the comparison period. */\n delta?: number;\n /** '%' (default) or 'pt' for percentage points. */\n deltaUnit?: '%' | 'pt';\n /** Whether the change is good. Default: delta > 0. Set false where up is bad (error rate, cost). */\n good?: boolean;\n /** Recent values for the sparkline. */\n spark?: number[];\n /** Default 「較上週」. */\n compareLabel?: 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. */\n verdict?: { tone: 'success' | 'warning' | 'danger'; text: string };\n /** One gray line under the number, e.g. 「目標 ≤ 0.5 °C
|
|
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 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 decimals?: number;\n /** Change versus the comparison period. */\n delta?: number;\n /** '%' (default) or 'pt' for percentage points. */\n deltaUnit?: '%' | 'pt';\n /** Whether the change is good. Default: delta > 0. Set false where up is bad (error rate, cost). */\n good?: boolean;\n /** Recent values for the sparkline. */\n spark?: number[];\n /** Default 「較上週」. */\n compareLabel?: 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 className?: string;\n}\n\n/** Chinese in a figure (the 萬 and 億 of an abbreviated number) in the text font; Geist Mono stays on the digits. */\nfunction sansCjk(text: string): React.ReactNode[] {\n return text.split(/([\\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 { label, value, unit, decimals = 0, delta, deltaUnit, good, spark, compareLabel, size = 'default', verdict, target, className } = props;\n const compact = size === 'compact';\n devWarn(compact && !!spark, 'KpiCard', 'size=\"compact\" 不畫迷你折線,spark 會被忽略。拿掉 spark,或改用一般大小。');\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 isGood = good ?? up;\n const dTxt = hasDelta ? (deltaUnit === 'pt' ? tr('{n} 個百分點', { n: format.number(Math.abs(delta), 2) }) : format.percent(Math.abs(delta))) : '';\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\" aria-label={kpiText(value, props, decimals) + (showUnit ? ' ' + unit : '')}>\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', isGood ? 'is-good' : 'is-bad')}>\n {up ? '▲ ' : '▼ '}\n {digits(dTxt)}\n </span>\n <span className=\"ui-kpi-note\">{compareLabel || 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":";;;;;;;;;;;AA0CA,SAAS,QAAQ,MAAiC;CAChD,OAAO,KAAK,MAAM,iCAAiC,CAAC,CAAC,KAAK,GAAG,MAC3D,IAAI,IACF,oBAAC,QAAD;EAAc,WAAU;EACrB,UAAA;CACG,GAFK,CAEL,IAEN,CAEJ;AACF;;AAGA,SAAgB,QAAQ,OAAqB;CAC3C,MAAM,EAAE,OAAO,OAAO,MAAM,WAAW,GAAG,OAAO,WAAW,MAAM,OAAO,cAAc,OAAO,WAAW,S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r } from "../../i18n.js";
|
|
|
7
7
|
import { format } from "../../format.js";
|
|
8
8
|
import { cx, monoNums, resizeObserver } from "../../internal/util.js";
|
|
9
9
|
import { ScrollHint, useScrollHint } from "../../internal/scrollHint.js";
|
|
10
|
+
import { codeSpans } from "../../internal/codeSpans.js";
|
|
10
11
|
import { devWarn } from "../../internal/dev.js";
|
|
11
12
|
import { Icon } from "../../icons/Icon.js";
|
|
12
13
|
import { includeIcons } from "../../icons/store.js";
|
|
@@ -18,7 +19,17 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
18
19
|
includeIcons(lock_default, tag_default);
|
|
19
20
|
const scrollMemory = /* @__PURE__ */ new Map();
|
|
20
21
|
let measure;
|
|
21
|
-
const
|
|
22
|
+
const NUM = /(\d[\d,.]*)/;
|
|
23
|
+
/** A label in pieces: `code` (read the same way as CodeText, by codeSpans) and numbers are mono, the rest sans. */
|
|
24
|
+
function labelPieces(text) {
|
|
25
|
+
return codeSpans(text).flatMap((s) => s.code ? [{
|
|
26
|
+
mono: true,
|
|
27
|
+
text: s.text
|
|
28
|
+
}] : s.text.split(NUM).map((t, i) => ({
|
|
29
|
+
mono: i % 2 === 1,
|
|
30
|
+
text: t
|
|
31
|
+
})).filter((p) => p.text !== ""));
|
|
32
|
+
}
|
|
22
33
|
/** A label with a number: {n} in a string, or a function of the number; the number comes back as \u0001 (monoNums). */
|
|
23
34
|
function withNum(label, n, fallback) {
|
|
24
35
|
if (typeof label === "function") {
|
|
@@ -116,17 +127,16 @@ function HeightHandle(p) {
|
|
|
116
127
|
});
|
|
117
128
|
}
|
|
118
129
|
function labelWidth(text) {
|
|
119
|
-
const parts = text
|
|
130
|
+
const parts = labelPieces(text);
|
|
120
131
|
if (measure === void 0) measure = canvas2d();
|
|
121
132
|
const c = measure;
|
|
122
133
|
if (!c) return text.length * 9;
|
|
123
134
|
const cs = getComputedStyle(document.documentElement);
|
|
124
135
|
const sans = cs.getPropertyValue("--font-sans") || "sans-serif";
|
|
125
136
|
const mono = cs.getPropertyValue("--font-mono") || "monospace";
|
|
126
|
-
return parts.reduce((w,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return w + c.measureText(t[0] === "`" ? t.slice(1, -1) : t).width;
|
|
137
|
+
return parts.reduce((w, p) => {
|
|
138
|
+
c.font = "600 12px " + (p.mono ? mono : sans);
|
|
139
|
+
return w + c.measureText(p.text).width;
|
|
130
140
|
}, 0);
|
|
131
141
|
}
|
|
132
142
|
const LABELS_KEY = "ui-lg-labels:";
|
|
@@ -176,10 +186,10 @@ function wraps(text) {
|
|
|
176
186
|
return out;
|
|
177
187
|
}
|
|
178
188
|
function labelParts(text) {
|
|
179
|
-
return text
|
|
189
|
+
return labelPieces(text).map((p, i) => p.mono ? /* @__PURE__ */ jsx("span", {
|
|
180
190
|
className: "ui-lg-code",
|
|
181
|
-
children:
|
|
182
|
-
}, i) :
|
|
191
|
+
children: p.text
|
|
192
|
+
}, i) : p.text);
|
|
183
193
|
}
|
|
184
194
|
/** Rounded orthogonal path through the points. */
|
|
185
195
|
function route(pts, R) {
|