@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
|
@@ -10,7 +10,7 @@ import * as React from "react";
|
|
|
10
10
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
// src/components/Tabs/Tabs.tsx
|
|
12
12
|
/** Views of the same content. The underline moves like a droplet; arrow keys move between tabs. */
|
|
13
|
-
function Tabs({ items, value, onChange, label, unit, className }) {
|
|
13
|
+
function Tabs({ items, value, onChange, label, unit, hideUnit = false, className }) {
|
|
14
14
|
const refs = React.useRef([]);
|
|
15
15
|
const track = React.useRef(null);
|
|
16
16
|
const [box, setBox] = React.useState(null);
|
|
@@ -103,7 +103,10 @@ function Tabs({ items, value, onChange, label, unit, className }) {
|
|
|
103
103
|
t.count != null ? " " : null,
|
|
104
104
|
t.count != null ? /* @__PURE__ */ jsxs("span", {
|
|
105
105
|
className: "ui-tab-count",
|
|
106
|
-
children: [format.number(t.count), t.unit || unit ?
|
|
106
|
+
children: [format.number(t.count), t.unit || unit ? hideUnit ? /* @__PURE__ */ jsxs("span", {
|
|
107
|
+
className: "ui-visually-hidden",
|
|
108
|
+
children: [" ", unitFor(t.unit || unit, t.count)]
|
|
109
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [" ", /* @__PURE__ */ jsx("span", {
|
|
107
110
|
className: "ui-unit",
|
|
108
111
|
children: unitFor(t.unit || unit, t.count)
|
|
109
112
|
})] }) : null]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.js","names":[],"sources":["../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["import * as React from 'react';\nimport { format } from '../../format';\nimport { dropTransition, useMoving } from '../../motion';\nimport { cx, browserKey, resizeObserver } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { useFocusRescue } from '../../internal/focus';\nimport { announce } from '../../announce';\nimport { unitFor, type CountUnit } from '../../i18n';\n\nexport interface TabItem<V extends string = string> {\n id: V;\n label: string;\n /** A count after the label, e.g. how many rows a view has. */\n count?: number;\n /** Unit after this tab's count, e.g. 「筆」, or a function of the count for plurals. Default: the list's unit. */\n unit?: CountUnit;\n}\n\nexport interface TabsProps<V extends string = string> {\n items: TabItem<V>[];\n value: V;\n onChange?: (id: V) => void;\n /** aria-label of the tab list. */\n label?: string;\n /** Unit after every count, e.g. 「筆」 or 「個」: a number carries its unit. A function gets the count, for plurals:\n * `(n) => (n === 1 ? 'item' : 'items')`. */\n unit?: CountUnit;\n className?: string;\n}\n\n/** Views of the same content. The underline moves like a droplet; arrow keys move between tabs. */\nexport function Tabs<V extends string = string>({ items, value, onChange, label, unit, className }: TabsProps<V>) {\n const refs = React.useRef<(HTMLButtonElement | null)[]>([]);\n const track = React.useRef<HTMLDivElement>(null);\n const [box, setBox] = React.useState<{ left: number; right: number } | null>(null);\n const [forward, setForward] = React.useState(true);\n const [moving, bump] = useMoving();\n // Wider than its box (G0): a fade on the side that has more tabs, and the selected tab kept in view.\n const [more, setMore] = React.useState({ left: false, right: false });\n const edges = React.useCallback(() => {\n const el = track.current;\n if (!el) return;\n const left = el.scrollLeft > 1;\n // The end of the last tab, not scrollWidth: the moving indicator can stick out for a moment and leave a fade on a\n // row that fits.\n const last = refs.current.filter(Boolean).pop();\n const end = last ? last.offsetLeft + last.offsetWidth : el.scrollWidth;\n const right = el.scrollLeft + el.clientWidth < end - 1;\n setMore((m) => (m.left === left && m.right === right ? m : { left, right }));\n }, []);\n // The focused tab re-rendered away (new items, the app swapped the list): focus goes to the selected tab.\n useFocusRescue(\n track,\n () =>\n refs.current[\n Math.max(\n 0,\n items.findIndex((t) => t.id === value),\n )\n ],\n );\n devWarn(\n items.some((t) => t.count != null && !(t.unit || unit)),\n 'Tabs',\n \"a count has no unit, so it reads as a bare number. Pass unit, e.g. unit: '筆', on Tabs or on the item.\",\n );\n const idx = Math.max(\n 0,\n items.findIndex((t) => t.id === value),\n );\n React.useLayoutEffect(() => {\n const el = refs.current[idx];\n const tr = track.current;\n if (!el || !tr) return;\n // Counts, fonts and the container change tab widths without changing the selection.\n const measure = () => {\n // Both sides from the row's own box: a tab past the visible part gets a negative right, and scrolls with the row.\n setBox({ left: el.offsetLeft, right: tr.clientWidth - el.offsetLeft - el.offsetWidth });\n edges();\n };\n measure();\n // The selected tab in view, without scrolling the page.\n if (el.offsetLeft < tr.scrollLeft) tr.scrollLeft = el.offsetLeft - 4;\n else if (el.offsetLeft + el.offsetWidth > tr.scrollLeft + tr.clientWidth) tr.scrollLeft = el.offsetLeft + el.offsetWidth - tr.clientWidth + 4;\n const ro = resizeObserver(measure);\n ro?.observe(tr);\n for (const t of refs.current) if (t) ro?.observe(t);\n return () => ro?.disconnect();\n }, [idx, items.length, edges]);\n const go = (i: number) => {\n if (i === idx || !items[i]) return;\n setForward(i > idx);\n bump();\n onChange?.(items[i].id);\n announce(\n items[i].label +\n (items[i].count != null\n ? ' ' + format.number(items[i].count ?? 0) + (items[i].unit || unit ? ' ' + unitFor(items[i].unit || unit, items[i].count ?? 0) : '')\n : ''),\n );\n };\n return (\n <div\n ref={track}\n className={cx('ui-tabs', more.left && 'has-more-left', more.right && 'has-more-right', className)}\n role=\"tablist\"\n aria-label={label}\n onScroll={edges}\n >\n {box ? (\n <span\n className=\"ui-tabs-ind\"\n aria-hidden=\"true\"\n style={{ left: box.left, right: box.right, transform: moving ? 'scaleY(.82)' : 'none', transition: dropTransition('left', 'right', forward) }}\n />\n ) : null}\n {items.map((t, i) => (\n <button\n key={t.id}\n ref={(n) => {\n refs.current[i] = n;\n }}\n type=\"button\"\n role=\"tab\"\n aria-selected={i === idx}\n tabIndex={i === idx ? 0 : -1}\n className={cx('ui-tab', i === idx && 'is-selected')}\n onClick={() => go(i)}\n onKeyDown={(e) => {\n if (browserKey(e)) return;\n const to = e.key === 'ArrowRight' ? (i + 1) % items.length : e.key === 'ArrowLeft' ? (i - 1 + items.length) % items.length : -1;\n if (to < 0) return;\n e.preventDefault();\n refs.current[to]?.focus();\n go(to);\n }}\n >\n {t.label}\n {/* A space between the name and its count, also for screen readers: 「全部 26 個」. */}\n {t.count != null ? ' ' : null}\n {t.count != null ? (\n <span className=\"ui-tab-count\">\n {format.number(t.count)}\n {t.unit || unit ? (\n
|
|
1
|
+
{"version":3,"file":"Tabs.js","names":[],"sources":["../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["import * as React from 'react';\nimport { format } from '../../format';\nimport { dropTransition, useMoving } from '../../motion';\nimport { cx, browserKey, resizeObserver } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { useFocusRescue } from '../../internal/focus';\nimport { announce } from '../../announce';\nimport { unitFor, type CountUnit } from '../../i18n';\n\nexport interface TabItem<V extends string = string> {\n id: V;\n label: string;\n /** A count after the label, e.g. how many rows a view has. */\n count?: number;\n /** Unit after this tab's count, e.g. 「筆」, or a function of the count for plurals. Default: the list's unit. */\n unit?: CountUnit;\n}\n\nexport interface TabsProps<V extends string = string> {\n items: TabItem<V>[];\n value: V;\n onChange?: (id: V) => void;\n /** aria-label of the tab list. */\n label?: string;\n /** Unit after every count, e.g. 「筆」 or 「個」: a number carries its unit. A function gets the count, for plurals:\n * `(n) => (n === 1 ? 'item' : 'items')`. */\n unit?: CountUnit;\n /** Counts show the number only; the unit is still read by screen readers and announced. For a row of status counts\n * (DataTable's summary) where the unit is the same on every tab. Default false. */\n hideUnit?: boolean;\n className?: string;\n}\n\n/** Views of the same content. The underline moves like a droplet; arrow keys move between tabs. */\nexport function Tabs<V extends string = string>({ items, value, onChange, label, unit, hideUnit = false, className }: TabsProps<V>) {\n const refs = React.useRef<(HTMLButtonElement | null)[]>([]);\n const track = React.useRef<HTMLDivElement>(null);\n const [box, setBox] = React.useState<{ left: number; right: number } | null>(null);\n const [forward, setForward] = React.useState(true);\n const [moving, bump] = useMoving();\n // Wider than its box (G0): a fade on the side that has more tabs, and the selected tab kept in view.\n const [more, setMore] = React.useState({ left: false, right: false });\n const edges = React.useCallback(() => {\n const el = track.current;\n if (!el) return;\n const left = el.scrollLeft > 1;\n // The end of the last tab, not scrollWidth: the moving indicator can stick out for a moment and leave a fade on a\n // row that fits.\n const last = refs.current.filter(Boolean).pop();\n const end = last ? last.offsetLeft + last.offsetWidth : el.scrollWidth;\n const right = el.scrollLeft + el.clientWidth < end - 1;\n setMore((m) => (m.left === left && m.right === right ? m : { left, right }));\n }, []);\n // The focused tab re-rendered away (new items, the app swapped the list): focus goes to the selected tab.\n useFocusRescue(\n track,\n () =>\n refs.current[\n Math.max(\n 0,\n items.findIndex((t) => t.id === value),\n )\n ],\n );\n devWarn(\n items.some((t) => t.count != null && !(t.unit || unit)),\n 'Tabs',\n \"a count has no unit, so it reads as a bare number. Pass unit, e.g. unit: '筆', on Tabs or on the item.\",\n );\n const idx = Math.max(\n 0,\n items.findIndex((t) => t.id === value),\n );\n React.useLayoutEffect(() => {\n const el = refs.current[idx];\n const tr = track.current;\n if (!el || !tr) return;\n // Counts, fonts and the container change tab widths without changing the selection.\n const measure = () => {\n // Both sides from the row's own box: a tab past the visible part gets a negative right, and scrolls with the row.\n setBox({ left: el.offsetLeft, right: tr.clientWidth - el.offsetLeft - el.offsetWidth });\n edges();\n };\n measure();\n // The selected tab in view, without scrolling the page.\n if (el.offsetLeft < tr.scrollLeft) tr.scrollLeft = el.offsetLeft - 4;\n else if (el.offsetLeft + el.offsetWidth > tr.scrollLeft + tr.clientWidth) tr.scrollLeft = el.offsetLeft + el.offsetWidth - tr.clientWidth + 4;\n const ro = resizeObserver(measure);\n ro?.observe(tr);\n for (const t of refs.current) if (t) ro?.observe(t);\n return () => ro?.disconnect();\n }, [idx, items.length, edges]);\n const go = (i: number) => {\n if (i === idx || !items[i]) return;\n setForward(i > idx);\n bump();\n onChange?.(items[i].id);\n announce(\n items[i].label +\n (items[i].count != null\n ? ' ' + format.number(items[i].count ?? 0) + (items[i].unit || unit ? ' ' + unitFor(items[i].unit || unit, items[i].count ?? 0) : '')\n : ''),\n );\n };\n return (\n <div\n ref={track}\n className={cx('ui-tabs', more.left && 'has-more-left', more.right && 'has-more-right', className)}\n role=\"tablist\"\n aria-label={label}\n onScroll={edges}\n >\n {box ? (\n <span\n className=\"ui-tabs-ind\"\n aria-hidden=\"true\"\n style={{ left: box.left, right: box.right, transform: moving ? 'scaleY(.82)' : 'none', transition: dropTransition('left', 'right', forward) }}\n />\n ) : null}\n {items.map((t, i) => (\n <button\n key={t.id}\n ref={(n) => {\n refs.current[i] = n;\n }}\n type=\"button\"\n role=\"tab\"\n aria-selected={i === idx}\n tabIndex={i === idx ? 0 : -1}\n className={cx('ui-tab', i === idx && 'is-selected')}\n onClick={() => go(i)}\n onKeyDown={(e) => {\n if (browserKey(e)) return;\n const to = e.key === 'ArrowRight' ? (i + 1) % items.length : e.key === 'ArrowLeft' ? (i - 1 + items.length) % items.length : -1;\n if (to < 0) return;\n e.preventDefault();\n refs.current[to]?.focus();\n go(to);\n }}\n >\n {t.label}\n {/* A space between the name and its count, also for screen readers: 「全部 26 個」. */}\n {t.count != null ? ' ' : null}\n {t.count != null ? (\n <span className=\"ui-tab-count\">\n {format.number(t.count)}\n {t.unit || unit ? (\n hideUnit ? (\n <span className=\"ui-visually-hidden\"> {unitFor(t.unit || unit, t.count)}</span>\n ) : (\n <>\n {' '}\n <span className=\"ui-unit\">{unitFor(t.unit || unit, t.count)}</span>\n </>\n )\n ) : null}\n </span>\n ) : null}\n </button>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAkCA,SAAgB,KAAgC,EAAE,OAAO,OAAO,UAAU,OAAO,MAAM,WAAW,OAAO,aAA2B;CAClI,MAAM,OAAO,MAAM,OAAqC,CAAC,CAAC;CAC1D,MAAM,QAAQ,MAAM,OAAuB,IAAI;CAC/C,MAAM,CAAC,KAAK,UAAU,MAAM,SAAiD,IAAI;CACjF,MAAM,CAAC,SAAS,cAAc,MAAM,SAAS,IAAI;CACjD,MAAM,CAAC,QAAQ,QAAQ,UAAU;CAEjC,MAAM,CAAC,MAAM,WAAW,MAAM,SAAS;EAAE,MAAM;EAAO,OAAO;C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ACxB,GAAG,EAAE;GACP;GAlBF,UAAA;IAoBG,EAAE;IAEF,EAAE,SAAS,OAAO,MAAM;IACxB,EAAE,SAAS,OACV,qBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CACG,OAAO,OAAO,EAAE,KAAK,GACrB,EAAE,QAAQ,OACT,WACE,qBAAC,QAAD;MAAM,WAAU;MAAhB,UAAA,CAAqC,KAAE,QAAQ,EAAE,QAAQ,MAAM,EAAE,KAAK,CAAQ;KAE9E,CAAA,IAAA,qBAAA,UAAA,EAAA,UAAA,CACG,KACD,oBAAC,QAAD;MAAM,WAAU;MAAW,UAAA,QAAQ,EAAE,QAAQ,MAAM,EAAE,KAAK;KAAQ,CAAA,CAClE,EAAA,CAAA,IAEF,IACA;IACJ,CAAA,IAAA;GACE;EArCD,GAAA,EAAE,EAqCD,CACT,CACE;;AAET"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
export interface TextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'onChange' | 'value'> {
|
|
3
3
|
label?: string;
|
|
4
|
+
/** One short line under the field; `backticks` are code. */
|
|
4
5
|
hint?: string;
|
|
5
6
|
value: string;
|
|
6
7
|
onChange: (value: string) => void;
|
|
@@ -8,7 +9,7 @@ export interface TextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTex
|
|
|
8
9
|
maxLength?: number;
|
|
9
10
|
required?: boolean;
|
|
10
11
|
/** The cause and the fix (「請寫下退款原因」). Red border, the warning icon and this line in place of the hint, announced
|
|
11
|
-
* when it appears. Set it when the field is left or the form is sent. */
|
|
12
|
+
* when it appears. Set it when the field is left or the form is sent. `backticks` are code. */
|
|
12
13
|
error?: string;
|
|
13
14
|
}
|
|
14
15
|
/** Multi-line text that grows up to 8 lines, with a character counter. */
|
|
@@ -3,6 +3,7 @@ import { cx } from "../../internal/util.js";
|
|
|
3
3
|
import { FieldErrorIcon, FieldLabel } from "../../internal/Field.js";
|
|
4
4
|
import { format } from "../../format.js";
|
|
5
5
|
import { tr } from "../../i18n.js";
|
|
6
|
+
import { codeText } from "../InlineCode/InlineCode.js";
|
|
6
7
|
import * as React from "react";
|
|
7
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
9
|
// src/components/TextArea/TextArea.tsx
|
|
@@ -48,11 +49,11 @@ function TextArea({ label, hint, error, value, onChange, maxLength = 200, classN
|
|
|
48
49
|
id: hintId,
|
|
49
50
|
className: "ui-field-error",
|
|
50
51
|
role: "alert",
|
|
51
|
-
children: error
|
|
52
|
+
children: codeText(error)
|
|
52
53
|
}, error) : /* @__PURE__ */ jsx("span", {
|
|
53
54
|
id: hintId,
|
|
54
55
|
className: "ui-field-hint",
|
|
55
|
-
children: hint || ""
|
|
56
|
+
children: codeText(hint || "")
|
|
56
57
|
}), /* @__PURE__ */ jsxs("span", {
|
|
57
58
|
className: "ui-count",
|
|
58
59
|
children: [/* @__PURE__ */ jsx("span", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea.js","names":[],"sources":["../../../src/components/TextArea/TextArea.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cx } from '../../internal/util';\nimport { FieldErrorIcon, FieldLabel } from '../../internal/Field';\nimport { format } from '../../format';\nimport { tr } from '../../i18n';\n\nexport interface TextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'onChange' | 'value'> {\n label?: string;\n hint?: string;\n value: string;\n onChange: (value: string) => void;\n /** Shown as a counter. Default 200. */\n maxLength?: number;\n required?: boolean;\n /** The cause and the fix (「請寫下退款原因」). Red border, the warning icon and this line in place of the hint, announced\n * when it appears. Set it when the field is left or the form is sent. */\n error?: string;\n}\n\n/** Multi-line text that grows up to 8 lines, with a character counter. */\nexport function TextArea({ label, hint, error, value, onChange, maxLength = 200, className, id, required, ...native }: TextAreaProps) {\n const auto = React.useId();\n const fieldId = id || auto;\n const hintId = error ? fieldId + '-err' : hint ? fieldId + '-hint' : undefined;\n const ref = React.useRef<HTMLTextAreaElement>(null);\n React.useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n el.style.height = 'auto';\n el.style.height = Math.min(el.scrollHeight + 2, 8 * 26 + 22) + 'px';\n }, [value]);\n return (\n <div className={cx('ui-field', error && 'has-error', className)}>\n {label ? (\n <FieldLabel htmlFor={fieldId} required={required}>\n {label}\n </FieldLabel>\n ) : null}\n <div className=\"ui-field-box\">\n <textarea\n rows={3}\n {...native}\n ref={ref}\n id={fieldId}\n className=\"ui-input ui-textarea\"\n maxLength={maxLength}\n value={value || ''}\n aria-required={required || undefined}\n aria-describedby={[native['aria-describedby'], hintId].filter(Boolean).join(' ') || undefined}\n aria-invalid={error ? true : undefined}\n onChange={(e) => onChange(e.target.value)}\n />\n {error ? <FieldErrorIcon /> : null}\n </div>\n <div className=\"ui-field-foot\">\n {error ? (\n <span key={error} id={hintId} className=\"ui-field-error\" role=\"alert\">\n {error}\n </span>\n ) : (\n <span id={hintId} className=\"ui-field-hint\">\n {hint || ''}\n </span>\n )}\n <span className=\"ui-count\">\n {/* Shown 「12 / 200」, drawn by CSS; read and copied as 「200 字中的 12 字」, not 「12 斜線 200」. */}\n <span aria-hidden=\"true\">\n <span className=\"ui-seen\" data-text={format.fraction((value || '').length, maxLength)} />\n </span>\n <span className=\"ui-visually-hidden\">{format.fractionLabel((value || '').length, maxLength, tr('字'))}</span>\n </span>\n </div>\n </div>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"TextArea.js","names":[],"sources":["../../../src/components/TextArea/TextArea.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cx } from '../../internal/util';\nimport { FieldErrorIcon, FieldLabel } from '../../internal/Field';\nimport { format } from '../../format';\nimport { tr } from '../../i18n';\nimport { codeText } from '../InlineCode/InlineCode';\n\nexport interface TextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'onChange' | 'value'> {\n label?: string;\n /** One short line under the field; `backticks` are code. */\n hint?: string;\n value: string;\n onChange: (value: string) => void;\n /** Shown as a counter. Default 200. */\n maxLength?: number;\n required?: boolean;\n /** The cause and the fix (「請寫下退款原因」). Red border, the warning icon and this line in place of the hint, announced\n * when it appears. Set it when the field is left or the form is sent. `backticks` are code. */\n error?: string;\n}\n\n/** Multi-line text that grows up to 8 lines, with a character counter. */\nexport function TextArea({ label, hint, error, value, onChange, maxLength = 200, className, id, required, ...native }: TextAreaProps) {\n const auto = React.useId();\n const fieldId = id || auto;\n const hintId = error ? fieldId + '-err' : hint ? fieldId + '-hint' : undefined;\n const ref = React.useRef<HTMLTextAreaElement>(null);\n React.useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n el.style.height = 'auto';\n el.style.height = Math.min(el.scrollHeight + 2, 8 * 26 + 22) + 'px';\n }, [value]);\n return (\n <div className={cx('ui-field', error && 'has-error', className)}>\n {label ? (\n <FieldLabel htmlFor={fieldId} required={required}>\n {label}\n </FieldLabel>\n ) : null}\n <div className=\"ui-field-box\">\n <textarea\n rows={3}\n {...native}\n ref={ref}\n id={fieldId}\n className=\"ui-input ui-textarea\"\n maxLength={maxLength}\n value={value || ''}\n aria-required={required || undefined}\n aria-describedby={[native['aria-describedby'], hintId].filter(Boolean).join(' ') || undefined}\n aria-invalid={error ? true : undefined}\n onChange={(e) => onChange(e.target.value)}\n />\n {error ? <FieldErrorIcon /> : null}\n </div>\n <div className=\"ui-field-foot\">\n {error ? (\n <span key={error} id={hintId} className=\"ui-field-error\" role=\"alert\">\n {codeText(error)}\n </span>\n ) : (\n <span id={hintId} className=\"ui-field-hint\">\n {codeText(hint || '')}\n </span>\n )}\n <span className=\"ui-count\">\n {/* Shown 「12 / 200」, drawn by CSS; read and copied as 「200 字中的 12 字」, not 「12 斜線 200」. */}\n <span aria-hidden=\"true\">\n <span className=\"ui-seen\" data-text={format.fraction((value || '').length, maxLength)} />\n </span>\n <span className=\"ui-visually-hidden\">{format.fractionLabel((value || '').length, maxLength, tr('字'))}</span>\n </span>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AA,SAAS,QAAQ,EAAE;IAChB,CAAA,GAER,qBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CAEE,oBAAC,QAAD;MAAM,eAAY;MAChB,UAAA,oBAAC,QAAD;OAAM,WAAU;OAAU,aAAW,OAAO,UAAU,SAAS,GAAA,CAAI,QAAQ,SAAS;MAAI,CAAA;KACpF,CAAA,GACN,oBAAC,QAAD;MAAM,WAAU;MAAsB,UAAA,OAAO,eAAe,SAAS,GAAA,CAAI,QAAQ,WAAW,GAAG,GAAG,CAAC;KAAQ,CAAA,CACvG;IACH,CAAA,CAAA;;EACF;;AAET"}
|
|
@@ -4,10 +4,10 @@ export interface TextFieldProps extends React.InputHTMLAttributes<HTMLInputEleme
|
|
|
4
4
|
label: string;
|
|
5
5
|
/** Red asterisk after the label. */
|
|
6
6
|
required?: boolean;
|
|
7
|
-
/** One short line under the field. */
|
|
7
|
+
/** One short line under the field; `backticks` are code. */
|
|
8
8
|
hint?: string;
|
|
9
9
|
/** The cause and the fix: 「日期格式不正確,請寫成 2026/11/14」. Turns the border red and is announced when it appears.
|
|
10
|
-
* Set it when the field is left (blur) or the form is sent, not on every key; clear it as soon as the value is right. */
|
|
10
|
+
* Set it when the field is left (blur) or the form is sent, not on every key; clear it as soon as the value is right. `backticks` are code. */
|
|
11
11
|
error?: string;
|
|
12
12
|
ref?: React.Ref<HTMLInputElement>;
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.js","names":[],"sources":["../../../src/components/TextField/TextField.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cx } from '../../internal/util';\nimport { FieldErrorIcon, FieldLabel, FieldMessage } from '../../internal/Field';\n\nexport interface TextFieldProps extends React.InputHTMLAttributes<HTMLInputElement> {\n /** Above the field, always visible. Never only a placeholder. */\n label: string;\n /** Red asterisk after the label. */\n required?: boolean;\n /** One short line under the field. */\n hint?: string;\n /** The cause and the fix: 「日期格式不正確,請寫成 2026/11/14」. Turns the border red and is announced when it appears.\n * Set it when the field is left (blur) or the form is sent, not on every key; clear it as soon as the value is right. */\n error?: string;\n ref?: React.Ref<HTMLInputElement>;\n}\n\n/** A labelled one-line input with a hint or an error under it. */\nexport function TextField({ label, hint, error, id, className, required, disabled, ...native }: TextFieldProps) {\n const auto = React.useId();\n const fieldId = id || auto;\n const desc = error ? fieldId + '-err' : hint ? fieldId + '-hint' : undefined;\n return (\n <div className={cx('ui-field', error && 'has-error', disabled && 'is-disabled', className)}>\n <FieldLabel htmlFor={fieldId} required={required}>\n {label}\n </FieldLabel>\n <div className=\"ui-field-box\">\n <input\n type=\"text\"\n {...native}\n required={required}\n disabled={disabled}\n id={fieldId}\n className=\"ui-input\"\n aria-invalid={error ? true : undefined}\n aria-describedby={desc}\n />\n {error ? <FieldErrorIcon /> : null}\n </div>\n {desc ? <FieldMessage id={desc} error={error} hint={hint} /> : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;AAkBA,SAAgB,UAAU,EAAE,OAAO,MAAM,OAAO,IAAI,WAAW,UAAU,UAAU,GAAG,UAA0B;CAC9G,MAAM,OAAO,MAAM,MAAM;CACzB,MAAM,UAAU,MAAM;CACtB,MAAM,OAAO,QAAQ,UAAU,SAAS,OAAO,UAAU,UAAU,KAAA;CACnE,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,YAAY,SAAS,aAAa,YAAY,eAAe,SAAS;EAAzF,UAAA;GACE,oBAAC,YAAD;IAAY,SAAS;IAAmB;IACrC,UAAA;GACS,CAAA;GACZ,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,oBAAC,SAAD;KACE,MAAK;KACL,GAAI;KACM;KACA;KACV,IAAI;KACJ,WAAU;KACV,gBAAc,QAAQ,OAAO,KAAA;KAC7B,oBAAkB;IACnB,CAAA,GACA,QAAQ,oBAAC,gBAAD,CAAiB,CAAA,IAAI,IAC3B;;GACJ,OAAO,oBAAC,cAAD;IAAc,IAAI;IAAa;IAAa;GAAO,CAAA,IAAI;EAC5D;;AAET"}
|
|
1
|
+
{"version":3,"file":"TextField.js","names":[],"sources":["../../../src/components/TextField/TextField.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cx } from '../../internal/util';\nimport { FieldErrorIcon, FieldLabel, FieldMessage } from '../../internal/Field';\n\nexport interface TextFieldProps extends React.InputHTMLAttributes<HTMLInputElement> {\n /** Above the field, always visible. Never only a placeholder. */\n label: string;\n /** Red asterisk after the label. */\n required?: boolean;\n /** One short line under the field; `backticks` are code. */\n hint?: string;\n /** The cause and the fix: 「日期格式不正確,請寫成 2026/11/14」. Turns the border red and is announced when it appears.\n * Set it when the field is left (blur) or the form is sent, not on every key; clear it as soon as the value is right. `backticks` are code. */\n error?: string;\n ref?: React.Ref<HTMLInputElement>;\n}\n\n/** A labelled one-line input with a hint or an error under it. */\nexport function TextField({ label, hint, error, id, className, required, disabled, ...native }: TextFieldProps) {\n const auto = React.useId();\n const fieldId = id || auto;\n const desc = error ? fieldId + '-err' : hint ? fieldId + '-hint' : undefined;\n return (\n <div className={cx('ui-field', error && 'has-error', disabled && 'is-disabled', className)}>\n <FieldLabel htmlFor={fieldId} required={required}>\n {label}\n </FieldLabel>\n <div className=\"ui-field-box\">\n <input\n type=\"text\"\n {...native}\n required={required}\n disabled={disabled}\n id={fieldId}\n className=\"ui-input\"\n aria-invalid={error ? true : undefined}\n aria-describedby={desc}\n />\n {error ? <FieldErrorIcon /> : null}\n </div>\n {desc ? <FieldMessage id={desc} error={error} hint={hint} /> : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;AAkBA,SAAgB,UAAU,EAAE,OAAO,MAAM,OAAO,IAAI,WAAW,UAAU,UAAU,GAAG,UAA0B;CAC9G,MAAM,OAAO,MAAM,MAAM;CACzB,MAAM,UAAU,MAAM;CACtB,MAAM,OAAO,QAAQ,UAAU,SAAS,OAAO,UAAU,UAAU,KAAA;CACnE,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,YAAY,SAAS,aAAa,YAAY,eAAe,SAAS;EAAzF,UAAA;GACE,oBAAC,YAAD;IAAY,SAAS;IAAmB;IACrC,UAAA;GACS,CAAA;GACZ,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,oBAAC,SAAD;KACE,MAAK;KACL,GAAI;KACM;KACA;KACV,IAAI;KACJ,WAAU;KACV,gBAAc,QAAQ,OAAO,KAAA;KAC7B,oBAAkB;IACnB,CAAA,GACA,QAAQ,oBAAC,gBAAD,CAAiB,CAAA,IAAI,IAC3B;;GACJ,OAAO,oBAAC,cAAD;IAAc,IAAI;IAAa;IAAa;GAAO,CAAA,IAAI;EAC5D;;AAET"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
export interface ToastProps {
|
|
3
|
-
/** What happened, in the past tense: 「已刪除 3
|
|
3
|
+
/** What happened, in the past tense: 「已刪除 3 筆」; in a string, `backticks` are code. */
|
|
4
4
|
children?: React.ReactNode;
|
|
5
5
|
/** Usually 「復原」. */
|
|
6
6
|
actionLabel?: string;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Icon } from "../../icons/Icon.js";
|
|
3
3
|
import { includeIcons } from "../../icons/store.js";
|
|
4
4
|
import check_default from "../../icons/ph/check.js";
|
|
5
|
+
import { codeText } from "../InlineCode/InlineCode.js";
|
|
5
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
// src/components/Toast/Toast.tsx
|
|
7
8
|
includeIcons(check_default);
|
|
@@ -15,7 +16,7 @@ function Toast({ children, actionLabel, onAction }) {
|
|
|
15
16
|
name: "check",
|
|
16
17
|
className: "ui-toast-icon"
|
|
17
18
|
}),
|
|
18
|
-
/* @__PURE__ */ jsx("span", { children }),
|
|
19
|
+
/* @__PURE__ */ jsx("span", { children: codeText(children) }),
|
|
19
20
|
actionLabel ? /* @__PURE__ */ jsx("button", {
|
|
20
21
|
type: "button",
|
|
21
22
|
className: "ui-toast-action",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.js","names":["phCheck"],"sources":["../../../src/components/Toast/Toast.tsx"],"sourcesContent":["import type * as React from 'react';\nimport { Icon } from '../../icons/Icon';\nimport { includeIcons } from '../../icons/store';\nimport phCheck from '../../icons/ph/check';\n\nincludeIcons(phCheck);\n\nexport interface ToastProps {\n /** What happened, in the past tense: 「已刪除 3
|
|
1
|
+
{"version":3,"file":"Toast.js","names":["phCheck"],"sources":["../../../src/components/Toast/Toast.tsx"],"sourcesContent":["import type * as React from 'react';\nimport { Icon } from '../../icons/Icon';\nimport { includeIcons } from '../../icons/store';\nimport phCheck from '../../icons/ph/check';\nimport { codeText } from '../InlineCode/InlineCode';\n\nincludeIcons(phCheck);\n\nexport interface ToastProps {\n /** What happened, in the past tense: 「已刪除 3 筆」; in a string, `backticks` are code. */\n children?: React.ReactNode;\n /** Usually 「復原」. */\n actionLabel?: string;\n onAction?: () => void;\n}\n\n/** A short confirmation at the bottom right. The caller shows it for 3 s. */\nexport function Toast({ children, actionLabel, onAction }: ToastProps) {\n return (\n <div className=\"ui-toast\" role=\"status\">\n <Icon name=\"check\" className=\"ui-toast-icon\" />\n <span>{codeText(children)}</span>\n {actionLabel ? (\n <button type=\"button\" className=\"ui-toast-action\" onClick={onAction}>\n {actionLabel}\n </button>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;AAMA,aAAaA,aAAO;;AAWpB,SAAgB,MAAM,EAAE,UAAU,aAAa,YAAwB;CACrE,OACE,qBAAC,OAAD;EAAK,WAAU;EAAW,MAAK;EAA/B,UAAA;GACE,oBAAC,MAAD;IAAM,MAAK;IAAQ,WAAU;GAAiB,CAAA;GAC9C,oBAAC,QAAD,EAAA,UAAO,SAAS,QAAQ,EAAQ,CAAA;GAC/B,cACC,oBAAC,UAAD;IAAQ,MAAK;IAAS,WAAU;IAAkB,SAAS;IACxD,UAAA;GACK,CAAA,IACN;EACD;;AAET"}
|
package/dist/css/Alert.css
CHANGED
package/dist/css/Button.css
CHANGED
package/dist/css/Checkbox.css
CHANGED
package/dist/css/CodeView.css
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
@layer theme, base, ui, components, utilities;
|
|
2
2
|
@layer ui.tokens, ui.components;
|
|
3
|
+
@import './InlineCode.css';
|
|
3
4
|
@import './IconButton.css';
|
|
4
5
|
@import './Popover.css';
|
|
5
|
-
@import './InlineCode.css';
|
|
6
6
|
@import './Term.css';
|
|
7
7
|
@layer ui.components {
|
|
8
8
|
/* CodeView: the keys that move inside the code, shown while it has focus. */
|
package/dist/css/DangerZone.css
CHANGED
package/dist/css/DataTable.css
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
@layer theme, base, ui, components, utilities;
|
|
2
2
|
@layer ui.tokens, ui.components;
|
|
3
|
+
@import './InlineCode.css';
|
|
3
4
|
@import './Button.css';
|
|
4
5
|
@import './Dialog.css';
|
|
5
6
|
@import './Tabs.css';
|
|
@@ -190,15 +191,21 @@
|
|
|
190
191
|
.ui-dt-tools {
|
|
191
192
|
flex-wrap: wrap;
|
|
192
193
|
}
|
|
193
|
-
|
|
194
|
+
/* The search field takes the room the buttons leave; when both do not fit, the buttons go to the next row,
|
|
195
|
+
right-aligned, and the field fills its row. */
|
|
196
|
+
.ui-dt-tools > .ui-dt-search {
|
|
197
|
+
flex: 1 1 240px;
|
|
198
|
+
min-width: 200px;
|
|
199
|
+
}
|
|
194
200
|
.ui-dt-tools > .ui-dt-search + .ui-dt-actions {
|
|
195
|
-
flex:
|
|
196
|
-
|
|
201
|
+
flex: none;
|
|
202
|
+
max-width: 100%;
|
|
203
|
+
margin-left: auto;
|
|
197
204
|
}
|
|
198
205
|
}
|
|
199
|
-
/* Under 480 px:
|
|
200
|
-
|
|
201
|
-
accessible names.
|
|
206
|
+
/* Under 480 px: the search field and the buttons back on one row, the field taking the room left. 「排序」 and the
|
|
207
|
+
number of levels instead of the whole sort; 「篩選」「排序」 keep only their icons and counts, the words stay in the
|
|
208
|
+
accessible names. */
|
|
202
209
|
@container ui-dt (max-width: 479px) {
|
|
203
210
|
.ui-dt-sortbtn-text {
|
|
204
211
|
display: none;
|
|
@@ -209,7 +216,23 @@
|
|
|
209
216
|
.ui-dt-actions > .ui-dt-sortbtn {
|
|
210
217
|
min-width: 0;
|
|
211
218
|
}
|
|
212
|
-
|
|
219
|
+
/* One row: the search field takes the room left, the buttons keep to their icons. */
|
|
220
|
+
.ui-dt-tools {
|
|
221
|
+
flex-wrap: nowrap;
|
|
222
|
+
}
|
|
223
|
+
.ui-dt-tools > .ui-dt-search {
|
|
224
|
+
flex: 1 1 0;
|
|
225
|
+
min-width: 100px;
|
|
226
|
+
}
|
|
227
|
+
/* The summary tabs keep a row of their own above. */
|
|
228
|
+
.ui-dt-tools.has-summary {
|
|
229
|
+
flex-wrap: wrap;
|
|
230
|
+
}
|
|
231
|
+
.ui-dt-tools > .ui-dt-search + .ui-dt-actions {
|
|
232
|
+
flex: none;
|
|
233
|
+
flex-wrap: nowrap;
|
|
234
|
+
}
|
|
235
|
+
.ui-dt-actions .ui-dt-btntext {
|
|
213
236
|
position: absolute;
|
|
214
237
|
width: 1px;
|
|
215
238
|
height: 1px;
|
|
@@ -217,18 +240,56 @@
|
|
|
217
240
|
clip: rect(0 0 0 0);
|
|
218
241
|
white-space: nowrap;
|
|
219
242
|
}
|
|
220
|
-
.ui-dt-actions
|
|
243
|
+
.ui-dt-actions :is(.ui-dt-filterbtn, .ui-dt-sortbtn) {
|
|
221
244
|
padding-inline: 10px;
|
|
222
245
|
}
|
|
223
246
|
.ui-dt-actions {
|
|
224
247
|
flex-wrap: wrap;
|
|
225
248
|
}
|
|
226
249
|
}
|
|
227
|
-
/*
|
|
250
|
+
/* With summary tabs: the tabs first. A row of their own (scrolling sideways when they are wider) unless the tabs, the
|
|
251
|
+
search field at 240 px and the buttons all fit on one row (DataTable measures it: is-onerow). Every part is 40 px. */
|
|
252
|
+
.ui-dt-tools.has-summary {
|
|
253
|
+
flex-wrap: wrap;
|
|
254
|
+
row-gap: var(--space-3);
|
|
255
|
+
}
|
|
256
|
+
.ui-dt-sumwrap {
|
|
257
|
+
flex: 1 1 100%;
|
|
258
|
+
min-width: 0;
|
|
259
|
+
display: flex;
|
|
260
|
+
}
|
|
261
|
+
.ui-dt-tools.is-onerow {
|
|
262
|
+
flex-wrap: nowrap;
|
|
263
|
+
}
|
|
264
|
+
.ui-dt-tools.is-onerow > .ui-dt-sumwrap {
|
|
265
|
+
/* Measured to fit: the tabs keep their width, the search field gives way down to 240 px. */
|
|
266
|
+
flex: none;
|
|
267
|
+
margin-right: var(--space-2);
|
|
268
|
+
}
|
|
269
|
+
.ui-dt-tools.is-onerow > .ui-dt-search {
|
|
270
|
+
flex: 1 1 320px;
|
|
271
|
+
min-width: 240px;
|
|
272
|
+
max-width: 400px;
|
|
273
|
+
margin-left: auto;
|
|
274
|
+
}
|
|
275
|
+
.ui-dt-tools.is-onerow > .ui-dt-actions {
|
|
276
|
+
flex: none;
|
|
277
|
+
}
|
|
278
|
+
.ui-dt-summary .ui-tab {
|
|
279
|
+
min-width: 0;
|
|
280
|
+
height: 32px;
|
|
281
|
+
padding: 0 var(--space-3);
|
|
282
|
+
}
|
|
283
|
+
/* Phones, also for tools that moved into a Card title row (outside the table, so not reached by the container). The
|
|
284
|
+
buttons are as tall as the 48 px search field beside them. */
|
|
228
285
|
@media (max-width: 599px) {
|
|
229
286
|
.ui-dt-sortbtn-text {
|
|
230
287
|
display: none;
|
|
231
288
|
}
|
|
289
|
+
.ui-dt-tools:has(> .ui-dt-search) > .ui-dt-actions > :is(.ui-dt-filterbtn, .ui-dt-sortbtn),
|
|
290
|
+
.ui-dt-tools:has(> .ui-dt-search) > .ui-dt-actions > .ui-dt-primary > * {
|
|
291
|
+
height: var(--touch-target);
|
|
292
|
+
}
|
|
232
293
|
.ui-dt-sortbtn-short {
|
|
233
294
|
display: inline-flex;
|
|
234
295
|
}
|
|
@@ -274,14 +335,16 @@
|
|
|
274
335
|
min-width: min-content;
|
|
275
336
|
}
|
|
276
337
|
.ui-dt-row {
|
|
338
|
+
/* The row's ground in one variable, so the row actions drawn over its end (.ui-dt-acts) take the same color. */
|
|
339
|
+
--dt-row-bg: var(--surface);
|
|
277
340
|
display: grid;
|
|
278
341
|
align-items: center;
|
|
279
342
|
min-height: 48px;
|
|
280
343
|
border-bottom: 1px solid var(--line);
|
|
281
|
-
background: var(--
|
|
344
|
+
background: var(--dt-row-bg);
|
|
282
345
|
}
|
|
283
346
|
.ui-dt-body .ui-dt-row.is-even {
|
|
284
|
-
|
|
347
|
+
--dt-row-bg: var(--dt-zebra);
|
|
285
348
|
}
|
|
286
349
|
.ui-dt-body {
|
|
287
350
|
position: relative;
|
|
@@ -290,7 +353,7 @@
|
|
|
290
353
|
transition: background-color 0.12s ease;
|
|
291
354
|
}
|
|
292
355
|
.ui-dt-body .ui-dt-row:hover {
|
|
293
|
-
|
|
356
|
+
--dt-row-bg: var(--dt-hover);
|
|
294
357
|
}
|
|
295
358
|
/* EC: rows with details or a page (rowHref) are clickable as a whole; the hover above already shows it. */
|
|
296
359
|
.ui-dt-body .ui-dt-row:is(.has-exp, .has-href) {
|
|
@@ -307,7 +370,7 @@
|
|
|
307
370
|
.ui-dt-body .ui-dt-row.is-selected,
|
|
308
371
|
.ui-dt-body .ui-dt-row.is-selected:hover {
|
|
309
372
|
--dt-mark: inset 3px 0 0 var(--accent);
|
|
310
|
-
|
|
373
|
+
--dt-row-bg: var(--accent-soft);
|
|
311
374
|
}
|
|
312
375
|
.ui-dt-body .ui-dt-row > .ui-dt-cell:first-child {
|
|
313
376
|
box-shadow: var(--dt-mark);
|
|
@@ -386,9 +449,14 @@
|
|
|
386
449
|
border-right: 1px solid var(--line);
|
|
387
450
|
overflow: hidden;
|
|
388
451
|
}
|
|
389
|
-
.ui-dt-cell:last-child
|
|
452
|
+
.ui-dt-cell:last-child,
|
|
453
|
+
.ui-dt-cell.is-lastcol {
|
|
390
454
|
border-right: 0;
|
|
391
455
|
}
|
|
456
|
+
/* An empty cell's 「—」: muted, so it does not read as content. */
|
|
457
|
+
.ui-dt-none {
|
|
458
|
+
color: var(--ink-muted);
|
|
459
|
+
}
|
|
392
460
|
.ui-dt-cell.is-num {
|
|
393
461
|
justify-content: flex-end;
|
|
394
462
|
text-align: right;
|
|
@@ -473,36 +541,73 @@
|
|
|
473
541
|
padding: 0;
|
|
474
542
|
cursor: pointer;
|
|
475
543
|
}
|
|
476
|
-
.
|
|
477
|
-
|
|
478
|
-
|
|
544
|
+
/* The checkbox column: 40 px, no border of its own (it belongs to the row, like the caret). The header's checkbox is
|
|
545
|
+
always shown, so the column reads as a column of checkboxes; a row's shows when the row is hovered or has keyboard
|
|
546
|
+
focus, and on every row once one is selected. */
|
|
547
|
+
.ui-dt-cell.ui-dt-sel,
|
|
548
|
+
.ui-dt-cell.ui-dt-exp {
|
|
549
|
+
padding: 0;
|
|
550
|
+
justify-content: center;
|
|
551
|
+
border-right: 0;
|
|
479
552
|
}
|
|
480
|
-
.ui-dt-sel > * {
|
|
553
|
+
.ui-dt-body .ui-dt-sel > * {
|
|
481
554
|
opacity: 0;
|
|
555
|
+
transition: opacity 0.12s ease;
|
|
482
556
|
}
|
|
483
557
|
.ui-dt-row:hover .ui-dt-sel > *,
|
|
484
558
|
.ui-dt-row:focus-within .ui-dt-sel > *,
|
|
485
559
|
.ui-dt.has-sel .ui-dt-sel > * {
|
|
486
560
|
opacity: 1;
|
|
487
561
|
}
|
|
488
|
-
|
|
562
|
+
/* Row actions take no column: they are drawn over the row's right end while the row is hovered or has keyboard focus,
|
|
563
|
+
on the row's own ground (zebra, hover, selected) with a short fade, so the text under them is covered cleanly. */
|
|
564
|
+
.ui-dt-row.has-acts {
|
|
565
|
+
position: relative;
|
|
566
|
+
}
|
|
567
|
+
.ui-dt-body .ui-dt-cell.ui-dt-acts {
|
|
568
|
+
position: absolute;
|
|
569
|
+
top: 0;
|
|
570
|
+
right: 0;
|
|
571
|
+
bottom: 0;
|
|
489
572
|
justify-content: flex-end;
|
|
490
573
|
gap: 2px;
|
|
491
|
-
padding: 0
|
|
492
|
-
|
|
493
|
-
|
|
574
|
+
padding: 0 var(--space-2) 0 var(--space-6);
|
|
575
|
+
border-right: 0;
|
|
576
|
+
background: linear-gradient(to right, transparent, var(--dt-row-bg) var(--space-6));
|
|
494
577
|
opacity: 0;
|
|
578
|
+
transition: opacity 0.12s ease;
|
|
495
579
|
}
|
|
496
|
-
.ui-dt-row:hover .ui-dt-acts
|
|
497
|
-
.ui-dt-row:focus-within .ui-dt-acts
|
|
580
|
+
.ui-dt-row:hover > .ui-dt-acts,
|
|
581
|
+
.ui-dt-row:focus-within > .ui-dt-acts {
|
|
498
582
|
opacity: 1;
|
|
499
583
|
}
|
|
584
|
+
/* IconButtons in a row are quiet whatever their variant: 32 px, no border, ink-muted until hovered. */
|
|
585
|
+
.ui-dt-acts .ui-iconbtn {
|
|
586
|
+
width: 32px;
|
|
587
|
+
height: 32px;
|
|
588
|
+
border: 0;
|
|
589
|
+
border-radius: var(--radius-sm);
|
|
590
|
+
color: var(--ink-muted);
|
|
591
|
+
}
|
|
592
|
+
.ui-dt-acts .ui-iconbtn:hover {
|
|
593
|
+
color: var(--ink);
|
|
594
|
+
background: color-mix(in srgb, var(--dt-row-bg), var(--ink) 8%);
|
|
595
|
+
}
|
|
596
|
+
/* Touch screens have no hover: the actions always show, and every row keeps their width free at its end. */
|
|
500
597
|
@media (hover: none) {
|
|
501
598
|
.ui-dt-sel > *,
|
|
502
|
-
.ui-dt-
|
|
599
|
+
.ui-dt-body .ui-dt-sel > *,
|
|
503
600
|
.ui-dt-arrow {
|
|
504
601
|
opacity: 1;
|
|
505
602
|
}
|
|
603
|
+
.ui-dt-body .ui-dt-cell.ui-dt-acts {
|
|
604
|
+
opacity: 1;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
/* The last cell keeps the row actions' width (--dt-acts-w, measured) free at its end, in the header, the rows and the
|
|
608
|
+
totals alike: the actions never cover a date or a number, and no empty column is drawn for them. */
|
|
609
|
+
.ui-dt.has-acts .ui-dt-row > .ui-dt-cell.is-lastcol {
|
|
610
|
+
padding-right: calc(12px + var(--dt-acts-w, 72px));
|
|
506
611
|
}
|
|
507
612
|
.ui-dt-bulk {
|
|
508
613
|
display: flex;
|
|
@@ -577,9 +682,22 @@
|
|
|
577
682
|
cursor: default;
|
|
578
683
|
}
|
|
579
684
|
|
|
685
|
+
/* The summary tabs and the page's primary action (action) on one row, the action at its right end. */
|
|
686
|
+
.ui-dt-top {
|
|
687
|
+
display: flex;
|
|
688
|
+
align-items: center;
|
|
689
|
+
gap: var(--space-3);
|
|
690
|
+
min-width: 0;
|
|
691
|
+
}
|
|
692
|
+
.ui-dt-primary {
|
|
693
|
+
flex: none;
|
|
694
|
+
margin-left: auto;
|
|
695
|
+
display: flex;
|
|
696
|
+
align-items: center;
|
|
697
|
+
}
|
|
580
698
|
.ui-dt-summary {
|
|
581
|
-
|
|
582
|
-
|
|
699
|
+
flex: 0 1 auto;
|
|
700
|
+
min-width: 0;
|
|
583
701
|
/* Wider than the table (phones): the row scrolls sideways, the edge with more tabs fades (Tabs), and it comes to rest
|
|
584
702
|
on a whole tab rather than in the middle of a word. */
|
|
585
703
|
scroll-snap-type: x mandatory;
|
|
@@ -677,6 +795,14 @@
|
|
|
677
795
|
width: auto;
|
|
678
796
|
min-width: 0;
|
|
679
797
|
}
|
|
798
|
+
/* In a Card the cards' box is the Card itself: no second shadow, a line between the toolbar and the first row. */
|
|
799
|
+
.ui-card .ui-dt-scroll {
|
|
800
|
+
box-shadow: none;
|
|
801
|
+
border-radius: 0;
|
|
802
|
+
}
|
|
803
|
+
.ui-card.is-flush > .ui-dt > .ui-dt-scroller > .ui-dt-scroll {
|
|
804
|
+
border-top: 1px solid var(--line);
|
|
805
|
+
}
|
|
680
806
|
.ui-dt-head:not(.ui-dt-bulk) {
|
|
681
807
|
display: none;
|
|
682
808
|
}
|
|
@@ -763,17 +889,27 @@
|
|
|
763
889
|
.ui-dt-body .ui-dt-cell.is-m-hide {
|
|
764
890
|
display: none;
|
|
765
891
|
}
|
|
892
|
+
/* Phone cards: the actions at the title row's end, always shown; the 32 px quiet buttons (48 px touch area) pull
|
|
893
|
+
into the card's padding so they do not make the title row taller. */
|
|
766
894
|
.ui-dt-body .ui-dt-cell.ui-dt-acts {
|
|
895
|
+
position: static;
|
|
767
896
|
grid-column: 4;
|
|
768
897
|
grid-row: 1;
|
|
769
898
|
display: flex;
|
|
770
899
|
justify-content: flex-end;
|
|
771
900
|
align-items: center;
|
|
772
901
|
gap: 4px;
|
|
773
|
-
|
|
902
|
+
width: auto;
|
|
903
|
+
margin: -6px -8px -6px var(--space-1);
|
|
904
|
+
padding: 0;
|
|
905
|
+
background: none;
|
|
906
|
+
opacity: 1;
|
|
907
|
+
}
|
|
908
|
+
.ui-dt.has-acts .ui-dt-row > .ui-dt-cell.is-lastcol {
|
|
909
|
+
padding-right: 0;
|
|
774
910
|
}
|
|
775
911
|
.ui-dt-sel > *,
|
|
776
|
-
.ui-dt-
|
|
912
|
+
.ui-dt-body .ui-dt-sel > * {
|
|
777
913
|
opacity: 1;
|
|
778
914
|
}
|
|
779
915
|
.ui-dt-body .ui-dt-cell.is-long > .ui-dt-long {
|
|
@@ -783,9 +919,9 @@
|
|
|
783
919
|
/* Equal widths while every tab fits; else each keeps its text whole and the row scrolls. */
|
|
784
920
|
.ui-dt-summary {
|
|
785
921
|
display: grid;
|
|
922
|
+
flex: 1 1 auto;
|
|
786
923
|
grid-auto-flow: column;
|
|
787
924
|
grid-auto-columns: minmax(max-content, 1fr);
|
|
788
|
-
align-self: stretch;
|
|
789
925
|
}
|
|
790
926
|
}
|
|
791
927
|
@media (max-width: 599px) {
|
|
@@ -853,9 +989,9 @@
|
|
|
853
989
|
background: var(--accent);
|
|
854
990
|
}
|
|
855
991
|
.ui-dt-view-n {
|
|
856
|
-
margin-left:
|
|
857
|
-
font-family: var(--font-
|
|
858
|
-
font-
|
|
992
|
+
margin-left: 2px;
|
|
993
|
+
font-family: var(--font-sans);
|
|
994
|
+
font-variant-numeric: tabular-nums;
|
|
859
995
|
color: var(--ink-muted);
|
|
860
996
|
font-weight: 400;
|
|
861
997
|
}
|
|
@@ -1180,13 +1316,16 @@
|
|
|
1180
1316
|
.ui-card.is-flush > .ui-dt:first-child {
|
|
1181
1317
|
padding-top: var(--space-4);
|
|
1182
1318
|
}
|
|
1183
|
-
.ui-card.is-flush > .ui-dt > :not(.ui-dt-scroller
|
|
1319
|
+
.ui-card.is-flush > .ui-dt > :not(.ui-dt-scroller) {
|
|
1184
1320
|
padding-inline: var(--space-4);
|
|
1185
1321
|
}
|
|
1186
|
-
/*
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1322
|
+
/* Nothing under the table (no page numbers, no scroll hint): the last row ends at the card's edge, without an empty
|
|
1323
|
+
band and a second line under it. */
|
|
1324
|
+
.ui-card.is-flush > .ui-dt:not(:has(> .ui-dt-foot, > .ui-scroll-hint)) {
|
|
1325
|
+
padding-bottom: 0;
|
|
1326
|
+
}
|
|
1327
|
+
.ui-card.is-flush > .ui-dt:not(:has(> .ui-dt-foot, > .ui-scroll-hint)) > .ui-dt-scroller > .ui-dt-scroll {
|
|
1328
|
+
border-bottom: 0;
|
|
1190
1329
|
}
|
|
1191
1330
|
.ui-card.is-flush > .ui-dt .ui-dt-scroll {
|
|
1192
1331
|
border-inline: 0;
|
package/dist/css/DatePicker.css
CHANGED
package/dist/css/Drawer.css
CHANGED