@seanyeh77/ui 0.43.0 → 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 +19 -19
- 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 +159 -65
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/DataTable/parts.js +4 -4
- package/dist/components/DataTable/parts.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 +31 -17
- package/dist/components/LayerGraph/LayerGraph.js.map +1 -1
- package/dist/components/LineChart/LineChart.js +1 -1
- package/dist/components/LineChart/LineChart.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 +23 -5
- 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/Section/Section.js +1 -1
- package/dist/components/Section/Section.js.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.js +4 -4
- package/dist/components/SegmentedControl/SegmentedControl.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/SplitPane/SplitPane.js +6 -6
- package/dist/components/SplitPane/SplitPane.js.map +1 -1
- package/dist/components/Tabs/Tabs.d.ts +4 -1
- package/dist/components/Tabs/Tabs.js +10 -7
- 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/components/Tour/Tour.js +3 -3
- package/dist/components/Tour/Tour.js.map +1 -1
- package/dist/components/Workbench/Workbench.js +7 -7
- package/dist/components/Workbench/Workbench.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/internal/scrollHint.js +5 -5
- package/dist/internal/scrollHint.js.map +1 -1
- package/dist/internal/tableTools.js +1 -1
- package/dist/internal/tableTools.js.map +1 -1
- package/dist/internal/util.js +5 -1
- package/dist/internal/util.js.map +1 -1
- 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 +4 -2
|
@@ -4,7 +4,7 @@ export interface AlertProps {
|
|
|
4
4
|
/** Default 'info'. danger is announced at once (role alert). */
|
|
5
5
|
tone?: AlertTone;
|
|
6
6
|
title?: string;
|
|
7
|
-
/** The cause and the fix, at most 2 short sentences. */
|
|
7
|
+
/** The cause and the fix, at most 2 short sentences; in a string, `backticks` are code. */
|
|
8
8
|
children?: React.ReactNode;
|
|
9
9
|
/** A verb, such as 重試. */
|
|
10
10
|
actionLabel?: string;
|
|
@@ -4,6 +4,7 @@ import { Icon } from "../../icons/Icon.js";
|
|
|
4
4
|
import { cx } from "../../internal/util.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 { jsx, jsxs } from "react/jsx-runtime";
|
|
8
9
|
// src/components/Alert/Alert.tsx
|
|
9
10
|
includeIcons(x_default);
|
|
@@ -32,7 +33,7 @@ function Alert({ tone = "info", title, children, actionLabel, onAction, onDismis
|
|
|
32
33
|
children: title
|
|
33
34
|
}) : null, children ? /* @__PURE__ */ jsx("div", {
|
|
34
35
|
className: "ui-alert-body",
|
|
35
|
-
children
|
|
36
|
+
children: codeText(children)
|
|
36
37
|
}) : null]
|
|
37
38
|
}),
|
|
38
39
|
actionLabel ? /* @__PURE__ */ jsx("button", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.js","names":["phX"],"sources":["../../../src/components/Alert/Alert.tsx"],"sourcesContent":["import type * as React from 'react';\nimport { tr } from '../../i18n';\nimport { Icon, type CustomIcon } from '../../icons/Icon';\nimport { cx } from '../../internal/util';\nimport { includeIcons } from '../../icons/store';\nimport phX from '../../icons/ph/x';\n\nincludeIcons(phX);\n\nexport type AlertTone = 'info' | 'success' | 'warning' | 'danger';\n\nconst ALERT_ICONS: Record<AlertTone, CustomIcon> = {\n info: 'M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18zM12 11v5M12 7.5v.5',\n success: 'M5 12.5l4.5 4.5L19 7',\n warning: 'M12 4l9 16H3zM12 10v4M12 17v.5',\n danger: 'M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18zM12 8v5M12 16.5v.5',\n};\n\nexport interface AlertProps {\n /** Default 'info'. danger is announced at once (role alert). */\n tone?: AlertTone;\n title?: string;\n /** The cause and the fix, at most 2 short sentences. */\n children?: React.ReactNode;\n /** A verb, such as 重試. */\n actionLabel?: string;\n onAction?: () => void;\n /** Adds × for info and success; warning and danger stay until the problem is solved. */\n onDismiss?: () => void;\n className?: string;\n}\n\n/** A message inside the page with a colored bar and icon. */\nexport function Alert({ tone = 'info', title, children, actionLabel, onAction, onDismiss, className }: AlertProps) {\n const t = ALERT_ICONS[tone] ? tone : 'info';\n const canClose = (t === 'info' || t === 'success') && onDismiss;\n return (\n <div className={cx('ui-alert', 'ui-alert-' + t, className)} role={t === 'danger' ? 'alert' : 'status'}>\n <Icon d={ALERT_ICONS[t]} className=\"ui-alert-icon\" />\n <div className=\"ui-alert-content\">\n {title ? <div className=\"ui-alert-title\">{title}</div> : null}\n {children ? <div className=\"ui-alert-body\">{children}</div> : null}\n </div>\n {actionLabel ? (\n <button type=\"button\" className=\"ui-btn ui-btn-secondary ui-alert-action\" onClick={onAction}>\n {actionLabel}\n </button>\n ) : null}\n {canClose ? (\n <button type=\"button\" className=\"ui-alert-close\" aria-label={tr('關閉提示')} onClick={onDismiss}>\n <Icon name=\"x\" size={16} />\n </button>\n ) : null}\n </div>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Alert.js","names":["phX"],"sources":["../../../src/components/Alert/Alert.tsx"],"sourcesContent":["import type * as React from 'react';\nimport { tr } from '../../i18n';\nimport { Icon, type CustomIcon } from '../../icons/Icon';\nimport { cx } from '../../internal/util';\nimport { includeIcons } from '../../icons/store';\nimport phX from '../../icons/ph/x';\nimport { codeText } from '../InlineCode/InlineCode';\n\nincludeIcons(phX);\n\nexport type AlertTone = 'info' | 'success' | 'warning' | 'danger';\n\nconst ALERT_ICONS: Record<AlertTone, CustomIcon> = {\n info: 'M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18zM12 11v5M12 7.5v.5',\n success: 'M5 12.5l4.5 4.5L19 7',\n warning: 'M12 4l9 16H3zM12 10v4M12 17v.5',\n danger: 'M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18zM12 8v5M12 16.5v.5',\n};\n\nexport interface AlertProps {\n /** Default 'info'. danger is announced at once (role alert). */\n tone?: AlertTone;\n title?: string;\n /** The cause and the fix, at most 2 short sentences; in a string, `backticks` are code. */\n children?: React.ReactNode;\n /** A verb, such as 重試. */\n actionLabel?: string;\n onAction?: () => void;\n /** Adds × for info and success; warning and danger stay until the problem is solved. */\n onDismiss?: () => void;\n className?: string;\n}\n\n/** A message inside the page with a colored bar and icon. */\nexport function Alert({ tone = 'info', title, children, actionLabel, onAction, onDismiss, className }: AlertProps) {\n const t = ALERT_ICONS[tone] ? tone : 'info';\n const canClose = (t === 'info' || t === 'success') && onDismiss;\n return (\n <div className={cx('ui-alert', 'ui-alert-' + t, className)} role={t === 'danger' ? 'alert' : 'status'}>\n <Icon d={ALERT_ICONS[t]} className=\"ui-alert-icon\" />\n <div className=\"ui-alert-content\">\n {title ? <div className=\"ui-alert-title\">{title}</div> : null}\n {children ? <div className=\"ui-alert-body\">{codeText(children)}</div> : null}\n </div>\n {actionLabel ? (\n <button type=\"button\" className=\"ui-btn ui-btn-secondary ui-alert-action\" onClick={onAction}>\n {actionLabel}\n </button>\n ) : null}\n {canClose ? (\n <button type=\"button\" className=\"ui-alert-close\" aria-label={tr('關閉提示')} onClick={onDismiss}>\n <Icon name=\"x\" size={16} />\n </button>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAQA,aAAaA,SAAG;AAIhB,MAAM,cAA6C;CACjD,MAAM;CACN,SAAS;CACT,SAAS;CACT,QAAQ;AACV;;AAiBA,SAAgB,MAAM,EAAE,OAAO,QAAQ,OAAO,UAAU,aAAa,UAAU,WAAW,aAAyB;CACjH,MAAM,IAAI,YAAY,QAAQ,OAAO;CACrC,MAAM,YAAY,MAAM,UAAU,MAAM,cAAc;CACtD,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,YAAY,cAAc,GAAG,SAAS;EAAG,MAAM,MAAM,WAAW,UAAU;EAA7F,UAAA;GACE,oBAAC,MAAD;IAAM,GAAG,YAAY;IAAI,WAAU;GAAiB,CAAA;GACpD,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACG,QAAQ,oBAAC,OAAD;KAAK,WAAU;KAAkB,UAAA;IAAW,CAAA,IAAI,MACxD,WAAW,oBAAC,OAAD;KAAK,WAAU;KAAiB,UAAA,SAAS,QAAQ;IAAO,CAAA,IAAI,IACrE;;GACJ,cACC,oBAAC,UAAD;IAAQ,MAAK;IAAS,WAAU;IAA0C,SAAS;IAChF,UAAA;GACK,CAAA,IACN;GACH,WACC,oBAAC,UAAD;IAAQ,MAAK;IAAS,WAAU;IAAiB,cAAY,GAAG,MAAM;IAAG,SAAS;IAChF,UAAA,oBAAC,MAAD;KAAM,MAAK;KAAI,MAAM;IAAK,CAAA;GACpB,CAAA,IACN;EACD;;AAET"}
|
|
@@ -2,7 +2,7 @@ import { DangerConfirm } from "../Button/Button.js";
|
|
|
2
2
|
export interface DangerZoneProps {
|
|
3
3
|
/** Default 「危險操作」. */
|
|
4
4
|
title?: string;
|
|
5
|
-
/** What the action destroys. */
|
|
5
|
+
/** What the action destroys; `backticks` are code. */
|
|
6
6
|
description: string;
|
|
7
7
|
/** Default 「刪除」. */
|
|
8
8
|
actionLabel?: string;
|
|
@@ -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/DangerZone/DangerZone.tsx
|
|
7
8
|
/** A red-bordered block at the bottom of a settings page for delete-type actions; the button asks to confirm. */
|
|
@@ -14,7 +15,7 @@ function DangerZone({ title, description, actionLabel, onAction, confirm, classN
|
|
|
14
15
|
children: title || tr("危險操作")
|
|
15
16
|
}), /* @__PURE__ */ jsxs("div", {
|
|
16
17
|
className: "ui-danger-row",
|
|
17
|
-
children: [/* @__PURE__ */ jsx("p", { children: description }), /* @__PURE__ */ jsx(Button, {
|
|
18
|
+
children: [/* @__PURE__ */ jsx("p", { children: codeText(description) }), /* @__PURE__ */ jsx(Button, {
|
|
18
19
|
variant: "danger",
|
|
19
20
|
confirm: confirm ?? { title: tr("{label}?", { label }) },
|
|
20
21
|
onClick: onAction,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DangerZone.js","names":[],"sources":["../../../src/components/DangerZone/DangerZone.tsx"],"sourcesContent":["import { tr } from '../../i18n';\nimport { cx } from '../../internal/util';\nimport { Button, type DangerConfirm } from '../Button/Button';\n\nexport interface DangerZoneProps {\n /** Default 「危險操作」. */\n title?: string;\n /** What the action destroys. */\n description: string;\n /** Default 「刪除」. */\n actionLabel?: string;\n /** Runs after the person confirms. */\n onAction: () => void;\n /** The confirm dialog: name the object in the title. */\n confirm: DangerConfirm;\n className?: string;\n}\n\n/** A red-bordered block at the bottom of a settings page for delete-type actions; the button asks to confirm. */\nexport function DangerZone({ title, description, actionLabel, onAction, confirm, className }: DangerZoneProps) {\n const label = actionLabel || tr('刪除');\n return (\n <section className={cx('ui-danger', className)}>\n <h2 className=\"ui-danger-title\">{title || tr('危險操作')}</h2>\n <div className=\"ui-danger-row\">\n <p>{description}</p>\n {/* Without a build step nothing enforces confirm: ask anyway. */}\n <Button variant=\"danger\" confirm={confirm ?? { title: tr('{label}?', { label }) }} onClick={onAction}>\n {label}\n </Button>\n </div>\n </section>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"DangerZone.js","names":[],"sources":["../../../src/components/DangerZone/DangerZone.tsx"],"sourcesContent":["import { tr } from '../../i18n';\nimport { cx } from '../../internal/util';\nimport { Button, type DangerConfirm } from '../Button/Button';\nimport { codeText } from '../InlineCode/InlineCode';\n\nexport interface DangerZoneProps {\n /** Default 「危險操作」. */\n title?: string;\n /** What the action destroys; `backticks` are code. */\n description: string;\n /** Default 「刪除」. */\n actionLabel?: string;\n /** Runs after the person confirms. */\n onAction: () => void;\n /** The confirm dialog: name the object in the title. */\n confirm: DangerConfirm;\n className?: string;\n}\n\n/** A red-bordered block at the bottom of a settings page for delete-type actions; the button asks to confirm. */\nexport function DangerZone({ title, description, actionLabel, onAction, confirm, className }: DangerZoneProps) {\n const label = actionLabel || tr('刪除');\n return (\n <section className={cx('ui-danger', className)}>\n <h2 className=\"ui-danger-title\">{title || tr('危險操作')}</h2>\n <div className=\"ui-danger-row\">\n <p>{codeText(description)}</p>\n {/* Without a build step nothing enforces confirm: ask anyway. */}\n <Button variant=\"danger\" confirm={confirm ?? { title: tr('{label}?', { label }) }} onClick={onAction}>\n {label}\n </Button>\n </div>\n </section>\n );\n}\n"],"mappings":";;;;;;;;AAoBA,SAAgB,WAAW,EAAE,OAAO,aAAa,aAAa,UAAU,SAAS,aAA8B;CAC7G,MAAM,QAAQ,eAAe,GAAG,IAAI;CACpC,OACE,qBAAC,WAAD;EAAS,WAAW,GAAG,aAAa,SAAS;EAA7C,UAAA,CACE,oBAAC,MAAD;GAAI,WAAU;GAAmB,UAAA,SAAS,GAAG,MAAM;EAAM,CAAA,GACzD,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,oBAAC,KAAD,EAAA,UAAI,SAAS,WAAW,EAAK,CAAA,GAE7B,oBAAC,QAAD;IAAQ,SAAQ;IAAS,SAAS,WAAW,EAAE,OAAO,GAAG,YAAY,EAAE,MAAM,CAAC,EAAE;IAAG,SAAS;IACzF,UAAA;GACK,CAAA,CACL;EACE,CAAA,CAAA;;AAEb"}
|
|
@@ -24,13 +24,18 @@ export interface DataTableProps<R extends Row = Record<string, unknown>> {
|
|
|
24
24
|
pageSize?: number;
|
|
25
25
|
/** Change it when the rows become a different data set: search, filters, sort, page, selection and summary reset. */
|
|
26
26
|
resetKey?: string | number;
|
|
27
|
-
/**
|
|
27
|
+
/** The page's primary action, one primary Button (「新增」): at the right end of the toolbar, on one row with the
|
|
28
|
+
* summary tabs and the search field when they fit. Use it instead of a Card head that holds only this button. */
|
|
29
|
+
action?: React.ReactNode;
|
|
30
|
+
/** Checkboxes appear when a row is hovered, and on every row once any row is selected; the header's is always shown. */
|
|
28
31
|
selectable?: boolean;
|
|
29
32
|
/** Buttons for the bar that replaces the header while rows are selected. */
|
|
30
33
|
bulkActions?: (ids: string[], clear: () => void) => React.ReactNode;
|
|
31
|
-
/** IconButtons
|
|
34
|
+
/** IconButtons over the row's right end, shown while the row is hovered or has keyboard focus (always on touch
|
|
35
|
+
* screens and phone cards). They take no column of their own. */
|
|
32
36
|
rowActions?: (row: R) => React.ReactNode;
|
|
33
|
-
/** px
|
|
37
|
+
/** px kept free at the end of each row's last cell for the row actions, so they never cover its content. Default:
|
|
38
|
+
* the width the actions take, measured. */
|
|
34
39
|
actionsWidth?: number;
|
|
35
40
|
/** Search box (default on; false hides it). Searches every column unless keys is given. */
|
|
36
41
|
search?: false | {
|
|
@@ -5,7 +5,7 @@ import { Tabs } from "../Tabs/Tabs.js";
|
|
|
5
5
|
import { format } from "../../format.js";
|
|
6
6
|
import { tr, unitFor } from "../../i18n.js";
|
|
7
7
|
import { Icon } from "../../icons/Icon.js";
|
|
8
|
-
import { TOUCH_ONLY, copyText, cx, idPart, monoNums, reduced, seenOnly, useMedia, useNarrow } from "../../internal/util.js";
|
|
8
|
+
import { TOUCH_ONLY, copyText, cx, idPart, monoNums, reduced, resizeObserver, seenOnly, useMedia, useNarrow } from "../../internal/util.js";
|
|
9
9
|
import { Tooltip } from "../Tooltip/Tooltip.js";
|
|
10
10
|
import { devWarn } from "../../internal/dev.js";
|
|
11
11
|
import { CheckMark } from "../../internal/Field.js";
|
|
@@ -24,6 +24,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
24
24
|
import { createPortal } from "react-dom";
|
|
25
25
|
// src/components/DataTable/DataTable.tsx
|
|
26
26
|
includeIcons(caret_right_default, check_default, x_default);
|
|
27
|
+
const SEL = 40;
|
|
27
28
|
const MOVE = {
|
|
28
29
|
dur: 320,
|
|
29
30
|
stagger: 25,
|
|
@@ -39,13 +40,18 @@ const isNum = (c) => c.numeric || c.format === "money" || c.format === "percent"
|
|
|
39
40
|
const isShort = (c) => isNum(c) || !!c.unit || isDateCol(c) || c.mobile === "status";
|
|
40
41
|
const TEXT_HUG_MAX = 280;
|
|
41
42
|
const HUG_START = 96;
|
|
42
|
-
const
|
|
43
|
+
const TEXT_HUG_MIN = 128;
|
|
44
|
+
const MAIN_WANT_MAX = 320;
|
|
45
|
+
const LONG_WANT_MAX = 512;
|
|
46
|
+
const TOOL_GAP = 8;
|
|
43
47
|
const isoOf = (d, dateOnly) => dateOnly ? `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}` : d.toISOString();
|
|
44
|
-
/** The width of what an element holds (its text and children, not absolutely placed parts such as the column border).
|
|
48
|
+
/** The width of what an element holds (its text and children, not absolutely placed parts such as the column border).
|
|
49
|
+
* Null where text cannot be measured (jsdom has no Range#getBoundingClientRect): the column keeps its default width. */
|
|
45
50
|
function contentWidth(el) {
|
|
46
51
|
let left = Infinity;
|
|
47
52
|
let right = -Infinity;
|
|
48
53
|
const range = document.createRange();
|
|
54
|
+
if (typeof range.getBoundingClientRect !== "function") return null;
|
|
49
55
|
for (const n of el.childNodes) {
|
|
50
56
|
let r = null;
|
|
51
57
|
if (n instanceof HTMLElement) {
|
|
@@ -188,6 +194,12 @@ function DataTable(p) {
|
|
|
188
194
|
const [sel, setSel] = React.useState({});
|
|
189
195
|
const [sumVal, setSumVal] = React.useState("all");
|
|
190
196
|
const [fit, setFit] = React.useState({});
|
|
197
|
+
const [clipped, setClipped] = React.useState(null);
|
|
198
|
+
const [want, setWant] = React.useState({});
|
|
199
|
+
const wantRef = React.useRef(want);
|
|
200
|
+
const [roomy, setRoomy] = React.useState(false);
|
|
201
|
+
const [actsW, setActsW] = React.useState(null);
|
|
202
|
+
const [onerowState, setOnerow] = React.useState(false);
|
|
191
203
|
const [widths, setWidthsState] = React.useState(() => {
|
|
192
204
|
if (!p.widthKey) return null;
|
|
193
205
|
try {
|
|
@@ -214,6 +226,10 @@ function DataTable(p) {
|
|
|
214
226
|
const prev = noSearch ? rootRef.current?.previousElementSibling : null;
|
|
215
227
|
setHeadSlot(prev instanceof HTMLElement && prev.classList.contains("ui-card-head") && prev.parentElement?.classList.contains("ui-card") ? prev : null);
|
|
216
228
|
}, [noSearch]);
|
|
229
|
+
React.useEffect(() => {
|
|
230
|
+
const prev = rootRef.current?.previousElementSibling;
|
|
231
|
+
devWarn(prev?.classList.contains("ui-card-head") && !prev.querySelector(".ui-card-title") && prev.querySelector(".ui-card-actions"), "DataTable", "the Card around this table has actions but no title, so its one button takes a row of its own above the table. Pass the page's primary action to DataTable's action instead: it goes at the right end of the toolbar.");
|
|
232
|
+
}, []);
|
|
217
233
|
const [resetKey, setResetKey] = React.useState(p.resetKey);
|
|
218
234
|
const resetting = resetKey !== p.resetKey;
|
|
219
235
|
if (resetting) {
|
|
@@ -227,6 +243,8 @@ function DataTable(p) {
|
|
|
227
243
|
if (!colsKey) setToggledState({});
|
|
228
244
|
setOpened({});
|
|
229
245
|
setFit({});
|
|
246
|
+
setWant({});
|
|
247
|
+
setClipped(null);
|
|
230
248
|
}
|
|
231
249
|
const valuesKey = JSON.stringify(values);
|
|
232
250
|
const sortKey = JSON.stringify(sort);
|
|
@@ -481,32 +499,32 @@ function DataTable(p) {
|
|
|
481
499
|
setPage(0);
|
|
482
500
|
};
|
|
483
501
|
const hasAct = !!p.rowActions;
|
|
484
|
-
const
|
|
502
|
+
const onerow = onerowState && !narrow;
|
|
485
503
|
const hasTitle = shownCols.some((c) => c.mobile === "title");
|
|
486
504
|
const mobileClass = (c, ci) => {
|
|
487
505
|
const m = c.mobile || (!hasTitle && ci === 0 ? "title" : null);
|
|
488
506
|
return m ? "is-m-" + m : null;
|
|
489
507
|
};
|
|
490
508
|
const longCols = shownCols.filter((c) => c.long || c.fullText);
|
|
491
|
-
const expander = longCols.length > 0 && !narrow;
|
|
509
|
+
const expander = longCols.length > 0 && !narrow && (clipped !== false || longCols.some((c) => c.fullText) || visIds.some((id) => opened[id]));
|
|
492
510
|
const EXP = 40;
|
|
493
511
|
const mainKey = (shownCols.find((c) => !isShort(c) && !c.long && c.grow !== 0) ?? shownCols[0])?.key;
|
|
494
512
|
const grows = (c) => c.grow != null ? c.grow > 0 : c.long || c.key === mainKey;
|
|
495
513
|
const minOf = (c) => {
|
|
496
|
-
if (grows(c)) return Math.max(c.width || (isNum(c) ? 96 : 120), fit[c.key] || 0);
|
|
497
|
-
const
|
|
498
|
-
|
|
514
|
+
if (grows(c)) return Math.max(c.width || (isNum(c) ? 96 : 120), fit[c.key] || 0, roomy ? want[c.key] || 0 : 0);
|
|
515
|
+
const text = c.width == null && !isShort(c);
|
|
516
|
+
const cap = text ? TEXT_HUG_MAX : Infinity;
|
|
517
|
+
return Math.max(c.width || 0, 48, text ? TEXT_HUG_MIN : 0, Math.min(fit[c.key] ?? c.width ?? HUG_START, cap));
|
|
499
518
|
};
|
|
500
519
|
const layout = (w) => {
|
|
501
520
|
const colW = (c) => w ? `${w[c.key] ?? minOf(c)}px` : grows(c) ? `minmax(${minOf(c)}px, ${c.grow || 1}fr)` : `${minOf(c)}px`;
|
|
502
521
|
return {
|
|
503
522
|
gridTemplateColumns: [
|
|
504
523
|
expander ? "40px" : null,
|
|
505
|
-
selectable ? "
|
|
506
|
-
...shownCols.map(colW)
|
|
507
|
-
hasAct ? actW + "px" : null
|
|
524
|
+
selectable ? "40px" : null,
|
|
525
|
+
...shownCols.map(colW)
|
|
508
526
|
].filter(Boolean).join(" "),
|
|
509
|
-
minWidth: (expander ? EXP : 0) + (selectable ?
|
|
527
|
+
minWidth: (expander ? EXP : 0) + (selectable ? SEL : 0) + shownCols.reduce((a, c) => a + (w ? w[c.key] ?? minOf(c) : minOf(c)), 0)
|
|
510
528
|
};
|
|
511
529
|
};
|
|
512
530
|
const pageGrid = layout(widths);
|
|
@@ -527,6 +545,7 @@ function DataTable(p) {
|
|
|
527
545
|
React.useLayoutEffect(() => {
|
|
528
546
|
const root = rootRef.current;
|
|
529
547
|
if (!root || narrow) return;
|
|
548
|
+
wantRef.current = {};
|
|
530
549
|
const measure = () => {
|
|
531
550
|
const need = {};
|
|
532
551
|
for (const el of root.querySelectorAll(":scope > .ui-dt-scroller .ui-dt-body .ui-dt-cell[data-col]:not(.is-long):not(.is-hug)")) {
|
|
@@ -534,13 +553,27 @@ function DataTable(p) {
|
|
|
534
553
|
const key = el.dataset.col;
|
|
535
554
|
if (over > 1 && key) need[key] = Math.max(need[key] ?? 0, Math.ceil(el.getBoundingClientRect().width + over));
|
|
536
555
|
}
|
|
556
|
+
const pad = (el) => {
|
|
557
|
+
const st = getComputedStyle(el);
|
|
558
|
+
return (parseFloat(st.paddingLeft) || 0) + (parseFloat(st.paddingRight) || 0) + (parseFloat(st.borderRightWidth) || 0);
|
|
559
|
+
};
|
|
537
560
|
const hugs = root.querySelectorAll(":scope > .ui-dt-scroller .ui-dt-cell.is-hug[data-col]");
|
|
538
|
-
|
|
561
|
+
const growCells = root.querySelectorAll(":scope > .ui-dt-scroller .ui-dt-cell.is-grow[data-col]");
|
|
562
|
+
const asks = {};
|
|
563
|
+
if (hugs.length || growCells.length) {
|
|
539
564
|
root.classList.add("is-measuring");
|
|
540
565
|
for (const el of hugs) {
|
|
541
566
|
const key = el.dataset.col;
|
|
542
|
-
const
|
|
543
|
-
if (key) need[key] = Math.max(need[key] ?? 0, Math.ceil(
|
|
567
|
+
const w = contentWidth(el.querySelector(":scope > .ui-dt-stack > .ui-dt-main") ?? el);
|
|
568
|
+
if (key && w !== null) need[key] = Math.max(need[key] ?? 0, Math.ceil(w + pad(el)));
|
|
569
|
+
}
|
|
570
|
+
for (const el of growCells) {
|
|
571
|
+
const key = el.dataset.col;
|
|
572
|
+
const long = el.querySelector(".ui-dt-long-text");
|
|
573
|
+
const w = long ? long.getBoundingClientRect().width : contentWidth(el.querySelector(":scope > .ui-dt-stack > .ui-dt-main") ?? el);
|
|
574
|
+
if (!key || w === null || !w) continue;
|
|
575
|
+
const max = el.classList.contains("is-long") ? LONG_WANT_MAX : MAIN_WANT_MAX;
|
|
576
|
+
asks[key] = Math.max(asks[key] ?? 0, Math.min(max, Math.ceil(w + pad(el))));
|
|
544
577
|
}
|
|
545
578
|
root.classList.remove("is-measuring");
|
|
546
579
|
}
|
|
@@ -551,6 +584,46 @@ function DataTable(p) {
|
|
|
551
584
|
...Object.fromEntries(grow)
|
|
552
585
|
} : f;
|
|
553
586
|
});
|
|
587
|
+
const head = root.querySelector(":scope > .ui-dt-scroller .ui-dt-head");
|
|
588
|
+
const scroll = root.querySelector(":scope > .ui-dt-scroller .ui-dt-scroll");
|
|
589
|
+
if (head && scroll && scroll.clientWidth > 0) {
|
|
590
|
+
const before = wantRef.current;
|
|
591
|
+
const more = Object.entries(asks).filter(([k, w]) => w > (before[k] ?? 0));
|
|
592
|
+
const merged = more.length ? {
|
|
593
|
+
...before,
|
|
594
|
+
...Object.fromEntries(more)
|
|
595
|
+
} : before;
|
|
596
|
+
wantRef.current = merged;
|
|
597
|
+
if (more.length) setWant(merged);
|
|
598
|
+
let used = 0;
|
|
599
|
+
for (const el of head.children) {
|
|
600
|
+
if (el.classList.contains("ui-dt-exp")) continue;
|
|
601
|
+
const key = el.dataset.col;
|
|
602
|
+
used += key && el.classList.contains("is-grow") ? Math.max(asks[key] ?? 0, merged[key] ?? 0, 48) : el.getBoundingClientRect().width;
|
|
603
|
+
}
|
|
604
|
+
setRoomy(used <= scroll.clientWidth);
|
|
605
|
+
}
|
|
606
|
+
let aw = 0;
|
|
607
|
+
for (const el of root.querySelectorAll(":scope > .ui-dt-scroller .ui-dt-body .ui-dt-acts")) if (el.childElementCount) aw = Math.max(aw, Math.ceil(el.getBoundingClientRect().width));
|
|
608
|
+
if (root.querySelector(":scope > .ui-dt-scroller .ui-dt-body .ui-dt-acts")) setActsW((v) => v !== null && Math.abs(v - aw) <= 1 ? v : aw);
|
|
609
|
+
const tools = root.querySelector(":scope > .ui-dt-tools.has-summary");
|
|
610
|
+
if (tools && tools.clientWidth > 0) {
|
|
611
|
+
const tabs = tools.querySelector(".ui-dt-summary");
|
|
612
|
+
const actions = tools.querySelector(":scope > .ui-dt-actions");
|
|
613
|
+
let need2 = (tabs?.scrollWidth ?? 0) + (tools.querySelector(":scope > .ui-dt-search") ? 256 : TOOL_GAP);
|
|
614
|
+
const parts = actions ? [...actions.children].filter((e) => getComputedStyle(e).position !== "absolute") : [];
|
|
615
|
+
for (const e of parts) {
|
|
616
|
+
const text = e.querySelector(".ui-dt-sortbtn-text");
|
|
617
|
+
need2 += e.getBoundingClientRect().width + (text ? Math.max(0, text.scrollWidth - text.clientWidth) : 0);
|
|
618
|
+
}
|
|
619
|
+
need2 += Math.max(0, parts.length - 1) * TOOL_GAP;
|
|
620
|
+
setOnerow(need2 <= tools.clientWidth);
|
|
621
|
+
}
|
|
622
|
+
const scroller = root.querySelector(":scope > .ui-dt-scroller .ui-dt-scroll");
|
|
623
|
+
if (scroller && scroller.clientWidth > 0) {
|
|
624
|
+
const cut = [...root.querySelectorAll(":scope > .ui-dt-scroller .ui-dt-body .ui-dt-long")].some((el) => el.scrollWidth > el.clientWidth + 1);
|
|
625
|
+
setClipped(cut);
|
|
626
|
+
}
|
|
554
627
|
};
|
|
555
628
|
let frame = 0;
|
|
556
629
|
const later = () => {
|
|
@@ -565,18 +638,29 @@ function DataTable(p) {
|
|
|
565
638
|
const mo = new MutationObserver(later);
|
|
566
639
|
for (const el of root.querySelectorAll(":scope > .ui-dt-scroller .ui-dt-table, :scope > .ui-dt-scroller .ui-dt-body")) mo.observe(el, { childList: true });
|
|
567
640
|
document.fonts?.ready.then(later).catch(() => {});
|
|
641
|
+
let lastW = -1;
|
|
642
|
+
const ro = resizeObserver((entries) => {
|
|
643
|
+
const w = Math.round(entries[0]?.contentRect.width ?? 0);
|
|
644
|
+
if (w !== lastW && lastW >= 0) later();
|
|
645
|
+
lastW = w;
|
|
646
|
+
});
|
|
647
|
+
ro?.observe(root);
|
|
568
648
|
return () => {
|
|
569
649
|
mo.disconnect();
|
|
650
|
+
ro?.disconnect();
|
|
570
651
|
cancelAnimationFrame(frame);
|
|
571
652
|
measureRef.current = () => {};
|
|
572
653
|
};
|
|
573
654
|
}, [narrow, resetKey]);
|
|
655
|
+
React.useLayoutEffect(() => {
|
|
656
|
+
measureRef.current();
|
|
657
|
+
}, [actsW]);
|
|
574
658
|
const contentKey = `${visIds.join("")}|${shownCols.map((c) => c.key).join(",")}|${list.length}|${q}|${!!p.totals}`;
|
|
575
659
|
React.useLayoutEffect(() => {
|
|
576
660
|
measureRef.current();
|
|
577
661
|
}, [contentKey, rows]);
|
|
578
|
-
const stickyStyle = (ci) => ci === 0 && sticky ? { left: (expander ? EXP : 0) + (selectable ?
|
|
579
|
-
const cellClass = (c, ci, ...more) => cx("ui-dt-cell", isNum(c) && "is-num",
|
|
662
|
+
const stickyStyle = (ci) => ci === 0 && sticky ? { left: (expander ? EXP : 0) + (selectable ? SEL : 0) } : void 0;
|
|
663
|
+
const cellClass = (c, ci, ...more) => cx("ui-dt-cell", isNum(c) && "is-num", grows(c) ? "is-grow" : "is-hug", ci === 0 && sticky && "is-sticky is-sticky-end", ci === shownCols.length - 1 && "is-lastcol", ...more);
|
|
580
664
|
const lead = (what) => sticky ? {
|
|
581
665
|
className: "is-sticky",
|
|
582
666
|
style: { left: what === "sel" && expander ? EXP : 0 }
|
|
@@ -694,12 +778,7 @@ function DataTable(p) {
|
|
|
694
778
|
onReset: () => setW(null)
|
|
695
779
|
})]
|
|
696
780
|
}, c.key);
|
|
697
|
-
})
|
|
698
|
-
hasAct ? /* @__PURE__ */ jsx("div", {
|
|
699
|
-
className: "ui-dt-cell",
|
|
700
|
-
role: "columnheader",
|
|
701
|
-
"aria-label": tr("操作")
|
|
702
|
-
}) : null
|
|
781
|
+
})
|
|
703
782
|
]
|
|
704
783
|
});
|
|
705
784
|
};
|
|
@@ -742,6 +821,10 @@ function DataTable(p) {
|
|
|
742
821
|
})
|
|
743
822
|
]
|
|
744
823
|
});
|
|
824
|
+
else if (raw === null || raw === void 0 || raw === "") v = /* @__PURE__ */ jsx("span", {
|
|
825
|
+
className: "ui-dt-none",
|
|
826
|
+
children: cellText(c, raw)
|
|
827
|
+
});
|
|
745
828
|
else v = markMatch(cellText(c, raw), mark);
|
|
746
829
|
return v;
|
|
747
830
|
};
|
|
@@ -890,9 +973,35 @@ function DataTable(p) {
|
|
|
890
973
|
},
|
|
891
974
|
filterButton: () => (inZoom ? zoomRef : rootRef).current?.querySelector(".ui-dt-filterbtn") ?? null
|
|
892
975
|
});
|
|
976
|
+
const summaryView = summary ? /* @__PURE__ */ jsx(Tabs, {
|
|
977
|
+
className: "ui-dt-summary",
|
|
978
|
+
label: summary.label || tr("依狀態篩選"),
|
|
979
|
+
unit: summary.unit || "筆",
|
|
980
|
+
value: sumVal,
|
|
981
|
+
onChange: (v) => {
|
|
982
|
+
capture("sort");
|
|
983
|
+
setSumVal(v);
|
|
984
|
+
setPage(0);
|
|
985
|
+
},
|
|
986
|
+
items: [{
|
|
987
|
+
id: "all",
|
|
988
|
+
label: tr("全部"),
|
|
989
|
+
count: sumAll.length
|
|
990
|
+
}, ...summary.items.map((it) => ({
|
|
991
|
+
id: String(it.value),
|
|
992
|
+
label: it.label,
|
|
993
|
+
count: sumAll.filter((x) => String(get(x.r, summary.key)) === String(it.value)).length
|
|
994
|
+
}))],
|
|
995
|
+
hideUnit: true
|
|
996
|
+
}) : null;
|
|
997
|
+
const showCount = !summary || list.length !== baseCount;
|
|
893
998
|
const toolsView = (inZoom, inHead = false) => /* @__PURE__ */ jsxs("div", {
|
|
894
|
-
className: cx("ui-dt-tools", inHead && "is-inhead"),
|
|
999
|
+
className: cx("ui-dt-tools", inHead && "is-inhead", summaryView && !inZoom && !inHead && "has-summary", onerow && !inZoom && !inHead && "is-onerow"),
|
|
895
1000
|
children: [
|
|
1001
|
+
summaryView && !inZoom && !inHead ? /* @__PURE__ */ jsx("div", {
|
|
1002
|
+
className: "ui-dt-sumwrap",
|
|
1003
|
+
children: summaryView
|
|
1004
|
+
}) : null,
|
|
896
1005
|
search === false && p.caption && !inZoom && !inHead ? /* @__PURE__ */ jsx("div", {
|
|
897
1006
|
className: "ui-dt-caption",
|
|
898
1007
|
children: p.caption
|
|
@@ -933,7 +1042,7 @@ function DataTable(p) {
|
|
|
933
1042
|
}
|
|
934
1043
|
}) : null,
|
|
935
1044
|
/* @__PURE__ */ jsxs("span", {
|
|
936
|
-
className: "ui-dt-result",
|
|
1045
|
+
className: cx("ui-dt-result", !showCount && "ui-visually-hidden"),
|
|
937
1046
|
children: [/* @__PURE__ */ jsx("span", {
|
|
938
1047
|
"aria-hidden": "true",
|
|
939
1048
|
children: seenOnly(tr("{n} / {total} 筆", {
|
|
@@ -970,6 +1079,10 @@ function DataTable(p) {
|
|
|
970
1079
|
onCopy: p.copy !== false ? doCopy : void 0,
|
|
971
1080
|
onZoom: p.zoom !== false && !inZoom ? () => setZoomed(true) : void 0
|
|
972
1081
|
}),
|
|
1082
|
+
p.action && !inZoom ? /* @__PURE__ */ jsx("div", {
|
|
1083
|
+
className: "ui-dt-primary",
|
|
1084
|
+
children: p.action
|
|
1085
|
+
}) : null,
|
|
973
1086
|
copied && !narrow ? /* @__PURE__ */ jsxs("span", {
|
|
974
1087
|
className: "ui-dt-copied",
|
|
975
1088
|
"aria-hidden": "true",
|
|
@@ -1014,7 +1127,7 @@ function DataTable(p) {
|
|
|
1014
1127
|
},
|
|
1015
1128
|
role: "row",
|
|
1016
1129
|
"aria-labelledby": shownCols.length ? `${pfx}-n-${start + i}` : void 0,
|
|
1017
|
-
className: cx("ui-dt-row", i % 2 && "is-even", on && "is-selected", selectable && "has-sel", expander && !p.rowHref && "has-exp", p.rowHref && "has-href"),
|
|
1130
|
+
className: cx("ui-dt-row", i % 2 && "is-even", hasAct && "has-acts", on && "is-selected", selectable && "has-sel", expander && !p.rowHref && "has-exp", p.rowHref && "has-href"),
|
|
1018
1131
|
style: grid,
|
|
1019
1132
|
onClick: expander || p.rowHref ? (e) => {
|
|
1020
1133
|
if (!rowClick(e)) return;
|
|
@@ -1085,7 +1198,7 @@ function DataTable(p) {
|
|
|
1085
1198
|
children: /* @__PURE__ */ jsx("div", {
|
|
1086
1199
|
role: "cell",
|
|
1087
1200
|
className: "ui-dt-detail-cell",
|
|
1088
|
-
style: { paddingLeft: EXP + (selectable ?
|
|
1201
|
+
style: { paddingLeft: EXP + (selectable ? SEL : 0) + 12 },
|
|
1089
1202
|
children: longCols.map((c) => /* @__PURE__ */ jsxs("div", {
|
|
1090
1203
|
className: "ui-dt-detail-item",
|
|
1091
1204
|
children: [/* @__PURE__ */ jsx("div", {
|
|
@@ -1112,12 +1225,12 @@ function DataTable(p) {
|
|
|
1112
1225
|
style: grid,
|
|
1113
1226
|
children: [
|
|
1114
1227
|
expander ? /* @__PURE__ */ jsx("div", {
|
|
1115
|
-
className: cx("ui-dt-cell", lead("exp").className),
|
|
1228
|
+
className: cx("ui-dt-cell ui-dt-exp", lead("exp").className),
|
|
1116
1229
|
style: lead("exp").style,
|
|
1117
1230
|
role: "cell"
|
|
1118
1231
|
}) : null,
|
|
1119
1232
|
selectable ? /* @__PURE__ */ jsx("div", {
|
|
1120
|
-
className: cx("ui-dt-cell", lead("sel").className),
|
|
1233
|
+
className: cx("ui-dt-cell ui-dt-sel", lead("sel").className),
|
|
1121
1234
|
style: lead("sel").style,
|
|
1122
1235
|
role: "cell"
|
|
1123
1236
|
}) : null,
|
|
@@ -1128,11 +1241,7 @@ function DataTable(p) {
|
|
|
1128
1241
|
"data-col": c.key,
|
|
1129
1242
|
"data-label": ci > 0 && p.totals?.[c.key] ? c.label : void 0,
|
|
1130
1243
|
children: total(c, ci)
|
|
1131
|
-
}, c.key))
|
|
1132
|
-
hasAct ? /* @__PURE__ */ jsx("div", {
|
|
1133
|
-
className: "ui-dt-cell",
|
|
1134
|
-
role: "cell"
|
|
1135
|
-
}) : null
|
|
1244
|
+
}, c.key))
|
|
1136
1245
|
]
|
|
1137
1246
|
}) : null
|
|
1138
1247
|
]
|
|
@@ -1185,7 +1294,8 @@ function DataTable(p) {
|
|
|
1185
1294
|
}) : null });
|
|
1186
1295
|
return /* @__PURE__ */ jsxs("div", {
|
|
1187
1296
|
ref: rootRef,
|
|
1188
|
-
className: cx("ui-dt", search === false && "is-nosearch", selIds.length && "has-sel", p.className),
|
|
1297
|
+
className: cx("ui-dt", search === false && "is-nosearch", selIds.length && "has-sel", hasAct && "has-acts", p.className),
|
|
1298
|
+
style: hasAct ? { "--dt-acts-w": (p.actionsWidth ?? actsW ?? 72) + "px" } : void 0,
|
|
1189
1299
|
children: [
|
|
1190
1300
|
p.caption && search !== false ? /* @__PURE__ */ jsx("div", {
|
|
1191
1301
|
className: "ui-dt-caption",
|
|
@@ -1207,39 +1317,23 @@ function DataTable(p) {
|
|
|
1207
1317
|
setView(v.id);
|
|
1208
1318
|
setPage(0);
|
|
1209
1319
|
},
|
|
1210
|
-
children: [
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
/* @__PURE__ */
|
|
1216
|
-
className: "ui-
|
|
1217
|
-
children: unitFor("筆", vn)
|
|
1218
|
-
})
|
|
1219
|
-
|
|
1220
|
-
|
|
1320
|
+
children: [
|
|
1321
|
+
v.label,
|
|
1322
|
+
" ",
|
|
1323
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1324
|
+
className: "ui-dt-view-n",
|
|
1325
|
+
children: [format.number(vn), /* @__PURE__ */ jsxs("span", {
|
|
1326
|
+
className: "ui-visually-hidden",
|
|
1327
|
+
children: [" ", unitFor("筆", vn)]
|
|
1328
|
+
})]
|
|
1329
|
+
})
|
|
1330
|
+
]
|
|
1221
1331
|
}, v.id);
|
|
1222
1332
|
})
|
|
1223
1333
|
}) : null,
|
|
1224
|
-
|
|
1225
|
-
className: "ui-dt-
|
|
1226
|
-
|
|
1227
|
-
unit: summary.unit || "筆",
|
|
1228
|
-
value: sumVal,
|
|
1229
|
-
onChange: (v) => {
|
|
1230
|
-
capture("sort");
|
|
1231
|
-
setSumVal(v);
|
|
1232
|
-
setPage(0);
|
|
1233
|
-
},
|
|
1234
|
-
items: [{
|
|
1235
|
-
id: "all",
|
|
1236
|
-
label: tr("全部"),
|
|
1237
|
-
count: sumAll.length
|
|
1238
|
-
}, ...summary.items.map((it) => ({
|
|
1239
|
-
id: String(it.value),
|
|
1240
|
-
label: it.label,
|
|
1241
|
-
count: sumAll.filter((x) => String(get(x.r, summary.key)) === String(it.value)).length
|
|
1242
|
-
}))]
|
|
1334
|
+
summaryView && headSlot ? /* @__PURE__ */ jsx("div", {
|
|
1335
|
+
className: "ui-dt-top",
|
|
1336
|
+
children: summaryView
|
|
1243
1337
|
}) : null,
|
|
1244
1338
|
headSlot ? createPortal(toolsView(false, true), headSlot) : toolsView(false),
|
|
1245
1339
|
chipsView(false),
|