@eifi1/ui-kit 0.22.0 → 0.23.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/README.md +42 -25
- package/dist/chart.d.ts +11 -8
- package/dist/components/amount-input.d.ts +28 -8
- package/dist/components/amount-input.js +3 -1
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/autocomplete.d.ts +21 -0
- package/dist/components/autocomplete.js +128 -103
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/button-group.d.ts +11 -8
- package/dist/components/calculator.d.ts +11 -8
- package/dist/components/column-mapper.d.ts +182 -0
- package/dist/components/column-mapper.js +375 -0
- package/dist/components/column-mapper.js.map +1 -0
- package/dist/components/combobox-core.d.ts +39 -2
- package/dist/components/combobox-core.js +29 -6
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/combobox.d.ts +80 -2
- package/dist/components/combobox.js +448 -311
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/confirm-dialog.d.ts +11 -8
- package/dist/components/confirm-dialog.js +7 -8
- package/dist/components/confirm-dialog.js.map +1 -1
- package/dist/components/copy-button.d.ts +8 -5
- package/dist/components/country-select.d.ts +50 -7
- package/dist/components/country-select.js +65 -9
- package/dist/components/country-select.js.map +1 -1
- package/dist/components/danger-confirm.d.ts +11 -8
- package/dist/components/danger-confirm.js +13 -3
- package/dist/components/danger-confirm.js.map +1 -1
- package/dist/components/date-picker.d.ts +41 -0
- package/dist/components/date-picker.js +269 -8
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/entity-combobox.d.ts +35 -1
- package/dist/components/entity-combobox.js +148 -112
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/facing-pair.d.ts +11 -8
- package/dist/components/field-parts.d.ts +116 -6
- package/dist/components/field-parts.js +84 -0
- package/dist/components/field-parts.js.map +1 -1
- package/dist/components/field-strip.d.ts +105 -0
- package/dist/components/field-strip.js +46 -0
- package/dist/components/field-strip.js.map +1 -0
- package/dist/components/file-button.d.ts +11 -8
- package/dist/components/file-dropzone.d.ts +11 -8
- package/dist/components/form-actions.d.ts +10 -7
- package/dist/components/form-actions.js +8 -2
- package/dist/components/form-actions.js.map +1 -1
- package/dist/components/iban-input.d.ts +11 -8
- package/dist/components/icon-picker.d.ts +10 -1
- package/dist/components/icon-picker.js +12 -4
- package/dist/components/icon-picker.js.map +1 -1
- package/dist/components/language-select.d.ts +11 -8
- package/dist/components/money-field.d.ts +14 -8
- package/dist/components/money-field.js.map +1 -1
- package/dist/components/month-picker.js +2 -1
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/multi-entity-combobox.d.ts +26 -1
- package/dist/components/multi-entity-combobox.js +143 -102
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/number-field.d.ts +11 -8
- package/dist/components/number-input.d.ts +11 -8
- package/dist/components/numpad-sheet.d.ts +11 -8
- package/dist/components/phone-input.d.ts +11 -8
- package/dist/components/reauth-dialog.d.ts +2 -2
- package/dist/components/reauth-dialog.js +6 -8
- package/dist/components/reauth-dialog.js.map +1 -1
- package/dist/components/series-chart.d.ts +11 -8
- package/dist/components/settings-fields.d.ts +11 -8
- package/dist/components/share-card.d.ts +10 -7
- package/dist/components/swatch-picker.d.ts +17 -1
- package/dist/components/swatch-picker.js +10 -4
- package/dist/components/swatch-picker.js.map +1 -1
- package/dist/components/text-link.d.ts +10 -7
- package/dist/components/tile-radio.d.ts +20 -0
- package/dist/components/tile-radio.js +25 -8
- package/dist/components/tile-radio.js.map +1 -1
- package/dist/components/time-input.d.ts +11 -8
- package/dist/components/toggle-group.js +2 -2
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/trigger-aria.d.ts +3 -0
- package/dist/components/trigger-aria.js +3 -1
- package/dist/components/trigger-aria.js.map +1 -1
- package/dist/components/ui.d.ts +8 -5
- package/dist/components/ui.js +5 -11
- package/dist/components/ui.js.map +1 -1
- package/dist/feedback/feedback-attachment.d.ts +1 -1
- package/dist/feedback/feedback-attachment.js +156 -56
- package/dist/feedback/feedback-attachment.js.map +1 -1
- package/dist/feedback/feedback-dialog.d.ts +1 -1
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback/feedback-inbox.d.ts +3 -2
- package/dist/feedback/feedback-inbox.js.map +1 -1
- package/dist/feedback/feedback-thread.d.ts +68 -287
- package/dist/feedback/feedback-thread.js +8 -1
- package/dist/feedback/feedback-thread.js.map +1 -1
- package/dist/{kit-labels-R8mIAc9N.d.ts → feedback-BxeQVzwq.d.ts} +405 -22
- package/dist/{feedback-attachment-NhUm7Zga.d.ts → feedback-attachment-fGAzZPf0.d.ts} +112 -10
- package/dist/feedback.d.ts +66 -2
- package/dist/hooks/use-file-drop.d.ts +11 -8
- package/dist/i18n/defaults.d.ts +11 -8
- package/dist/i18n/defaults.js +3 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.d.ts +11 -8
- package/dist/i18n/german.js +36 -2
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +7 -4
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/languages.d.ts +11 -8
- package/dist/i18n/locales/de-CH.d.ts +11 -8
- package/dist/i18n/locales/en.d.ts +11 -8
- package/dist/i18n/locales/en.js +7 -0
- package/dist/i18n/locales/en.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +11 -8
- package/dist/i18n/locales/es.js +37 -2
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +11 -8
- package/dist/i18n/locales/fr.js +36 -2
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +11 -8
- package/dist/i18n/locales/hu.js +38 -2
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +11 -8
- package/dist/i18n/locales/it.js +37 -2
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +11 -8
- package/dist/i18n/locales/zh.js +34 -2
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.d.ts +11 -8
- package/dist/i18n/review.js +20 -1
- package/dist/i18n/review.js.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/column-mapping.d.ts +81 -0
- package/dist/lib/column-mapping.js +108 -0
- package/dist/lib/column-mapping.js.map +1 -0
- package/dist/lib/table-text.d.ts +109 -1
- package/dist/lib/table-text.js +122 -1
- package/dist/lib/table-text.js.map +1 -1
- package/dist/rhf/fields.d.ts +89 -11
- package/dist/rhf/fields.js +124 -0
- package/dist/rhf/fields.js.map +1 -1
- package/dist/rhf/form.d.ts +11 -8
- package/dist/rhf.d.ts +12 -9
- package/dist/rhf.js.map +1 -1
- package/dist/shell/app-shell.d.ts +10 -7
- package/dist/shell/top-bar-brand.d.ts +11 -8
- package/dist/shell/topbar-action-menu.d.ts +36 -3
- package/dist/shell/topbar-action-menu.js +74 -33
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell.d.ts +10 -7
- package/dist/table-text.d.ts +1 -1
- package/dist/wizard/stepper-nav.d.ts +41 -10
- package/dist/wizard/stepper-nav.js +4 -0
- package/dist/wizard/stepper-nav.js.map +1 -1
- package/dist/wizard.d.ts +11 -8
- package/package.json +1 -1
- package/src/components/amount-input.tsx +20 -1
- package/src/components/autocomplete.tsx +172 -111
- package/src/components/column-mapper.tsx +666 -0
- package/src/components/combobox-core.tsx +82 -9
- package/src/components/combobox.tsx +614 -332
- package/src/components/confirm-dialog.tsx +12 -8
- package/src/components/country-select.tsx +135 -22
- package/src/components/danger-confirm.tsx +91 -12
- package/src/components/date-picker.tsx +423 -10
- package/src/components/entity-combobox.tsx +217 -126
- package/src/components/field-parts.tsx +224 -5
- package/src/components/field-strip.tsx +149 -0
- package/src/components/form-actions.tsx +32 -4
- package/src/components/icon-picker.tsx +23 -4
- package/src/components/money-field.tsx +3 -0
- package/src/components/month-picker.tsx +2 -1
- package/src/components/multi-entity-combobox.tsx +207 -120
- package/src/components/reauth-dialog.tsx +17 -18
- package/src/components/swatch-picker.tsx +29 -5
- package/src/components/tile-radio.tsx +74 -13
- package/src/components/toggle-group.tsx +2 -2
- package/src/components/trigger-aria.ts +5 -0
- package/src/components/ui.tsx +7 -33
- package/src/feedback/feedback-attachment.tsx +308 -61
- package/src/feedback/feedback-dialog.tsx +7 -3
- package/src/feedback/feedback-inbox.tsx +3 -2
- package/src/feedback/feedback-thread.tsx +47 -4
- package/src/i18n/defaults.ts +2 -0
- package/src/i18n/german.ts +42 -0
- package/src/i18n/kit-labels.tsx +4 -0
- package/src/i18n/locales/en.ts +27 -5
- package/src/i18n/locales/es.ts +41 -0
- package/src/i18n/locales/fr.ts +42 -0
- package/src/i18n/locales/hu.ts +37 -0
- package/src/i18n/locales/it.ts +41 -0
- package/src/i18n/locales/zh.ts +32 -0
- package/src/i18n/review.ts +19 -0
- package/src/index.ts +18 -0
- package/src/lib/column-mapping.ts +234 -0
- package/src/lib/table-text.ts +271 -0
- package/src/rhf/fields.tsx +254 -0
- package/src/rhf.ts +2 -1
- package/src/shell/topbar-action-menu.tsx +134 -38
- package/src/wizard/stepper-nav.tsx +35 -1
- package/dist/components/field-anatomy.d.ts +0 -95
- package/dist/components/field-anatomy.js +0 -84
- package/dist/components/field-anatomy.js.map +0 -1
- package/src/components/field-anatomy.tsx +0 -190
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// @eifi1/ui-kit — shared design-system barrel.\n//\n// Domain-free UI + theme surface shared across apps (lead app: Keksdose). Consumers import\n// components/theme from \"@eifi1/ui-kit\" and the token stylesheet from \"@eifi1/ui-kit/tokens.css\".\n\n// ── lib ────────────────────────────────────────────────────────────────────\nexport * from \"./lib/calc\";\nexport { cn } from \"./lib/cn\";\nexport { logger, setStoreLog } from \"./lib/logger\";\n// Intl number / money / percent / date / relative-time formatting, and `useKitFormat()`\n// for the same bound to the provider's locale (kastlan's formatters.ts, English \"5m ago\").\nexport * from \"./lib/format\";\n// localStorage that never throws (Safari private mode, blocked site data).\nexport { readStored, writeStored } from \"./lib/safe-storage\";\n// Date helpers are also available via the \"@eifi1/ui-kit/dates\" subpath.\n\n// ── hooks ────────────────────────────────────────────────────────────────────\nexport { useMediaQuery } from \"./hooks/use-media-query\";\nexport { useBodyScrollLock } from \"./hooks/use-body-scroll-lock\";\nexport { useAnchoredRect } from \"./hooks/use-anchored-rect\";\nexport type { AnchorRect } from \"./hooks/use-anchored-rect\";\nexport { useAnchoredPanel, anchoredPanelPlacement, useVisualViewport } from \"./hooks/use-anchored-panel\";\nexport type {\n AnchoredPanel,\n AnchoredPanelOptions,\n ViewportBox,\n} from \"./hooks/use-anchored-panel\";\nexport { useEscapeKey, useOutsideClick } from \"./hooks/use-dismiss\";\n// Focus containment for an overlay, and a live region for a change that moves no focus.\n// Both were extracted from the two components that already did them correctly (Modal and\n// CommandPalette) so the rest of the kit stops being the exception.\nexport { useFocusTrap } from \"./hooks/use-focus-trap\";\nexport type { FocusTrapOptions } from \"./hooks/use-focus-trap\";\nexport { useAnnounce } from \"./hooks/use-announce\";\nexport type { UseAnnounceReturn, UseAnnounceOptions, AnnounceRegionProps } from \"./hooks/use-announce\";\nexport { useOverlayHistory } from \"./hooks/use-overlay-history\";\nexport { useCloseTransition, OVERLAY_EXIT_MS } from \"./hooks/use-close-transition\";\nexport { useRowSwipe } from \"./hooks/use-row-swipe\";\nexport type { SwipeStage, RowSwipeOptions, RowSwipeReturn } from \"./hooks/use-row-swipe\";\n// Any element as a file drop target, screened like FileButton (kastlan).\nexport { useFileDrop, dragHasFiles } from \"./hooks/use-file-drop\";\nexport type { UseFileDropOptions, UseFileDropReturn, FileDropProps } from \"./hooks/use-file-drop\";\n// kastlan's search boxes each carried a hand-rolled copy, two without the cleanup.\nexport { useDebounce, useDebouncedCallback } from \"./hooks/use-debounce\";\nexport type { DebouncedCallbackOptions, DebouncedFunction } from \"./hooks/use-debounce\";\n// One search param as state, the active tab in `?tab=`, and a dialog's open state in the\n// URL (Modal's `urlParam`) — kastlan's and keksdose's use-search-param-state, in the kit.\nexport { useSearchParamState, useTabParam, useDialogParam } from \"./hooks/use-search-param-state\";\nexport type { SearchParamStateOptions, DialogParam } from \"./hooks/use-search-param-state\";\n// Copy that reports whether it worked — keksdose's copy buttons said \"Copied\" when it had not.\nexport { useCopyToClipboard, copyToClipboard } from \"./hooks/use-copy-to-clipboard\";\nexport type { CopyState, UseCopyToClipboardOptions, UseCopyToClipboardReturn } from \"./hooks/use-copy-to-clipboard\";\n// Keyboard shortcuts (\"Mod+K\", \"Ctrl+Shift+F\") that leave typing in fields alone.\nexport { useHotkey, parseHotkey, matchesHotkey } from \"./hooks/use-hotkey\";\nexport type { Hotkey, ParsedHotkey, UseHotkeyOptions } from \"./hooks/use-hotkey\";\n// A protected file as an object URL, fetched with the app's own auth (kastlan's AuthedImage).\nexport { useAuthedSrc } from \"./hooks/use-authed-src\";\nexport type { AuthedFetcher, AuthedSrcStatus, UseAuthedSrcOptions, UseAuthedSrcResult } from \"./hooks/use-authed-src\";\n\n// ── theme / palettes ─────────────────────────────────────────────────────────\nexport * from \"./theme/chart-palette\";\n// Colour maths (sRGB ↔ OKLCH, WCAG contrast, CVD simulation) and the palette deriver\n// that builds a whole, contrast-solved palette from one brand colour plus any colours\n// pinned by hand. `auditPalette` / `auditChartRamp` measure a palette rather than\n// trusting a comment about it.\nexport * from \"./theme/color\";\nexport * from \"./theme/palette-derive\";\nexport * from \"./theme/palette-presets\";\nexport * from \"./theme/theme-store\";\nexport * from \"./theme/palette-store\";\n\n// ── components ───────────────────────────────────────────────────────────────\nexport * from \"./components/ui\";\n// The label-ABOVE field group (label, hint, error, required), inside wizards or out.\nexport * from \"./components/field\";\nexport * from \"./components/search-field\";\nexport * from \"./components/dropdown\";\nexport * from \"./components/popover\";\nexport { SwipeableRow } from \"./components/swipeable-row\";\nexport type { SwipeAction, SwipeableRowProps } from \"./components/swipeable-row\";\nexport * from \"./components/calculator\";\nexport * from \"./components/numpad-sheet\";\nexport * from \"./components/number-input\";\nexport * from \"./components/currency-select\";\nexport * from \"./components/amount-input\";\nexport * from \"./components/money-field\";\nexport * from \"./components/combobox\";\nexport * from \"./components/picker-sheet\";\nexport * from \"./components/entity-combobox\";\nexport * from \"./components/multi-entity-combobox\";\nexport * from \"./components/multi-select\";\nexport * from \"./components/tooltip\";\nexport * from \"./components/user-avatar\";\nexport * from \"./components/settings-fields\";\n// Sync state for a database-backed field: the engine (`useFieldSync`) and the\n// affordance (`FieldSyncIndicator`), kept separate because the state is useful\n// without the dot — a form can gate its submit on any field being `pending`.\nexport * from \"./components/field-sync\";\nexport * from \"./components/month-picker\";\nexport * from \"./components/checkbox\";\nexport * from \"./components/switch\";\nexport * from \"./components/slider\";\nexport * from \"./components/time-input\";\nexport * from \"./components/number-field\";\nexport * from \"./components/sparkline\";\nexport * from \"./components/stat-tile\";\nexport * from \"./components/signature-pad\";\nexport * from \"./components/password-strength\";\nexport * from \"./components/page-contents\";\nexport * from \"./components/disclosure\";\nexport * from \"./components/dialog-frame\";\n// Named, not `*`: danger-confirm also holds the password field and pending hook that\n// ReauthDialog shares with it, which are kit-internal.\nexport {\n DangerConfirm,\n DEFAULT_DANGER_CONFIRM_LABELS,\n typedMatches,\n // 0.22.0: the typed-confirmation field on its own (keksdose K7) and the current-password\n // field kastlan wants for sign-in and re-authentication (kastlan 1).\n TypedConfirmField,\n CurrentPasswordInput,\n} from \"./components/danger-confirm\";\nexport type {\n DangerConfirmLabels,\n DangerConfirmProps,\n TypedMatch,\n DangerConsequence,\n TypedConfirmFieldProps,\n TypedConfirmFieldLabels,\n CurrentPasswordInputProps,\n CurrentPasswordInputLabels,\n} from \"./components/danger-confirm\";\n// 0.18: re-authentication before a sensitive action (Kurvenschmiede 4).\nexport { ReauthDialog, DEFAULT_REAUTH_DIALOG_LABELS } from \"./components/reauth-dialog\";\nexport type { ReauthDialogProps, ReauthDialogLabels } from \"./components/reauth-dialog\";\n// `useConfirm()` — the promise-based replacement for `window.confirm`, one host per app.\nexport * from \"./components/confirm-dialog\";\n// A non-modal corner panel and its round trigger (keksdose's assistant launcher).\nexport * from \"./components/floating-panel\";\n// The count / clear / actions bar a selection brings up (keksdose's three copies).\nexport * from \"./components/bulk-action-bar\";\nexport * from \"./components/swatch-picker\";\nexport * from \"./components/icon-picker\";\nexport * from \"./components/choice-card\";\nexport * from \"./components/autocomplete\";\nexport * from \"./components/measured-grid\";\nexport { useWindowedRows } from \"./hooks/use-windowed-rows\";\nexport type { WindowedRows } from \"./hooks/use-windowed-rows\";\n// Named, not `export *`: file-button.tsx also holds the screening helpers the\n// dropzone shares, which are internal.\nexport { FileButton, useFilePicker, matchesAccept, DEFAULT_FILE_PICKER_LABELS } from \"./components/file-button\";\nexport type {\n FileButtonProps,\n UseFilePickerOptions,\n UseFilePickerReturn,\n FilePickerLabels,\n FileRejection,\n FileRejectionReason,\n FileScreenOptions,\n} from \"./components/file-button\";\nexport * from \"./components/treemap\";\nexport * from \"./components/series-chart\";\nexport * from \"./components/chart-zoom\";\nexport * from \"./components/toggle-legend\";\nexport * from \"./components/facing-pair\";\nexport * from \"./components/series-chart-labels\";\nexport * from \"./components/pie-chart\";\nexport * from \"./components/pie-chart-labels\";\nexport * from \"./components/account-settings\";\n// 0.12.0: the fourth account section, and the QR code TwoFactorSetting draws its\n// otpauth URI with (encoder in lib/qr-encode.ts — no dependency, see there).\nexport * from \"./components/passkeys-setting\";\nexport * from \"./components/qr-code\";\nexport { encodeQr } from \"./lib/qr-encode\";\nexport type { QrEncodeOptions, QrErrorCorrection, QrMatrix } from \"./lib/qr-encode\";\nexport * from \"./components/alert-banner\";\nexport * from \"./components/toggle-group\";\n// A wrapping set of links/buttons marked `aria-current` — Tabs-like looks, not tabs.\nexport * from \"./components/nav-pills\";\n// A pill carrying one VALUE — inert, a link, or a toggle, depending on which prop it is\n// given — and the list field built from it. Distinct from Button on purpose: a row of\n// buttons reads as \"choose an action\", a row of chips as \"here are the things\".\nexport * from \"./components/chip\";\nexport * from \"./components/wizard-stepper\";\nexport * from \"./components/hover-menu\";\nexport * from \"./components/modal\";\nexport * from \"./components/full-bleed-dialog\";\nexport * from \"./components/grouped-picker\";\nexport * from \"./components/file-dropzone\";\nexport * from \"./components/mini-calendar\";\nexport * from \"./components/calendar-heatmap\";\nexport * from \"./components/date-picker\";\nexport * from \"./components/tree-view\";\nexport * from \"./components/chart\";\n// 0.8.0 layout and feedback primitives the apps hand-rolled or took from shadcn/Radix.\nexport * from \"./components/description-list\";\n// The Save / Cancel row forms and dialogs end in, and the editable line-item repeater\n// (journal lines, lease components, invoice positions). 0.12.0.\nexport * from \"./components/form-actions\";\n// 0.18: lock every opted-in commit under one provider, the reason in its tooltip\n// (Kurvenschmiede 2). `useCommitReason` stays internal.\nexport { WriteLockProvider, useWriteLock, DEFAULT_WRITE_LOCK_LABELS } from \"./components/write-lock\";\nexport type { WriteLock, WriteLockLabels, WriteLockProviderProps } from \"./components/write-lock\";\n// 0.18: the parts both apps' admin rosters repeat (Kurvenschmiede 6).\nexport { RoleChip, AccountStateChip, DateMark, dateColumn, DEFAULT_ACCOUNT_STATE_LABELS, ACCOUNT_STATE_TONES } from \"./components/account-chips\";\nexport type { RoleChipProps, RoleDefinition, RoleVocabulary, AccountState, AccountStateLabels, AccountStateChipProps, DateMarkProps, DateColumnOptions } from \"./components/account-chips\";\n// 0.18: the cold-start notice keksdose built (#199), for every app: a framework-free\n// watchdog over the app's requests and the corner notice that explains the wait.\nexport { createServerWake, serverWake, watchReadsAnd, attachServerWake, wrapFetch } from \"./lib/server-wake\";\nexport type { ServerWakeStage, ServerWakeFilter, ServerWakeOptions, ServerWakeRequest, ServerWakeWatcher, ServerWakeAxiosConfig, AxiosLikeInstance } from \"./lib/server-wake\";\nexport { ServerWakeNotice, useServerWakeStage, DEFAULT_SERVER_WAKE_LABELS } from \"./components/server-wake\";\nexport type { ServerWakeLabels, ServerWakeNoticeProps } from \"./components/server-wake\";\n// 0.18: sharing — grantees, roles, pending grants, candidates (Kurvenschmiede 1).\nexport { ShareCard, ShareDialog, SharePanel, DEFAULT_SHARE_CARD_LABELS } from \"./components/share-card\";\nexport type { ShareCardProps, ShareDialogProps, SharePanelProps, ShareCardLabels, ShareRole, ShareGrantee, SharePendingGrant, ShareCandidate, ShareAddRequest } from \"./components/share-card\";\nexport * from \"./components/line-items\";\nexport * from \"./components/progress-bar\";\n// Named: skeleton.tsx also holds SKELETON_CLASS, the look StatTile shares — internal.\nexport { Skeleton } from \"./components/skeleton\";\nexport type { SkeletonProps, SkeletonShape } from \"./components/skeleton\";\n// 0.12.0: a centred spinner with words, signed figures and deltas, a render-error fallback.\nexport * from \"./components/loading-state\";\nexport * from \"./components/signed-amount\";\nexport * from \"./components/error-boundary\";\nexport * from \"./components/copy-button\";\nexport { AuthedImage, DEFAULT_AUTHED_IMAGE_LABELS } from \"./components/authed-image\";\nexport type { AuthedImageProps, AuthedImageLabels } from \"./components/authed-image\";\nexport * from \"./components/image-grid\";\nexport * from \"./components/lightbox\";\nexport * from \"./components/button-group\";\nexport * from \"./components/table\";\nexport * from \"./components/separator\";\n// Named: scroll-area.tsx also holds the overflow hook and scrollbar class Table shares.\nexport { ScrollArea } from \"./components/scroll-area\";\nexport type { ScrollAreaProps } from \"./components/scroll-area\";\n// 0.10.0 rows, menu rows, text primitives and page chrome the apps drew by hand.\nexport * from \"./components/list\";\nexport * from \"./components/menu-item\";\nexport * from \"./components/text\";\nexport * from \"./components/status-dot\";\nexport * from \"./components/page-header\";\nexport * from \"./components/breadcrumbs\";\n// The one inline link (kastlan's EntityLink / CellLink / legal and source links), through\n// `<UiKitProvider linkComponent>`. Named: the file also holds the kit's internal link picker.\nexport { TextLink } from \"./components/text-link\";\nexport type {\n TextLinkProps,\n TextLinkRenderProps,\n TextLinkTone,\n TextLinkUnderline,\n TextLinkCurrent,\n} from \"./components/text-link\";\n// The toast layer over sonner (an OPTIONAL peer, loaded lazily): `toast` mirrors sonner's\n// API so apps migrate by swapping the import; `<Toaster>` carries the placement, theme,\n// tones and z-index both apps had wired by hand.\nexport { toast, Toaster, DEFAULT_TOAST_LABELS, TOAST_ACTION_DURATION } from \"./components/toast\";\nexport type {\n ToastId,\n ToastAction,\n ToastOptions,\n ToastPromiseOptions,\n ToastUndoOptions,\n ToastRedoOptions,\n ToastLabels,\n ToastPosition,\n ToastSwipeDirection,\n ToasterOffset,\n ToasterProps,\n} from \"./components/toast\";\n\n// ── data-table suite ─────────────────────────────────────────────────────────\nexport * from \"./components/data-table-labels\";\nexport * from \"./components/data-table-sort\";\nexport * from \"./components/data-table-filters\";\nexport * from \"./components/data-table-pagination\";\nexport { FilterPopover } from \"./components/data-table-filter-popover\";\n// data-table re-exports SortState internally; export the rest explicitly to\n// avoid a duplicate SortState star-export (it comes from data-table-sort).\nexport { DataTable, DEFAULT_DATA_TABLE_SORT_LABELS } from \"./components/data-table\";\nexport type {\n DataTableSortLabels,\n DataTableColumn,\n DataTableCellProps,\n DataTableHeadProps,\n DataTableProps,\n ServerPagination,\n FilterState,\n MobileSwipeActions,\n DataTableDensity,\n DataTableChrome,\n DataTableRowAction,\n} from \"./components/data-table\";\n// 0.12.0: the yes/no cell, and a server table's state held by its owner, URL-synced.\nexport * from \"./components/data-table-cells\";\nexport { useTableUrlState, readTableUrlState } from \"./components/use-table-state\";\nexport type {\n TableUrlState,\n TableUrlSync,\n TableUrlStateProps,\n UseTableUrlStateOptions,\n UseTableUrlStateReturn,\n} from \"./components/use-table-state\";\n\n// ── shell (composable app chrome) ────────────────────────────────────────────\nexport * from \"./shell/topbar-controls\";\nexport * from \"./shell/top-bar\";\nexport * from \"./shell/app-shell\";\nexport * from \"./shell/option-switcher-menu\";\nexport * from \"./shell/role-switcher\";\nexport * from \"./shell/topbar-action-menu\";\nexport * from \"./shell/top-bar-brand\";\nexport * from \"./shell/auth-layout\";\n\n// ── feedback ─────────────────────────────────────────────────────────────────\n// The form somebody files a report with, and the parts an inbox is built from:\n// the status vocabulary both apps share value for value, the policy about what a\n// row may move to from where it stands, and the look of a status control, a\n// category badge and an opened report. The app still wires its own API, columns\n// and strings — see the note at the top of `feedback-inbox.tsx` for what is\n// deliberately left to it.\nexport * from \"./feedback/feedback-attachment\";\nexport * from \"./feedback/feedback-dialog\";\nexport * from \"./feedback/feedback-inbox\";\nexport * from \"./feedback/feedback-thread\";\n\n// ── multi-step wizard ────────────────────────────────────────────────────────\n// The engine (step machine, validators, collected data), the chrome around it\n// (indicator + nav bar + cancel confirm) and the review step it ends on.\n// `components/wizard-stepper` next door is a different, much smaller thing: a bare\n// step indicator for a two-step import flow, with no engine.\n//\n// Two modules were removed here rather than kept as stock. `wizard-field` held a\n// `WizardField`/`WizardSelectField` pair that had never been rendered in any app —\n// a field group nothing was built from, which this comment used to advertise. And\n// `use-rhf-wizard-step` was the only thing in the package that touched\n// react-hook-form, for a hook neither consumer called: keeping it meant an optional\n// peer, a dev dependency and a type import in every consumer's typecheck, bought\n// for nobody. A design system may carry stock; untested stock nothing has ever\n// rendered is not stock, it is a liability with an export.\nexport * from \"./wizard/types\";\nexport * from \"./wizard/use-wizard\";\nexport * from \"./wizard/wizard-context\";\nexport * from \"./wizard/validation\";\nexport * from \"./wizard/wizard-step\";\nexport * from \"./wizard/wizard-summary\";\nexport * from \"./wizard/stepper-nav\";\n\n// ── guided tours ─────────────────────────────────────────────────────────────\nexport * from \"./tour/tour\";\n\n// ── command palette / global search ──────────────────────────────────────────\nexport * from \"./search/command-palette\";\nexport * from \"./search/search-index\";\nexport * from \"./search/global-search\";\n\n// ── i18n: one label tree, one optional provider ──────────────────────────────\n// `UiKitLabels` names every string the kit renders; `<UiKitProvider labels locale>`\n// hands a translation to every component below it. Precedence: a component's own\n// prop > the provider > the English default. See src/i18n/kit-labels.tsx.\nexport * from \"./i18n/kit-labels\";\nexport * from \"./i18n/defaults\";\n// The kit's words as `key → text` rows for an app's translation review (keksdose).\nexport { kitLabelStrings } from \"./i18n/review\";\n// The seven languages, how an app resolves one, and the kit catalogue loader for it.\nexport * from \"./i18n/languages\";\n// CLDR plural categories for an app's i18next catalogue, filled from `_other`.\nexport { withAllPlurals } from \"./i18n/plurals\";\n// Translation review (0.19): one contract for kastlan's and keksdose's review pages —\n// the pure rows/status/placeholder logic and the presentational page parts.\nexport {\n REVIEW_STATUSES,\n fromApiReview,\n toApiWrite,\n flattenStrings,\n keyNamespace,\n placeholderTokens,\n placeholderMismatch,\n reviewStatus,\n keyInArea,\n keyInAreas,\n translationRows,\n summariseRows,\n DEFAULT_TRANSLATION_REVIEW_FILTER,\n filterTranslationRows,\n reviewWrite,\n mergeReviews,\n dropReviews,\n translationCorrections,\n} from \"./lib/translation-review\";\nexport type {\n TranslationVerdict,\n TranslationReview,\n TranslationReviewWrite,\n TranslationReviewKey,\n ReviewStatus,\n TranslationRow,\n ApiTranslationReview,\n ApiTranslationReviewWrite,\n TranslationRowsInput,\n TranslationSummary,\n TranslationReviewFilter,\n TranslationCorrection,\n} from \"./lib/translation-review\";\nexport {\n TranslationReviewPanel,\n TranslationReviewEditor,\n ReviewStatusChip,\n TranslationProgress,\n TranslationLocaleTabs,\n TranslationExportButton,\n REVIEW_STATUS_TONES,\n DEFAULT_TRANSLATION_REVIEW_LABELS,\n} from \"./components/translation-review\";\nexport type {\n TranslationReviewPanelProps,\n TranslationReviewEditorProps,\n ReviewStatusChipProps,\n TranslationProgressProps,\n TranslationLocaleTab,\n TranslationLocaleTabsProps,\n TranslationExportButtonProps,\n TranslationReviewLabels,\n} from \"./components/translation-review\";\n// The legal pages' shell (0.19, H10): Imprint, Privacy Policy, Terms in every app.\nexport { LegalLayout, LegalSection, LegalLinks, DEFAULT_LEGAL_LABELS } from \"./components/legal\";\nexport type { LegalLabels, LegalLink, LegalLinksProps, LegalSectionProps, LegalLayoutProps } from \"./components/legal\";\n\n// ── 0.22.0: the inputs round (kastlan's, keksdose's and Kurvenschmiede's audits) ──\nexport * from \"./components/checkbox-group\";\nexport * from \"./components/one-time-code-input\";\nexport * from \"./components/language-select\";\nexport * from \"./components/tile-radio\";\nexport * from \"./components/inline-edit-field\";\nexport * from \"./components/sign-chip\";\nexport * from \"./components/country-select\";\nexport { COUNTRY_CODES, countryName } from \"./lib/countries\";\nexport * from \"./components/iban-input\";\nexport {\n IBAN_LENGTHS,\n compactIban,\n formatIban,\n ibanCheckDigits,\n ibanProblem,\n isValidIban,\n isQrIban,\n} from \"./lib/iban\";\nexport type { IbanKind, IbanProblem } from \"./lib/iban\";\nexport { formatIsin, isinCheckDigit, isValidIsin } from \"./lib/isin\";\nexport * from \"./components/phone-input\";\nexport {\n PHONE_DIAL_CODES,\n PHONE_COUNTRIES,\n parsePhone,\n formatNationalPhone,\n formatPhone,\n isE164,\n} from \"./lib/phone\";\nexport type { PhoneCountryCode, PhoneCountry, ParsedPhone } from \"./lib/phone\";\n"],"mappings":";AAMA,cAAc;AACd,SAAS,UAAU;AACnB,SAAS,QAAQ,mBAAmB;AAGpC,cAAc;AAEd,SAAS,YAAY,mBAAmB;AAIxC,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAClC,SAAS,uBAAuB;AAEhC,SAAS,kBAAkB,wBAAwB,yBAAyB;AAM5E,SAAS,cAAc,uBAAuB;AAI9C,SAAS,oBAAoB;AAE7B,SAAS,mBAAmB;AAE5B,SAAS,yBAAyB;AAClC,SAAS,oBAAoB,uBAAuB;AACpD,SAAS,mBAAmB;AAG5B,SAAS,aAAa,oBAAoB;AAG1C,SAAS,aAAa,4BAA4B;AAIlD,SAAS,qBAAqB,aAAa,sBAAsB;AAGjE,SAAS,oBAAoB,uBAAuB;AAGpD,SAAS,WAAW,aAAa,qBAAqB;AAGtD,SAAS,oBAAoB;AAI7B,cAAc;AAKd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,oBAAoB;AAE7B,cAAc;AACd,cAAc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mBAAmB;AACxD,cAAc;AACd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// @eifi1/ui-kit — shared design-system barrel.\n//\n// Domain-free UI + theme surface shared across apps (lead app: Keksdose). Consumers import\n// components/theme from \"@eifi1/ui-kit\" and the token stylesheet from \"@eifi1/ui-kit/tokens.css\".\n\n// ── lib ────────────────────────────────────────────────────────────────────\nexport * from \"./lib/calc\";\nexport { cn } from \"./lib/cn\";\nexport { logger, setStoreLog } from \"./lib/logger\";\n// Intl number / money / percent / date / relative-time formatting, and `useKitFormat()`\n// for the same bound to the provider's locale (kastlan's formatters.ts, English \"5m ago\").\nexport * from \"./lib/format\";\n// localStorage that never throws (Safari private mode, blocked site data).\nexport { readStored, writeStored } from \"./lib/safe-storage\";\n// Date helpers are also available via the \"@eifi1/ui-kit/dates\" subpath.\n\n// ── hooks ────────────────────────────────────────────────────────────────────\nexport { useMediaQuery } from \"./hooks/use-media-query\";\nexport { useBodyScrollLock } from \"./hooks/use-body-scroll-lock\";\nexport { useAnchoredRect } from \"./hooks/use-anchored-rect\";\nexport type { AnchorRect } from \"./hooks/use-anchored-rect\";\nexport { useAnchoredPanel, anchoredPanelPlacement, useVisualViewport } from \"./hooks/use-anchored-panel\";\nexport type {\n AnchoredPanel,\n AnchoredPanelOptions,\n ViewportBox,\n} from \"./hooks/use-anchored-panel\";\nexport { useEscapeKey, useOutsideClick } from \"./hooks/use-dismiss\";\n// Focus containment for an overlay, and a live region for a change that moves no focus.\n// Both were extracted from the two components that already did them correctly (Modal and\n// CommandPalette) so the rest of the kit stops being the exception.\nexport { useFocusTrap } from \"./hooks/use-focus-trap\";\nexport type { FocusTrapOptions } from \"./hooks/use-focus-trap\";\nexport { useAnnounce } from \"./hooks/use-announce\";\nexport type { UseAnnounceReturn, UseAnnounceOptions, AnnounceRegionProps } from \"./hooks/use-announce\";\nexport { useOverlayHistory } from \"./hooks/use-overlay-history\";\nexport { useCloseTransition, OVERLAY_EXIT_MS } from \"./hooks/use-close-transition\";\nexport { useRowSwipe } from \"./hooks/use-row-swipe\";\nexport type { SwipeStage, RowSwipeOptions, RowSwipeReturn } from \"./hooks/use-row-swipe\";\n// Any element as a file drop target, screened like FileButton (kastlan).\nexport { useFileDrop, dragHasFiles } from \"./hooks/use-file-drop\";\nexport type { UseFileDropOptions, UseFileDropReturn, FileDropProps } from \"./hooks/use-file-drop\";\n// kastlan's search boxes each carried a hand-rolled copy, two without the cleanup.\nexport { useDebounce, useDebouncedCallback } from \"./hooks/use-debounce\";\nexport type { DebouncedCallbackOptions, DebouncedFunction } from \"./hooks/use-debounce\";\n// One search param as state, the active tab in `?tab=`, and a dialog's open state in the\n// URL (Modal's `urlParam`) — kastlan's and keksdose's use-search-param-state, in the kit.\nexport { useSearchParamState, useTabParam, useDialogParam } from \"./hooks/use-search-param-state\";\nexport type { SearchParamStateOptions, DialogParam } from \"./hooks/use-search-param-state\";\n// Copy that reports whether it worked — keksdose's copy buttons said \"Copied\" when it had not.\nexport { useCopyToClipboard, copyToClipboard } from \"./hooks/use-copy-to-clipboard\";\nexport type { CopyState, UseCopyToClipboardOptions, UseCopyToClipboardReturn } from \"./hooks/use-copy-to-clipboard\";\n// Keyboard shortcuts (\"Mod+K\", \"Ctrl+Shift+F\") that leave typing in fields alone.\nexport { useHotkey, parseHotkey, matchesHotkey } from \"./hooks/use-hotkey\";\nexport type { Hotkey, ParsedHotkey, UseHotkeyOptions } from \"./hooks/use-hotkey\";\n// A protected file as an object URL, fetched with the app's own auth (kastlan's AuthedImage).\nexport { useAuthedSrc } from \"./hooks/use-authed-src\";\nexport type { AuthedFetcher, AuthedSrcStatus, UseAuthedSrcOptions, UseAuthedSrcResult } from \"./hooks/use-authed-src\";\n\n// ── theme / palettes ─────────────────────────────────────────────────────────\nexport * from \"./theme/chart-palette\";\n// Colour maths (sRGB ↔ OKLCH, WCAG contrast, CVD simulation) and the palette deriver\n// that builds a whole, contrast-solved palette from one brand colour plus any colours\n// pinned by hand. `auditPalette` / `auditChartRamp` measure a palette rather than\n// trusting a comment about it.\nexport * from \"./theme/color\";\nexport * from \"./theme/palette-derive\";\nexport * from \"./theme/palette-presets\";\nexport * from \"./theme/theme-store\";\nexport * from \"./theme/palette-store\";\n\n// ── components ───────────────────────────────────────────────────────────────\nexport * from \"./components/ui\";\n// The label-ABOVE field group (label, hint, error, required), inside wizards or out.\nexport * from \"./components/field\";\nexport * from \"./components/search-field\";\nexport * from \"./components/dropdown\";\nexport * from \"./components/popover\";\nexport { SwipeableRow } from \"./components/swipeable-row\";\nexport type { SwipeAction, SwipeableRowProps } from \"./components/swipeable-row\";\nexport * from \"./components/calculator\";\nexport * from \"./components/numpad-sheet\";\nexport * from \"./components/number-input\";\nexport * from \"./components/currency-select\";\nexport * from \"./components/amount-input\";\nexport * from \"./components/money-field\";\nexport * from \"./components/combobox\";\nexport * from \"./components/picker-sheet\";\nexport * from \"./components/entity-combobox\";\nexport * from \"./components/multi-entity-combobox\";\nexport * from \"./components/multi-select\";\nexport * from \"./components/tooltip\";\nexport * from \"./components/user-avatar\";\nexport * from \"./components/settings-fields\";\n// Sync state for a database-backed field: the engine (`useFieldSync`) and the\n// affordance (`FieldSyncIndicator`), kept separate because the state is useful\n// without the dot — a form can gate its submit on any field being `pending`.\nexport * from \"./components/field-sync\";\nexport * from \"./components/month-picker\";\nexport * from \"./components/checkbox\";\nexport * from \"./components/switch\";\nexport * from \"./components/slider\";\nexport * from \"./components/time-input\";\nexport * from \"./components/number-field\";\nexport * from \"./components/sparkline\";\nexport * from \"./components/stat-tile\";\nexport * from \"./components/signature-pad\";\nexport * from \"./components/password-strength\";\nexport * from \"./components/page-contents\";\nexport * from \"./components/disclosure\";\nexport * from \"./components/dialog-frame\";\n// Named, not `*`: danger-confirm also holds the password field and pending hook that\n// ReauthDialog shares with it, which are kit-internal.\nexport {\n DangerConfirm,\n DEFAULT_DANGER_CONFIRM_LABELS,\n typedMatches,\n // 0.22.0: the typed-confirmation field on its own (keksdose K7) and the current-password\n // field kastlan wants for sign-in and re-authentication (kastlan 1).\n TypedConfirmField,\n CurrentPasswordInput,\n} from \"./components/danger-confirm\";\nexport type {\n DangerConfirmLabels,\n DangerConfirmProps,\n TypedMatch,\n DangerConsequence,\n TypedConfirmFieldProps,\n TypedConfirmFieldLabels,\n CurrentPasswordInputProps,\n CurrentPasswordInputLabels,\n // 0.23.0: onConfirm's second argument — the guards' values (keksdose G4b).\n DangerConfirmValues,\n} from \"./components/danger-confirm\";\n// 0.18: re-authentication before a sensitive action (Kurvenschmiede 4).\nexport { ReauthDialog, DEFAULT_REAUTH_DIALOG_LABELS } from \"./components/reauth-dialog\";\nexport type { ReauthDialogProps, ReauthDialogLabels } from \"./components/reauth-dialog\";\n// `useConfirm()` — the promise-based replacement for `window.confirm`, one host per app.\nexport * from \"./components/confirm-dialog\";\n// A non-modal corner panel and its round trigger (keksdose's assistant launcher).\nexport * from \"./components/floating-panel\";\n// The count / clear / actions bar a selection brings up (keksdose's three copies).\nexport * from \"./components/bulk-action-bar\";\nexport * from \"./components/swatch-picker\";\nexport * from \"./components/icon-picker\";\nexport * from \"./components/choice-card\";\nexport * from \"./components/autocomplete\";\nexport * from \"./components/measured-grid\";\nexport { useWindowedRows } from \"./hooks/use-windowed-rows\";\nexport type { WindowedRows } from \"./hooks/use-windowed-rows\";\n// Named, not `export *`: file-button.tsx also holds the screening helpers the\n// dropzone shares, which are internal.\nexport { FileButton, useFilePicker, matchesAccept, DEFAULT_FILE_PICKER_LABELS } from \"./components/file-button\";\nexport type {\n FileButtonProps,\n UseFilePickerOptions,\n UseFilePickerReturn,\n FilePickerLabels,\n FileRejection,\n FileRejectionReason,\n FileScreenOptions,\n} from \"./components/file-button\";\nexport * from \"./components/treemap\";\nexport * from \"./components/series-chart\";\nexport * from \"./components/chart-zoom\";\nexport * from \"./components/toggle-legend\";\nexport * from \"./components/facing-pair\";\nexport * from \"./components/series-chart-labels\";\nexport * from \"./components/pie-chart\";\nexport * from \"./components/pie-chart-labels\";\nexport * from \"./components/account-settings\";\n// 0.12.0: the fourth account section, and the QR code TwoFactorSetting draws its\n// otpauth URI with (encoder in lib/qr-encode.ts — no dependency, see there).\nexport * from \"./components/passkeys-setting\";\nexport * from \"./components/qr-code\";\nexport { encodeQr } from \"./lib/qr-encode\";\nexport type { QrEncodeOptions, QrErrorCorrection, QrMatrix } from \"./lib/qr-encode\";\nexport * from \"./components/alert-banner\";\nexport * from \"./components/toggle-group\";\n// A wrapping set of links/buttons marked `aria-current` — Tabs-like looks, not tabs.\nexport * from \"./components/nav-pills\";\n// A pill carrying one VALUE — inert, a link, or a toggle, depending on which prop it is\n// given — and the list field built from it. Distinct from Button on purpose: a row of\n// buttons reads as \"choose an action\", a row of chips as \"here are the things\".\nexport * from \"./components/chip\";\nexport * from \"./components/wizard-stepper\";\nexport * from \"./components/hover-menu\";\nexport * from \"./components/modal\";\nexport * from \"./components/full-bleed-dialog\";\nexport * from \"./components/grouped-picker\";\nexport * from \"./components/file-dropzone\";\nexport * from \"./components/mini-calendar\";\nexport * from \"./components/calendar-heatmap\";\nexport * from \"./components/date-picker\";\nexport * from \"./components/tree-view\";\nexport * from \"./components/chart\";\n// 0.8.0 layout and feedback primitives the apps hand-rolled or took from shadcn/Radix.\nexport * from \"./components/description-list\";\n// The Save / Cancel row forms and dialogs end in, and the editable line-item repeater\n// (journal lines, lease components, invoice positions). 0.12.0.\nexport * from \"./components/form-actions\";\n// 0.18: lock every opted-in commit under one provider, the reason in its tooltip\n// (Kurvenschmiede 2). `useCommitReason` stays internal.\nexport { WriteLockProvider, useWriteLock, DEFAULT_WRITE_LOCK_LABELS } from \"./components/write-lock\";\nexport type { WriteLock, WriteLockLabels, WriteLockProviderProps } from \"./components/write-lock\";\n// 0.18: the parts both apps' admin rosters repeat (Kurvenschmiede 6).\nexport { RoleChip, AccountStateChip, DateMark, dateColumn, DEFAULT_ACCOUNT_STATE_LABELS, ACCOUNT_STATE_TONES } from \"./components/account-chips\";\nexport type { RoleChipProps, RoleDefinition, RoleVocabulary, AccountState, AccountStateLabels, AccountStateChipProps, DateMarkProps, DateColumnOptions } from \"./components/account-chips\";\n// 0.18: the cold-start notice keksdose built (#199), for every app: a framework-free\n// watchdog over the app's requests and the corner notice that explains the wait.\nexport { createServerWake, serverWake, watchReadsAnd, attachServerWake, wrapFetch } from \"./lib/server-wake\";\nexport type { ServerWakeStage, ServerWakeFilter, ServerWakeOptions, ServerWakeRequest, ServerWakeWatcher, ServerWakeAxiosConfig, AxiosLikeInstance } from \"./lib/server-wake\";\nexport { ServerWakeNotice, useServerWakeStage, DEFAULT_SERVER_WAKE_LABELS } from \"./components/server-wake\";\nexport type { ServerWakeLabels, ServerWakeNoticeProps } from \"./components/server-wake\";\n// 0.18: sharing — grantees, roles, pending grants, candidates (Kurvenschmiede 1).\nexport { ShareCard, ShareDialog, SharePanel, DEFAULT_SHARE_CARD_LABELS } from \"./components/share-card\";\nexport type { ShareCardProps, ShareDialogProps, SharePanelProps, ShareCardLabels, ShareRole, ShareGrantee, SharePendingGrant, ShareCandidate, ShareAddRequest } from \"./components/share-card\";\nexport * from \"./components/line-items\";\nexport * from \"./components/progress-bar\";\n// Named: skeleton.tsx also holds SKELETON_CLASS, the look StatTile shares — internal.\nexport { Skeleton } from \"./components/skeleton\";\nexport type { SkeletonProps, SkeletonShape } from \"./components/skeleton\";\n// 0.12.0: a centred spinner with words, signed figures and deltas, a render-error fallback.\nexport * from \"./components/loading-state\";\nexport * from \"./components/signed-amount\";\nexport * from \"./components/error-boundary\";\nexport * from \"./components/copy-button\";\nexport { AuthedImage, DEFAULT_AUTHED_IMAGE_LABELS } from \"./components/authed-image\";\nexport type { AuthedImageProps, AuthedImageLabels } from \"./components/authed-image\";\nexport * from \"./components/image-grid\";\nexport * from \"./components/lightbox\";\nexport * from \"./components/button-group\";\nexport * from \"./components/table\";\nexport * from \"./components/separator\";\n// Named: scroll-area.tsx also holds the overflow hook and scrollbar class Table shares.\nexport { ScrollArea } from \"./components/scroll-area\";\nexport type { ScrollAreaProps } from \"./components/scroll-area\";\n// 0.10.0 rows, menu rows, text primitives and page chrome the apps drew by hand.\nexport * from \"./components/list\";\nexport * from \"./components/menu-item\";\nexport * from \"./components/text\";\nexport * from \"./components/status-dot\";\nexport * from \"./components/page-header\";\nexport * from \"./components/breadcrumbs\";\n// The one inline link (kastlan's EntityLink / CellLink / legal and source links), through\n// `<UiKitProvider linkComponent>`. Named: the file also holds the kit's internal link picker.\nexport { TextLink } from \"./components/text-link\";\nexport type {\n TextLinkProps,\n TextLinkRenderProps,\n TextLinkTone,\n TextLinkUnderline,\n TextLinkCurrent,\n} from \"./components/text-link\";\n// The toast layer over sonner (an OPTIONAL peer, loaded lazily): `toast` mirrors sonner's\n// API so apps migrate by swapping the import; `<Toaster>` carries the placement, theme,\n// tones and z-index both apps had wired by hand.\nexport { toast, Toaster, DEFAULT_TOAST_LABELS, TOAST_ACTION_DURATION } from \"./components/toast\";\nexport type {\n ToastId,\n ToastAction,\n ToastOptions,\n ToastPromiseOptions,\n ToastUndoOptions,\n ToastRedoOptions,\n ToastLabels,\n ToastPosition,\n ToastSwipeDirection,\n ToasterOffset,\n ToasterProps,\n} from \"./components/toast\";\n\n// ── data-table suite ─────────────────────────────────────────────────────────\nexport * from \"./components/data-table-labels\";\nexport * from \"./components/data-table-sort\";\nexport * from \"./components/data-table-filters\";\nexport * from \"./components/data-table-pagination\";\nexport { FilterPopover } from \"./components/data-table-filter-popover\";\n// data-table re-exports SortState internally; export the rest explicitly to\n// avoid a duplicate SortState star-export (it comes from data-table-sort).\nexport { DataTable, DEFAULT_DATA_TABLE_SORT_LABELS } from \"./components/data-table\";\nexport type {\n DataTableSortLabels,\n DataTableColumn,\n DataTableCellProps,\n DataTableHeadProps,\n DataTableProps,\n ServerPagination,\n FilterState,\n MobileSwipeActions,\n DataTableDensity,\n DataTableChrome,\n DataTableRowAction,\n} from \"./components/data-table\";\n// 0.12.0: the yes/no cell, and a server table's state held by its owner, URL-synced.\nexport * from \"./components/data-table-cells\";\nexport { useTableUrlState, readTableUrlState } from \"./components/use-table-state\";\nexport type {\n TableUrlState,\n TableUrlSync,\n TableUrlStateProps,\n UseTableUrlStateOptions,\n UseTableUrlStateReturn,\n} from \"./components/use-table-state\";\n\n// ── shell (composable app chrome) ────────────────────────────────────────────\nexport * from \"./shell/topbar-controls\";\nexport * from \"./shell/top-bar\";\nexport * from \"./shell/app-shell\";\nexport * from \"./shell/option-switcher-menu\";\nexport * from \"./shell/role-switcher\";\nexport * from \"./shell/topbar-action-menu\";\nexport * from \"./shell/top-bar-brand\";\nexport * from \"./shell/auth-layout\";\n\n// ── feedback ─────────────────────────────────────────────────────────────────\n// The form somebody files a report with, and the parts an inbox is built from:\n// the status vocabulary both apps share value for value, the policy about what a\n// row may move to from where it stands, and the look of a status control, a\n// category badge and an opened report. The app still wires its own API, columns\n// and strings — see the note at the top of `feedback-inbox.tsx` for what is\n// deliberately left to it.\nexport * from \"./feedback/feedback-attachment\";\nexport * from \"./feedback/feedback-dialog\";\nexport * from \"./feedback/feedback-inbox\";\nexport * from \"./feedback/feedback-thread\";\n\n// ── multi-step wizard ────────────────────────────────────────────────────────\n// The engine (step machine, validators, collected data), the chrome around it\n// (indicator + nav bar + cancel confirm) and the review step it ends on.\n// `components/wizard-stepper` next door is a different, much smaller thing: a bare\n// step indicator for a two-step import flow, with no engine.\n//\n// Two modules were removed here rather than kept as stock. `wizard-field` held a\n// `WizardField`/`WizardSelectField` pair that had never been rendered in any app —\n// a field group nothing was built from, which this comment used to advertise. And\n// `use-rhf-wizard-step` was the only thing in the package that touched\n// react-hook-form, for a hook neither consumer called: keeping it meant an optional\n// peer, a dev dependency and a type import in every consumer's typecheck, bought\n// for nobody. A design system may carry stock; untested stock nothing has ever\n// rendered is not stock, it is a liability with an export.\nexport * from \"./wizard/types\";\nexport * from \"./wizard/use-wizard\";\nexport * from \"./wizard/wizard-context\";\nexport * from \"./wizard/validation\";\nexport * from \"./wizard/wizard-step\";\nexport * from \"./wizard/wizard-summary\";\nexport * from \"./wizard/stepper-nav\";\n\n// ── guided tours ─────────────────────────────────────────────────────────────\nexport * from \"./tour/tour\";\n\n// ── command palette / global search ──────────────────────────────────────────\nexport * from \"./search/command-palette\";\nexport * from \"./search/search-index\";\nexport * from \"./search/global-search\";\n\n// ── i18n: one label tree, one optional provider ──────────────────────────────\n// `UiKitLabels` names every string the kit renders; `<UiKitProvider labels locale>`\n// hands a translation to every component below it. Precedence: a component's own\n// prop > the provider > the English default. See src/i18n/kit-labels.tsx.\nexport * from \"./i18n/kit-labels\";\nexport * from \"./i18n/defaults\";\n// The kit's words as `key → text` rows for an app's translation review (keksdose).\nexport { kitLabelStrings } from \"./i18n/review\";\n// The seven languages, how an app resolves one, and the kit catalogue loader for it.\nexport * from \"./i18n/languages\";\n// CLDR plural categories for an app's i18next catalogue, filled from `_other`.\nexport { withAllPlurals } from \"./i18n/plurals\";\n// Translation review (0.19): one contract for kastlan's and keksdose's review pages —\n// the pure rows/status/placeholder logic and the presentational page parts.\nexport {\n REVIEW_STATUSES,\n fromApiReview,\n toApiWrite,\n flattenStrings,\n keyNamespace,\n placeholderTokens,\n placeholderMismatch,\n reviewStatus,\n keyInArea,\n keyInAreas,\n translationRows,\n summariseRows,\n DEFAULT_TRANSLATION_REVIEW_FILTER,\n filterTranslationRows,\n reviewWrite,\n mergeReviews,\n dropReviews,\n translationCorrections,\n} from \"./lib/translation-review\";\nexport type {\n TranslationVerdict,\n TranslationReview,\n TranslationReviewWrite,\n TranslationReviewKey,\n ReviewStatus,\n TranslationRow,\n ApiTranslationReview,\n ApiTranslationReviewWrite,\n TranslationRowsInput,\n TranslationSummary,\n TranslationReviewFilter,\n TranslationCorrection,\n} from \"./lib/translation-review\";\nexport {\n TranslationReviewPanel,\n TranslationReviewEditor,\n ReviewStatusChip,\n TranslationProgress,\n TranslationLocaleTabs,\n TranslationExportButton,\n REVIEW_STATUS_TONES,\n DEFAULT_TRANSLATION_REVIEW_LABELS,\n} from \"./components/translation-review\";\nexport type {\n TranslationReviewPanelProps,\n TranslationReviewEditorProps,\n ReviewStatusChipProps,\n TranslationProgressProps,\n TranslationLocaleTab,\n TranslationLocaleTabsProps,\n TranslationExportButtonProps,\n TranslationReviewLabels,\n} from \"./components/translation-review\";\n// The legal pages' shell (0.19, H10): Imprint, Privacy Policy, Terms in every app.\nexport { LegalLayout, LegalSection, LegalLinks, DEFAULT_LEGAL_LABELS } from \"./components/legal\";\nexport type { LegalLabels, LegalLink, LegalLinksProps, LegalSectionProps, LegalLayoutProps } from \"./components/legal\";\n\n// ── 0.22.0: the inputs round (kastlan's, keksdose's and Kurvenschmiede's audits) ──\nexport * from \"./components/checkbox-group\";\nexport * from \"./components/one-time-code-input\";\nexport * from \"./components/language-select\";\nexport * from \"./components/tile-radio\";\nexport * from \"./components/inline-edit-field\";\nexport * from \"./components/sign-chip\";\nexport * from \"./components/country-select\";\nexport { COUNTRY_CODES, countryName } from \"./lib/countries\";\nexport * from \"./components/iban-input\";\nexport {\n IBAN_LENGTHS,\n compactIban,\n formatIban,\n ibanCheckDigits,\n ibanProblem,\n isValidIban,\n isQrIban,\n} from \"./lib/iban\";\nexport type { IbanKind, IbanProblem } from \"./lib/iban\";\nexport { formatIsin, isinCheckDigit, isValidIsin } from \"./lib/isin\";\nexport * from \"./components/phone-input\";\nexport {\n PHONE_DIAL_CODES,\n PHONE_COUNTRIES,\n parsePhone,\n formatNationalPhone,\n formatPhone,\n isE164,\n} from \"./lib/phone\";\nexport type { PhoneCountryCode, PhoneCountry, ParsedPhone } from \"./lib/phone\";\n\n// ── 0.23.0: the apps' 0.22 adoption round (kastlan, keksdose, Kurvenschmiede) ──\n// The label strip over custom content (keksdose G8).\nexport * from \"./components/field-strip\";\n// Paste or drop a table, give each column a role (Kurvenschmiede's columns input,\n// keksdose's import map step). The lexer itself stays in `@eifi1/ui-kit/table-text`.\nexport * from \"./components/column-mapper\";\nexport {\n assignColumnRole,\n guessMapping,\n missingRoles,\n readMappedTable,\n readTextFile,\n roleOfColumn,\n} from \"./lib/column-mapping\";\nexport type { ColumnMapperResult, ColumnMapping, ColumnRole } from \"./lib/column-mapping\";\n"],"mappings":";AAMA,cAAc;AACd,SAAS,UAAU;AACnB,SAAS,QAAQ,mBAAmB;AAGpC,cAAc;AAEd,SAAS,YAAY,mBAAmB;AAIxC,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAClC,SAAS,uBAAuB;AAEhC,SAAS,kBAAkB,wBAAwB,yBAAyB;AAM5E,SAAS,cAAc,uBAAuB;AAI9C,SAAS,oBAAoB;AAE7B,SAAS,mBAAmB;AAE5B,SAAS,yBAAyB;AAClC,SAAS,oBAAoB,uBAAuB;AACpD,SAAS,mBAAmB;AAG5B,SAAS,aAAa,oBAAoB;AAG1C,SAAS,aAAa,4BAA4B;AAIlD,SAAS,qBAAqB,aAAa,sBAAsB;AAGjE,SAAS,oBAAoB,uBAAuB;AAGpD,SAAS,WAAW,aAAa,qBAAqB;AAGtD,SAAS,oBAAoB;AAI7B,cAAc;AAKd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,oBAAoB;AAE7B,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAId,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,OACK;AAcP,SAAS,cAAc,oCAA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ACd,cAAc;AACd,cAAc;AASd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAgBd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AAMd,cAAc;AACd,cAAc;AAEd,SAAS,uBAAuB;AAEhC,cAAc;AAEd,SAAS,sBAAsB;AAG/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAeP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAYP,SAAS,aAAa,cAAc,YAAY,4BAA4B;AAI5E,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,eAAe,mBAAmB;AAC3C,cAAc;AACd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,YAAY,gBAAgB,mBAAmB;AACxD,cAAc;AACd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAKP,cAAc;AAGd,cAAc;AACd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { TextTable } from './table-text.js';
|
|
2
|
+
|
|
3
|
+
/** One part a column can play, defined by the caller. */
|
|
4
|
+
interface ColumnRole<R extends string = string> {
|
|
5
|
+
/** The key the mapping is stored under. */
|
|
6
|
+
value: R;
|
|
7
|
+
/** What the role select shows — translated by the caller. */
|
|
8
|
+
label: string;
|
|
9
|
+
/**
|
|
10
|
+
* `true`: the table cannot be used until a column plays this role. A string names a
|
|
11
|
+
* GROUP: the table needs any one of the roles that share it — keksdose's amount,
|
|
12
|
+
* debit and credit, any of which carries the money.
|
|
13
|
+
*/
|
|
14
|
+
required?: boolean | string;
|
|
15
|
+
/**
|
|
16
|
+
* Every cell this role reads must be a number in the table's decimal convention
|
|
17
|
+
* ({@link tableNumber}). A row where one is not — a footer, a units line, a total
|
|
18
|
+
* with a grouping mark — is moved to `unread` with its line number instead of being
|
|
19
|
+
* handed over. Kurvenschmiede's time, setpoint and actual. The cells stay strings:
|
|
20
|
+
* converting is the caller's, with `tableNumber(cell, result.decimalComma)`.
|
|
21
|
+
*/
|
|
22
|
+
numeric?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** Role → column index. A role that is absent or `null` sits on no column — so a
|
|
25
|
+
* mapping with nullable fields (keksdose's `CsvMapping`) is one as it stands. */
|
|
26
|
+
type ColumnMapping<R extends string = string> = Partial<Record<R, number | null>>;
|
|
27
|
+
/** What the table is, read through a mapping. */
|
|
28
|
+
interface ColumnMapperResult<R extends string = string> extends TextTable {
|
|
29
|
+
mapping: ColumnMapping<R>;
|
|
30
|
+
/** What the table still needs before it can be used: one entry per gap, each the
|
|
31
|
+
* roles any of which would fill it (one role, or a required group). */
|
|
32
|
+
missing: R[][];
|
|
33
|
+
/** Every required role placed, and at least one row read. */
|
|
34
|
+
complete: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** The role on this column, or `null` for an ignored one. */
|
|
37
|
+
declare function roleOfColumn<R extends string>(roles: readonly ColumnRole<R>[], mapping: ColumnMapping<R>, column: number): R | null;
|
|
38
|
+
/**
|
|
39
|
+
* Put `role` on `column` — or, with `null`, take the column's role off it.
|
|
40
|
+
*
|
|
41
|
+
* Whatever this column played before stops, and the role moves here from any other
|
|
42
|
+
* column, in one new mapping (keksdose's `assignColumn`: "both halves are patches to
|
|
43
|
+
* the same object"). Other fields of the mapping are kept as they are.
|
|
44
|
+
*/
|
|
45
|
+
declare function assignColumnRole<R extends string, M extends ColumnMapping<R>>(roles: readonly ColumnRole<R>[], mapping: M, column: number, role: R | null): M;
|
|
46
|
+
/**
|
|
47
|
+
* The gaps: each required role with no column, and each required group none of whose
|
|
48
|
+
* roles has one. In the order of `roles`. A column index past `width` is no column.
|
|
49
|
+
*/
|
|
50
|
+
declare function missingRoles<R extends string>(roles: readonly ColumnRole<R>[], mapping: ColumnMapping<R>, width?: number): R[][];
|
|
51
|
+
/**
|
|
52
|
+
* A first mapping for a table nobody has mapped yet.
|
|
53
|
+
*
|
|
54
|
+
* A column whose header IS a role's label or key gets that role. The required roles
|
|
55
|
+
* left over then take the free columns in order — Kurvenschmiede's "time, setpoint,
|
|
56
|
+
* actual are the first three columns", which is how a recorder writes them. Optional
|
|
57
|
+
* roles are not guessed by position: in a bank
|
|
58
|
+
* export of twelve columns, "the fourth role is the fourth column" is a wrong answer
|
|
59
|
+
* presented as a suggestion, and an "ignore" is the honest one.
|
|
60
|
+
*/
|
|
61
|
+
declare function guessMapping<R extends string>(roles: readonly ColumnRole<R>[], header: readonly string[] | null, width: number): ColumnMapping<R>;
|
|
62
|
+
/**
|
|
63
|
+
* The table read through the mapping: the rows every `numeric` role can read, the
|
|
64
|
+
* others moved to `unread` (in line order, with the parse's own), what is missing,
|
|
65
|
+
* and whether the table can be used. Column indexes past the table's width count as
|
|
66
|
+
* unplaced.
|
|
67
|
+
*/
|
|
68
|
+
declare function readMappedTable<R extends string>(table: TextTable, roles: readonly ColumnRole<R>[], mapping: ColumnMapping<R>): ColumnMapperResult<R>;
|
|
69
|
+
/**
|
|
70
|
+
* A dropped or chosen file's text — UTF-8 when it is UTF-8, else Windows-1252.
|
|
71
|
+
*
|
|
72
|
+
* A German bank or bench export is very often written in Windows-1252, and reading it
|
|
73
|
+
* as UTF-8 turns every "ä" in a column name into "�" — no error, just a header nobody
|
|
74
|
+
* recognises. So the bytes are tried as strict UTF-8 first and read as Windows-1252
|
|
75
|
+
* when that fails (keksdose's server sniffs the encoding for the same reason; a file
|
|
76
|
+
* read in the browser had nothing doing it). Falls back to `FileReader` where a `File`
|
|
77
|
+
* has no `arrayBuffer` (Kurvenschmiede's `readText`).
|
|
78
|
+
*/
|
|
79
|
+
declare function readTextFile(file: Blob): Promise<string>;
|
|
80
|
+
|
|
81
|
+
export { type ColumnMapperResult, type ColumnMapping, type ColumnRole, assignColumnRole, guessMapping, missingRoles, readMappedTable, readTextFile, roleOfColumn };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { tableNumber } from "./table-text.js";
|
|
3
|
+
const placedAt = (mapping, role, width) => {
|
|
4
|
+
const column = mapping[role];
|
|
5
|
+
if (typeof column !== "number") return null;
|
|
6
|
+
return width === void 0 || column < width ? column : null;
|
|
7
|
+
};
|
|
8
|
+
function roleOfColumn(roles, mapping, column) {
|
|
9
|
+
return roles.find((role) => mapping[role.value] === column)?.value ?? null;
|
|
10
|
+
}
|
|
11
|
+
function assignColumnRole(roles, mapping, column, role) {
|
|
12
|
+
const next = { ...mapping };
|
|
13
|
+
for (const { value } of roles) {
|
|
14
|
+
if (mapping[value] === column) next[value] = null;
|
|
15
|
+
}
|
|
16
|
+
if (role !== null) next[role] = column;
|
|
17
|
+
return next;
|
|
18
|
+
}
|
|
19
|
+
function missingRoles(roles, mapping, width) {
|
|
20
|
+
const gaps = [];
|
|
21
|
+
const groups = /* @__PURE__ */ new Set();
|
|
22
|
+
for (const role of roles) {
|
|
23
|
+
if (role.required === true) {
|
|
24
|
+
if (placedAt(mapping, role.value, width) === null) gaps.push([role.value]);
|
|
25
|
+
} else if (typeof role.required === "string" && !groups.has(role.required)) {
|
|
26
|
+
groups.add(role.required);
|
|
27
|
+
const members = roles.filter((other) => other.required === role.required);
|
|
28
|
+
if (members.every((member) => placedAt(mapping, member.value, width) === null)) {
|
|
29
|
+
gaps.push(members.map((member) => member.value));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return gaps;
|
|
34
|
+
}
|
|
35
|
+
const normalised = (text) => text.trim().toLowerCase();
|
|
36
|
+
function guessMapping(roles, header, width) {
|
|
37
|
+
const mapping = {};
|
|
38
|
+
const taken = /* @__PURE__ */ new Set();
|
|
39
|
+
if (header) {
|
|
40
|
+
for (const role of roles) {
|
|
41
|
+
const names = [normalised(role.label), normalised(role.value)];
|
|
42
|
+
const column = header.findIndex((name, index) => !taken.has(index) && names.includes(normalised(name)));
|
|
43
|
+
if (column >= 0) {
|
|
44
|
+
mapping[role.value] = column;
|
|
45
|
+
taken.add(column);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const free = Array.from({ length: width }, (_, index) => index).filter((index) => !taken.has(index));
|
|
50
|
+
for (const role of roles) {
|
|
51
|
+
if (role.required !== true || typeof mapping[role.value] === "number") continue;
|
|
52
|
+
const column = free.shift();
|
|
53
|
+
if (column === void 0) break;
|
|
54
|
+
mapping[role.value] = column;
|
|
55
|
+
}
|
|
56
|
+
return mapping;
|
|
57
|
+
}
|
|
58
|
+
function readMappedTable(table, roles, mapping) {
|
|
59
|
+
const numeric = roles.filter((role) => role.numeric).map((role) => placedAt(mapping, role.value, table.width)).filter((column) => column !== null);
|
|
60
|
+
const rows = [];
|
|
61
|
+
const lines = [];
|
|
62
|
+
const refused = [];
|
|
63
|
+
table.rows.forEach((row, index) => {
|
|
64
|
+
if (numeric.every((column) => Number.isFinite(tableNumber(row[column] ?? "", table.decimalComma)))) {
|
|
65
|
+
rows.push(row);
|
|
66
|
+
lines.push(table.lines[index]);
|
|
67
|
+
} else {
|
|
68
|
+
refused.push(table.lines[index]);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
const unread = refused.length ? [...table.unread, ...refused].sort((a, b) => a.line - b.line) : table.unread;
|
|
72
|
+
const missing = missingRoles(roles, mapping, table.width);
|
|
73
|
+
return {
|
|
74
|
+
...table,
|
|
75
|
+
rows,
|
|
76
|
+
lines,
|
|
77
|
+
unread,
|
|
78
|
+
mapping,
|
|
79
|
+
missing,
|
|
80
|
+
complete: missing.length === 0 && rows.length > 0
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
async function readTextFile(file) {
|
|
84
|
+
const bytes = await bytesOf(file);
|
|
85
|
+
try {
|
|
86
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
87
|
+
} catch {
|
|
88
|
+
return new TextDecoder("windows-1252").decode(bytes);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function bytesOf(file) {
|
|
92
|
+
if (typeof file.arrayBuffer === "function") return file.arrayBuffer();
|
|
93
|
+
return new Promise((resolve, reject) => {
|
|
94
|
+
const reader = new FileReader();
|
|
95
|
+
reader.onload = () => resolve(reader.result);
|
|
96
|
+
reader.onerror = () => reject(reader.error ?? new Error("read failed"));
|
|
97
|
+
reader.readAsArrayBuffer(file);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
export {
|
|
101
|
+
assignColumnRole,
|
|
102
|
+
guessMapping,
|
|
103
|
+
missingRoles,
|
|
104
|
+
readMappedTable,
|
|
105
|
+
readTextFile,
|
|
106
|
+
roleOfColumn
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=column-mapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/column-mapping.ts"],"sourcesContent":["/**\n * Which column of a table plays which part — the headless half of {@link ColumnMapper}.\n *\n * Two apps built this by hand, the same way. Kurvenschmiede's columns input\n * (`features/control/columns-input.tsx`) reads a recorder's export and asks which\n * column is the time, the setpoint and the actual; keksdose's bank-file import\n * (`import-map-step.tsx`, `use-file-import.ts`) shows a bank's CSV and asks which\n * column is the booking date, the amount, the payee. Both then have the same four\n * rules, and keksdose wrote them down after getting each one wrong once:\n *\n * * **A role sits on one column at most, and a column carries one role.** Picking a\n * role for a column MOVES it there from wherever it was ({@link assignColumnRole});\n * the column it left falls back to \"ignore\" in the same step. There is no error\n * state, because there is nothing wrong to report.\n * * **What is still missing is named**, not left to a disabled button\n * ({@link missingRoles}). A required role can be one of a group: a bank export that\n * splits debit and credit has no amount column and needs none, so `required` may\n * name a group, satisfied by any one of its members (keksdose's \"money\").\n * * **A mapping is indexes into ONE table.** When the column count changes, the\n * indexes mean nothing any more and are guessed afresh; when it does not (the\n * header line toggled), they still point where they did — keksdose's `keepRoles`.\n * * **The rows a role cannot read are reported by line**, not dropped in silence\n * ({@link readMappedTable}): a footer under a recording, a total under a statement.\n *\n * Pure functions over plain data, so a two-step wizard can hold the mapping in its own\n * state between steps, and a table the server sniffed (keksdose's) can be mapped with\n * the same rules as one parsed here.\n */\nimport { tableNumber } from \"./table-text\";\nimport type { TableLine, TextTable } from \"./table-text\";\n\n/** One part a column can play, defined by the caller. */\nexport interface ColumnRole<R extends string = string> {\n /** The key the mapping is stored under. */\n value: R;\n /** What the role select shows — translated by the caller. */\n label: string;\n /**\n * `true`: the table cannot be used until a column plays this role. A string names a\n * GROUP: the table needs any one of the roles that share it — keksdose's amount,\n * debit and credit, any of which carries the money.\n */\n required?: boolean | string;\n /**\n * Every cell this role reads must be a number in the table's decimal convention\n * ({@link tableNumber}). A row where one is not — a footer, a units line, a total\n * with a grouping mark — is moved to `unread` with its line number instead of being\n * handed over. Kurvenschmiede's time, setpoint and actual. The cells stay strings:\n * converting is the caller's, with `tableNumber(cell, result.decimalComma)`.\n */\n numeric?: boolean;\n}\n\n/** Role → column index. A role that is absent or `null` sits on no column — so a\n * mapping with nullable fields (keksdose's `CsvMapping`) is one as it stands. */\nexport type ColumnMapping<R extends string = string> = Partial<Record<R, number | null>>;\n\n/** What the table is, read through a mapping. */\nexport interface ColumnMapperResult<R extends string = string> extends TextTable {\n mapping: ColumnMapping<R>;\n /** What the table still needs before it can be used: one entry per gap, each the\n * roles any of which would fill it (one role, or a required group). */\n missing: R[][];\n /** Every required role placed, and at least one row read. */\n complete: boolean;\n}\n\nconst placedAt = <R extends string>(mapping: ColumnMapping<R>, role: R, width?: number): number | null => {\n const column = mapping[role];\n if (typeof column !== \"number\") return null;\n return width === undefined || column < width ? column : null;\n};\n\n/** The role on this column, or `null` for an ignored one. */\nexport function roleOfColumn<R extends string>(\n roles: readonly ColumnRole<R>[],\n mapping: ColumnMapping<R>,\n column: number,\n): R | null {\n return roles.find((role) => mapping[role.value] === column)?.value ?? null;\n}\n\n/**\n * Put `role` on `column` — or, with `null`, take the column's role off it.\n *\n * Whatever this column played before stops, and the role moves here from any other\n * column, in one new mapping (keksdose's `assignColumn`: \"both halves are patches to\n * the same object\"). Other fields of the mapping are kept as they are.\n */\nexport function assignColumnRole<R extends string, M extends ColumnMapping<R>>(\n roles: readonly ColumnRole<R>[],\n mapping: M,\n column: number,\n role: R | null,\n): M {\n const next = { ...mapping } as Record<string, unknown>;\n for (const { value } of roles) {\n if (mapping[value] === column) next[value] = null;\n }\n if (role !== null) next[role] = column;\n return next as M;\n}\n\n/**\n * The gaps: each required role with no column, and each required group none of whose\n * roles has one. In the order of `roles`. A column index past `width` is no column.\n */\nexport function missingRoles<R extends string>(\n roles: readonly ColumnRole<R>[],\n mapping: ColumnMapping<R>,\n width?: number,\n): R[][] {\n const gaps: R[][] = [];\n const groups = new Set<string>();\n for (const role of roles) {\n if (role.required === true) {\n if (placedAt(mapping, role.value, width) === null) gaps.push([role.value]);\n } else if (typeof role.required === \"string\" && !groups.has(role.required)) {\n groups.add(role.required);\n const members = roles.filter((other) => other.required === role.required);\n if (members.every((member) => placedAt(mapping, member.value, width) === null)) {\n gaps.push(members.map((member) => member.value));\n }\n }\n }\n return gaps;\n}\n\nconst normalised = (text: string) => text.trim().toLowerCase();\n\n/**\n * A first mapping for a table nobody has mapped yet.\n *\n * A column whose header IS a role's label or key gets that role. The required roles\n * left over then take the free columns in order — Kurvenschmiede's \"time, setpoint,\n * actual are the first three columns\", which is how a recorder writes them. Optional\n * roles are not guessed by position: in a bank\n * export of twelve columns, \"the fourth role is the fourth column\" is a wrong answer\n * presented as a suggestion, and an \"ignore\" is the honest one.\n */\nexport function guessMapping<R extends string>(\n roles: readonly ColumnRole<R>[],\n header: readonly string[] | null,\n width: number,\n): ColumnMapping<R> {\n const mapping: ColumnMapping<R> = {};\n const taken = new Set<number>();\n if (header) {\n for (const role of roles) {\n const names = [normalised(role.label), normalised(role.value)];\n const column = header.findIndex((name, index) => !taken.has(index) && names.includes(normalised(name)));\n if (column >= 0) {\n mapping[role.value] = column;\n taken.add(column);\n }\n }\n }\n const free = Array.from({ length: width }, (_, index) => index).filter((index) => !taken.has(index));\n for (const role of roles) {\n if (role.required !== true || typeof mapping[role.value] === \"number\") continue;\n const column = free.shift();\n if (column === undefined) break;\n mapping[role.value] = column;\n }\n return mapping;\n}\n\n/**\n * The table read through the mapping: the rows every `numeric` role can read, the\n * others moved to `unread` (in line order, with the parse's own), what is missing,\n * and whether the table can be used. Column indexes past the table's width count as\n * unplaced.\n */\nexport function readMappedTable<R extends string>(\n table: TextTable,\n roles: readonly ColumnRole<R>[],\n mapping: ColumnMapping<R>,\n): ColumnMapperResult<R> {\n const numeric = roles\n .filter((role) => role.numeric)\n .map((role) => placedAt(mapping, role.value, table.width))\n .filter((column): column is number => column !== null);\n const rows: string[][] = [];\n const lines: TableLine[] = [];\n const refused: TableLine[] = [];\n table.rows.forEach((row, index) => {\n if (numeric.every((column) => Number.isFinite(tableNumber(row[column] ?? \"\", table.decimalComma)))) {\n rows.push(row);\n lines.push(table.lines[index]);\n } else {\n refused.push(table.lines[index]);\n }\n });\n const unread = refused.length ? [...table.unread, ...refused].sort((a, b) => a.line - b.line) : table.unread;\n const missing = missingRoles(roles, mapping, table.width);\n return {\n ...table,\n rows,\n lines,\n unread,\n mapping,\n missing,\n complete: missing.length === 0 && rows.length > 0,\n };\n}\n\n/**\n * A dropped or chosen file's text — UTF-8 when it is UTF-8, else Windows-1252.\n *\n * A German bank or bench export is very often written in Windows-1252, and reading it\n * as UTF-8 turns every \"ä\" in a column name into \"�\" — no error, just a header nobody\n * recognises. So the bytes are tried as strict UTF-8 first and read as Windows-1252\n * when that fails (keksdose's server sniffs the encoding for the same reason; a file\n * read in the browser had nothing doing it). Falls back to `FileReader` where a `File`\n * has no `arrayBuffer` (Kurvenschmiede's `readText`).\n */\nexport async function readTextFile(file: Blob): Promise<string> {\n const bytes = await bytesOf(file);\n try {\n return new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes);\n } catch {\n return new TextDecoder(\"windows-1252\").decode(bytes);\n }\n}\n\nfunction bytesOf(file: Blob): Promise<ArrayBuffer> {\n if (typeof file.arrayBuffer === \"function\") return file.arrayBuffer();\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () => resolve(reader.result as ArrayBuffer);\n reader.onerror = () => reject(reader.error ?? new Error(\"read failed\"));\n reader.readAsArrayBuffer(file);\n });\n}\n"],"mappings":";AA4BA,SAAS,mBAAmB;AAuC5B,MAAM,WAAW,CAAmB,SAA2B,MAAS,UAAkC;AACxG,QAAM,SAAS,QAAQ,IAAI;AAC3B,MAAI,OAAO,WAAW,SAAU,QAAO;AACvC,SAAO,UAAU,UAAa,SAAS,QAAQ,SAAS;AAC1D;AAGO,SAAS,aACd,OACA,SACA,QACU;AACV,SAAO,MAAM,KAAK,CAAC,SAAS,QAAQ,KAAK,KAAK,MAAM,MAAM,GAAG,SAAS;AACxE;AASO,SAAS,iBACd,OACA,SACA,QACA,MACG;AACH,QAAM,OAAO,EAAE,GAAG,QAAQ;AAC1B,aAAW,EAAE,MAAM,KAAK,OAAO;AAC7B,QAAI,QAAQ,KAAK,MAAM,OAAQ,MAAK,KAAK,IAAI;AAAA,EAC/C;AACA,MAAI,SAAS,KAAM,MAAK,IAAI,IAAI;AAChC,SAAO;AACT;AAMO,SAAS,aACd,OACA,SACA,OACO;AACP,QAAM,OAAc,CAAC;AACrB,QAAM,SAAS,oBAAI,IAAY;AAC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EAAE,OAAO,KAAK;AAAA,EACrD;AACF;AAEA,SAAS,QAAQ,MAAkC;AACjD,MAAI,OAAO,KAAK,gBAAgB,WAAY,QAAO,KAAK,YAAY;AACpE,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,SAAS,IAAI,WAAW;AAC9B,WAAO,SAAS,MAAM,QAAQ,OAAO,MAAqB;AAC1D,WAAO,UAAU,MAAM,OAAO,OAAO,SAAS,IAAI,MAAM,aAAa,CAAC;AACtE,WAAO,kBAAkB,IAAI;AAAA,EAC/B,CAAC;AACH;","names":[]}
|
package/dist/lib/table-text.d.ts
CHANGED
|
@@ -46,6 +46,11 @@
|
|
|
46
46
|
* * **Quoted fields.** No `"a;b"` escaping. These are numbers; the only text in them
|
|
47
47
|
* is the header line, and a header field with a separator in it costs a column
|
|
48
48
|
* name, not a measurement.
|
|
49
|
+
*
|
|
50
|
+
* Both of those are the NUMERIC lexer's limits. A table whose cells are text — a bank
|
|
51
|
+
* export, read for a column mapper — needs both, and {@link parseTextTable} (0.23) is
|
|
52
|
+
* that door: empty cells held in place, quoted cells, and the same separator and comma
|
|
53
|
+
* rules underneath.
|
|
49
54
|
*/
|
|
50
55
|
/** Where the decision about the comma is taken. See the module docstring: the
|
|
51
56
|
* file door decides once for the whole text, the paste door decides per line. */
|
|
@@ -123,5 +128,108 @@ declare const cellNumber: (cell: string) => number;
|
|
|
123
128
|
/** Whether one cell holds a number yet. An empty cell is not one — it is a hole
|
|
124
129
|
* in the measurement, which is a different thing from a zero. */
|
|
125
130
|
declare const isCellNumber: (cell: string) => boolean;
|
|
131
|
+
/**
|
|
132
|
+
* What separates the columns of a {@link TextTable}, named. `" "` is a run of
|
|
133
|
+
* whitespace — one separator however many spaces or tabs it is made of — as in a
|
|
134
|
+
* printed or MATLAB-dumped table.
|
|
135
|
+
*/
|
|
136
|
+
type TableSeparator = "\t" | ";" | "," | " ";
|
|
137
|
+
/** One line of the text as it was handed over: its 1-based number (blank lines
|
|
138
|
+
* counted, so a reader can count to it in the box they pasted into) and its text,
|
|
139
|
+
* trimmed. */
|
|
140
|
+
interface TableLine {
|
|
141
|
+
line: number;
|
|
142
|
+
text: string;
|
|
143
|
+
}
|
|
144
|
+
interface ParseTextTableOptions {
|
|
145
|
+
/** The separator, decided by the caller — a "separated by" override, a format
|
|
146
|
+
* the app already knows. Default: detected (see {@link parseTextTable}). */
|
|
147
|
+
separator?: TableSeparator;
|
|
148
|
+
/** Whether a comma between two digits is a decimal mark. Default: the
|
|
149
|
+
* `"whole-text"` rule, decided once for the file. */
|
|
150
|
+
decimalComma?: boolean;
|
|
151
|
+
/** Whether the table's first line names its columns. Default: detected — a
|
|
152
|
+
* word over a column of values ("Amount" over `-12,50`) is a header. */
|
|
153
|
+
header?: boolean;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* A table read as text: every cell a string, as written.
|
|
157
|
+
*
|
|
158
|
+
* The *file* door's decisions, for a table that is not only numbers. Everything a
|
|
159
|
+
* reader has to know to trust it is in the answer — the separator and the decimal
|
|
160
|
+
* mark that were assumed, and the lines that were not read, with their number and
|
|
161
|
+
* their text — because a guess nobody can see is a guess nobody can correct.
|
|
162
|
+
*/
|
|
163
|
+
interface TextTable {
|
|
164
|
+
/** The first line's cells, when it names the columns; `null` when it is data. */
|
|
165
|
+
header: string[] | null;
|
|
166
|
+
/** Each read row, `width` cells long. An empty cell is `""`, kept in its place. */
|
|
167
|
+
rows: string[][];
|
|
168
|
+
/** Where each row came from — row-aligned with `rows`. */
|
|
169
|
+
lines: TableLine[];
|
|
170
|
+
/** How many columns the table has. */
|
|
171
|
+
width: number;
|
|
172
|
+
separator: TableSeparator;
|
|
173
|
+
/** Whether a comma is this table's decimal mark — the convention its numbers are
|
|
174
|
+
* written in, to read them with {@link tableNumber} and to say back to the reader. */
|
|
175
|
+
decimalComma: boolean;
|
|
176
|
+
/** Lines that are not a row of this table: a title above it, a total under it, a
|
|
177
|
+
* row with a cell too many or too few. */
|
|
178
|
+
unread: TableLine[];
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* A pasted or dropped table, read as text — the lexer's file door for a table whose
|
|
182
|
+
* cells are not all numbers (a bank export: a date, a payee, an amount), and the
|
|
183
|
+
* parse under {@link ColumnMapper}.
|
|
184
|
+
*
|
|
185
|
+
* Moved under the same roof as {@link parseTable} because it has the same three
|
|
186
|
+
* questions — what separates the columns, what the comma is, whether the first
|
|
187
|
+
* line is a header — and answering them a second time somewhere else is how the
|
|
188
|
+
* three readers this module replaced came to disagree. Kurvenschmiede's columns
|
|
189
|
+
* input and keksdose's bank-file import both read a table whose columns the reader
|
|
190
|
+
* then assigns, and both state what was assumed; this is that reading, once.
|
|
191
|
+
*
|
|
192
|
+
* Where it differs from {@link parseTable}, and why:
|
|
193
|
+
*
|
|
194
|
+
* * **Cells stay text.** Which cell is a number is the caller's question (its
|
|
195
|
+
* column roles), so nothing here converts. {@link tableNumber} reads one in the
|
|
196
|
+
* table's own convention.
|
|
197
|
+
* * **An empty cell keeps its place.** A bank row with no memo has `;;` in it, and
|
|
198
|
+
* dropping that field — which the numeric lexer does — would move the amount into
|
|
199
|
+
* the memo's column. A trailing separator that ends most lines (`1;2;3;`, which
|
|
200
|
+
* spreadsheets write) is a line ending, not a column.
|
|
201
|
+
* * **Quoted cells.** `"Example Ltd; branch 2"` is one cell, and `""` inside quotes
|
|
202
|
+
* is a quote. Text has separators in it where numbers never do. A quoted cell that
|
|
203
|
+
* runs over a line break is not joined — the line then has the wrong number of
|
|
204
|
+
* cells and is reported.
|
|
205
|
+
* * **The width is the file's.** The column count most lines share. A line with
|
|
206
|
+
* another count is reported in `unread` rather than padded or cut: a row with a
|
|
207
|
+
* cell too many is a row whose columns have slid, and reading it would put a payee
|
|
208
|
+
* in the amount.
|
|
209
|
+
* * **The separator is voted on**, over the first lines, rather than taken from the
|
|
210
|
+
* second: an export that opens with a title block (a bank's account name and
|
|
211
|
+
* period over the table) would otherwise be read with the title's separator.
|
|
212
|
+
* * **The header is detected by its words.** The numeric lexer's rule — "a line
|
|
213
|
+
* that is not numbers" — cannot work where the rows are text too. A first line is
|
|
214
|
+
* a header when one of its cells is a word and every cell under it, as far as the
|
|
215
|
+
* first rows go, is a value (digits and the marks numbers and dates are written
|
|
216
|
+
* with): "Amount" over `-12,50`, "Date" over `01.02.2026`. A table of words only
|
|
217
|
+
* is read without one; `options.header` says otherwise.
|
|
218
|
+
*
|
|
219
|
+
* Blank lines and `#` banners are skipped, as by the numeric lexer.
|
|
220
|
+
*/
|
|
221
|
+
declare function parseTextTable(text: string, options?: ParseTextTableOptions): TextTable;
|
|
222
|
+
/**
|
|
223
|
+
* One cell of a {@link TextTable} as a number, read in the table's convention.
|
|
224
|
+
*
|
|
225
|
+
* Not {@link cellNumber}, which reads every comma as a decimal mark — right for a
|
|
226
|
+
* cell typed on its own, wrong for a cell of a file written with decimal points,
|
|
227
|
+
* where `1,234` is a grouped thousand and reading it as 1.234 would be off by a
|
|
228
|
+
* factor of a thousand without a word. Here a comma is a decimal mark only in a
|
|
229
|
+
* table whose convention it is, and a cell with both marks is `NaN` either way: the
|
|
230
|
+
* lexer does not read grouped numbers, it reports them. An empty cell is `NaN` too —
|
|
231
|
+
* a hole in the table, not a zero.
|
|
232
|
+
*/
|
|
233
|
+
declare function tableNumber(cell: string, decimalComma: boolean): number;
|
|
126
234
|
|
|
127
|
-
export { type DecimalRule, type ParseTableOptions, type ParsedTable, cellNumber, isCellNumber, parseRows, parseTable, splitRow };
|
|
235
|
+
export { type DecimalRule, type ParseTableOptions, type ParseTextTableOptions, type ParsedTable, type TableLine, type TableSeparator, type TextTable, cellNumber, isCellNumber, parseRows, parseTable, parseTextTable, splitRow, tableNumber };
|
package/dist/lib/table-text.js
CHANGED
|
@@ -72,11 +72,132 @@ function fieldsOf(line, separator) {
|
|
|
72
72
|
return line.split(separator).map((field) => field.trim()).filter((field) => field !== "");
|
|
73
73
|
}
|
|
74
74
|
const point = (field) => field.replace(",", ".");
|
|
75
|
+
function parseTextTable(text, options = {}) {
|
|
76
|
+
const content = textLines(text);
|
|
77
|
+
if (!content.length) {
|
|
78
|
+
return { header: null, rows: [], lines: [], width: 0, separator: options.separator ?? ",", decimalComma: false, unread: [] };
|
|
79
|
+
}
|
|
80
|
+
const separator = options.separator ?? votedSeparator(content);
|
|
81
|
+
const decimalComma = options.decimalComma ?? (separator !== "," && DECIMAL_COMMA.test(content.map((entry) => entry.line).join("\n")));
|
|
82
|
+
const trailing = separator !== " " && content.filter(({ line }) => line.endsWith(separator)).length * 2 > content.length;
|
|
83
|
+
const split = content.map(({ line, number }) => {
|
|
84
|
+
const cells = cellsOf(line, separator);
|
|
85
|
+
if (trailing && line.endsWith(separator) && cells[cells.length - 1] === "") cells.pop();
|
|
86
|
+
return { cells, entry: { line: number, text: line } };
|
|
87
|
+
});
|
|
88
|
+
const width = commonWidth(split.map(({ cells }) => cells.length));
|
|
89
|
+
const first = split.findIndex(({ cells }) => cells.length === width);
|
|
90
|
+
const unread = split.slice(0, first).map(({ entry }) => entry);
|
|
91
|
+
const body = split.slice(first);
|
|
92
|
+
const fitting = body.filter(({ cells }) => cells.length === width);
|
|
93
|
+
const header = options.header ?? looksLikeHeader(fitting[0].cells, fitting.slice(1, 21).map(({ cells }) => cells));
|
|
94
|
+
const rows = [];
|
|
95
|
+
const lines = [];
|
|
96
|
+
body.forEach(({ cells, entry }, index) => {
|
|
97
|
+
if (index === 0 && header) return;
|
|
98
|
+
if (cells.length !== width) {
|
|
99
|
+
unread.push(entry);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
rows.push(cells);
|
|
103
|
+
lines.push(entry);
|
|
104
|
+
});
|
|
105
|
+
return { header: header ? body[0].cells : null, rows, lines, width, separator, decimalComma, unread };
|
|
106
|
+
}
|
|
107
|
+
function tableNumber(cell, decimalComma) {
|
|
108
|
+
const trimmed = cell.trim();
|
|
109
|
+
if (trimmed === "") return Number.NaN;
|
|
110
|
+
return Number(decimalComma ? point(trimmed) : trimmed);
|
|
111
|
+
}
|
|
112
|
+
const SEPARATOR_TRUST = [" ", ";", ",", " "];
|
|
113
|
+
function textLines(text) {
|
|
114
|
+
return text.split(/\r?\n/).map((line, index) => ({ line: line.replace(/^ +| +$/g, ""), number: index + 1 })).filter(({ line }) => line.trim() !== "" && !line.trimStart().startsWith("#"));
|
|
115
|
+
}
|
|
116
|
+
function votedSeparator(lines) {
|
|
117
|
+
const votes = /* @__PURE__ */ new Map();
|
|
118
|
+
for (const { line } of lines.slice(0, 50)) {
|
|
119
|
+
const found = separatorOf(withoutQuoted(line));
|
|
120
|
+
const named = typeof found === "string" ? found : " ";
|
|
121
|
+
votes.set(named, (votes.get(named) ?? 0) + 1);
|
|
122
|
+
}
|
|
123
|
+
let best = SEPARATOR_TRUST[0];
|
|
124
|
+
let bestCount = -1;
|
|
125
|
+
for (const candidate of SEPARATOR_TRUST) {
|
|
126
|
+
const count = votes.get(candidate) ?? 0;
|
|
127
|
+
if (count > bestCount) {
|
|
128
|
+
best = candidate;
|
|
129
|
+
bestCount = count;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return best;
|
|
133
|
+
}
|
|
134
|
+
const withoutQuoted = (line) => line.replace(/"(?:[^"]|"")*"/g, '""');
|
|
135
|
+
function cellsOf(line, separator) {
|
|
136
|
+
if (separator === " ") return line.split(/\s+/).filter((field) => field !== "").map(unquote);
|
|
137
|
+
const cells = [];
|
|
138
|
+
let cell = "";
|
|
139
|
+
let quoted = false;
|
|
140
|
+
let started = false;
|
|
141
|
+
for (let index = 0; index < line.length; index += 1) {
|
|
142
|
+
const char = line[index];
|
|
143
|
+
if (quoted) {
|
|
144
|
+
if (char === '"' && line[index + 1] === '"') {
|
|
145
|
+
cell += '"';
|
|
146
|
+
index += 1;
|
|
147
|
+
} else if (char === '"') {
|
|
148
|
+
quoted = false;
|
|
149
|
+
} else {
|
|
150
|
+
cell += char;
|
|
151
|
+
}
|
|
152
|
+
} else if (char === separator) {
|
|
153
|
+
cells.push(cell.trim());
|
|
154
|
+
cell = "";
|
|
155
|
+
started = false;
|
|
156
|
+
} else if (char === '"' && !started) {
|
|
157
|
+
quoted = true;
|
|
158
|
+
started = true;
|
|
159
|
+
cell = "";
|
|
160
|
+
} else {
|
|
161
|
+
if (char.trim() !== "") started = true;
|
|
162
|
+
cell += char;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
cells.push(cell.trim());
|
|
166
|
+
return cells;
|
|
167
|
+
}
|
|
168
|
+
function unquote(field) {
|
|
169
|
+
return field.length >= 2 && field.startsWith('"') && field.endsWith('"') ? field.slice(1, -1).replace(/""/g, '"') : field;
|
|
170
|
+
}
|
|
171
|
+
function commonWidth(counts) {
|
|
172
|
+
const tally = /* @__PURE__ */ new Map();
|
|
173
|
+
for (const count of counts) tally.set(count, (tally.get(count) ?? 0) + 1);
|
|
174
|
+
let width = 0;
|
|
175
|
+
let best = 0;
|
|
176
|
+
for (const [count, times] of tally) {
|
|
177
|
+
if (times > best || times === best && count > width) {
|
|
178
|
+
width = count;
|
|
179
|
+
best = times;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return width;
|
|
183
|
+
}
|
|
184
|
+
const isWord = (cell) => /\p{L}/u.test(cell);
|
|
185
|
+
const isValue = (cell) => /\d/.test(cell) && !isWord(cell);
|
|
186
|
+
function looksLikeHeader(first, below) {
|
|
187
|
+
if (!below.length) return first.some((cell) => cell !== "") && first.every((cell) => cell === "" || isWord(cell));
|
|
188
|
+
return first.some((cell, column) => {
|
|
189
|
+
if (!isWord(cell)) return false;
|
|
190
|
+
const values = below.map((row) => row[column]).filter((value) => value !== "");
|
|
191
|
+
return values.length > 0 && values.every(isValue);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
75
194
|
export {
|
|
76
195
|
cellNumber,
|
|
77
196
|
isCellNumber,
|
|
78
197
|
parseRows,
|
|
79
198
|
parseTable,
|
|
80
|
-
|
|
199
|
+
parseTextTable,
|
|
200
|
+
splitRow,
|
|
201
|
+
tableNumber
|
|
81
202
|
};
|
|
82
203
|
//# sourceMappingURL=table-text.js.map
|