@zonsh/ui 0.0.0 → 0.4.1
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/LICENSE +43 -0
- package/README.md +81 -1
- package/assets/illustrations/drawing/bracket-construction-dark.svg +77 -0
- package/assets/illustrations/drawing/bracket-construction-filled-dark.svg +50 -0
- package/assets/illustrations/drawing/bracket-construction-filled.svg +50 -0
- package/assets/illustrations/drawing/bracket-construction.svg +77 -0
- package/assets/illustrations/drawing/crescent-dark.svg +28 -0
- package/assets/illustrations/drawing/crescent-guides-dark.svg +33 -0
- package/assets/illustrations/drawing/crescent-guides.svg +33 -0
- package/assets/illustrations/drawing/crescent.svg +28 -0
- package/assets/illustrations/drawing/eclipse-dark.svg +187 -0
- package/assets/illustrations/drawing/eclipse-guides-dark.svg +191 -0
- package/assets/illustrations/drawing/eclipse-guides.svg +191 -0
- package/assets/illustrations/drawing/eclipse.svg +187 -0
- package/assets/illustrations/drawing/elevation-guides-dark.svg +31 -0
- package/assets/illustrations/drawing/elevation-guides-plain-dark.svg +9 -0
- package/assets/illustrations/drawing/elevation-guides-plain.svg +9 -0
- package/assets/illustrations/drawing/elevation-guides.svg +31 -0
- package/assets/illustrations/drawing/horizon-dark.svg +30 -0
- package/assets/illustrations/drawing/horizon.svg +30 -0
- package/assets/illustrations/drawing/nib-study-dark.svg +107 -0
- package/assets/illustrations/drawing/nib-study-plain-dark.svg +93 -0
- package/assets/illustrations/drawing/nib-study-plain.svg +93 -0
- package/assets/illustrations/drawing/nib-study.svg +107 -0
- package/assets/illustrations/editorial/assistant-640.webp +0 -0
- package/assets/illustrations/editorial/assistant.webp +0 -0
- package/assets/illustrations/editorial/automation-640.webp +0 -0
- package/assets/illustrations/editorial/automation.webp +0 -0
- package/assets/illustrations/editorial/bracket-left-640.webp +0 -0
- package/assets/illustrations/editorial/bracket-left.webp +0 -0
- package/assets/illustrations/editorial/bracket-right-640.webp +0 -0
- package/assets/illustrations/editorial/bracket-right.webp +0 -0
- package/assets/illustrations/editorial/custom-software-640.webp +0 -0
- package/assets/illustrations/editorial/custom-software.webp +0 -0
- package/assets/illustrations/editorial/digitalization-640.webp +0 -0
- package/assets/illustrations/editorial/digitalization.webp +0 -0
- package/assets/illustrations/editorial/integration-640.webp +0 -0
- package/assets/illustrations/editorial/integration.webp +0 -0
- package/assets/illustrations/editorial/problem-640.webp +0 -0
- package/assets/illustrations/editorial/problem.webp +0 -0
- package/assets/illustrations/editorial/process-analysis-640.webp +0 -0
- package/assets/illustrations/editorial/process-analysis.webp +0 -0
- package/assets/illustrations/editorial/process-concept-640.webp +0 -0
- package/assets/illustrations/editorial/process-concept.webp +0 -0
- package/assets/illustrations/editorial/process-development-640.webp +0 -0
- package/assets/illustrations/editorial/process-development.webp +0 -0
- package/assets/illustrations/editorial/process-discovery-640.webp +0 -0
- package/assets/illustrations/editorial/process-discovery.webp +0 -0
- package/assets/illustrations/editorial/process-maintenance-640.webp +0 -0
- package/assets/illustrations/editorial/process-maintenance.webp +0 -0
- package/assets/illustrations/editorial/process-prototype-640.webp +0 -0
- package/assets/illustrations/editorial/process-prototype.webp +0 -0
- package/assets/illustrations/editorial/process-testing-640.webp +0 -0
- package/assets/illustrations/editorial/process-testing.webp +0 -0
- package/assets/illustrations/iso/automation-dark.svg +6 -0
- package/assets/illustrations/iso/automation.svg +6 -0
- package/assets/illustrations/iso/bar-chart-dark.svg +6 -0
- package/assets/illustrations/iso/bar-chart.svg +6 -0
- package/assets/illustrations/iso/brackets-classic-dark.svg +6 -0
- package/assets/illustrations/iso/brackets-classic.svg +6 -0
- package/assets/illustrations/iso/brackets-dark.svg +6 -0
- package/assets/illustrations/iso/brackets.svg +6 -0
- package/assets/illustrations/iso/city-dark.svg +6 -0
- package/assets/illustrations/iso/city.svg +6 -0
- package/assets/illustrations/iso/conveyor-dark.svg +6 -0
- package/assets/illustrations/iso/conveyor.svg +6 -0
- package/assets/illustrations/iso/database-dark.svg +6 -0
- package/assets/illustrations/iso/database.svg +6 -0
- package/assets/illustrations/iso/documents-dark.svg +6 -0
- package/assets/illustrations/iso/documents.svg +6 -0
- package/assets/illustrations/iso/inbox-dark.svg +6 -0
- package/assets/illustrations/iso/inbox.svg +6 -0
- package/assets/illustrations/iso/laptop-dark.svg +6 -0
- package/assets/illustrations/iso/laptop.svg +6 -0
- package/assets/illustrations/iso/monitor-dark.svg +6 -0
- package/assets/illustrations/iso/monitor.svg +6 -0
- package/assets/illustrations/iso/pipeline-dark.svg +6 -0
- package/assets/illustrations/iso/pipeline.svg +6 -0
- package/assets/illustrations/iso/platform-dark.svg +6 -0
- package/assets/illustrations/iso/platform.svg +6 -0
- package/assets/illustrations/iso/server-dark.svg +6 -0
- package/assets/illustrations/iso/server.svg +6 -0
- package/assets/illustrations/iso/spreadsheet-dark.svg +6 -0
- package/assets/illustrations/iso/spreadsheet.svg +6 -0
- package/assets/illustrations/iso/timeline-dark.svg +6 -0
- package/assets/illustrations/iso/timeline.svg +6 -0
- package/assets/illustrations/sheet/construction.svg +115 -0
- package/assets/illustrations/sheet/crescent.svg +40 -0
- package/assets/illustrations/sheet/limb.svg +42 -0
- package/assets/illustrations/sheet/stress-axis.svg +119 -0
- package/assets/illustrations/sheet/totality.svg +215 -0
- package/assets/illustrations/sheet/vertical-metrics.svg +43 -0
- package/assets/logo-left.svg +1 -0
- package/assets/logo-right.svg +1 -0
- package/assets/logo.svg +1 -0
- package/dist/components/_overlay.d.ts +47 -0
- package/dist/components/_overlay.js +59 -0
- package/dist/components/accordion.d.ts +32 -0
- package/dist/components/accordion.js +39 -0
- package/dist/components/alert-dialog.d.ts +45 -0
- package/dist/components/alert-dialog.js +56 -0
- package/dist/components/alert.d.ts +35 -0
- package/dist/components/alert.js +42 -0
- package/dist/components/ascii-field.d.ts +34 -0
- package/dist/components/ascii-field.js +410 -0
- package/dist/components/aspect-ratio.d.ts +14 -0
- package/dist/components/aspect-ratio.js +17 -0
- package/dist/components/avatar.d.ts +42 -0
- package/dist/components/avatar.js +55 -0
- package/dist/components/badge.d.ts +70 -0
- package/dist/components/badge.js +62 -0
- package/dist/components/bottom-nav.d.ts +86 -0
- package/dist/components/bottom-nav.js +175 -0
- package/dist/components/breadcrumb.d.ts +31 -0
- package/dist/components/breadcrumb.js +37 -0
- package/dist/components/button-group.d.ts +30 -0
- package/dist/components/button-group.js +47 -0
- package/dist/components/button.d.ts +53 -0
- package/dist/components/button.js +130 -0
- package/dist/components/calendar.d.ts +26 -0
- package/dist/components/calendar.js +179 -0
- package/dist/components/card.d.ts +42 -0
- package/dist/components/card.js +76 -0
- package/dist/components/carousel.d.ts +109 -0
- package/dist/components/carousel.js +231 -0
- package/dist/components/chart.d.ts +189 -0
- package/dist/components/chart.js +323 -0
- package/dist/components/checkbox.d.ts +23 -0
- package/dist/components/checkbox.js +43 -0
- package/dist/components/code-block.d.ts +55 -0
- package/dist/components/code-block.js +100 -0
- package/dist/components/collapsible.d.ts +20 -0
- package/dist/components/collapsible.js +32 -0
- package/dist/components/color-picker.d.ts +107 -0
- package/dist/components/color-picker.js +428 -0
- package/dist/components/combobox.d.ts +99 -0
- package/dist/components/combobox.js +172 -0
- package/dist/components/command.d.ts +132 -0
- package/dist/components/command.js +257 -0
- package/dist/components/context-menu.d.ts +29 -0
- package/dist/components/context-menu.js +35 -0
- package/dist/components/conversation.d.ts +36 -0
- package/dist/components/conversation.js +303 -0
- package/dist/components/copy-button.d.ts +55 -0
- package/dist/components/copy-button.js +133 -0
- package/dist/components/data-table.d.ts +235 -0
- package/dist/components/data-table.js +655 -0
- package/dist/components/date-picker.d.ts +160 -0
- package/dist/components/date-picker.js +338 -0
- package/dist/components/dialog.d.ts +57 -0
- package/dist/components/dialog.js +95 -0
- package/dist/components/direction.d.ts +16 -0
- package/dist/components/direction.js +18 -0
- package/dist/components/drawer.d.ts +69 -0
- package/dist/components/drawer.js +79 -0
- package/dist/components/empty.d.ts +31 -0
- package/dist/components/empty.js +50 -0
- package/dist/components/feature-list.d.ts +54 -0
- package/dist/components/feature-list.js +43 -0
- package/dist/components/field.d.ts +34 -0
- package/dist/components/field.js +81 -0
- package/dist/components/file-drop.d.ts +77 -0
- package/dist/components/file-drop.js +258 -0
- package/dist/components/filter-bar.d.ts +153 -0
- package/dist/components/filter-bar.js +334 -0
- package/dist/components/form.d.ts +35 -0
- package/dist/components/form.js +56 -0
- package/dist/components/graph.d.ts +146 -0
- package/dist/components/graph.js +825 -0
- package/dist/components/illustration.d.ts +85 -0
- package/dist/components/illustration.js +165 -0
- package/dist/components/input-group.d.ts +138 -0
- package/dist/components/input-group.js +312 -0
- package/dist/components/input.d.ts +16 -0
- package/dist/components/input.js +25 -0
- package/dist/components/item.d.ts +64 -0
- package/dist/components/item.js +116 -0
- package/dist/components/kbd.d.ts +50 -0
- package/dist/components/kbd.js +45 -0
- package/dist/components/label.d.ts +12 -0
- package/dist/components/label.js +24 -0
- package/dist/components/layout.d.ts +136 -0
- package/dist/components/layout.js +162 -0
- package/dist/components/lightbox.d.ts +100 -0
- package/dist/components/lightbox.js +439 -0
- package/dist/components/locale.d.ts +44 -0
- package/dist/components/locale.js +37 -0
- package/dist/components/logo.d.ts +54 -0
- package/dist/components/logo.js +96 -0
- package/dist/components/menu.d.ts +60 -0
- package/dist/components/menu.js +140 -0
- package/dist/components/menubar.d.ts +62 -0
- package/dist/components/menubar.js +223 -0
- package/dist/components/message.d.ts +42 -0
- package/dist/components/message.js +59 -0
- package/dist/components/meter.d.ts +31 -0
- package/dist/components/meter.js +27 -0
- package/dist/components/money-input.d.ts +80 -0
- package/dist/components/money-input.js +253 -0
- package/dist/components/native-select.d.ts +26 -0
- package/dist/components/native-select.js +35 -0
- package/dist/components/navigation-menu.d.ts +42 -0
- package/dist/components/navigation-menu.js +97 -0
- package/dist/components/number-field.d.ts +55 -0
- package/dist/components/number-field.js +164 -0
- package/dist/components/otp-field.d.ts +48 -0
- package/dist/components/otp-field.js +102 -0
- package/dist/components/pagination.d.ts +37 -0
- package/dist/components/pagination.js +81 -0
- package/dist/components/pdf-viewer.d.ts +134 -0
- package/dist/components/pdf-viewer.js +996 -0
- package/dist/components/phone-input.d.ts +79 -0
- package/dist/components/phone-input.js +282 -0
- package/dist/components/popover.d.ts +33 -0
- package/dist/components/popover.js +48 -0
- package/dist/components/preview-card.d.ts +25 -0
- package/dist/components/preview-card.js +22 -0
- package/dist/components/progress.d.ts +27 -0
- package/dist/components/progress.js +25 -0
- package/dist/components/prompt-input.d.ts +156 -0
- package/dist/components/prompt-input.js +415 -0
- package/dist/components/quote.d.ts +22 -0
- package/dist/components/quote.js +15 -0
- package/dist/components/radio-group.d.ts +18 -0
- package/dist/components/radio-group.js +34 -0
- package/dist/components/rating.d.ts +73 -0
- package/dist/components/rating.js +124 -0
- package/dist/components/reasoning.d.ts +46 -0
- package/dist/components/reasoning.js +73 -0
- package/dist/components/resizable.d.ts +47 -0
- package/dist/components/resizable.js +44 -0
- package/dist/components/response.d.ts +41 -0
- package/dist/components/response.js +566 -0
- package/dist/components/scroll-area.d.ts +33 -0
- package/dist/components/scroll-area.js +31 -0
- package/dist/components/select.d.ts +35 -0
- package/dist/components/select.js +71 -0
- package/dist/components/separator.d.ts +14 -0
- package/dist/components/separator.js +17 -0
- package/dist/components/sidebar.d.ts +163 -0
- package/dist/components/sidebar.js +505 -0
- package/dist/components/site-header.d.ts +93 -0
- package/dist/components/site-header.js +121 -0
- package/dist/components/skeleton.d.ts +31 -0
- package/dist/components/skeleton.js +29 -0
- package/dist/components/slider.d.ts +24 -0
- package/dist/components/slider.js +131 -0
- package/dist/components/sortable.d.ts +178 -0
- package/dist/components/sortable.js +1258 -0
- package/dist/components/sources.d.ts +40 -0
- package/dist/components/sources.js +42 -0
- package/dist/components/spinner.d.ts +48 -0
- package/dist/components/spinner.js +75 -0
- package/dist/components/stat.d.ts +91 -0
- package/dist/components/stat.js +141 -0
- package/dist/components/stepper.d.ts +71 -0
- package/dist/components/stepper.js +101 -0
- package/dist/components/suggestions.d.ts +20 -0
- package/dist/components/suggestions.js +18 -0
- package/dist/components/switch.d.ts +14 -0
- package/dist/components/switch.js +26 -0
- package/dist/components/table.d.ts +172 -0
- package/dist/components/table.js +895 -0
- package/dist/components/tabs.d.ts +25 -0
- package/dist/components/tabs.js +162 -0
- package/dist/components/tag.d.ts +41 -0
- package/dist/components/tag.js +88 -0
- package/dist/components/tags-input.d.ts +56 -0
- package/dist/components/tags-input.js +271 -0
- package/dist/components/textarea.d.ts +13 -0
- package/dist/components/textarea.js +16 -0
- package/dist/components/theme.d.ts +55 -0
- package/dist/components/theme.js +120 -0
- package/dist/components/time-field.d.ts +70 -0
- package/dist/components/time-field.js +450 -0
- package/dist/components/timeline.d.ts +92 -0
- package/dist/components/timeline.js +108 -0
- package/dist/components/tippy.d.ts +48 -0
- package/dist/components/tippy.js +648 -0
- package/dist/components/toast.d.ts +88 -0
- package/dist/components/toast.js +205 -0
- package/dist/components/toggle-group.d.ts +41 -0
- package/dist/components/toggle-group.js +140 -0
- package/dist/components/toggle.d.ts +23 -0
- package/dist/components/toggle.js +35 -0
- package/dist/components/tool-call.d.ts +63 -0
- package/dist/components/tool-call.js +68 -0
- package/dist/components/toolbar.d.ts +17 -0
- package/dist/components/toolbar.js +39 -0
- package/dist/components/tooltip.d.ts +42 -0
- package/dist/components/tooltip.js +47 -0
- package/dist/components/tour.d.ts +127 -0
- package/dist/components/tour.js +648 -0
- package/dist/components/tree.d.ts +75 -0
- package/dist/components/tree.js +649 -0
- package/dist/components/typography.d.ts +134 -0
- package/dist/components/typography.js +176 -0
- package/dist/components/video-player.d.ts +284 -0
- package/dist/components/video-player.js +1392 -0
- package/dist/illustration.d.ts +2 -0
- package/dist/illustration.js +7 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.js +94 -0
- package/dist/lib/cn.d.ts +20 -0
- package/dist/lib/cn.js +38 -0
- package/dist/lib/code-highlight.d.ts +18 -0
- package/dist/lib/code-highlight.js +174 -0
- package/dist/lib/code-theme.d.ts +19 -0
- package/dist/lib/code-theme.js +140 -0
- package/dist/lib/collapse-row.d.ts +9 -0
- package/dist/lib/collapse-row.js +129 -0
- package/dist/lib/digit-roll.d.ts +21 -0
- package/dist/lib/digit-roll.js +31 -0
- package/dist/lib/editorial-assets.d.ts +16 -0
- package/dist/lib/editorial-assets.js +56 -0
- package/dist/lib/field-errors.d.ts +28 -0
- package/dist/lib/field-errors.js +24 -0
- package/dist/lib/field-value.d.ts +13 -0
- package/dist/lib/field-value.js +44 -0
- package/dist/lib/figure/catalog.d.ts +127 -0
- package/dist/lib/figure/catalog.js +130 -0
- package/dist/lib/figure/figures/automation.d.ts +7 -0
- package/dist/lib/figure/figures/automation.js +143 -0
- package/dist/lib/figure/figures/bar-chart.d.ts +7 -0
- package/dist/lib/figure/figures/bar-chart.js +99 -0
- package/dist/lib/figure/figures/brackets-classic.d.ts +11 -0
- package/dist/lib/figure/figures/brackets-classic.js +170 -0
- package/dist/lib/figure/figures/brackets.d.ts +8 -0
- package/dist/lib/figure/figures/brackets.js +84 -0
- package/dist/lib/figure/figures/city.d.ts +7 -0
- package/dist/lib/figure/figures/city.js +93 -0
- package/dist/lib/figure/figures/conveyor.d.ts +7 -0
- package/dist/lib/figure/figures/conveyor.js +97 -0
- package/dist/lib/figure/figures/database.d.ts +7 -0
- package/dist/lib/figure/figures/database.js +65 -0
- package/dist/lib/figure/figures/documents.d.ts +7 -0
- package/dist/lib/figure/figures/documents.js +83 -0
- package/dist/lib/figure/figures/inbox.d.ts +7 -0
- package/dist/lib/figure/figures/inbox.js +92 -0
- package/dist/lib/figure/figures/laptop.d.ts +7 -0
- package/dist/lib/figure/figures/laptop.js +67 -0
- package/dist/lib/figure/figures/monitor.d.ts +7 -0
- package/dist/lib/figure/figures/monitor.js +59 -0
- package/dist/lib/figure/figures/pipeline.d.ts +8 -0
- package/dist/lib/figure/figures/pipeline.js +117 -0
- package/dist/lib/figure/figures/platform.d.ts +7 -0
- package/dist/lib/figure/figures/platform.js +117 -0
- package/dist/lib/figure/figures/server.d.ts +7 -0
- package/dist/lib/figure/figures/server.js +115 -0
- package/dist/lib/figure/figures/spreadsheet.d.ts +7 -0
- package/dist/lib/figure/figures/spreadsheet.js +87 -0
- package/dist/lib/figure/figures/timeline.d.ts +7 -0
- package/dist/lib/figure/figures/timeline.js +65 -0
- package/dist/lib/figure/kernel.d.ts +152 -0
- package/dist/lib/figure/kernel.js +576 -0
- package/dist/lib/figure/parts.d.ts +42 -0
- package/dist/lib/figure/parts.js +126 -0
- package/dist/lib/form-reset.d.ts +11 -0
- package/dist/lib/form-reset.js +22 -0
- package/dist/lib/glide.d.ts +53 -0
- package/dist/lib/glide.js +138 -0
- package/dist/lib/graph-layout.d.ts +58 -0
- package/dist/lib/graph-layout.js +209 -0
- package/dist/lib/illustration-drawings.d.ts +89 -0
- package/dist/lib/illustration-drawings.js +539 -0
- package/dist/lib/illustration-info.d.ts +37 -0
- package/dist/lib/illustration-info.js +22 -0
- package/dist/lib/illustration-library.d.ts +87 -0
- package/dist/lib/illustration-library.js +352 -0
- package/dist/lib/logo-geometry.d.ts +29 -0
- package/dist/lib/logo-geometry.js +67 -0
- package/dist/lib/markdown-guard.d.ts +16 -0
- package/dist/lib/markdown-guard.js +123 -0
- package/dist/lib/merge-refs.d.ts +10 -0
- package/dist/lib/merge-refs.js +26 -0
- package/dist/lib/money.d.ts +73 -0
- package/dist/lib/money.js +343 -0
- package/dist/lib/motion.d.ts +6 -0
- package/dist/lib/motion.js +12 -0
- package/dist/lib/pdf-worker.d.ts +1 -0
- package/dist/lib/pdf-worker.js +6 -0
- package/dist/lib/pdf.d.ts +19 -0
- package/dist/lib/pdf.js +58 -0
- package/dist/lib/phone-countries.d.ts +1 -0
- package/dist/lib/phone-countries.js +281 -0
- package/dist/lib/phone.d.ts +90 -0
- package/dist/lib/phone.js +286 -0
- package/dist/lib/platform.d.ts +38 -0
- package/dist/lib/platform.js +75 -0
- package/dist/lib/room.d.ts +25 -0
- package/dist/lib/room.js +46 -0
- package/dist/lib/row-index.d.ts +15 -0
- package/dist/lib/row-index.js +136 -0
- package/dist/lib/table-fit.d.ts +143 -0
- package/dist/lib/table-fit.js +596 -0
- package/dist/lib/theme-script.d.ts +31 -0
- package/dist/lib/theme-script.js +49 -0
- package/dist/lib/tippy/pixels.d.ts +47 -0
- package/dist/lib/tippy/pixels.js +187 -0
- package/dist/lib/tippy/sprite.d.ts +86 -0
- package/dist/lib/tippy/sprite.js +753 -0
- package/dist/messages/de.d.ts +12 -0
- package/dist/messages/de.js +326 -0
- package/dist/styles/expressive.css +203 -0
- package/dist/styles/fonts.css +145 -0
- package/dist/styles/index.css +207 -0
- package/dist/styles/material.css +317 -0
- package/dist/styles/parts/ai.css +361 -0
- package/dist/styles/parts/brand.css +75 -0
- package/dist/styles/parts/controls.css +774 -0
- package/dist/styles/parts/data.css +222 -0
- package/dist/styles/parts/editorial.css +120 -0
- package/dist/styles/parts/feedback.css +340 -0
- package/dist/styles/parts/foundations.css +166 -0
- package/dist/styles/parts/graph.css +214 -0
- package/dist/styles/parts/inputs.css +261 -0
- package/dist/styles/parts/isometric.css +124 -0
- package/dist/styles/parts/navigation.css +424 -0
- package/dist/styles/parts/overlays.css +250 -0
- package/dist/styles/parts/pdf.css +154 -0
- package/dist/styles/parts/react-flow.css +519 -0
- package/dist/styles/tokens.css +299 -0
- package/dist/vite.d.ts +66 -0
- package/dist/vite.js +29 -0
- package/package.json +183 -5
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Field as BaseField } from "@base-ui/react/field";
|
|
4
|
+
import { FileIcon, UploadIcon, XIcon } from "lucide-react";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { mergeRefs } from "../lib/merge-refs.js";
|
|
8
|
+
import { keyNames, useShortcutKeys } from "../lib/platform.js";
|
|
9
|
+
import { Button } from "./button.js";
|
|
10
|
+
import { Item, ItemActions, ItemContent, ItemDescription, ItemMedia, ItemTitle } from "./item.js";
|
|
11
|
+
import { Kbd, KbdGroup, useKeyNames } from "./kbd.js";
|
|
12
|
+
import { useLocale, useMessages } from "./locale.js";
|
|
13
|
+
const defaultMessages = {
|
|
14
|
+
title: (multiple) => (multiple ? "Drop files here" : "Drop a file here"),
|
|
15
|
+
clickOrPaste: "or click to choose — paste with",
|
|
16
|
+
tap: "or tap to choose",
|
|
17
|
+
hint: (multiple) => `Drop, choose or paste ${multiple ? "files" : "a file"}`,
|
|
18
|
+
remove: (fileName) => `Remove ${fileName}`,
|
|
19
|
+
};
|
|
20
|
+
/** Does `file` match an `accept` list: extensions (`.pdf`), types (`image/png`) and families (`image/*`)? */
|
|
21
|
+
function accepts(file, accept) {
|
|
22
|
+
if (!accept?.trim())
|
|
23
|
+
return true;
|
|
24
|
+
const name = file.name.toLowerCase();
|
|
25
|
+
const type = file.type.toLowerCase();
|
|
26
|
+
return accept.split(",").some((raw) => {
|
|
27
|
+
const token = raw.trim().toLowerCase();
|
|
28
|
+
if (!token)
|
|
29
|
+
return false;
|
|
30
|
+
if (token.startsWith("."))
|
|
31
|
+
return name.endsWith(token);
|
|
32
|
+
if (token.endsWith("/*"))
|
|
33
|
+
return type.startsWith(token.slice(0, -1));
|
|
34
|
+
return type === token;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/** The files in a drop or a paste: `files`, or file items where a browser only lists those. */
|
|
38
|
+
function filesOf(data) {
|
|
39
|
+
if (!data)
|
|
40
|
+
return [];
|
|
41
|
+
if (data.files.length)
|
|
42
|
+
return [...data.files];
|
|
43
|
+
return [...data.items].flatMap((item) => item.kind === "file" ? [item.getAsFile()].filter((f) => !!f) : []);
|
|
44
|
+
}
|
|
45
|
+
/** A field that takes typed text, so a paste while it has focus is meant for it. */
|
|
46
|
+
const takesText = (el) => !!el &&
|
|
47
|
+
(el.isContentEditable ||
|
|
48
|
+
el.matches("textarea, input:not([type=checkbox], [type=radio], [type=button], [type=submit], [type=reset], [type=file], [type=range], [type=color])"));
|
|
49
|
+
/**
|
|
50
|
+
* FileDrop — a place to add files, three ways: drop one or more on it, click it (or press Enter or
|
|
51
|
+
* Space) to choose them in the file picker, or paste them with ⌘V / Ctrl+V while it is focused or
|
|
52
|
+
* under the pointer. A recessed field with a dashed edge and a raised upload well; the edge takes
|
|
53
|
+
* the focus colour while files are dragged over it. It checks `accept`, `maxSize` and `multiple`
|
|
54
|
+
* the same way for all three, and hands what it takes to `onFiles` — show them with
|
|
55
|
+
* `FileDropItem`s.
|
|
56
|
+
*
|
|
57
|
+
* The rule people break: a zone that only takes drops. Dragging needs a mouse and a file manager
|
|
58
|
+
* beside the page; clicking and pasting are how most people add a file.
|
|
59
|
+
*/
|
|
60
|
+
export function FileDrop({ onFiles, onReject, accept, multiple = true, maxSize, disabled = false, title, description, hint, children, className, onKeyDown, onClick, onDragEnter, onDragOver, onDragLeave, onPointerEnter, onPointerLeave, onFocus, onBlur, id, ref, labels, ...props }) {
|
|
61
|
+
const text = useMessages("fileDrop", defaultMessages, labels);
|
|
62
|
+
const zone = React.useRef(null);
|
|
63
|
+
const zoneRefs = React.useMemo(() => mergeRefs(zone, ref), [ref]);
|
|
64
|
+
const input = React.useRef(null);
|
|
65
|
+
const hovered = React.useRef(false);
|
|
66
|
+
const [dragging, setDragging] = React.useState(false);
|
|
67
|
+
const hintId = React.useId();
|
|
68
|
+
const contentId = React.useId();
|
|
69
|
+
// A hint of your own is drawn under the default contents; the default one is only read.
|
|
70
|
+
const hintShown = children == null && hint != null;
|
|
71
|
+
// Disabled by the prop or by a disabled Field, which Base UI sets on the Field's input.
|
|
72
|
+
const locked = React.useRef(disabled);
|
|
73
|
+
// One check for drops, the picker and pastes.
|
|
74
|
+
const take = React.useCallback((files) => {
|
|
75
|
+
if (locked.current || !files.length)
|
|
76
|
+
return;
|
|
77
|
+
const taken = [];
|
|
78
|
+
const rejected = [];
|
|
79
|
+
for (const file of files) {
|
|
80
|
+
if (!accepts(file, accept))
|
|
81
|
+
rejected.push({ file, reason: "type" });
|
|
82
|
+
else if (maxSize != null && file.size > maxSize)
|
|
83
|
+
rejected.push({ file, reason: "size" });
|
|
84
|
+
else if (!multiple && taken.length)
|
|
85
|
+
rejected.push({ file, reason: "count" });
|
|
86
|
+
else
|
|
87
|
+
taken.push(file);
|
|
88
|
+
}
|
|
89
|
+
if (taken.length)
|
|
90
|
+
onFiles(taken);
|
|
91
|
+
if (rejected.length)
|
|
92
|
+
onReject?.(rejected);
|
|
93
|
+
}, [accept, disabled, maxSize, multiple, onFiles, onReject]);
|
|
94
|
+
// Paste: files pasted while the zone has focus, or while the pointer is over it — unless a text
|
|
95
|
+
// field elsewhere has focus (the paste is for it), or something on the way took the paste already.
|
|
96
|
+
React.useEffect(() => {
|
|
97
|
+
if (disabled)
|
|
98
|
+
return;
|
|
99
|
+
const paste = (event) => {
|
|
100
|
+
const el = zone.current;
|
|
101
|
+
const active = document.activeElement;
|
|
102
|
+
if (!el || event.defaultPrevented)
|
|
103
|
+
return;
|
|
104
|
+
if (!(el.contains(active) || (hovered.current && !takesText(active))))
|
|
105
|
+
return;
|
|
106
|
+
const files = filesOf(event.clipboardData);
|
|
107
|
+
if (!files.length)
|
|
108
|
+
return;
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
take(files);
|
|
111
|
+
};
|
|
112
|
+
document.addEventListener("paste", paste);
|
|
113
|
+
return () => document.removeEventListener("paste", paste);
|
|
114
|
+
}, [disabled, take]);
|
|
115
|
+
const open = () => {
|
|
116
|
+
if (!locked.current)
|
|
117
|
+
input.current?.click();
|
|
118
|
+
};
|
|
119
|
+
const hasFiles = (event) => event.dataTransfer.types.includes("Files");
|
|
120
|
+
/*
|
|
121
|
+
* Inside a Field, the zone is its control: the label names it, the description and the error
|
|
122
|
+
* describe it, and an invalid Field marks it. The Field's own input, out of sight and without a
|
|
123
|
+
* name (the files are yours to send), stands in for it in validation: a Form that focuses it, to
|
|
124
|
+
* show an error, has it hand focus on to the zone.
|
|
125
|
+
*/
|
|
126
|
+
return (_jsx(BaseField.Control, { id: id, value: "", disabled: disabled, render: (control) => {
|
|
127
|
+
const { ref: fieldRef, id: controlId, name: _name, value: _value, disabled: fieldDisabled, onChange: fieldChange, onFocus: fieldFocus, onBlur: fieldBlur, onKeyDown: _onKeyDown, className: _className, defaultValue: _defaultValue, autoFocus: _autoFocus, "aria-labelledby": labelledBy, "aria-describedby": describedBy, "aria-invalid": invalid, ...state } = control;
|
|
128
|
+
const off = !!fieldDisabled;
|
|
129
|
+
locked.current = off;
|
|
130
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { ...state, ref: zoneRefs, id: controlId, role: "button", tabIndex: off ? -1 : 0, "aria-disabled": off || undefined, "aria-labelledby": [
|
|
131
|
+
props["aria-label"] ? controlId : null,
|
|
132
|
+
labelledBy,
|
|
133
|
+
contentId,
|
|
134
|
+
hintShown ? hintId : null,
|
|
135
|
+
]
|
|
136
|
+
.filter(Boolean)
|
|
137
|
+
.join(" "), "aria-describedby": [describedBy, hintShown ? null : hintId].filter(Boolean).join(" ") || undefined, "aria-invalid": invalid, "data-slot": "file-drop", "data-dragging": dragging ? "" : undefined, "data-disabled": off ? "" : undefined, className: cn("group/file-drop relative flex min-h-40 w-full cursor-pointer flex-col items-center justify-center gap-1 rounded-control border border-dashed border-field-edge bg-field-surface px-6 py-8 text-center shadow-field focus-ring outline-none select-none", "transition-[background-color,border-color,box-shadow] duration-(--duration) ease-(--ease)", "hover:border-muted-foreground data-dragging:border-control-focus data-dragging:bg-control-hover",
|
|
138
|
+
// A contrast theme keeps neither colour: there, the edge turns solid while files are over it.
|
|
139
|
+
"forced-colors:data-dragging:border-solid",
|
|
140
|
+
// Invalid, it takes the red edge and soft ring of an invalid field.
|
|
141
|
+
"data-invalid:border-destructive data-invalid:shadow-invalid", "data-disabled:pointer-events-none data-disabled:opacity-55", className), onFocus: (event) => {
|
|
142
|
+
onFocus?.(event);
|
|
143
|
+
fieldFocus?.(event);
|
|
144
|
+
}, onBlur: (event) => {
|
|
145
|
+
onBlur?.(event);
|
|
146
|
+
// Focus leaving the zone (not moving to a button inside it) is a blur for the Field.
|
|
147
|
+
if (event.currentTarget.contains(event.relatedTarget))
|
|
148
|
+
return;
|
|
149
|
+
fieldBlur?.(event);
|
|
150
|
+
}, onClick: (event) => {
|
|
151
|
+
onClick?.(event);
|
|
152
|
+
// Clicks on the zone's own controls (a remove button inside custom children) stay theirs.
|
|
153
|
+
if (event.defaultPrevented || event.target.closest("button, a, input"))
|
|
154
|
+
return;
|
|
155
|
+
open();
|
|
156
|
+
}, onKeyDown: (event) => {
|
|
157
|
+
onKeyDown?.(event);
|
|
158
|
+
if (event.defaultPrevented || event.target !== event.currentTarget)
|
|
159
|
+
return;
|
|
160
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
161
|
+
event.preventDefault();
|
|
162
|
+
open();
|
|
163
|
+
}
|
|
164
|
+
}, onDragEnter: (event) => {
|
|
165
|
+
onDragEnter?.(event);
|
|
166
|
+
if (off || !hasFiles(event))
|
|
167
|
+
return;
|
|
168
|
+
event.preventDefault();
|
|
169
|
+
setDragging(true);
|
|
170
|
+
}, onDragOver: (event) => {
|
|
171
|
+
onDragOver?.(event);
|
|
172
|
+
if (off || !hasFiles(event))
|
|
173
|
+
return;
|
|
174
|
+
event.preventDefault();
|
|
175
|
+
event.dataTransfer.dropEffect = "copy";
|
|
176
|
+
setDragging(true);
|
|
177
|
+
}, onDragLeave: (event) => {
|
|
178
|
+
onDragLeave?.(event);
|
|
179
|
+
if (!event.currentTarget.contains(event.relatedTarget))
|
|
180
|
+
setDragging(false);
|
|
181
|
+
}, onDrop: (event) => {
|
|
182
|
+
setDragging(false);
|
|
183
|
+
if (off || !hasFiles(event))
|
|
184
|
+
return;
|
|
185
|
+
event.preventDefault();
|
|
186
|
+
take(filesOf(event.dataTransfer));
|
|
187
|
+
}, onPointerEnter: (event) => {
|
|
188
|
+
onPointerEnter?.(event);
|
|
189
|
+
hovered.current = true;
|
|
190
|
+
}, onPointerLeave: (event) => {
|
|
191
|
+
onPointerLeave?.(event);
|
|
192
|
+
hovered.current = false;
|
|
193
|
+
}, ...props, children: [_jsx("input", { ref: input, type: "file", hidden: true, tabIndex: -1, accept: accept, multiple: multiple, disabled: off, "data-slot": "file-drop-input", onChange: (event) => {
|
|
194
|
+
take([...(event.currentTarget.files ?? [])]);
|
|
195
|
+
// Reset, so the same file can be chosen again.
|
|
196
|
+
event.currentTarget.value = "";
|
|
197
|
+
} }), _jsx("span", { id: contentId, "data-slot": "file-drop-content", className: "contents", children: children ?? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, "data-slot": "file-drop-icon", className: "mb-3 inline-flex size-(--control-h-lg) items-center justify-center rounded-full bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent text-foreground shadow-raised transition-[translate] duration-(--duration) ease-(--ease) group-data-dragging/file-drop:-translate-y-0.5 [&_svg]:size-5", children: _jsx(UploadIcon, {}) }), _jsx("span", { "data-slot": "file-drop-title", className: "text-sm font-medium text-foreground", children: title ?? text.title(multiple) }), " ", _jsx("span", { "data-slot": "file-drop-description", className: "text-[13px] text-muted-foreground", children: description ?? _jsx(DefaultDescription, { text: text }) })] })) }), " ", _jsx("span", { id: hintId, "data-slot": "file-drop-hint", className: cn("mt-2 font-mono text-[11px] text-muted-foreground", !hintShown && "sr-only"), children: hint ?? text.hint(multiple) })] }), _jsx("input", { ref: fieldRef, value: "", onChange: fieldChange, disabled: off, "aria-hidden": true, tabIndex: -1, autoComplete: "off", onFocus: () => zone.current?.focus(), className: "sr-only" })] }));
|
|
198
|
+
} }));
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* How else to add files: click to choose, or paste with the device's own keys (⌘ V on Apple,
|
|
202
|
+
* Ctrl V elsewhere). A touch-only phone or tablet has no keys to press, so it only says tap.
|
|
203
|
+
*/
|
|
204
|
+
function DefaultDescription({ text }) {
|
|
205
|
+
const { mod, hasKeyboard } = useShortcutKeys();
|
|
206
|
+
const names = useKeyNames();
|
|
207
|
+
if (!hasKeyboard)
|
|
208
|
+
return text.tap;
|
|
209
|
+
return (_jsxs(_Fragment, { children: [text.clickOrPaste, " ", _jsxs(KbdGroup, { className: "align-middle", children: [_jsx(Kbd, { children: keyNames(["mod"], mod, names)[0] }), _jsx(Kbd, { children: "V" })] })] }));
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* A size in bytes, as people read it: 840 B, 12 KB, 3.4 MB — the number written for `locale`
|
|
213
|
+
* (3,4 MB in German), or for the browser's language without one.
|
|
214
|
+
*/
|
|
215
|
+
export function formatFileSize(bytes, locale) {
|
|
216
|
+
const number = (n, digits) => new Intl.NumberFormat(locale, {
|
|
217
|
+
minimumFractionDigits: digits,
|
|
218
|
+
maximumFractionDigits: digits,
|
|
219
|
+
useGrouping: false,
|
|
220
|
+
}).format(n);
|
|
221
|
+
if (bytes < 1024)
|
|
222
|
+
return `${number(bytes, 0)} B`;
|
|
223
|
+
const units = ["KB", "MB", "GB"];
|
|
224
|
+
// One decimal under 10, whole numbers above; 9.96 KB reads "10 KB", not "10.0 KB".
|
|
225
|
+
const shown = (n) => (n < 9.95 ? n.toFixed(1) : String(Math.round(n)));
|
|
226
|
+
let size = bytes / 1024;
|
|
227
|
+
let unit = 0;
|
|
228
|
+
// Decided on the number shown, so 1023.7 KB moves on to "1.0 MB" rather than reading "1024 KB".
|
|
229
|
+
while (Number(shown(size)) >= 1024 && unit < units.length - 1) {
|
|
230
|
+
size /= 1024;
|
|
231
|
+
unit++;
|
|
232
|
+
}
|
|
233
|
+
// The same thresholds as `shown`, written in the locale's digits and decimal sign.
|
|
234
|
+
return `${size < 9.95 ? number(size, 1) : number(Math.round(size), 0)} ${units[unit]}`;
|
|
235
|
+
}
|
|
236
|
+
/** An object URL for an image file while it is shown, revoked after. */
|
|
237
|
+
function usePreview(file) {
|
|
238
|
+
const [url, setUrl] = React.useState();
|
|
239
|
+
React.useEffect(() => {
|
|
240
|
+
if (!file || !file.type.startsWith("image/"))
|
|
241
|
+
return setUrl(undefined);
|
|
242
|
+
const next = URL.createObjectURL(file);
|
|
243
|
+
setUrl(next);
|
|
244
|
+
return () => URL.revokeObjectURL(next);
|
|
245
|
+
}, [file]);
|
|
246
|
+
return url;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* FileDropItem — one file added through a `FileDrop`: a thumbnail for an image (an icon for
|
|
250
|
+
* anything else), the name, its size in mono, and a remove button. Outlined 12px rows; stack
|
|
251
|
+
* them in a list under the zone.
|
|
252
|
+
*/
|
|
253
|
+
export function FileDropItem({ file, onRemove, removeLabel, className, ...props }) {
|
|
254
|
+
const preview = usePreview(file);
|
|
255
|
+
const text = useMessages("fileDrop", defaultMessages);
|
|
256
|
+
const locale = useLocale();
|
|
257
|
+
return (_jsxs(Item, { variant: "outline", size: "sm", "data-slot": "file-drop-item", className: className, ...props, children: [preview ? (_jsx(ItemMedia, { variant: "image", children: _jsx("img", { src: preview, alt: "" }) })) : (_jsx(ItemMedia, { variant: "image", className: "grid place-items-center bg-control-surface text-muted-foreground", children: _jsx(FileIcon, { className: "size-4" }) })), _jsxs(ItemContent, { className: "min-w-0", children: [_jsx(ItemTitle, { className: "block max-w-full truncate", title: file.name, children: file.name }), _jsx(ItemDescription, { className: "font-mono text-[11px] tabular-nums", children: formatFileSize(file.size, locale) })] }), onRemove && (_jsx(ItemActions, { children: _jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": removeLabel ?? text.remove(file.name), onClick: onRemove, children: _jsx(XIcon, {}) }) }))] }));
|
|
258
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/** One choice of a `select` field. */
|
|
3
|
+
export interface FilterOption {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
/** A 16px icon or status dot before the label in the list. */
|
|
7
|
+
icon?: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
interface FilterFieldBase<Row> {
|
|
10
|
+
/** The filter's key, and the row property `matchesFilters` reads unless `accessor` says otherwise. */
|
|
11
|
+
id: string;
|
|
12
|
+
/** The field's name in the menu and on the chip: "Status", "Amount". */
|
|
13
|
+
label: string;
|
|
14
|
+
/** A 16px icon in the "Filter" menu. */
|
|
15
|
+
icon?: React.ReactNode;
|
|
16
|
+
/** Reads the value to compare from a row, for `matchesFilters`. Defaults to `row[id]`. */
|
|
17
|
+
accessor?: (row: Row) => unknown;
|
|
18
|
+
}
|
|
19
|
+
/** A field from a fixed list: "Status is Active, Paused". Rows may hold one value or an array. */
|
|
20
|
+
export interface FilterSelectField<Row = any> extends FilterFieldBase<Row> {
|
|
21
|
+
kind: "select";
|
|
22
|
+
options: FilterOption[];
|
|
23
|
+
/** Show a search field over the options. Defaults to on from 8 options. */
|
|
24
|
+
searchable?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** Free text: "Customer contains “berg”". Case-insensitive. */
|
|
27
|
+
export interface FilterTextField<Row = any> extends FilterFieldBase<Row> {
|
|
28
|
+
kind: "text";
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
}
|
|
31
|
+
/** A number compared with an operator: "Amount ≥ 500". */
|
|
32
|
+
export interface FilterNumberField<Row = any> extends FilterFieldBase<Row> {
|
|
33
|
+
kind: "number";
|
|
34
|
+
min?: number;
|
|
35
|
+
max?: number;
|
|
36
|
+
step?: number;
|
|
37
|
+
/** How the number reads on the chip and in the field: `{ style: "currency", currency: "EUR" }`. */
|
|
38
|
+
format?: Intl.NumberFormatOptions;
|
|
39
|
+
}
|
|
40
|
+
/** A date range: "Due 1 Oct – 15 Oct 2026". Either end may be open. */
|
|
41
|
+
export interface FilterDateField<Row = any> extends FilterFieldBase<Row> {
|
|
42
|
+
kind: "date";
|
|
43
|
+
/**
|
|
44
|
+
* Replace the range `Calendar` with your own editor — presets, two months. It receives the
|
|
45
|
+
* range as ISO dates and a setter.
|
|
46
|
+
*/
|
|
47
|
+
editor?: (props: FilterDateEditorProps) => React.ReactNode;
|
|
48
|
+
}
|
|
49
|
+
export type FilterField<Row = any> = FilterSelectField<Row> | FilterTextField<Row> | FilterNumberField<Row> | FilterDateField<Row>;
|
|
50
|
+
/** A range of ISO dates (`"2026-10-01"`), both ends inclusive and optional. */
|
|
51
|
+
export interface FilterDateRange {
|
|
52
|
+
from?: string;
|
|
53
|
+
to?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface FilterDateEditorProps {
|
|
56
|
+
value: FilterDateRange;
|
|
57
|
+
onChange: (value: FilterDateRange) => void;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* How a filter compares. `select`: `is`, `is-not`. `text`: `contains`, `does-not-contain`.
|
|
61
|
+
* `number`: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`. `date`: `between`.
|
|
62
|
+
*/
|
|
63
|
+
export type FilterOperator = "is" | "is-not" | "contains" | "does-not-contain" | "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "between";
|
|
64
|
+
/** `select`: `string[]` · `text`: `string` · `number`: `number | null` · `date`: `FilterDateRange`. */
|
|
65
|
+
export type FilterValue = string[] | string | number | null | FilterDateRange;
|
|
66
|
+
/** One applied filter. A filter with no value yet (an empty list, "", null) matches every row. */
|
|
67
|
+
export interface Filter {
|
|
68
|
+
/** The `id` of its field. */
|
|
69
|
+
field: string;
|
|
70
|
+
operator: FilterOperator;
|
|
71
|
+
value: FilterValue;
|
|
72
|
+
}
|
|
73
|
+
export interface FilterBarMessages {
|
|
74
|
+
/** The bar's group name. */
|
|
75
|
+
group: string;
|
|
76
|
+
/** The add button. */
|
|
77
|
+
add: string;
|
|
78
|
+
clearAll: string;
|
|
79
|
+
/** A chip's group name, by its field's label. */
|
|
80
|
+
chip: (field: string) => string;
|
|
81
|
+
/** A chip's × button. */
|
|
82
|
+
remove: (field: string) => string;
|
|
83
|
+
/** The operator select in a chip's editor. */
|
|
84
|
+
condition: (field: string) => string;
|
|
85
|
+
/** The search field over a long list of options: its placeholder and its name. */
|
|
86
|
+
searchPlaceholder: (field: string) => string;
|
|
87
|
+
search: (field: string) => string;
|
|
88
|
+
/** Shown when the search matches no option. */
|
|
89
|
+
noMatch: (field: string) => string;
|
|
90
|
+
/** A text field's placeholder, when the field gives none. */
|
|
91
|
+
textPlaceholder: (field: string) => string;
|
|
92
|
+
/** Typed text as the chip shows it, in quotation marks. */
|
|
93
|
+
quote: (text: string) => string;
|
|
94
|
+
/** A date range open at its end, or its start: "from 1 Oct", "until 15 Oct". */
|
|
95
|
+
from: string;
|
|
96
|
+
until: string;
|
|
97
|
+
/** The operators, in the condition select — and, for options and text, on the chip. */
|
|
98
|
+
is: string;
|
|
99
|
+
isNot: string;
|
|
100
|
+
contains: string;
|
|
101
|
+
doesNotContain: string;
|
|
102
|
+
gte: string;
|
|
103
|
+
lte: string;
|
|
104
|
+
gt: string;
|
|
105
|
+
lt: string;
|
|
106
|
+
eq: string;
|
|
107
|
+
neq: string;
|
|
108
|
+
between: string;
|
|
109
|
+
}
|
|
110
|
+
declare module "./locale" {
|
|
111
|
+
interface Messages {
|
|
112
|
+
filterBar: FilterBarMessages;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Whether a row passes every filter — for filtering on the client:
|
|
117
|
+
* `rows.filter((row) => matchesFilters(row, filters, fields))`. Filters without a value yet, and
|
|
118
|
+
* filters on fields not in `fields`, are skipped. Text compares case-insensitively; dates compare
|
|
119
|
+
* as local days, from `Date`s, timestamps or ISO strings.
|
|
120
|
+
*/
|
|
121
|
+
export declare function matchesFilters<Row>(row: Row, filters: readonly Filter[], fields: readonly FilterField<Row>[]): boolean;
|
|
122
|
+
export interface FilterBarProps extends Omit<React.ComponentProps<"div">, "defaultValue" | "onChange"> {
|
|
123
|
+
/** What can be filtered on, in the order the "Filter" menu lists them. */
|
|
124
|
+
fields: readonly FilterField[];
|
|
125
|
+
/** The applied filters, controlled. Pair with `onValueChange`. */
|
|
126
|
+
value?: Filter[];
|
|
127
|
+
/** The applied filters on first render, uncontrolled. */
|
|
128
|
+
defaultValue?: Filter[];
|
|
129
|
+
/** Every change: a filter added, edited, removed or cleared. Filters still empty are included. */
|
|
130
|
+
onValueChange?: (value: Filter[]) => void;
|
|
131
|
+
/** `sm` (default) 30px chips for toolbars above tables; `default` 38px. */
|
|
132
|
+
size?: "sm" | "default";
|
|
133
|
+
/** The locale for dates and numbers on the chips. Defaults to the LocaleProvider's, else the browser's. */
|
|
134
|
+
locale?: string;
|
|
135
|
+
/**
|
|
136
|
+
* The add button's label. Defaults to "Filter".
|
|
137
|
+
* @deprecated Use `labels.add`.
|
|
138
|
+
*/
|
|
139
|
+
addLabel?: string;
|
|
140
|
+
/** The bar's words; a LocaleProvider sets them for every FilterBar. */
|
|
141
|
+
labels?: Partial<FilterBarMessages>;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* FilterBar — faceted filters above a list or a table: each applied filter is a raised chip
|
|
145
|
+
* ("Status is Active, Paused") that opens a popover to edit it, with × to remove it; "Filter"
|
|
146
|
+
* opens a menu of the fields to add one, and "Clear all" removes them all.
|
|
147
|
+
*
|
|
148
|
+
* It holds filters, not rows: filter your data with `matchesFilters` on the client, or send the
|
|
149
|
+
* value to a server. The rule people break: a filter bar for one or two fixed choices — that is a
|
|
150
|
+
* `ToggleGroup` or a `Select` beside the table, always visible.
|
|
151
|
+
*/
|
|
152
|
+
export declare function FilterBar({ fields, value: valueProp, defaultValue, onValueChange, size, locale: localeProp, addLabel, labels, className, ...props }: FilterBarProps): React.JSX.Element;
|
|
153
|
+
export {};
|