@sarunyu/system-one 4.9.33 → 4.9.35

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/index.js CHANGED
@@ -6139,6 +6139,207 @@ function Breadcrumb({ items, className }) {
6139
6139
  ] }, index2);
6140
6140
  }) });
6141
6141
  }
6142
+ function PaginationBanner({
6143
+ count: count2,
6144
+ activeIndex,
6145
+ onIndexChange,
6146
+ className
6147
+ }) {
6148
+ return /* @__PURE__ */ jsx(
6149
+ "div",
6150
+ {
6151
+ className: cn("flex items-center gap-1", className),
6152
+ role: "tablist",
6153
+ "aria-label": "Slide indicators",
6154
+ children: Array.from({ length: count2 }, (_, i) => /* @__PURE__ */ jsx(
6155
+ "button",
6156
+ {
6157
+ type: "button",
6158
+ role: "tab",
6159
+ "aria-selected": i === activeIndex,
6160
+ "aria-label": `Slide ${i + 1}`,
6161
+ onClick: () => onIndexChange == null ? void 0 : onIndexChange(i),
6162
+ className: cn(
6163
+ "h-1.5 rounded-[12px] transition-all duration-200",
6164
+ i === activeIndex ? "w-8 bg-bg-brand" : "w-1.5 bg-black/10 hover:bg-black/20"
6165
+ )
6166
+ },
6167
+ i
6168
+ ))
6169
+ }
6170
+ );
6171
+ }
6172
+ function PaginationCarousel({
6173
+ progress,
6174
+ trackWidth = 40,
6175
+ className
6176
+ }) {
6177
+ const clamped = Math.min(1, Math.max(0, progress));
6178
+ return /* @__PURE__ */ jsx(
6179
+ "div",
6180
+ {
6181
+ className: cn("flex items-center", className),
6182
+ role: "progressbar",
6183
+ "aria-valuenow": Math.round(clamped * 100),
6184
+ "aria-valuemin": 0,
6185
+ "aria-valuemax": 100,
6186
+ children: /* @__PURE__ */ jsx(
6187
+ "div",
6188
+ {
6189
+ className: "relative h-1.5 overflow-hidden rounded-[48px] bg-black/10",
6190
+ style: { width: trackWidth },
6191
+ children: /* @__PURE__ */ jsx(
6192
+ "div",
6193
+ {
6194
+ className: "absolute left-0 top-0 h-full rounded-[12px] bg-bg-brand transition-all duration-200",
6195
+ style: { width: Math.round(clamped * trackWidth) }
6196
+ }
6197
+ )
6198
+ }
6199
+ )
6200
+ }
6201
+ );
6202
+ }
6203
+ function buildPageItems(total) {
6204
+ if (total <= 5) return Array.from({ length: total }, (_, i) => i + 1);
6205
+ return [1, 2, 3, "...", total];
6206
+ }
6207
+ function buildHiddenPages(total) {
6208
+ if (total <= 5) return [];
6209
+ return Array.from({ length: total - 4 }, (_, i) => i + 4);
6210
+ }
6211
+ function Pagination({
6212
+ totalPages,
6213
+ currentPage,
6214
+ onPageChange,
6215
+ className
6216
+ }) {
6217
+ const [dropdownOpen, setDropdownOpen] = useState(false);
6218
+ const containerRef = useRef(null);
6219
+ const ellipsisRef = useRef(null);
6220
+ useEffect(() => {
6221
+ if (!dropdownOpen) return;
6222
+ function handleOutside(e) {
6223
+ var _a;
6224
+ if (!((_a = containerRef.current) == null ? void 0 : _a.contains(e.target))) {
6225
+ setDropdownOpen(false);
6226
+ }
6227
+ }
6228
+ document.addEventListener("mousedown", handleOutside);
6229
+ return () => document.removeEventListener("mousedown", handleOutside);
6230
+ }, [dropdownOpen]);
6231
+ const pageItems = buildPageItems(totalPages);
6232
+ const hiddenPages = buildHiddenPages(totalPages);
6233
+ const goTo = (page) => {
6234
+ if (page >= 1 && page <= totalPages && page !== currentPage) {
6235
+ onPageChange == null ? void 0 : onPageChange(page);
6236
+ setDropdownOpen(false);
6237
+ }
6238
+ };
6239
+ const cell = "flex h-8 w-[39px] shrink-0 items-center justify-center text-sm leading-5 transition-colors select-none";
6240
+ const divider = "border-l border-border";
6241
+ const ellipsisLeft = ellipsisRef.current ? ellipsisRef.current.offsetLeft + ellipsisRef.current.offsetWidth / 2 : void 0;
6242
+ return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: cn("relative inline-flex w-fit", className), children: [
6243
+ /* @__PURE__ */ jsxs(
6244
+ "nav",
6245
+ {
6246
+ "aria-label": "Pagination",
6247
+ className: "inline-flex w-fit overflow-hidden rounded-lg border border-border",
6248
+ children: [
6249
+ /* @__PURE__ */ jsx(
6250
+ "button",
6251
+ {
6252
+ type: "button",
6253
+ "aria-label": "Previous page",
6254
+ disabled: currentPage <= 1,
6255
+ onClick: () => goTo(currentPage - 1),
6256
+ className: cn(
6257
+ cell,
6258
+ "bg-bg-default text-icon-default hover:bg-bg-default-hover disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer"
6259
+ ),
6260
+ children: /* @__PURE__ */ jsx(CaretLeft, { size: 16, weight: "regular" })
6261
+ }
6262
+ ),
6263
+ pageItems.map(
6264
+ (item, idx) => item === "..." ? /* @__PURE__ */ jsx(
6265
+ "button",
6266
+ {
6267
+ ref: ellipsisRef,
6268
+ type: "button",
6269
+ "aria-label": "More pages",
6270
+ "aria-expanded": dropdownOpen,
6271
+ "aria-haspopup": "listbox",
6272
+ onClick: () => setDropdownOpen((v) => !v),
6273
+ className: cn(
6274
+ cell,
6275
+ divider,
6276
+ "bg-bg-default text-text-default cursor-pointer hover:bg-bg-default-hover"
6277
+ ),
6278
+ children: "..."
6279
+ },
6280
+ `ellipsis-${idx}`
6281
+ ) : /* @__PURE__ */ jsx(
6282
+ "button",
6283
+ {
6284
+ type: "button",
6285
+ "aria-label": `Page ${item}`,
6286
+ "aria-current": item === currentPage ? "page" : void 0,
6287
+ onClick: () => goTo(item),
6288
+ className: cn(
6289
+ cell,
6290
+ divider,
6291
+ "cursor-pointer",
6292
+ item === currentPage ? "bg-bg-brand font-bold text-text-default-white" : "bg-bg-default font-normal text-text-default hover:bg-bg-default-hover"
6293
+ ),
6294
+ children: item
6295
+ },
6296
+ item
6297
+ )
6298
+ ),
6299
+ /* @__PURE__ */ jsx(
6300
+ "button",
6301
+ {
6302
+ type: "button",
6303
+ "aria-label": "Next page",
6304
+ disabled: currentPage >= totalPages,
6305
+ onClick: () => goTo(currentPage + 1),
6306
+ className: cn(
6307
+ cell,
6308
+ divider,
6309
+ "bg-bg-default text-icon-default hover:bg-bg-default-hover disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer"
6310
+ ),
6311
+ children: /* @__PURE__ */ jsx(CaretRight, { size: 16, weight: "regular" })
6312
+ }
6313
+ )
6314
+ ]
6315
+ }
6316
+ ),
6317
+ dropdownOpen && hiddenPages.length > 0 && /* @__PURE__ */ jsx(
6318
+ "div",
6319
+ {
6320
+ role: "listbox",
6321
+ "aria-label": "Select page",
6322
+ className: "absolute bottom-full mb-1 z-50 flex w-[39px] flex-col overflow-y-auto rounded-lg border border-border bg-bg-default shadow-md [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
6323
+ style: { left: ellipsisLeft, transform: "translateX(-50%)", maxHeight: 160 },
6324
+ children: hiddenPages.map((page) => /* @__PURE__ */ jsx(
6325
+ "button",
6326
+ {
6327
+ type: "button",
6328
+ role: "option",
6329
+ "aria-selected": page === currentPage,
6330
+ onClick: () => goTo(page),
6331
+ className: cn(
6332
+ "flex h-8 w-full shrink-0 cursor-pointer items-center justify-center text-sm leading-5 transition-colors select-none",
6333
+ page === currentPage ? "bg-bg-brand font-bold text-text-default-white" : "bg-bg-default font-normal text-text-default hover:bg-bg-default-hover"
6334
+ ),
6335
+ children: page
6336
+ },
6337
+ page
6338
+ ))
6339
+ }
6340
+ )
6341
+ ] });
6342
+ }
6142
6343
  function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
6143
6344
  return function handleEvent(event) {
6144
6345
  originalEventHandler == null ? void 0 : originalEventHandler(event);
@@ -9566,6 +9767,9 @@ const index = {
9566
9767
  Avatar,
9567
9768
  AvatarStack,
9568
9769
  Breadcrumb,
9770
+ Pagination,
9771
+ PaginationBanner,
9772
+ PaginationCarousel,
9569
9773
  Tooltip,
9570
9774
  Popover,
9571
9775
  cn,
@@ -9589,6 +9793,9 @@ export {
9589
9793
  Modal,
9590
9794
  Notification,
9591
9795
  OptionList,
9796
+ Pagination,
9797
+ PaginationBanner,
9798
+ PaginationCarousel,
9592
9799
  Popover,
9593
9800
  Radio,
9594
9801
  SearchInput,