@eifi1/ui-kit 0.11.0 → 0.13.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 +59 -34
- package/dist/chart.d.ts +3 -1
- package/dist/chart.js +2 -0
- package/dist/chart.js.map +1 -1
- package/dist/components/account-settings-labels.d.ts +105 -0
- package/dist/components/account-settings-labels.js +81 -0
- package/dist/components/account-settings-labels.js.map +1 -0
- package/dist/components/account-settings.d.ts +36 -52
- package/dist/components/account-settings.js +44 -8
- package/dist/components/account-settings.js.map +1 -1
- package/dist/components/amount-input.d.ts +40 -4
- package/dist/components/amount-input.js +50 -12
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/authed-image.d.ts +68 -0
- package/dist/components/authed-image.js +117 -0
- package/dist/components/authed-image.js.map +1 -0
- package/dist/components/breadcrumbs.d.ts +2 -1
- package/dist/components/breadcrumbs.js +5 -2
- package/dist/components/breadcrumbs.js.map +1 -1
- package/dist/components/bulk-action-bar.d.ts +10 -2
- package/dist/components/bulk-action-bar.js.map +1 -1
- package/dist/components/button-group.d.ts +51 -2
- package/dist/components/button-group.js +5 -1
- package/dist/components/button-group.js.map +1 -1
- package/dist/components/calculator.d.ts +15 -4
- package/dist/components/calendar-heatmap.d.ts +41 -3
- package/dist/components/calendar-heatmap.js +48 -7
- package/dist/components/calendar-heatmap.js.map +1 -1
- package/dist/components/chart.js +14 -8
- package/dist/components/chart.js.map +1 -1
- package/dist/components/chip.d.ts +2 -1
- package/dist/components/chip.js +26 -18
- package/dist/components/chip.js.map +1 -1
- package/dist/components/choice-card.d.ts +35 -3
- package/dist/components/choice-card.js +83 -25
- package/dist/components/choice-card.js.map +1 -1
- package/dist/components/combobox-core.d.ts +3 -1
- package/dist/components/combobox-core.js +18 -5
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/combobox.d.ts +2 -2
- package/dist/components/combobox.js +31 -9
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/copy-button.d.ts +51 -70
- package/dist/components/copy-button.js +1 -1
- package/dist/components/copy-button.js.map +1 -1
- package/dist/components/data-table-cells.d.ts +63 -0
- package/dist/components/data-table-cells.js +64 -0
- package/dist/components/data-table-cells.js.map +1 -0
- package/dist/components/data-table-filter-popover.d.ts +1 -1
- package/dist/components/data-table-filter-popover.js +8 -1
- package/dist/components/data-table-filter-popover.js.map +1 -1
- package/dist/components/data-table-filters.d.ts +1 -1
- package/dist/components/data-table-filters.js +31 -1
- package/dist/components/data-table-filters.js.map +1 -1
- package/dist/components/data-table-labels.d.ts +13 -0
- package/dist/components/data-table-labels.js +8 -1
- package/dist/components/data-table-labels.js.map +1 -1
- package/dist/components/data-table.d.ts +1 -1
- package/dist/components/data-table.js +125 -27
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.d.ts +3 -1
- package/dist/components/date-picker.js +15 -2
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/description-list.d.ts +23 -3
- package/dist/components/description-list.js +23 -3
- package/dist/components/description-list.js.map +1 -1
- package/dist/components/dialog-frame.d.ts +1 -0
- package/dist/components/entity-combobox.d.ts +1 -1
- package/dist/components/entity-combobox.js +40 -20
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/error-boundary.d.ts +281 -0
- package/dist/components/error-boundary.js +302 -0
- package/dist/components/error-boundary.js.map +1 -0
- package/dist/components/field-sync.js +90 -83
- package/dist/components/field-sync.js.map +1 -1
- package/dist/components/field.d.ts +30 -4
- package/dist/components/field.js +40 -17
- package/dist/components/field.js.map +1 -1
- package/dist/components/file-button.d.ts +50 -208
- package/dist/components/file-dropzone.d.ts +49 -2
- package/dist/components/floating-panel.d.ts +13 -4
- package/dist/components/floating-panel.js +7 -3
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/form-actions.d.ts +53 -0
- package/dist/components/form-actions.js +98 -0
- package/dist/components/form-actions.js.map +1 -0
- package/dist/components/full-bleed-dialog.js +4 -0
- package/dist/components/full-bleed-dialog.js.map +1 -1
- package/dist/components/hover-menu.js +64 -56
- package/dist/components/hover-menu.js.map +1 -1
- package/dist/components/image-grid.d.ts +67 -0
- package/dist/components/image-grid.js +112 -0
- package/dist/components/image-grid.js.map +1 -0
- package/dist/components/lightbox.d.ts +104 -0
- package/dist/components/lightbox.js +229 -0
- package/dist/components/lightbox.js.map +1 -0
- package/dist/components/line-items.d.ts +114 -0
- package/dist/components/line-items.js +238 -0
- package/dist/components/line-items.js.map +1 -0
- package/dist/components/list.d.ts +37 -4
- package/dist/components/list.js +35 -14
- package/dist/components/list.js.map +1 -1
- package/dist/components/loading-state.d.ts +24 -0
- package/dist/components/loading-state.js +32 -0
- package/dist/components/loading-state.js.map +1 -0
- package/dist/components/menu-item.d.ts +2 -1
- package/dist/components/menu-item.js +5 -1
- package/dist/components/menu-item.js.map +1 -1
- package/dist/components/mini-calendar.d.ts +13 -1
- package/dist/components/mini-calendar.js +46 -2
- package/dist/components/mini-calendar.js.map +1 -1
- package/dist/components/modal.d.ts +20 -1
- package/dist/components/modal.js +26 -2
- package/dist/components/modal.js.map +1 -1
- package/dist/components/month-picker.d.ts +21 -1
- package/dist/components/month-picker.js +139 -26
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/multi-entity-combobox.d.ts +1 -1
- package/dist/components/multi-entity-combobox.js +42 -20
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/nav-pills.d.ts +2 -1
- package/dist/components/nav-pills.js +5 -1
- package/dist/components/nav-pills.js.map +1 -1
- package/dist/components/number-field.d.ts +24 -5
- package/dist/components/number-field.js +5 -7
- package/dist/components/number-field.js.map +1 -1
- package/dist/components/number-input.d.ts +25 -5
- package/dist/components/number-input.js +7 -1
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/numpad-sheet.d.ts +20 -5
- package/dist/components/numpad-sheet.js +3 -2
- package/dist/components/numpad-sheet.js.map +1 -1
- package/dist/components/page-header.d.ts +35 -6
- package/dist/components/page-header.js +7 -1
- package/dist/components/page-header.js.map +1 -1
- package/dist/components/passkeys-setting.d.ts +67 -0
- package/dist/components/passkeys-setting.js +214 -0
- package/dist/components/passkeys-setting.js.map +1 -0
- package/dist/components/picker-sheet.js +5 -1
- package/dist/components/picker-sheet.js.map +1 -1
- package/dist/components/pie-chart-labels.d.ts +20 -0
- package/dist/components/pie-chart-labels.js +12 -0
- package/dist/components/pie-chart-labels.js.map +1 -0
- package/dist/components/pie-chart.d.ts +101 -0
- package/dist/components/pie-chart.js +283 -0
- package/dist/components/pie-chart.js.map +1 -0
- package/dist/components/popover.js +3 -0
- package/dist/components/popover.js.map +1 -1
- package/dist/components/progress-bar.d.ts +44 -3
- package/dist/components/progress-bar.js +58 -22
- package/dist/components/progress-bar.js.map +1 -1
- package/dist/components/qr-code.d.ts +34 -0
- package/dist/components/qr-code.js +57 -0
- package/dist/components/qr-code.js.map +1 -0
- package/dist/components/search-field.d.ts +15 -3
- package/dist/components/search-field.js +5 -1
- package/dist/components/search-field.js.map +1 -1
- package/dist/components/settings-fields.d.ts +49 -1
- package/dist/components/signed-amount.d.ts +122 -0
- package/dist/components/signed-amount.js +152 -0
- package/dist/components/signed-amount.js.map +1 -0
- package/dist/components/skeleton.d.ts +10 -3
- package/dist/components/skeleton.js +12 -2
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/stat-tile.d.ts +2 -1
- package/dist/components/stat-tile.js +6 -3
- package/dist/components/stat-tile.js.map +1 -1
- package/dist/components/swipeable-row.js +4 -3
- package/dist/components/swipeable-row.js.map +1 -1
- package/dist/components/table.d.ts +39 -5
- package/dist/components/table.js +45 -11
- package/dist/components/table.js.map +1 -1
- package/dist/components/text-link.d.ts +238 -0
- package/dist/components/text-link.js +144 -0
- package/dist/components/text-link.js.map +1 -0
- package/dist/components/text.d.ts +26 -2
- package/dist/components/text.js +16 -2
- package/dist/components/text.js.map +1 -1
- package/dist/components/time-input.d.ts +49 -1
- package/dist/components/toggle-group.d.ts +35 -0
- package/dist/components/toggle-group.js +43 -14
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/toggle-legend.d.ts +53 -3
- package/dist/components/toggle-legend.js +54 -1
- package/dist/components/toggle-legend.js.map +1 -1
- package/dist/components/tooltip.d.ts +51 -1
- package/dist/components/tooltip.js +59 -35
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/ui.d.ts +51 -779
- package/dist/components/ui.js +364 -34
- package/dist/components/ui.js.map +1 -1
- package/dist/components/use-table-state.d.ts +3 -52
- package/dist/components/use-table-state.js +128 -30
- package/dist/components/use-table-state.js.map +1 -1
- package/dist/{data-table-filters-Dh9uF_S-.d.ts → data-table-Drun8Fk9.d.ts} +305 -61
- package/dist/data-table.d.ts +2 -1
- package/dist/data-table.js +5 -1
- package/dist/data-table.js.map +1 -1
- package/dist/feedback/feedback-attachment.js +4 -6
- package/dist/feedback/feedback-attachment.js.map +1 -1
- package/dist/feedback/feedback-dialog.d.ts +26 -3
- package/dist/feedback/feedback-dialog.js +21 -5
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback/feedback-inbox.js +86 -75
- package/dist/feedback/feedback-inbox.js.map +1 -1
- package/dist/feedback/feedback-thread.d.ts +173 -0
- package/dist/feedback/feedback-thread.js +264 -0
- package/dist/feedback/feedback-thread.js.map +1 -0
- package/dist/feedback.d.ts +2 -1
- package/dist/feedback.js +1 -0
- package/dist/feedback.js.map +1 -1
- package/dist/hooks/use-authed-src.d.ts +71 -0
- package/dist/hooks/use-authed-src.js +63 -0
- package/dist/hooks/use-authed-src.js.map +1 -0
- package/dist/hooks/use-file-drop.d.ts +49 -2
- package/dist/hooks/use-hotkey.d.ts +59 -0
- package/dist/hooks/use-hotkey.js +105 -0
- package/dist/hooks/use-hotkey.js.map +1 -0
- package/dist/hooks/use-search-param-state.d.ts +83 -0
- package/dist/hooks/use-search-param-state.js +94 -0
- package/dist/hooks/use-search-param-state.js.map +1 -0
- package/dist/i18n/defaults.d.ts +15 -4
- package/dist/i18n/defaults.js +31 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +46 -312
- package/dist/i18n/kit-labels.js +20 -5
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/de-CH-informal.d.ts +15 -4
- package/dist/i18n/locales/de-CH.d.ts +15 -4
- package/dist/i18n/locales/de-informal.d.ts +15 -4
- package/dist/i18n/locales/de.d.ts +15 -4
- package/dist/i18n/locales/de.js +164 -3
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +15 -4
- package/dist/i18n/locales/es.js +161 -3
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +15 -4
- package/dist/i18n/locales/fr.js +161 -3
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +15 -4
- package/dist/i18n/locales/hu.js +161 -3
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +15 -4
- package/dist/i18n/locales/it.js +161 -3
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +15 -4
- package/dist/i18n/locales/zh.js +161 -3
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.d.ts +39 -19
- package/dist/index.js +40 -1
- package/dist/index.js.map +1 -1
- package/dist/kit-labels-Mz8zZHIF.d.ts +1744 -0
- package/dist/lib/format.d.ts +162 -0
- package/dist/lib/format.js +151 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/qr-encode.d.ts +44 -0
- package/dist/lib/qr-encode.js +338 -0
- package/dist/lib/qr-encode.js.map +1 -0
- package/dist/rhf/fields.d.ts +283 -0
- package/dist/rhf/fields.js +631 -0
- package/dist/rhf/fields.js.map +1 -0
- package/dist/rhf/form.d.ts +49 -1
- package/dist/rhf/line-items.d.ts +31 -0
- package/dist/rhf/line-items.js +59 -0
- package/dist/rhf/line-items.js.map +1 -0
- package/dist/rhf.d.ts +61 -1
- package/dist/rhf.js +2 -0
- package/dist/rhf.js.map +1 -1
- package/dist/search/command-palette.js +20 -14
- package/dist/search/command-palette.js.map +1 -1
- package/dist/shell/app-shell.d.ts +99 -2
- package/dist/shell/app-shell.js +120 -57
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/auth-layout.d.ts +74 -0
- package/dist/shell/auth-layout.js +97 -0
- package/dist/shell/auth-layout.js.map +1 -0
- package/dist/shell/top-bar-brand.d.ts +81 -0
- package/dist/shell/top-bar-brand.js +47 -0
- package/dist/shell/top-bar-brand.js.map +1 -0
- package/dist/shell/topbar-action-menu.d.ts +21 -4
- package/dist/shell/topbar-action-menu.js +18 -2
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell.d.ts +56 -1
- package/dist/shell.js +2 -0
- package/dist/shell.js.map +1 -1
- package/dist/tour/tour.js +10 -4
- package/dist/tour/tour.js.map +1 -1
- package/dist/wizard/stepper-nav.d.ts +48 -1
- package/dist/wizard/use-wizard.js +4 -2
- package/dist/wizard/use-wizard.js.map +1 -1
- package/dist/wizard/wizard-context.d.ts +24 -1
- package/dist/wizard/wizard-context.js +19 -2
- package/dist/wizard/wizard-context.js.map +1 -1
- package/dist/wizard/wizard-step.d.ts +30 -5
- package/dist/wizard/wizard-step.js +34 -3
- package/dist/wizard/wizard-step.js.map +1 -1
- package/dist/wizard.d.ts +50 -3
- package/package.json +6 -6
- package/src/chart.ts +4 -0
- package/src/components/account-settings-labels.ts +190 -0
- package/src/components/account-settings.tsx +110 -63
- package/src/components/amount-input.tsx +109 -10
- package/src/components/authed-image.tsx +190 -0
- package/src/components/breadcrumbs.tsx +8 -2
- package/src/components/bulk-action-bar.tsx +16 -3
- package/src/components/button-group.tsx +7 -2
- package/src/components/calendar-heatmap.tsx +105 -10
- package/src/components/chart.tsx +19 -8
- package/src/components/chip.tsx +14 -4
- package/src/components/choice-card.tsx +136 -25
- package/src/components/combobox-core.tsx +33 -9
- package/src/components/combobox.tsx +33 -9
- package/src/components/copy-button.tsx +3 -2
- package/src/components/data-table-cells.tsx +119 -0
- package/src/components/data-table-filter-popover.tsx +13 -5
- package/src/components/data-table-filters.ts +77 -0
- package/src/components/data-table-labels.ts +23 -0
- package/src/components/data-table.tsx +230 -13
- package/src/components/date-picker.tsx +19 -3
- package/src/components/description-list.tsx +52 -3
- package/src/components/entity-combobox.tsx +25 -7
- package/src/components/error-boundary.tsx +640 -0
- package/src/components/field-sync.tsx +48 -40
- package/src/components/field.tsx +56 -5
- package/src/components/floating-panel.tsx +20 -7
- package/src/components/form-actions.tsx +191 -0
- package/src/components/full-bleed-dialog.tsx +4 -0
- package/src/components/hover-menu.tsx +26 -17
- package/src/components/image-grid.tsx +181 -0
- package/src/components/lightbox.tsx +374 -0
- package/src/components/line-items.tsx +385 -0
- package/src/components/list.tsx +82 -19
- package/src/components/loading-state.tsx +47 -0
- package/src/components/menu-item.tsx +7 -2
- package/src/components/mini-calendar.tsx +72 -3
- package/src/components/modal.tsx +65 -3
- package/src/components/month-picker.tsx +181 -26
- package/src/components/multi-entity-combobox.tsx +27 -7
- package/src/components/nav-pills.tsx +8 -1
- package/src/components/number-field.tsx +15 -10
- package/src/components/number-input.tsx +17 -1
- package/src/components/numpad-sheet.tsx +6 -1
- package/src/components/page-header.tsx +42 -5
- package/src/components/passkeys-setting.tsx +331 -0
- package/src/components/picker-sheet.tsx +10 -1
- package/src/components/pie-chart-labels.ts +32 -0
- package/src/components/pie-chart.tsx +479 -0
- package/src/components/popover.tsx +3 -0
- package/src/components/progress-bar.tsx +129 -19
- package/src/components/qr-code.tsx +83 -0
- package/src/components/search-field.tsx +20 -4
- package/src/components/signed-amount.tsx +295 -0
- package/src/components/skeleton.tsx +21 -3
- package/src/components/stat-tile.tsx +11 -3
- package/src/components/swipeable-row.tsx +7 -7
- package/src/components/table.tsx +102 -13
- package/src/components/text-link.tsx +356 -0
- package/src/components/text.tsx +46 -2
- package/src/components/toggle-group.tsx +93 -20
- package/src/components/toggle-legend.tsx +108 -2
- package/src/components/tooltip.tsx +79 -8
- package/src/components/ui.tsx +707 -49
- package/src/components/use-table-state.ts +265 -33
- package/src/data-table.ts +10 -0
- package/src/feedback/feedback-attachment.tsx +10 -7
- package/src/feedback/feedback-dialog.tsx +49 -7
- package/src/feedback/feedback-inbox.tsx +7 -0
- package/src/feedback/feedback-thread.tsx +510 -0
- package/src/feedback.ts +1 -0
- package/src/hooks/use-authed-src.ts +161 -0
- package/src/hooks/use-hotkey.ts +172 -0
- package/src/hooks/use-search-param-state.ts +187 -0
- package/src/i18n/defaults.ts +30 -0
- package/src/i18n/kit-labels.tsx +118 -8
- package/src/i18n/locales/de.ts +161 -0
- package/src/i18n/locales/es.ts +158 -0
- package/src/i18n/locales/fr.ts +161 -0
- package/src/i18n/locales/hu.ts +159 -0
- package/src/i18n/locales/it.ts +159 -0
- package/src/i18n/locales/zh.ts +158 -0
- package/src/index.ts +59 -0
- package/src/lib/format.ts +348 -0
- package/src/lib/qr-encode.ts +420 -0
- package/src/rhf/fields.tsx +1135 -0
- package/src/rhf/line-items.tsx +130 -0
- package/src/rhf.ts +6 -0
- package/src/search/command-palette.tsx +29 -19
- package/src/shell/app-shell.tsx +153 -3
- package/src/shell/auth-layout.tsx +190 -0
- package/src/shell/top-bar-brand.tsx +76 -0
- package/src/shell/topbar-action-menu.tsx +32 -4
- package/src/shell.ts +2 -0
- package/src/tour/tour.tsx +16 -5
- package/src/wizard/use-wizard.ts +8 -4
- package/src/wizard/wizard-context.tsx +41 -1
- package/src/wizard/wizard-step.tsx +75 -6
- package/tokens.css +12 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { createElement } from "react";
|
|
4
|
-
import { Fragment as Fragment2, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { Fragment as Fragment2, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { createPortal } from "react-dom";
|
|
6
6
|
import {
|
|
7
7
|
ArrowDown,
|
|
@@ -10,9 +10,11 @@ import {
|
|
|
10
10
|
ChevronDown,
|
|
11
11
|
ChevronRight,
|
|
12
12
|
Filter,
|
|
13
|
+
Pencil,
|
|
14
|
+
Trash2,
|
|
13
15
|
X
|
|
14
16
|
} from "lucide-react";
|
|
15
|
-
import { Card, Spinner } from "./ui.js";
|
|
17
|
+
import { Card, IconButton, Spinner } from "./ui.js";
|
|
16
18
|
import { cn } from "../lib/cn.js";
|
|
17
19
|
import {
|
|
18
20
|
defaultFilterState,
|
|
@@ -52,6 +54,22 @@ function dataAttrsOf(props) {
|
|
|
52
54
|
for (const [k, v] of Object.entries(props)) if (k.startsWith("data-") && k !== "data-col") out[k] = v;
|
|
53
55
|
return out;
|
|
54
56
|
}
|
|
57
|
+
const ROW_ACTIONS_KEY = "__rowActions";
|
|
58
|
+
function resolveRowAction(action, index, labels) {
|
|
59
|
+
const tone = action.tone ?? (action.kind === "delete" ? "danger" : "default");
|
|
60
|
+
return {
|
|
61
|
+
key: action.kind ?? `${index}:${action.label ?? ""}`,
|
|
62
|
+
label: action.label ?? (action.kind === "edit" ? labels.edit : action.kind === "delete" ? labels.delete : ""),
|
|
63
|
+
icon: action.icon ?? (action.kind === "edit" ? /* @__PURE__ */ jsx(Pencil, {}) : action.kind === "delete" ? /* @__PURE__ */ jsx(Trash2, {}) : null),
|
|
64
|
+
tone,
|
|
65
|
+
swipe: action.swipe ?? (tone === "danger" ? "start" : "end"),
|
|
66
|
+
action
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
async function runRowAction(action, row) {
|
|
70
|
+
if (action.confirm && !await action.confirm(row)) return;
|
|
71
|
+
action.onAction(row);
|
|
72
|
+
}
|
|
55
73
|
function physicalSwipe(actions, dir) {
|
|
56
74
|
const rtl = dir === "rtl";
|
|
57
75
|
return {
|
|
@@ -76,10 +94,14 @@ function cleanAttrs(attrs) {
|
|
|
76
94
|
for (const [k, v] of Object.entries(attrs)) if (v !== void 0) out[k] = v;
|
|
77
95
|
return out;
|
|
78
96
|
}
|
|
79
|
-
function columnLabel(col) {
|
|
97
|
+
function columnLabel(col, labels) {
|
|
98
|
+
if (col.key === ROW_ACTIONS_KEY && labels) return labels.actions;
|
|
80
99
|
return typeof col.header === "string" ? col.header : col.key;
|
|
81
100
|
}
|
|
82
101
|
const OWN_CONTROL = 'a[href],button,input,select,textarea,label,summary,[role="button"],[role="link"],[role="checkbox"],[role="switch"],[role="menuitem"],[role="option"],[contenteditable=""],[contenteditable="true"],[tabindex]:not([tabindex="-1"])';
|
|
102
|
+
function fromOutside(target, row) {
|
|
103
|
+
return !(target instanceof Node) || !row.contains(target);
|
|
104
|
+
}
|
|
83
105
|
function fromOwnControl(target, row) {
|
|
84
106
|
if (!(target instanceof Element)) return false;
|
|
85
107
|
const hit = target.closest(OWN_CONTROL);
|
|
@@ -114,9 +136,11 @@ function RowLink({
|
|
|
114
136
|
draggable: false,
|
|
115
137
|
className,
|
|
116
138
|
onClickCapture: (e) => {
|
|
139
|
+
if (fromOutside(e.target, e.currentTarget)) return;
|
|
117
140
|
if (isPlainLeftClick(e)) e.preventDefault();
|
|
118
141
|
},
|
|
119
142
|
onClick: (e) => {
|
|
143
|
+
if (fromOutside(e.target, e.currentTarget)) return;
|
|
120
144
|
if (!isPlainLeftClick(e)) {
|
|
121
145
|
e.stopPropagation();
|
|
122
146
|
return;
|
|
@@ -131,7 +155,7 @@ import { DEFAULT_PERSIST_PREFIX, useTableState } from "./use-table-state.js";
|
|
|
131
155
|
import { useMobileReveal } from "./use-mobile-reveal.js";
|
|
132
156
|
function DataTable({
|
|
133
157
|
rows,
|
|
134
|
-
columns,
|
|
158
|
+
columns: columnsProp,
|
|
135
159
|
rowKey,
|
|
136
160
|
defaultPageSize = 25,
|
|
137
161
|
onRowClick,
|
|
@@ -168,7 +192,9 @@ function DataTable({
|
|
|
168
192
|
resizable: resizableProp,
|
|
169
193
|
multiSort: multiSortProp,
|
|
170
194
|
frame = true,
|
|
171
|
-
className
|
|
195
|
+
className,
|
|
196
|
+
rowActions,
|
|
197
|
+
toolbar
|
|
172
198
|
}) {
|
|
173
199
|
const compact = density === "compact";
|
|
174
200
|
const minimal = chrome === "minimal";
|
|
@@ -189,6 +215,54 @@ function DataTable({
|
|
|
189
215
|
[labelOverrides, labelsProp]
|
|
190
216
|
);
|
|
191
217
|
const locale = useKitLocale(localeProp);
|
|
218
|
+
const rowActionsFor = useCallback(
|
|
219
|
+
(row) => rowActions ? (typeof rowActions === "function" ? rowActions(row) : rowActions).filter((a) => !a.hidden?.(row)).map((a, i) => resolveRowAction(a, i, labels)) : [],
|
|
220
|
+
[rowActions, labels]
|
|
221
|
+
);
|
|
222
|
+
const columns = useMemo(
|
|
223
|
+
() => rowActions ? [
|
|
224
|
+
...columnsProp,
|
|
225
|
+
{
|
|
226
|
+
key: ROW_ACTIONS_KEY,
|
|
227
|
+
header: /* @__PURE__ */ jsx("span", { className: "sr-only", children: labels.actions }),
|
|
228
|
+
cell: (row) => /* @__PURE__ */ jsx("div", { className: "flex items-center justify-end gap-0.5", children: rowActionsFor(row).map((a) => /* @__PURE__ */ jsx(
|
|
229
|
+
IconButton,
|
|
230
|
+
{
|
|
231
|
+
size: density === "compact" ? "2xs" : "xs",
|
|
232
|
+
label: a.label,
|
|
233
|
+
tone: a.tone === "danger" ? "danger" : void 0,
|
|
234
|
+
disabledReason: a.action.disabledReason?.(row),
|
|
235
|
+
stopPropagation: true,
|
|
236
|
+
onClick: () => void runRowAction(a.action, row),
|
|
237
|
+
children: a.icon
|
|
238
|
+
},
|
|
239
|
+
a.key
|
|
240
|
+
)) }),
|
|
241
|
+
className: "w-px whitespace-nowrap text-end",
|
|
242
|
+
headClassName: "w-px",
|
|
243
|
+
// On a phone the same actions are the card's swipes.
|
|
244
|
+
mobileHidden: true,
|
|
245
|
+
noRowLink: true
|
|
246
|
+
}
|
|
247
|
+
] : columnsProp,
|
|
248
|
+
[columnsProp, rowActions, rowActionsFor, labels.actions, density]
|
|
249
|
+
);
|
|
250
|
+
const swipesFromActions = (row) => {
|
|
251
|
+
const swipes = rowActionsFor(row).filter((a) => a.swipe && !a.action.disabledReason?.(row));
|
|
252
|
+
if (!swipes.length) return null;
|
|
253
|
+
const toSwipe = (a) => ({
|
|
254
|
+
label: a.label,
|
|
255
|
+
icon: a.icon,
|
|
256
|
+
onCommit: () => void runRowAction(a.action, row),
|
|
257
|
+
className: a.tone === "danger" ? "bg-[var(--danger)]" : "bg-[var(--brand)]",
|
|
258
|
+
armedClassName: a.tone === "danger" ? "bg-[var(--danger-hover)]" : "bg-[var(--brand-hover)]"
|
|
259
|
+
});
|
|
260
|
+
return {
|
|
261
|
+
start: swipes.filter((a) => a.swipe === "start").map(toSwipe),
|
|
262
|
+
end: swipes.filter((a) => a.swipe === "end").map(toSwipe)
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
const swipeActionsFor = mobileSwipeActions ?? (rowActions ? swipesFromActions : void 0);
|
|
192
266
|
const { announce, regionProps } = useAnnounce();
|
|
193
267
|
const {
|
|
194
268
|
sorts,
|
|
@@ -291,7 +365,7 @@ function DataTable({
|
|
|
291
365
|
});
|
|
292
366
|
if (onSortsChange) onSortsChange(next);
|
|
293
367
|
else setInternalSorts(next);
|
|
294
|
-
const name = col ? columnLabel(col) : key;
|
|
368
|
+
const name = col ? columnLabel(col, labels) : key;
|
|
295
369
|
const entry = next.find((s) => s.key === key);
|
|
296
370
|
announce(
|
|
297
371
|
!entry ? labels.sortCleared(name) : entry.dir === "asc" ? labels.sortedAscending(name) : labels.sortedDescending(name)
|
|
@@ -443,7 +517,7 @@ function DataTable({
|
|
|
443
517
|
const visibleCount = visibleColumns.length;
|
|
444
518
|
const totalCount = columns.length;
|
|
445
519
|
const totalColSpan = visibleCount + (selection ? 1 : 0);
|
|
446
|
-
const columnsCountLabel = labels.columnsCount(visibleCount, totalCount);
|
|
520
|
+
const columnsCountLabel = rowActions ? labels.columnsCount(visibleCount - 1, totalCount - 1) : labels.columnsCount(visibleCount, totalCount);
|
|
447
521
|
const isMdUp = useMediaQuery("(min-width: 768px)", true);
|
|
448
522
|
const mobileColumns = visibleColumns.filter((c) => !c.mobileHidden);
|
|
449
523
|
const mobilePrimaryCol = mobileColumns.find((c) => c.mobilePrimary) ?? mobileColumns[0] ?? null;
|
|
@@ -495,7 +569,7 @@ function DataTable({
|
|
|
495
569
|
const tint = rowClassName?.(row);
|
|
496
570
|
const interactive = !!onRowClick;
|
|
497
571
|
const opensDetail = interactive && !!expandedRow;
|
|
498
|
-
const swipeActions =
|
|
572
|
+
const swipeActions = swipeActionsFor?.(row);
|
|
499
573
|
const swipe = swipeActions ? physicalSwipe(swipeActions, mobileDir) : null;
|
|
500
574
|
const swipeEnabled = !!swipe && !expanded;
|
|
501
575
|
const href = mobileCardLinkable ? rowHref?.(row) : void 0;
|
|
@@ -576,23 +650,31 @@ function DataTable({
|
|
|
576
650
|
children: cardInner
|
|
577
651
|
}
|
|
578
652
|
)
|
|
579
|
-
) :
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
653
|
+
) : (
|
|
654
|
+
/* eslint-disable-next-line jsx-a11y/no-static-element-interactions -- the handlers are
|
|
655
|
+
only attached when `interactive`, and then so are role="button", tabIndex 0 and the
|
|
656
|
+
Enter/Space handler below; the rule cannot follow the conditional role. */
|
|
657
|
+
/* @__PURE__ */ jsx(
|
|
658
|
+
"div",
|
|
659
|
+
{
|
|
660
|
+
role: interactive ? "button" : void 0,
|
|
661
|
+
tabIndex: interactive ? 0 : void 0,
|
|
662
|
+
onClick: interactive ? (e) => {
|
|
663
|
+
if (fromOutside(e.target, e.currentTarget)) return;
|
|
589
664
|
onRowClick(row);
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
665
|
+
} : void 0,
|
|
666
|
+
onKeyDown: interactive ? (e) => {
|
|
667
|
+
if (e.target !== e.currentTarget) return;
|
|
668
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
669
|
+
e.preventDefault();
|
|
670
|
+
onRowClick(row);
|
|
671
|
+
}
|
|
672
|
+
} : void 0,
|
|
673
|
+
"aria-expanded": expandedRow ? expanded : void 0,
|
|
674
|
+
className: cardClass,
|
|
675
|
+
children: cardInner
|
|
676
|
+
}
|
|
677
|
+
)
|
|
596
678
|
);
|
|
597
679
|
return /* @__PURE__ */ jsxs("li", { className: cn(tint), ...cleanAttrs(rowAttributes?.(row)), children: [
|
|
598
680
|
swipeEnabled ? /* @__PURE__ */ jsx(SwipeableRow, { enabled: true, left: swipe.left, right: swipe.right, children: body }) : body,
|
|
@@ -630,6 +712,17 @@ function DataTable({
|
|
|
630
712
|
),
|
|
631
713
|
children: [
|
|
632
714
|
/* @__PURE__ */ jsx("span", { ...regionProps }),
|
|
715
|
+
toolbar != null && toolbar !== false && /* @__PURE__ */ jsx(
|
|
716
|
+
"div",
|
|
717
|
+
{
|
|
718
|
+
"data-table-toolbar": "",
|
|
719
|
+
className: cn(
|
|
720
|
+
"flex flex-wrap items-center gap-2",
|
|
721
|
+
frame ? cn("border-b border-[var(--border)]", compact ? "px-2 py-1.5" : "px-3 py-2") : "pb-3"
|
|
722
|
+
),
|
|
723
|
+
children: toolbar
|
|
724
|
+
}
|
|
725
|
+
),
|
|
633
726
|
!isMdUp && /* @__PURE__ */ jsxs("div", { ref: mobileRootRef, children: [
|
|
634
727
|
(!isServer || onFiltersChange) && /* @__PURE__ */ jsx(
|
|
635
728
|
MobileFilters,
|
|
@@ -667,7 +760,7 @@ function DataTable({
|
|
|
667
760
|
"text-center text-[var(--text-muted)]",
|
|
668
761
|
compact ? "px-3 py-3 text-xs" : "px-4 py-6 text-sm"
|
|
669
762
|
),
|
|
670
|
-
children: isLoading ? /* @__PURE__ */ jsx(LoadingText, { label: labels.loading }) : empty ??
|
|
763
|
+
children: isLoading ? /* @__PURE__ */ jsx(LoadingText, { label: labels.loading }) : empty ?? labels.empty
|
|
671
764
|
}
|
|
672
765
|
),
|
|
673
766
|
canRevealMoreMobile && /* @__PURE__ */ jsx(
|
|
@@ -842,7 +935,10 @@ function DataTable({
|
|
|
842
935
|
]
|
|
843
936
|
}
|
|
844
937
|
),
|
|
845
|
-
resizable && /*
|
|
938
|
+
resizable && col.key !== ROW_ACTIONS_KEY && /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- a
|
|
939
|
+
pointer-only drag handle for a visual preference (column width); it is
|
|
940
|
+
deliberately not a tab stop, and no content or action depends on it. */
|
|
941
|
+
/* @__PURE__ */ jsx(
|
|
846
942
|
"span",
|
|
847
943
|
{
|
|
848
944
|
role: "separator",
|
|
@@ -907,6 +1003,7 @@ function DataTable({
|
|
|
907
1003
|
),
|
|
908
1004
|
onClick: rowInteractive ? (e) => {
|
|
909
1005
|
if (fromOwnControl(e.target, e.currentTarget)) return;
|
|
1006
|
+
if (fromOutside(e.target, e.currentTarget)) return;
|
|
910
1007
|
if (selection && canSelect(row)) {
|
|
911
1008
|
if (e.shiftKey) {
|
|
912
1009
|
window.getSelection?.()?.removeAllRanges();
|
|
@@ -992,7 +1089,7 @@ function DataTable({
|
|
|
992
1089
|
{
|
|
993
1090
|
colSpan: totalColSpan,
|
|
994
1091
|
className: cn("text-center text-[var(--text-muted)]", compact ? "px-2 py-2" : "px-3 py-4"),
|
|
995
|
-
children: isLoading ? /* @__PURE__ */ jsx(LoadingText, { label: labels.loading }) : empty ??
|
|
1092
|
+
children: isLoading ? /* @__PURE__ */ jsx(LoadingText, { label: labels.loading }) : empty ?? labels.empty
|
|
996
1093
|
}
|
|
997
1094
|
) })
|
|
998
1095
|
]
|
|
@@ -1077,6 +1174,7 @@ function DataTable({
|
|
|
1077
1174
|
}
|
|
1078
1175
|
),
|
|
1079
1176
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-0.5", children: columns.map((col) => {
|
|
1177
|
+
if (col.key === ROW_ACTIONS_KEY) return null;
|
|
1080
1178
|
const checked = !hiddenCols.has(col.key);
|
|
1081
1179
|
const headerLabel = columnLabel(col);
|
|
1082
1180
|
return /* @__PURE__ */ jsxs(
|