@abpjs/ui 0.2.0-next.37 → 0.2.0-next.39

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/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0-next.39
4
+
5
+ A prerelease under npm's `next` tag.
6
+
7
+ - storage, from a review of next.37: a test that fails no longer leaves the last one's results; a running copy is read
8
+ again a second after each answer, so slow answers don't pile up; the copy's progress is announced (a polite live
9
+ region); a state the area doesn't know shows as itself; a problem without a store keeps its file's name and its own
10
+ row; the previous storage's place is set apart (U+2068 … U+2069), so a path or URL keeps its order in right-to-left
11
+ text; and an address under the page shows "There is no such page" with the way back, not the page.
12
+
13
+ ## 0.2.0-next.38
14
+
15
+ A prerelease under npm's `next` tag.
16
+
17
+ - Files as tables, for any "import from a file" flow: `readTable(file)` gives a CSV's or an Excel workbook's rows as
18
+ text cells, the header first (a workbook's first visible sheet, named in `sheet` when there are several).
19
+ `readXlsx` reads an .xlsx in the browser with no library (numbers as Excel shows them, date-styled cells as
20
+ yyyy-MM-dd in either date system, formulas as their last values) and throws `XlsxError` (`old` for an .xls or a
21
+ file with a password, `broken`, `tooBig`, `noSheet`). `parseCsv` (RFC 4180, the separator guessed by
22
+ `guessSeparator`), `writeCsv` and `remapCsv` (columns renamed or left out) prepare rows for an import on a server;
23
+ `tableKind` tells a CSV, a workbook and an older Excel file apart by name and type.
24
+
3
25
  ## 0.2.0-next.37
4
26
 
5
27
  A prerelease under npm's `next` tag.
package/dist/index.d.ts CHANGED
@@ -1730,6 +1730,51 @@ declare function placeItem(items: GridItem[], w: number, h: number, columns?: nu
1730
1730
  */
1731
1731
  declare function DashboardGrid<T extends GridItem>({ items, columns, rowHeight, editing, onLayoutChange, renderItem, labels, 'aria-label': ariaLabel, loading: own, }: DashboardGridProps<T>): react.JSX.Element;
1732
1732
 
1733
+ /** A file's rows as cells, the header first. Empty lines are skipped. */
1734
+ declare function parseCsv(text: string): string[][];
1735
+ /** The separator the first line uses most: comma, semicolon or tab (outside quotes). */
1736
+ declare function guessSeparator(text: string): string;
1737
+ /** Rows as CSV with commas, CRLF line ends, fields quoted when they must be. */
1738
+ declare function writeCsv(rows: string[][]): string;
1739
+ /**
1740
+ * The rows with their columns renamed and some left out: `targets[i]` is column i's new header, or null to leave it
1741
+ * out. Columns past the header's length are dropped; short rows are padded.
1742
+ */
1743
+ declare function remapCsv(rows: string[][], targets: (string | null)[]): string[][];
1744
+ /** The media type of an Excel workbook (.xlsx). */
1745
+ declare const XLSX_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
1746
+ /** What kind of table a file is, by its name and type: a CSV, an Excel workbook, an older Excel file, or neither. */
1747
+ declare function tableKind(file: {
1748
+ name: string;
1749
+ type?: string;
1750
+ }): 'csv' | 'xlsx' | 'old' | null;
1751
+
1752
+ /** Why a file can't be read: an older .xls or one with a password, not a zip, too big unpacked, or no sheet. */
1753
+ type XlsxProblem = 'old' | 'broken' | 'tooBig' | 'noSheet';
1754
+ declare class XlsxError extends Error {
1755
+ readonly problem: XlsxProblem;
1756
+ constructor(problem: XlsxProblem);
1757
+ }
1758
+ interface XlsxSheet {
1759
+ /** The sheet read: the workbook's first visible one. */
1760
+ sheet: string;
1761
+ /** How many visible sheets the workbook has. */
1762
+ sheets: number;
1763
+ rows: string[][];
1764
+ }
1765
+ /** The first visible sheet's rows as text: numbers as Excel shows them to 15 digits, dates as yyyy-MM-dd. */
1766
+ declare function readXlsx(data: ArrayBuffer | Uint8Array): Promise<XlsxSheet>;
1767
+
1768
+ /**
1769
+ * A file's rows as text cells, the header first, from a CSV or an Excel workbook (its first visible sheet, named in
1770
+ * `sheet` when the workbook has several). Throws `XlsxError` for a workbook it can't read, and an Error for a file
1771
+ * that is neither.
1772
+ */
1773
+ declare function readTable(file: File): Promise<{
1774
+ rows: string[][];
1775
+ sheet?: Pick<XlsxSheet, 'sheet' | 'sheets'>;
1776
+ }>;
1777
+
1733
1778
  declare const TRACKS = 60;
1734
1779
  /** Width presets in tracks: half, two-thirds, full. */
1735
1780
  declare const PRESETS: {
@@ -3417,4 +3462,4 @@ interface TooltipProps extends Omit<Tooltip$1.RootProps, 'children'> {
3417
3462
  */
3418
3463
  declare const Tooltip: react.ForwardRefExoticComponent<TooltipProps & react.RefAttributes<HTMLDivElement>>;
3419
3464
 
3420
- export { ABP_UI_VERSION, AbpApiError, type AbpBrand, type AbpHost, type AbpLabels, type AbpLabelsInput, type AbpListOptions, AbpProvider, type AbpProviderProps, type AbpSystemOptions, AddButton, type AddButtonProps, type ApiQuery, AppLink, type AppLinkProps, AppShell, type AppShellBrand, type AppShellNavItem, type AppShellNavSection, type AppShellPlace, type AppShellProps, type AppShellSidebar, type AreaTexts, type Arrival, ArriveOnChange, type ArriveOnChangeProps, AttentionChip, type AttentionChipProps, type AvatarPerson, AvatarStack, type AvatarStackProps, type BoardItem, Bone, type BoneProps, type BreadcrumbItem, Breadcrumbs, Button, type ButtonProps, type ButtonSize, type ButtonVariant, CalendarGrid, type CalendarGridProps, type CalendarItem, type CardDates, CategoryProgress, type CategoryProgressProps, type CelebrateTarget, Chart, type ChartProps, type ChartSeries, CheckboxField, type CheckboxFieldProps, Collapse, type CollapseProps, type ColorMode, ColorModeProvider, ColorModeToggle, type CommandGroup, type CommandItem, CommandPalette, type CommandPaletteProps, ConfirmDialog, type ConfirmDialogProps, type ConfirmOptions, ConfirmProvider, CountBadge, type CountBadgeProps, Counter, type CounterProps, DEFAULT_PAGE_SIZE, DashboardGrid, type DashboardGridProps, DataTable, type DataTableColumn, type DataTableProps, type DataTableSelection, type DataTableSort, type Direction, DirectionalIcon, DropHint, type DropHintProps, type DropZoneOptions, type DropZoneState, type DroppedFile, EMPTY_VALUE, EmotionRegistry, type EmptyArt, EmptyArtDrawing, type EmptyIllustration, EmptyState, type EmptyStateProps, FadeIn, type FadeInProps, Field, type FieldProps, FileDropArea, type FileDropAreaProps, FormDialog, type FormDialogProps, FormField, type GridItem, GroupPicker, Highlight, HighlightText, type HostEventHandler, type HostEvents, type HostFile, type HostLanguage, HostProvider, type HostRequest, type HostRequestInit, type HostRequestOptions, type HostScope, HostSlot, IconButton, type IconButtonProps, IconTile, type IconTileProps, Indicator, type IndicatorProps, InlineAlert, type InlineAlertProps, KanbanBoard, type KanbanBoardProps, type KanbanColumn, type KanbanItem, type KanbanLane, type KanbanMove, type LinkComponent, ListFooter, type ListPage, type ListQuery, type ListSource, type ListState, Loading, type LoadingProps, LoadingState, MotionProvider, type MotionSetting, type MotionState, type NameSuggestion, type NamesValue, Nudge, type NudgeProps, PageHeader, type PageHeaderProps, PageIllustration, PageTitleProvider, Pagination, type PaginationForm, type PaginationProps, Panel, type PanelProps, PanelTone, type Particle, PathChips, type PathChipsProps, PersonChip, type PersonChipProps, PersonPicker, type PickerGroup, type PickerLabels, type PickerPerson, type PlacedCard, PluginTextsProvider, type Pose, Presence, PresenceItem, type PresenceItemProps, PresenceList, type PresenceListProps, type PresenceProps, Pressable, type PressableProps, PreviewCard, type PreviewCardProps, PriorityMark, type PriorityMarkProps, type PropertyItem, PropertyList, type PropertyListProps, type QueryConditionJson, type QueryExportFormat, type QueryExportOptions, type QueryExportSeparator, type QueryField, type QueryGroup, type QueryJson, type QueryListLabels, type QueryNodeJson, type QueryRow, type QuerySuggestion, type QuerySuggestions, type QueryValueEditor, QueryableList, type QueryableListError, type QueryableListExport, type QueryableListProps, type QueryableListState, type QueryableListView, type QueueProgress, RecordKey, type RecordKeyProps, type RegisterSlotSave, Reveal, RevealItem, type RevealItemProps, type RevealProps, RowMenu, type RowMenuEntry, type RowMenuItem, type RowMenuProps, SHOWN, STEP_UP_REQUIRED, STRONG_FACTOR_REQUIRED, SaveBar, type SaveBarProps, type Scale, SearchInput, type SearchInputProps, SearchPicker, type SearchPickerMessages, type SearchPickerProps, type SectionMove, SegmentedControl, type SegmentedControlProps, type SegmentedItem, SelectField, type SelectFieldProps, type SelectOption, type ServerInsertedHTML, type SettingsArea, SettingsLayout, type SettingsLayoutProps, type SettingsPage, type SettingsSection, SlideItem, type SlideItemProps, SlideList, type SlideListProps, type SlotSave, type SortDirection, type SortableSection, SortableSections, type SortableSectionsProps, type StatusCategory, StatusPill, type StatusPillProps, type StatusTone, StepUpDialog, type StepUpHandler, type StepUpNeed, Swap, type SwapProps, SwitchField, type SwitchFieldProps, TITLE_SEPARATOR, TextBone, type TextBoneProps, TextSlot, type TextSlotProps, type TimelineCardItem, TimelineCards, type TimelineCardsProps, TimelineChart, type TimelineChartProps, type TimelineItem, type TimelineRow, type TimelineScale, type TitleParts, Toaster, Tooltip, type TooltipProps, TranslatedInput, type TranslatedInputProps, type TranslationsLabels, UPLOADS_AT_ONCE, type UploadJob, UploadList, type UploadListProps, type UploadRow, type UploadState, TRACKS as WIDGET_TRACKS, PRESETS as WIDGET_WIDTHS, WidgetBoard, type WidgetBoardLabels, type WidgetBoardProps, abpConfig, abpListParams, abpListSource, appendAt, arriveCss, asMotionSetting, avatarPalette, basicConditions, boneWidth, burst, compactLayout, compareOrdinal, composeTitle, covers, createAbpSystem, createAreaTexts, createHostEvents, createHostRequest, createPasskey, curves, defaultBrand, defaultLabels, defaultPickerLabels, defaultQueryListLabels, defaultTranslationsLabels, directionOf, droppedFiles, emptyQuery, errorText, fileNameOf, findSettingsPage, folderOf, foldersFor, formatDateTime, formatMessage, formatNumber, fromTwelve, getPasskey, ghostCss, groupKey, heavierFirst, hiddenPose, inSections, isStepUp, looksLikeCode, durations as motionDurations, needsStepUp, notify, pageCount, pageList, pagesShown, partsOf, passkeysSupported, pastedName, personLabel, placeCards, placeItem, priorityLevel, progressOf, readAbpError, readEvents, refusal, renumber, requestStepUp, setStepUpHandler, settingsArea, shineCss, springs, staggerDelay, stepUpNeedOf, targetOf, toStart, toaster, useAbpLabels, useAbpLocale, useAbpTimeZone, useApiAction, useApiDownload, useApiQuery, useAreaEvents, useAreaListSource, useAreaRequest, useArriving, useCan, useCelebrate, useColorMode, useConfirm, useDropZone, useFilesOverPage, useFormatters, useHost, useHostLanguages, useLinkComponent, useListState, useLoading, useMe, useMotionSetting, useNames, useNavigate, useOptionalHost, usePageDrop, usePageTitle, usePageTitleParts, usePageTitleSite, usePastedFiles, usePluginTexts, useProductName, useSettledValue, useSlotSaves, useTokenVar };
3465
+ export { ABP_UI_VERSION, AbpApiError, type AbpBrand, type AbpHost, type AbpLabels, type AbpLabelsInput, type AbpListOptions, AbpProvider, type AbpProviderProps, type AbpSystemOptions, AddButton, type AddButtonProps, type ApiQuery, AppLink, type AppLinkProps, AppShell, type AppShellBrand, type AppShellNavItem, type AppShellNavSection, type AppShellPlace, type AppShellProps, type AppShellSidebar, type AreaTexts, type Arrival, ArriveOnChange, type ArriveOnChangeProps, AttentionChip, type AttentionChipProps, type AvatarPerson, AvatarStack, type AvatarStackProps, type BoardItem, Bone, type BoneProps, type BreadcrumbItem, Breadcrumbs, Button, type ButtonProps, type ButtonSize, type ButtonVariant, CalendarGrid, type CalendarGridProps, type CalendarItem, type CardDates, CategoryProgress, type CategoryProgressProps, type CelebrateTarget, Chart, type ChartProps, type ChartSeries, CheckboxField, type CheckboxFieldProps, Collapse, type CollapseProps, type ColorMode, ColorModeProvider, ColorModeToggle, type CommandGroup, type CommandItem, CommandPalette, type CommandPaletteProps, ConfirmDialog, type ConfirmDialogProps, type ConfirmOptions, ConfirmProvider, CountBadge, type CountBadgeProps, Counter, type CounterProps, DEFAULT_PAGE_SIZE, DashboardGrid, type DashboardGridProps, DataTable, type DataTableColumn, type DataTableProps, type DataTableSelection, type DataTableSort, type Direction, DirectionalIcon, DropHint, type DropHintProps, type DropZoneOptions, type DropZoneState, type DroppedFile, EMPTY_VALUE, EmotionRegistry, type EmptyArt, EmptyArtDrawing, type EmptyIllustration, EmptyState, type EmptyStateProps, FadeIn, type FadeInProps, Field, type FieldProps, FileDropArea, type FileDropAreaProps, FormDialog, type FormDialogProps, FormField, type GridItem, GroupPicker, Highlight, HighlightText, type HostEventHandler, type HostEvents, type HostFile, type HostLanguage, HostProvider, type HostRequest, type HostRequestInit, type HostRequestOptions, type HostScope, HostSlot, IconButton, type IconButtonProps, IconTile, type IconTileProps, Indicator, type IndicatorProps, InlineAlert, type InlineAlertProps, KanbanBoard, type KanbanBoardProps, type KanbanColumn, type KanbanItem, type KanbanLane, type KanbanMove, type LinkComponent, ListFooter, type ListPage, type ListQuery, type ListSource, type ListState, Loading, type LoadingProps, LoadingState, MotionProvider, type MotionSetting, type MotionState, type NameSuggestion, type NamesValue, Nudge, type NudgeProps, PageHeader, type PageHeaderProps, PageIllustration, PageTitleProvider, Pagination, type PaginationForm, type PaginationProps, Panel, type PanelProps, PanelTone, type Particle, PathChips, type PathChipsProps, PersonChip, type PersonChipProps, PersonPicker, type PickerGroup, type PickerLabels, type PickerPerson, type PlacedCard, PluginTextsProvider, type Pose, Presence, PresenceItem, type PresenceItemProps, PresenceList, type PresenceListProps, type PresenceProps, Pressable, type PressableProps, PreviewCard, type PreviewCardProps, PriorityMark, type PriorityMarkProps, type PropertyItem, PropertyList, type PropertyListProps, type QueryConditionJson, type QueryExportFormat, type QueryExportOptions, type QueryExportSeparator, type QueryField, type QueryGroup, type QueryJson, type QueryListLabels, type QueryNodeJson, type QueryRow, type QuerySuggestion, type QuerySuggestions, type QueryValueEditor, QueryableList, type QueryableListError, type QueryableListExport, type QueryableListProps, type QueryableListState, type QueryableListView, type QueueProgress, RecordKey, type RecordKeyProps, type RegisterSlotSave, Reveal, RevealItem, type RevealItemProps, type RevealProps, RowMenu, type RowMenuEntry, type RowMenuItem, type RowMenuProps, SHOWN, STEP_UP_REQUIRED, STRONG_FACTOR_REQUIRED, SaveBar, type SaveBarProps, type Scale, SearchInput, type SearchInputProps, SearchPicker, type SearchPickerMessages, type SearchPickerProps, type SectionMove, SegmentedControl, type SegmentedControlProps, type SegmentedItem, SelectField, type SelectFieldProps, type SelectOption, type ServerInsertedHTML, type SettingsArea, SettingsLayout, type SettingsLayoutProps, type SettingsPage, type SettingsSection, SlideItem, type SlideItemProps, SlideList, type SlideListProps, type SlotSave, type SortDirection, type SortableSection, SortableSections, type SortableSectionsProps, type StatusCategory, StatusPill, type StatusPillProps, type StatusTone, StepUpDialog, type StepUpHandler, type StepUpNeed, Swap, type SwapProps, SwitchField, type SwitchFieldProps, TITLE_SEPARATOR, TextBone, type TextBoneProps, TextSlot, type TextSlotProps, type TimelineCardItem, TimelineCards, type TimelineCardsProps, TimelineChart, type TimelineChartProps, type TimelineItem, type TimelineRow, type TimelineScale, type TitleParts, Toaster, Tooltip, type TooltipProps, TranslatedInput, type TranslatedInputProps, type TranslationsLabels, UPLOADS_AT_ONCE, type UploadJob, UploadList, type UploadListProps, type UploadRow, type UploadState, TRACKS as WIDGET_TRACKS, PRESETS as WIDGET_WIDTHS, WidgetBoard, type WidgetBoardLabels, type WidgetBoardProps, XLSX_TYPE, XlsxError, type XlsxProblem, type XlsxSheet, abpConfig, abpListParams, abpListSource, appendAt, arriveCss, asMotionSetting, avatarPalette, basicConditions, boneWidth, burst, compactLayout, compareOrdinal, composeTitle, covers, createAbpSystem, createAreaTexts, createHostEvents, createHostRequest, createPasskey, curves, defaultBrand, defaultLabels, defaultPickerLabels, defaultQueryListLabels, defaultTranslationsLabels, directionOf, droppedFiles, emptyQuery, errorText, fileNameOf, findSettingsPage, folderOf, foldersFor, formatDateTime, formatMessage, formatNumber, fromTwelve, getPasskey, ghostCss, groupKey, guessSeparator, heavierFirst, hiddenPose, inSections, isStepUp, looksLikeCode, durations as motionDurations, needsStepUp, notify, pageCount, pageList, pagesShown, parseCsv, partsOf, passkeysSupported, pastedName, personLabel, placeCards, placeItem, priorityLevel, progressOf, readAbpError, readEvents, readTable, readXlsx, refusal, remapCsv, renumber, requestStepUp, setStepUpHandler, settingsArea, shineCss, springs, staggerDelay, stepUpNeedOf, tableKind, targetOf, toStart, toaster, useAbpLabels, useAbpLocale, useAbpTimeZone, useApiAction, useApiDownload, useApiQuery, useAreaEvents, useAreaListSource, useAreaRequest, useArriving, useCan, useCelebrate, useColorMode, useConfirm, useDropZone, useFilesOverPage, useFormatters, useHost, useHostLanguages, useLinkComponent, useListState, useLoading, useMe, useMotionSetting, useNames, useNavigate, useOptionalHost, usePageDrop, usePageTitle, usePageTitleParts, usePageTitleSite, usePastedFiles, usePluginTexts, useProductName, useSettledValue, useSlotSaves, useTokenVar, writeCsv };
package/dist/index.js CHANGED
@@ -1603,7 +1603,7 @@ function useTokenVar() {
1603
1603
  }
1604
1604
 
1605
1605
  // src/version.ts
1606
- var ABP_UI_VERSION = true ? "0.2.0-next.37" : "0.0.0-dev";
1606
+ var ABP_UI_VERSION = true ? "0.2.0-next.39" : "0.0.0-dev";
1607
1607
 
1608
1608
  // src/provider/time-zone.tsx
1609
1609
  import { createContext, useContext } from "react";
@@ -6537,6 +6537,283 @@ function DashboardGrid({
6537
6537
  ] });
6538
6538
  }
6539
6539
 
6540
+ // src/files/csv.ts
6541
+ function parseCsv(text) {
6542
+ const src = text.charCodeAt(0) === 65279 ? text.slice(1) : text;
6543
+ const sep = guessSeparator(src);
6544
+ const rows2 = [];
6545
+ let row = [];
6546
+ let cell = "";
6547
+ let quoted = false;
6548
+ for (let i = 0; i < src.length; i++) {
6549
+ const c2 = src[i];
6550
+ if (quoted) {
6551
+ if (c2 === '"') {
6552
+ if (src[i + 1] === '"') {
6553
+ cell += '"';
6554
+ i++;
6555
+ } else {
6556
+ quoted = false;
6557
+ }
6558
+ } else {
6559
+ cell += c2;
6560
+ }
6561
+ } else if (c2 === '"' && cell === "") {
6562
+ quoted = true;
6563
+ } else if (c2 === sep) {
6564
+ row.push(cell);
6565
+ cell = "";
6566
+ } else if (c2 === "\n" || c2 === "\r") {
6567
+ if (c2 === "\r" && src[i + 1] === "\n") i++;
6568
+ row.push(cell);
6569
+ if (row.some((x) => x.trim() !== "")) rows2.push(row);
6570
+ row = [];
6571
+ cell = "";
6572
+ } else {
6573
+ cell += c2;
6574
+ }
6575
+ }
6576
+ row.push(cell);
6577
+ if (row.some((x) => x.trim() !== "")) rows2.push(row);
6578
+ return rows2;
6579
+ }
6580
+ function guessSeparator(text) {
6581
+ const counts = { ",": 0, ";": 0, " ": 0 };
6582
+ let quoted = false;
6583
+ for (const c2 of text) {
6584
+ if (c2 === '"') quoted = !quoted;
6585
+ else if (!quoted && (c2 === "\n" || c2 === "\r")) break;
6586
+ else if (!quoted && c2 in counts) counts[c2]++;
6587
+ }
6588
+ const [best, count] = Object.entries(counts).sort((a, b) => b[1] - a[1])[0];
6589
+ return count > 0 ? best : ",";
6590
+ }
6591
+ function writeCsv(rows2) {
6592
+ const field = (v) => /[",\r\n]/.test(v) ? `"${v.replace(/"/g, '""')}"` : v;
6593
+ return rows2.map((r) => r.map(field).join(",")).join("\r\n") + "\r\n";
6594
+ }
6595
+ function remapCsv(rows2, targets) {
6596
+ const keep = targets.map((t, i) => t ? i : -1).filter((i) => i >= 0);
6597
+ return rows2.map((r, n) => keep.map((i) => n === 0 ? targets[i] : r[i] ?? ""));
6598
+ }
6599
+ var XLSX_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
6600
+ function tableKind(file) {
6601
+ if (/\.(xls|xlsb)$/i.test(file.name)) return "old";
6602
+ if (/\.(xlsx|xlsm)$/i.test(file.name) || file.type === XLSX_TYPE) return "xlsx";
6603
+ if (/\.csv$/i.test(file.name) || file.type === "text/csv") return "csv";
6604
+ return null;
6605
+ }
6606
+
6607
+ // src/files/xlsx.ts
6608
+ var XlsxError = class extends Error {
6609
+ problem;
6610
+ constructor(problem) {
6611
+ super(`xlsx: ${problem}`);
6612
+ this.problem = problem;
6613
+ }
6614
+ };
6615
+ var MAX_UNPACKED = 64e6;
6616
+ async function readXlsx(data) {
6617
+ const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
6618
+ if (bytes[0] === 208 && bytes[1] === 207 && bytes[2] === 17 && bytes[3] === 224) throw new XlsxError("old");
6619
+ const zip = entries(bytes);
6620
+ let unpacked = 0;
6621
+ const read = async (path) => {
6622
+ const entry = zip.get(path.replace(/^\/+/, ""));
6623
+ if (!entry) return null;
6624
+ const out = await inflate(bytes, entry, MAX_UNPACKED - unpacked);
6625
+ unpacked += out.length;
6626
+ return new TextDecoder().decode(out);
6627
+ };
6628
+ const workbook = await read("xl/workbook.xml");
6629
+ if (workbook == null) throw new XlsxError("broken");
6630
+ const rels = parseRels(await read("xl/_rels/workbook.xml.rels") ?? "");
6631
+ const visible = tags(workbook, "sheet").map(attrs).filter((a) => a.state !== "hidden" && a.state !== "veryHidden");
6632
+ const first = visible[0];
6633
+ const target = first && rels.get(first["r:id"] ?? first.id ?? "");
6634
+ if (!target) throw new XlsxError("noSheet");
6635
+ const sheetXml = await read(target.startsWith("/") ? target : `xl/${target}`);
6636
+ if (sheetXml == null) throw new XlsxError("noSheet");
6637
+ const date1904 = /<(?:\w+:)?workbookPr\b[^>]*\bdate1904="(?:1|true)"/.test(workbook);
6638
+ const strings = sharedStrings(await read("xl/sharedStrings.xml") ?? "");
6639
+ const dates = dateStyles(await read("xl/styles.xml") ?? "");
6640
+ return { sheet: decode(first.name ?? ""), sheets: visible.length, rows: sheetRows(sheetXml, strings, dates, date1904) };
6641
+ }
6642
+ function entries(b) {
6643
+ const view = new DataView(b.buffer, b.byteOffset, b.byteLength);
6644
+ if (b.length < 22 || view.getUint32(0, true) !== 67324752) throw new XlsxError("broken");
6645
+ let end = -1;
6646
+ for (let i = b.length - 22; i >= Math.max(0, b.length - 22 - 65535); i--) {
6647
+ if (view.getUint32(i, true) === 101010256) {
6648
+ end = i;
6649
+ break;
6650
+ }
6651
+ }
6652
+ if (end < 0) throw new XlsxError("broken");
6653
+ const count = view.getUint16(end + 10, true);
6654
+ let at = view.getUint32(end + 16, true);
6655
+ const names = new TextDecoder();
6656
+ const files = /* @__PURE__ */ new Map();
6657
+ for (let n = 0; n < count; n++) {
6658
+ if (at + 46 > b.length || view.getUint32(at, true) !== 33639248) throw new XlsxError("broken");
6659
+ const nameLength = view.getUint16(at + 28, true);
6660
+ const name = names.decode(b.subarray(at + 46, at + 46 + nameLength));
6661
+ files.set(name, {
6662
+ flags: view.getUint16(at + 8, true),
6663
+ method: view.getUint16(at + 10, true),
6664
+ size: view.getUint32(at + 20, true),
6665
+ unpacked: view.getUint32(at + 24, true),
6666
+ offset: view.getUint32(at + 42, true)
6667
+ });
6668
+ at += 46 + nameLength + view.getUint16(at + 30, true) + view.getUint16(at + 32, true);
6669
+ }
6670
+ return files;
6671
+ }
6672
+ async function inflate(b, e, room) {
6673
+ const view = new DataView(b.buffer, b.byteOffset, b.byteLength);
6674
+ if (e.flags & 1) throw new XlsxError("old");
6675
+ if (e.unpacked > room) throw new XlsxError("tooBig");
6676
+ if (e.offset + 30 > b.length || view.getUint32(e.offset, true) !== 67324752) throw new XlsxError("broken");
6677
+ const start = e.offset + 30 + view.getUint16(e.offset + 26, true) + view.getUint16(e.offset + 28, true);
6678
+ const packed = b.subarray(start, start + e.size);
6679
+ if (e.method === 0) return packed;
6680
+ if (e.method !== 8) throw new XlsxError("broken");
6681
+ const reader = new Blob([packed]).stream().pipeThrough(new DecompressionStream("deflate-raw")).getReader();
6682
+ const parts = [];
6683
+ let total = 0;
6684
+ try {
6685
+ for (; ; ) {
6686
+ const { done, value } = await reader.read();
6687
+ if (done) break;
6688
+ total += value.length;
6689
+ if (total > room) {
6690
+ await reader.cancel();
6691
+ throw new XlsxError("tooBig");
6692
+ }
6693
+ parts.push(value);
6694
+ }
6695
+ } catch (err) {
6696
+ throw err instanceof XlsxError ? err : new XlsxError("broken");
6697
+ }
6698
+ const out = new Uint8Array(total);
6699
+ let at = 0;
6700
+ for (const p of parts) {
6701
+ out.set(p, at);
6702
+ at += p.length;
6703
+ }
6704
+ return out;
6705
+ }
6706
+ function elements(xml, name) {
6707
+ const re = new RegExp(`<(?:[\\w.-]+:)?${name}\\b([^>]*?)(?:/>|>([\\s\\S]*?)</(?:[\\w.-]+:)?${name}>)`, "g");
6708
+ return [...xml.matchAll(re)].map((m4) => ({ attrs: m4[1], inner: m4[2] ?? "" }));
6709
+ }
6710
+ var tags = (xml, name) => elements(xml, name).map((e) => e.attrs);
6711
+ function attrs(text) {
6712
+ const out = {};
6713
+ for (const m4 of text.matchAll(/([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g)) out[m4[1]] = m4[2] ?? m4[3];
6714
+ return out;
6715
+ }
6716
+ function decode(text) {
6717
+ return text.replace(/&(?:#x([0-9a-f]+)|#(\d+)|(lt|gt|amp|quot|apos));/gi, (_, hex, dec, named) => hex ? String.fromCodePoint(parseInt(hex, 16)) : dec ? String.fromCodePoint(Number(dec)) : { lt: "<", gt: ">", amp: "&", quot: '"', apos: "'" }[named.toLowerCase()]).replace(/_x([0-9A-Fa-f]{4})_/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)));
6718
+ }
6719
+ function runText(inner) {
6720
+ const plain = inner.replace(/<(?:[\w.-]+:)?rPh\b[\s\S]*?<\/(?:[\w.-]+:)?rPh>/g, "");
6721
+ return elements(plain, "t").map((t) => decode(t.inner)).join("");
6722
+ }
6723
+ function parseRels(xml) {
6724
+ const map = /* @__PURE__ */ new Map();
6725
+ for (const a of tags(xml, "Relationship").map(attrs)) if (a.Id && a.Target) map.set(a.Id, a.Target);
6726
+ return map;
6727
+ }
6728
+ function sharedStrings(xml) {
6729
+ return elements(xml, "si").map((si) => runText(si.inner));
6730
+ }
6731
+ var BUILT_IN_DATES = /* @__PURE__ */ new Set([14, 15, 16, 17, 18, 19, 20, 21, 22, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 45, 46, 47, 50, 51, 52, 53, 54, 55, 56, 57, 58]);
6732
+ function isDateFormat(code) {
6733
+ const bare = code.replace(/"[^"]*"/g, "").replace(/\\./g, "").replace(/\[(?!h\]|m\]|s\])[^\]]*\]/gi, "").split(";")[0];
6734
+ return /[dmyhs]/i.test(bare) && !/^[#0.,%\s]*$/.test(bare);
6735
+ }
6736
+ function dateStyles(xml) {
6737
+ const custom = /* @__PURE__ */ new Map();
6738
+ for (const a of tags(xml, "numFmt").map(attrs)) custom.set(Number(a.numFmtId), decode(a.formatCode ?? ""));
6739
+ const xfs = elements(xml, "cellXfs")[0]?.inner ?? "";
6740
+ const out = /* @__PURE__ */ new Set();
6741
+ tags(xfs, "xf").map(attrs).forEach((a, i) => {
6742
+ const id = Number(a.numFmtId ?? 0);
6743
+ if (BUILT_IN_DATES.has(id) || custom.has(id) && isDateFormat(custom.get(id))) out.add(i);
6744
+ });
6745
+ return out;
6746
+ }
6747
+ function columnOf(ref) {
6748
+ let n = 0;
6749
+ for (const c2 of ref.toUpperCase()) {
6750
+ if (c2 < "A" || c2 > "Z") break;
6751
+ n = n * 26 + (c2.charCodeAt(0) - 64);
6752
+ }
6753
+ return n - 1;
6754
+ }
6755
+ function serialDate(serial, date1904 = false) {
6756
+ const days = date1904 ? serial + 1462 : serial < 60 ? serial + 1 : serial;
6757
+ const ms = Math.round((days - 25569) * 864e5 / 1e3) * 1e3;
6758
+ const iso = new Date(ms).toISOString();
6759
+ const time = iso.slice(11, 19);
6760
+ return time === "00:00:00" ? iso.slice(0, 10) : `${iso.slice(0, 10)}T${time.endsWith(":00") ? time.slice(0, 5) : time}`;
6761
+ }
6762
+ function numberText(v) {
6763
+ const n = Number(v);
6764
+ if (!Number.isFinite(n)) return v;
6765
+ return String(Number(n.toPrecision(15)));
6766
+ }
6767
+ function sheetRows(xml, strings, dates, date1904) {
6768
+ const data = elements(xml, "sheetData")[0]?.inner ?? "";
6769
+ const rows2 = [];
6770
+ for (const row of elements(data, "row")) {
6771
+ const cells = [];
6772
+ let next = 0;
6773
+ for (const c2 of elements(row.inner, "c")) {
6774
+ const a = attrs(c2.attrs);
6775
+ const col = a.r ? columnOf(a.r) : next;
6776
+ next = col + 1;
6777
+ const v = elements(c2.inner, "v")[0]?.inner;
6778
+ let text;
6779
+ switch (a.t) {
6780
+ case "s":
6781
+ text = strings[Number(v)] ?? "";
6782
+ break;
6783
+ case "inlineStr":
6784
+ text = runText(elements(c2.inner, "is")[0]?.inner ?? "");
6785
+ break;
6786
+ case "b":
6787
+ text = v === "1" ? "TRUE" : v === "0" ? "FALSE" : "";
6788
+ break;
6789
+ case "str":
6790
+ case "e":
6791
+ case "d":
6792
+ text = decode(v ?? "");
6793
+ break;
6794
+ default:
6795
+ text = v == null || v === "" ? "" : dates.has(Number(a.s ?? 0)) && Number.isFinite(Number(v)) ? serialDate(Number(v), date1904) : numberText(v);
6796
+ }
6797
+ if (text === "") continue;
6798
+ while (cells.length < col) cells.push("");
6799
+ cells[col] = text;
6800
+ }
6801
+ if (cells.some((x) => x.trim() !== "")) rows2.push(cells);
6802
+ }
6803
+ return rows2;
6804
+ }
6805
+
6806
+ // src/files/table.ts
6807
+ async function readTable(file) {
6808
+ const kind = tableKind(file);
6809
+ if (kind === "xlsx") {
6810
+ const book = await readXlsx(await file.arrayBuffer());
6811
+ return { rows: book.rows, sheet: { sheet: book.sheet, sheets: book.sheets } };
6812
+ }
6813
+ if (kind === "csv") return { rows: parseCsv(await file.text()) };
6814
+ throw new Error(kind === "old" ? "old" : "type");
6815
+ }
6816
+
6540
6817
  // src/components/WidgetBoard.tsx
6541
6818
  import { useEffect as useEffect13, useLayoutEffect as useLayoutEffect3, useMemo as useMemo9, useRef as useRef14, useState as useState17 } from "react";
6542
6819
  import { Box as Box8, chakra as chakra21, HStack as HStack7, Text as Text12 } from "@chakra-ui/react";
@@ -6679,10 +6956,10 @@ function WidgetBoard({
6679
6956
  return () => ro.disconnect();
6680
6957
  }, []);
6681
6958
  useEffect13(() => {
6682
- observer.current = new ResizeObserver((entries) => {
6959
+ observer.current = new ResizeObserver((entries2) => {
6683
6960
  setHeights((old) => {
6684
6961
  let next = null;
6685
- for (const entry of entries) {
6962
+ for (const entry of entries2) {
6686
6963
  const id = entry.target.dataset.widget;
6687
6964
  const h = Math.ceil(entry.target.offsetHeight);
6688
6965
  if (old.get(id) !== h) (next ??= new Map(old)).set(id, h);
@@ -6888,7 +7165,7 @@ function WidgetBoard({
6888
7165
  ] : [];
6889
7166
  const own2 = menu?.(item) ?? [];
6890
7167
  const red = own2.filter((e) => "danger" in e && e.danger);
6891
- const entries = [...own2.filter((e) => !red.includes(e)), ...presets, ...red.length ? [{ separator: true }, ...red] : []].filter((e, i, all) => !("separator" in e) || i > 0 && i < all.length - 1 && !("separator" in all[i - 1]));
7168
+ const entries2 = [...own2.filter((e) => !red.includes(e)), ...presets, ...red.length ? [{ separator: true }, ...red] : []].filter((e, i, all) => !("separator" in e) || i > 0 && i < all.length - 1 && !("separator" in all[i - 1]));
6892
7169
  return /* @__PURE__ */ jsx38(
6893
7170
  Box8,
6894
7171
  {
@@ -6942,7 +7219,7 @@ function WidgetBoard({
6942
7219
  }
6943
7220
  ) }),
6944
7221
  !narrow && /* @__PURE__ */ jsx38(chakra21.span, { "data-reveal": "", display: "inline-flex", children: /* @__PURE__ */ jsx38(Tooltip, { content: isOpen ? labels.restore : labels.expand, children: /* @__PURE__ */ jsx38(IconButton, { size: "xs", variant: "ghost", color: "fg.muted", "aria-label": isOpen ? labels.restore : labels.expand, "aria-pressed": isOpen, onClick: () => toggle(p.id), children: isOpen ? /* @__PURE__ */ jsx38(Minimize2, {}) : /* @__PURE__ */ jsx38(Maximize2, {}) }) }) }),
6945
- entries.length > 0 && /* @__PURE__ */ jsx38(RowMenu, { label: labels.actions(name), items: entries, size: "xs" })
7222
+ entries2.length > 0 && /* @__PURE__ */ jsx38(RowMenu, { label: labels.actions(name), items: entries2, size: "xs" })
6946
7223
  ] })
6947
7224
  ] }),
6948
7225
  /* @__PURE__ */ jsx38(Box8, { px: "4", pb: "4", pt: "1", minW: "0", overflowX: "auto", children: renderItem(item, { expanded: isOpen }) }),
@@ -10051,11 +10328,11 @@ async function walk(entry, prefix, out) {
10051
10328
  }
10052
10329
  function droppedFiles(data) {
10053
10330
  if (!data) return Promise.resolve([]);
10054
- const entries = Array.from(data.items ?? []).filter((item) => item.kind === "file").map((item) => item.webkitGetAsEntry?.() ?? null);
10055
- if (entries.length > 0 && entries.every((e) => e != null)) {
10331
+ const entries2 = Array.from(data.items ?? []).filter((item) => item.kind === "file").map((item) => item.webkitGetAsEntry?.() ?? null);
10332
+ if (entries2.length > 0 && entries2.every((e) => e != null)) {
10056
10333
  return (async () => {
10057
10334
  const out = [];
10058
- for (const entry of entries) await walk(entry, "", out);
10335
+ for (const entry of entries2) await walk(entry, "", out);
10059
10336
  return out;
10060
10337
  })();
10061
10338
  }
@@ -11480,6 +11757,8 @@ export {
11480
11757
  TRACKS as WIDGET_TRACKS,
11481
11758
  PRESETS as WIDGET_WIDTHS,
11482
11759
  WidgetBoard,
11760
+ XLSX_TYPE,
11761
+ XlsxError,
11483
11762
  abpConfig,
11484
11763
  abpListParams,
11485
11764
  abpListSource,
@@ -11520,6 +11799,7 @@ export {
11520
11799
  getPasskey,
11521
11800
  ghostCss,
11522
11801
  groupKey,
11802
+ guessSeparator,
11523
11803
  heavierFirst,
11524
11804
  hiddenPose,
11525
11805
  inSections,
@@ -11531,6 +11811,7 @@ export {
11531
11811
  pageCount,
11532
11812
  pageList,
11533
11813
  pagesShown,
11814
+ parseCsv,
11534
11815
  partsOf,
11535
11816
  passkeysSupported,
11536
11817
  pastedName,
@@ -11541,7 +11822,10 @@ export {
11541
11822
  progressOf,
11542
11823
  readAbpError,
11543
11824
  readEvents,
11825
+ readTable,
11826
+ readXlsx,
11544
11827
  refusal,
11828
+ remapCsv,
11545
11829
  renumber,
11546
11830
  requestStepUp,
11547
11831
  setStepUpHandler,
@@ -11550,6 +11834,7 @@ export {
11550
11834
  springs,
11551
11835
  staggerDelay,
11552
11836
  stepUpNeedOf,
11837
+ tableKind,
11553
11838
  targetOf,
11554
11839
  toStart,
11555
11840
  toaster,
@@ -11589,6 +11874,7 @@ export {
11589
11874
  useProductName,
11590
11875
  useSettledValue,
11591
11876
  useSlotSaves,
11592
- useTokenVar
11877
+ useTokenVar,
11878
+ writeCsv
11593
11879
  };
11594
11880
  //# sourceMappingURL=index.js.map