@robert-stackflow/oneui 0.6.51 → 0.6.52
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/README.md +4 -0
- package/components/Pagination.js +38 -9
- package/components/Pagination.module.css +11 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -353,3 +353,7 @@ Closing returns a visible source image with Hero motion. Missing/offscreen sourc
|
|
|
353
353
|
已有 React 事件表单可改为 `<Form onSubmit={submit}>`,保留事件处理、受控值和业务请求。Form 统一处理 required、type、pattern、范围、自定义有效性、首个错误焦点和异步提交锁;错误通过 FormField / Input 的 FieldMessages 展示。未包裹的原生字段使用可聚焦的错误摘要。`validationMode="blur"` 在离开字段后检查,默认提交时检查;出错后修改会更新反馈。内部自动使用 noValidate,不出现原生气泡。
|
|
354
354
|
|
|
355
355
|
`validateForm(formRef.current, false)` 检查并展示字段错误但不抢焦点,适合自动保存;省略第二个参数则聚焦首个错误。保留自定义业务错误、身份验证、并发和请求重试策略。字段使用稳定 id 或 name,并通过 OneUI FormField / 控件提供标签。`controller={useFormState(...)}` 模式保持兼容,用于显式规则与异步字段校验。
|
|
356
|
+
|
|
357
|
+
### 窄屏分页(0.6.52)
|
|
358
|
+
|
|
359
|
+
650px 及以下保留上一页、下一页、首页页码、末页页码和当前页;省略相邻页码与重复的首尾双箭头,用省略号标明页码间隔。44px 触屏目标保持不变,320px 视口中分页无需折到第二行。全部页码仍使用同一套按钮/原生链接和回调逻辑。
|
package/components/Pagination.js
CHANGED
|
@@ -57,10 +57,14 @@ function Pagination({
|
|
|
57
57
|
pages
|
|
58
58
|
])
|
|
59
59
|
].sort((a, b) => a - b);
|
|
60
|
+
const compactVisible = [.../* @__PURE__ */ new Set([1, current, pages])].sort(
|
|
61
|
+
(a, b) => a - b
|
|
62
|
+
);
|
|
60
63
|
function pageControl(target, options) {
|
|
61
64
|
const props = {
|
|
62
65
|
className: options.className,
|
|
63
66
|
"aria-label": options.label,
|
|
67
|
+
"data-pagination-boundary": options.boundary || void 0,
|
|
64
68
|
"aria-current": options.current ? "page" : void 0,
|
|
65
69
|
variant: options.current ? "primary" : options.className === s.page ? "ghost" : "secondary"
|
|
66
70
|
};
|
|
@@ -123,6 +127,7 @@ function Pagination({
|
|
|
123
127
|
/* @__PURE__ */ jsxs("div", { className: s.pages, children: [
|
|
124
128
|
pageControl(1, {
|
|
125
129
|
className: s.arrow,
|
|
130
|
+
boundary: true,
|
|
126
131
|
label: text("\u7B2C\u4E00\u9875", "First page", "\u7B2C\u4E00\u9801"),
|
|
127
132
|
disabled: current === 1,
|
|
128
133
|
children: /* @__PURE__ */ jsx(ChevronsLeft, {})
|
|
@@ -133,15 +138,38 @@ function Pagination({
|
|
|
133
138
|
disabled: current === 1,
|
|
134
139
|
children: /* @__PURE__ */ jsx(ChevronLeft, {})
|
|
135
140
|
}),
|
|
136
|
-
visible.map((n, i) => /* @__PURE__ */ jsxs(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
className: s.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
141
|
+
visible.map((n, i) => /* @__PURE__ */ jsxs(
|
|
142
|
+
"span",
|
|
143
|
+
{
|
|
144
|
+
className: s.number,
|
|
145
|
+
"data-compact-hidden": !compactVisible.includes(n) || void 0,
|
|
146
|
+
children: [
|
|
147
|
+
i > 0 && n - visible[i - 1] > 1 && /* @__PURE__ */ jsx(
|
|
148
|
+
"span",
|
|
149
|
+
{
|
|
150
|
+
className: `${s.ellipsis} ${s.expandedEllipsis}`,
|
|
151
|
+
"aria-hidden": "true",
|
|
152
|
+
children: "\u2026"
|
|
153
|
+
}
|
|
154
|
+
),
|
|
155
|
+
compactVisible.indexOf(n) > 0 && n - compactVisible[compactVisible.indexOf(n) - 1] > 1 && /* @__PURE__ */ jsx(
|
|
156
|
+
"span",
|
|
157
|
+
{
|
|
158
|
+
className: `${s.ellipsis} ${s.compactEllipsis}`,
|
|
159
|
+
"aria-hidden": "true",
|
|
160
|
+
children: "\u2026"
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
pageControl(n, {
|
|
164
|
+
className: s.page,
|
|
165
|
+
label: english ? "Page " + n : "\u7B2C " + n + text(" \u9875", "", " \u9801"),
|
|
166
|
+
current: n === current,
|
|
167
|
+
children: n
|
|
168
|
+
})
|
|
169
|
+
]
|
|
170
|
+
},
|
|
171
|
+
n
|
|
172
|
+
)),
|
|
145
173
|
pageControl(current + 1, {
|
|
146
174
|
className: s.arrow,
|
|
147
175
|
label: nextLabel ?? text("\u4E0B\u4E00\u9875", "Next", "\u4E0B\u4E00\u9801"),
|
|
@@ -150,6 +178,7 @@ function Pagination({
|
|
|
150
178
|
}),
|
|
151
179
|
pageControl(pages, {
|
|
152
180
|
className: s.arrow,
|
|
181
|
+
boundary: true,
|
|
153
182
|
label: text("\u6700\u540E\u4E00\u9875", "Last page", "\u6700\u5F8C\u4E00\u9801"),
|
|
154
183
|
disabled: current === pages,
|
|
155
184
|
children: /* @__PURE__ */ jsx(ChevronsRight, {})
|
|
@@ -56,6 +56,9 @@
|
|
|
56
56
|
padding: 0 3px;
|
|
57
57
|
color: var(--muted);
|
|
58
58
|
}
|
|
59
|
+
.compactEllipsis {
|
|
60
|
+
display: none;
|
|
61
|
+
}
|
|
59
62
|
.jump {
|
|
60
63
|
display: flex;
|
|
61
64
|
align-items: center;
|
|
@@ -70,6 +73,14 @@
|
|
|
70
73
|
color: var(--fg);
|
|
71
74
|
}
|
|
72
75
|
@media (max-width: 650px) {
|
|
76
|
+
.pages [data-pagination-boundary],
|
|
77
|
+
.number[data-compact-hidden],
|
|
78
|
+
.expandedEllipsis {
|
|
79
|
+
display: none;
|
|
80
|
+
}
|
|
81
|
+
.compactEllipsis {
|
|
82
|
+
display: inline;
|
|
83
|
+
}
|
|
73
84
|
.controls {
|
|
74
85
|
gap: 10px;
|
|
75
86
|
width: 100%;
|