@brightspot/ui 1.11.0 → 3.0.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/dist/components/action-bar/ActionBar.d.ts +1 -1
- package/dist/components/action-bar/ActionBar.js +7 -7
- package/dist/components/action-bar/ActionBar.js.map +1 -1
- package/dist/components/action-bar/ActionItem.d.ts +5 -5
- package/dist/components/action-bar/ActionItem.d.ts.map +1 -1
- package/dist/components/action-bar/ActionItem.js +13 -13
- package/dist/components/action-bar/ActionItem.js.map +1 -1
- package/dist/components/avatar/AvatarGroup.d.ts +3 -0
- package/dist/components/avatar/AvatarGroup.d.ts.map +1 -1
- package/dist/components/avatar/AvatarGroup.js +3 -0
- package/dist/components/avatar/AvatarGroup.js.map +1 -1
- package/dist/components/badge/Badge.d.ts +3 -1
- package/dist/components/badge/Badge.d.ts.map +1 -1
- package/dist/components/badge/Badge.js +2 -0
- package/dist/components/badge/Badge.js.map +1 -1
- package/dist/components/button-group/ButtonGroup.d.ts +138 -0
- package/dist/components/button-group/ButtonGroup.d.ts.map +1 -0
- package/dist/components/button-group/ButtonGroup.js +436 -0
- package/dist/components/button-group/ButtonGroup.js.map +1 -0
- package/dist/components/checkbox/Checkbox.d.ts +107 -0
- package/dist/components/checkbox/Checkbox.d.ts.map +1 -0
- package/dist/components/checkbox/Checkbox.js +224 -0
- package/dist/components/checkbox/Checkbox.js.map +1 -0
- package/dist/components/circular-progress/CircularProgress.d.ts +2 -2
- package/dist/components/circular-progress/CircularProgress.js +2 -2
- package/dist/components/copy-to-clipboard/CopyToClipboard.d.ts +7 -2
- package/dist/components/copy-to-clipboard/CopyToClipboard.d.ts.map +1 -1
- package/dist/components/copy-to-clipboard/CopyToClipboard.js +10 -5
- package/dist/components/copy-to-clipboard/CopyToClipboard.js.map +1 -1
- package/dist/components/dropdown/Dropdown.d.ts +5 -5
- package/dist/components/dropdown/Dropdown.d.ts.map +1 -1
- package/dist/components/dropdown/Dropdown.js +11 -16
- package/dist/components/dropdown/Dropdown.js.map +1 -1
- package/dist/components/dropdown/DropdownItem.d.ts +14 -6
- package/dist/components/dropdown/DropdownItem.d.ts.map +1 -1
- package/dist/components/dropdown/DropdownItem.js +21 -15
- package/dist/components/dropdown/DropdownItem.js.map +1 -1
- package/dist/components/dropdown/DropdownMenu.d.ts +4 -4
- package/dist/components/dropdown/DropdownMenu.d.ts.map +1 -1
- package/dist/components/dropdown/DropdownMenu.js +6 -6
- package/dist/components/dropdown/DropdownMenu.js.map +1 -1
- package/dist/components/empty-state/EmptyState.css +4 -0
- package/dist/components/empty-state/EmptyState.d.ts +103 -0
- package/dist/components/empty-state/EmptyState.d.ts.map +1 -0
- package/dist/components/empty-state/EmptyState.js +209 -0
- package/dist/components/empty-state/EmptyState.js.map +1 -0
- package/dist/components/icon/Icon.d.ts +23 -10
- package/dist/components/icon/Icon.d.ts.map +1 -1
- package/dist/components/icon/Icon.js +40 -9
- package/dist/components/icon/Icon.js.map +1 -1
- package/dist/components/icon-button/IconButton.d.ts +7 -21
- package/dist/components/icon-button/IconButton.d.ts.map +1 -1
- package/dist/components/icon-button/IconButton.js +12 -18
- package/dist/components/icon-button/IconButton.js.map +1 -1
- package/dist/components/linear-progress/LinearProgress.d.ts +2 -2
- package/dist/components/linear-progress/LinearProgress.js +2 -2
- package/dist/components/pagination/Pagination.js +10 -10
- package/dist/components/popover/Popover.d.ts +6 -0
- package/dist/components/popover/Popover.d.ts.map +1 -1
- package/dist/components/popover/Popover.js +6 -0
- package/dist/components/popover/Popover.js.map +1 -1
- package/dist/components/switch/Switch.d.ts +5 -1
- package/dist/components/switch/Switch.d.ts.map +1 -1
- package/dist/components/switch/Switch.js +10 -6
- package/dist/components/switch/Switch.js.map +1 -1
- package/dist/components/tabs/Tab.d.ts +4 -4
- package/dist/components/tabs/Tab.d.ts.map +1 -1
- package/dist/components/tabs/Tab.js +5 -5
- package/dist/components/tabs/Tab.js.map +1 -1
- package/dist/components/tabs/Tabs.d.ts +3 -3
- package/dist/components/tabs/Tabs.d.ts.map +1 -1
- package/dist/components/tabs/Tabs.js +20 -20
- package/dist/components/tabs/Tabs.js.map +1 -1
- package/dist/components/upload/Upload.d.ts +157 -0
- package/dist/components/upload/Upload.d.ts.map +1 -0
- package/dist/components/upload/Upload.js +538 -0
- package/dist/components/upload/Upload.js.map +1 -0
- package/dist/components/upload/UploadItem.d.ts +73 -0
- package/dist/components/upload/UploadItem.d.ts.map +1 -0
- package/dist/components/upload/UploadItem.js +180 -0
- package/dist/components/upload/UploadItem.js.map +1 -0
- package/dist/components/widget/Widget.d.ts +1 -6
- package/dist/components/widget/Widget.d.ts.map +1 -1
- package/dist/components/widget/Widget.js +1 -6
- package/dist/components/widget/Widget.js.map +1 -1
- package/dist/custom-elements.json +7499 -2087
- package/dist/storybook/assets/{ActionBar.stories--nAeDC-G.js → ActionBar.stories-DRIVI-W2.js} +65 -65
- package/dist/storybook/assets/{ActionItem.stories-BHrGjk-P.js → ActionItem.stories-5qlgxYNB.js} +41 -41
- package/dist/storybook/assets/{Avatar.stories-Da-mRj6_.js → Avatar.stories-B3VkhRhP.js} +2 -2
- package/dist/storybook/assets/{AvatarGroup.stories-BQlaC_yl.js → AvatarGroup.stories-DOfim2NY.js} +5 -5
- package/dist/storybook/assets/{Badge.stories-DnVnOrnF.js → Badge.stories-B04VNAcc.js} +2 -2
- package/dist/storybook/assets/{Button-CFLAI1H9.js → Button-CILTcGRT.js} +1 -1
- package/dist/storybook/assets/{Button.stories-DxaBOjwv.js → Button.stories-CzWAltrX.js} +1 -1
- package/dist/storybook/assets/ButtonGroup.stories-1uAJf79o.js +588 -0
- package/dist/storybook/assets/{Celebrate.stories-CuMm15Nr.js → Celebrate.stories-BEqj0VnW.js} +7 -7
- package/dist/storybook/assets/Checkbox.stories-DXAGFS0M.js +141 -0
- package/dist/storybook/assets/{CircularProgress.stories-DRN8Mtvj.js → CircularProgress.stories-D4rftw22.js} +7 -7
- package/dist/storybook/assets/{ClipboardMixin.stories-DR7Ou2Av.js → ClipboardMixin.stories-z2n2HWt1.js} +31 -28
- package/dist/storybook/assets/{Color-6BZIO3FS-Die62Y0Z.js → Color-6BZIO3FS-C6KyMgZz.js} +1 -1
- package/dist/storybook/assets/{Colors.stories-bIq_ssbI.js → Colors.stories-CX-Ny3B_.js} +1 -1
- package/dist/storybook/assets/{CombinedEffects.stories-CtKzOUZn.js → CombinedEffects.stories-BkqtiVHp.js} +33 -33
- package/dist/storybook/assets/{ComponentStatesMixin-DMLCk9fE.js → ComponentStatesMixin-DLd0feFg.js} +1 -1
- package/dist/storybook/assets/{ComponentStatesMixin.stories-D8UI9o-d.js → ComponentStatesMixin.stories-D6Yc5Jgl.js} +3 -3
- package/dist/storybook/assets/{CopyToClipboard.stories-ti6CpJNp.js → CopyToClipboard.stories-B-omwDDJ.js} +16 -16
- package/dist/storybook/assets/{Debounce.stories-DzZUSvbk.js → Debounce.stories-B2vE5QIx.js} +9 -9
- package/dist/storybook/assets/{DocsRenderer-LL677BLK-CIRGv5IX.js → DocsRenderer-LL677BLK-DNUlRvMg.js} +3 -3
- package/dist/storybook/assets/{Dropdown.stories-Lt4cY0Re.js → Dropdown.stories-_bx4WDLr.js} +60 -60
- package/dist/storybook/assets/EmptyState.stories-CGMbmo77.js +318 -0
- package/dist/storybook/assets/{Events.stories-B1ddcgpT.js → Events.stories-CkQYKcoZ.js} +1 -1
- package/dist/storybook/assets/{Heading.stories-DI4w61cf.js → Heading.stories-BU5Do_od.js} +1 -1
- package/dist/storybook/assets/{HueRipple.stories-DjhoxxEw.js → HueRipple.stories-Di2zmxo3.js} +11 -11
- package/dist/storybook/assets/Icon.stories-Dk4ZXhhJ.js +441 -0
- package/dist/storybook/assets/{IconButton.stories-KjN28hfc.js → IconButton.stories-BSCiXPXa.js} +126 -146
- package/dist/storybook/assets/{LinearProgress.stories-DcIpdz6R.js → LinearProgress.stories-BGxPZuni.js} +7 -7
- package/dist/storybook/assets/{Pagination.stories-BBkLEwoP.js → Pagination.stories-z3Zq8b4f.js} +6 -6
- package/dist/storybook/assets/{Popover.stories-DLv48c2h.js → Popover.stories-C9GxWcax.js} +33 -62
- package/dist/storybook/assets/ReadyMixin-CQw8N6P9.js +1 -0
- package/dist/storybook/assets/{RovingTabindexMixin.stories-BWaFx9mu.js → RovingTabindexMixin.stories-ByxLBi6m.js} +6 -6
- package/dist/storybook/assets/{Rtc.stories-Ve7Bwo_l.js → Rtc.stories-DQJlCXWR.js} +3 -3
- package/dist/storybook/assets/{ScrollShadow.stories-C6XmrRLm.js → ScrollShadow.stories-gjTIAbUA.js} +2 -2
- package/dist/storybook/assets/{Switch.stories-Cf8WM1LG.js → Switch.stories-BEeqPZiP.js} +21 -21
- package/dist/storybook/assets/{Tab.stories-CEtdEtOx.js → Tab.stories-DpB3I-WZ.js} +33 -33
- package/dist/storybook/assets/{Tabs.stories-CIAO1bPO.js → Tabs.stories-C6mG6Xi7.js} +2 -2
- package/dist/storybook/assets/{Throttle.stories-BqxVIb-r.js → Throttle.stories-x9tpGeQh.js} +10 -10
- package/dist/storybook/assets/{Tooltip.stories-B6fw6875.js → Tooltip.stories-CqcLqdmc.js} +2 -2
- package/dist/storybook/assets/Upload.stories-CMaAbCSH.js +447 -0
- package/dist/storybook/assets/UploadItem.stories-GB98L3JQ.js +167 -0
- package/dist/storybook/assets/{Welcome.stories-CfJtSM19.js → Welcome.stories-6h9cUZ7v.js} +1 -1
- package/dist/storybook/assets/{Widget.stories-CiOho7lO.js → Widget.stories-DiA1PR6Y.js} +13 -13
- package/dist/storybook/assets/{WithTooltip-65CFNBJE-PGcopp73.js → WithTooltip-65CFNBJE-DTsHhBb_.js} +1 -1
- package/dist/storybook/assets/{blocks-dP2DwISI.js → blocks-IXdn9TGW.js} +5 -5
- package/dist/storybook/assets/{formatter-EIJCOSYU-CZSAC3tg.js → formatter-EIJCOSYU-Cum4J6N4.js} +1 -1
- package/dist/storybook/assets/if-defined-CgfCxQoV.js +1 -0
- package/dist/storybook/assets/iframe-BgFj0b5u.css +1 -0
- package/dist/storybook/assets/{iframe-DloIUNZz.js → iframe-Sf9RHZFu.js} +191 -191
- package/dist/storybook/assets/{index-DKF0ypu5.js → index-D605PvQH.js} +1 -1
- package/dist/storybook/assets/{onFind-C0l4Gew0.js → onFind-C41m8c_a.js} +1 -1
- package/dist/storybook/assets/{onFind.stories-DOTt9puO.js → onFind.stories-MOTfGlJd.js} +53 -77
- package/dist/storybook/assets/{onRemove.stories-CQ9ZC5dm.js → onRemove.stories-DX58Bf6f.js} +6 -10
- package/dist/storybook/assets/{onVisible.stories-Cbj5_Vz0.js → onVisible.stories-NNFeFeD8.js} +3 -3
- package/dist/storybook/assets/{style-map-DLXysq3r.js → style-map-B99QiqCo.js} +1 -1
- package/dist/storybook/assets/{syntaxhighlighter-ED5Y7EFY-Bjjbl9ca.js → syntaxhighlighter-ED5Y7EFY-BqQ-o9mS.js} +1 -1
- package/dist/storybook/box-illustration.svg +51 -0
- package/dist/storybook/cloud-illustration.svg +49 -0
- package/dist/storybook/docs-illustration.svg +92 -0
- package/dist/storybook/iframe.html +2 -2
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/dist/tailwind-plugin-badge.js +1 -1
- package/dist/tailwind-plugin-badge.ts +1 -1
- package/dist/tailwind-plugin-button-group.d.ts +2 -0
- package/dist/tailwind-plugin-button-group.d.ts.map +1 -0
- package/dist/tailwind-plugin-button-group.js +215 -0
- package/dist/tailwind-plugin-button-group.js.map +1 -0
- package/dist/tailwind-plugin-button-group.ts +238 -0
- package/dist/tailwind-plugin-button.js +1 -1
- package/dist/tailwind-plugin-button.ts +1 -1
- package/dist/tailwind-plugin-checkbox.d.ts +2 -0
- package/dist/tailwind-plugin-checkbox.d.ts.map +1 -0
- package/dist/tailwind-plugin-checkbox.js +246 -0
- package/dist/tailwind-plugin-checkbox.js.map +1 -0
- package/dist/tailwind-plugin-checkbox.ts +281 -0
- package/dist/tailwind-plugin-empty-state.d.ts +2 -0
- package/dist/tailwind-plugin-empty-state.d.ts.map +1 -0
- package/dist/tailwind-plugin-empty-state.js +113 -0
- package/dist/tailwind-plugin-empty-state.js.map +1 -0
- package/dist/tailwind-plugin-empty-state.ts +124 -0
- package/dist/tailwind-plugin-icon.js +122 -18
- package/dist/tailwind-plugin-icon.js.map +1 -1
- package/dist/tailwind-plugin-icon.ts +131 -18
- package/dist/tailwind-plugin-loader.js +3 -3
- package/dist/tailwind-plugin-loader.ts +3 -3
- package/dist/tailwind-plugin-tabs.js +7 -0
- package/dist/tailwind-plugin-tabs.js.map +1 -1
- package/dist/tailwind-plugin-tabs.ts +7 -0
- package/dist/tailwind-plugin-upload.d.ts +2 -0
- package/dist/tailwind-plugin-upload.d.ts.map +1 -0
- package/dist/tailwind-plugin-upload.js +322 -0
- package/dist/tailwind-plugin-upload.js.map +1 -0
- package/dist/tailwind-plugin-upload.ts +362 -0
- package/dist/tailwind.config.d.ts.map +1 -1
- package/dist/tailwind.config.js +1 -0
- package/dist/tailwind.config.js.map +1 -1
- package/dist/tailwind.config.ts +1 -0
- package/dist/util/ClipboardMixin.d.ts +7 -2
- package/dist/util/ClipboardMixin.d.ts.map +1 -1
- package/dist/util/ClipboardMixin.js +15 -13
- package/dist/util/ClipboardMixin.js.map +1 -1
- package/dist/util/ComponentStatesMixin.d.ts +2 -1
- package/dist/util/ComponentStatesMixin.d.ts.map +1 -1
- package/dist/util/ComponentStatesMixin.js +4 -0
- package/dist/util/ComponentStatesMixin.js.map +1 -1
- package/dist/util/EventEmitterMixin.d.ts +42 -4
- package/dist/util/EventEmitterMixin.d.ts.map +1 -1
- package/dist/util/EventEmitterMixin.js +5 -2
- package/dist/util/EventEmitterMixin.js.map +1 -1
- package/dist/util/ProgressMixin.d.ts +9 -2
- package/dist/util/ProgressMixin.d.ts.map +1 -1
- package/dist/util/ProgressMixin.js +22 -18
- package/dist/util/ProgressMixin.js.map +1 -1
- package/dist/util/RovingTabindexMixin.d.ts +8 -0
- package/dist/util/RovingTabindexMixin.d.ts.map +1 -1
- package/dist/util/RovingTabindexMixin.js +8 -8
- package/dist/util/RovingTabindexMixin.js.map +1 -1
- package/dist/util/TetherLayout.d.ts.map +1 -1
- package/dist/util/TetherLayout.js +3 -0
- package/dist/util/TetherLayout.js.map +1 -1
- package/dist/util/TooltipMixin.d.ts.map +1 -1
- package/dist/util/TooltipMixin.js +5 -4
- package/dist/util/TooltipMixin.js.map +1 -1
- package/dist/util/upload.d.ts +53 -0
- package/dist/util/upload.d.ts.map +1 -0
- package/dist/util/upload.js +113 -0
- package/dist/util/upload.js.map +1 -0
- package/docs/components/ActionBar.md +6 -0
- package/docs/components/ActionItem.md +52 -27
- package/docs/components/Avatar.md +42 -12
- package/docs/components/AvatarGroup.md +4 -3
- package/docs/components/Badge.md +13 -1
- package/docs/components/ButtonGroup.md +91 -0
- package/docs/components/Checkbox.md +91 -0
- package/docs/components/CircularProgress.md +41 -12
- package/docs/components/CopyToClipboard.md +13 -11
- package/docs/components/Dropdown.md +44 -19
- package/docs/components/DropdownItem.md +39 -26
- package/docs/components/DropdownMenu.md +9 -9
- package/docs/components/EmptyState.md +75 -0
- package/docs/components/Icon.md +22 -14
- package/docs/components/IconButton.md +46 -21
- package/docs/components/LinearProgress.md +43 -4
- package/docs/components/Pagination.md +11 -10
- package/docs/components/Popover.md +16 -0
- package/docs/components/README.md +5 -0
- package/docs/components/Switch.md +21 -16
- package/docs/components/Tab.md +8 -2
- package/docs/components/Tabs.md +8 -0
- package/docs/components/Upload.md +112 -0
- package/docs/components/UploadItem.md +61 -0
- package/docs/components/Widget.md +12 -6
- package/package.json +4 -2
- package/dist/storybook/assets/Icon.stories-CpziAhae.js +0 -264
- package/dist/storybook/assets/ReadyMixin-Cw2Dfbu2.js +0 -1
- package/dist/storybook/assets/if-defined-B1RdczOE.js +0 -1
- package/dist/storybook/assets/iframe-bJgLXZKK.css +0 -1
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement, html, nothing } from 'lit';
|
|
8
|
+
import { property, state } from 'lit/decorators.js';
|
|
9
|
+
import { announce } from '../../util/aria.js';
|
|
10
|
+
import { EventEmitterMixin } from '../../util/EventEmitterMixin.js';
|
|
11
|
+
import { l10n } from '../../util/i18n.js';
|
|
12
|
+
import { ReadyMixin } from '../../util/ReadyMixin.js';
|
|
13
|
+
import { formatFileSize, matchesAccept, validateFileSize } from '../../util/upload.js';
|
|
14
|
+
import '../icon/Icon.js';
|
|
15
|
+
import './UploadItem.js';
|
|
16
|
+
/**
|
|
17
|
+
* A file upload component with drop zone and file list.
|
|
18
|
+
*
|
|
19
|
+
* The component is presentation + file-selection only. It handles file browsing,
|
|
20
|
+
* drag-and-drop reception, client-side validation, and rendering the file list
|
|
21
|
+
* with progress bars. It does not perform network requests — the consumer listens
|
|
22
|
+
* for events, performs their own upload, and drives state back via imperative methods.
|
|
23
|
+
*
|
|
24
|
+
* @element btu-upload
|
|
25
|
+
*
|
|
26
|
+
* @fires {CustomEvent<unknown>} btu-upload-ready - Fired when the component has completed first render
|
|
27
|
+
* @fires {CustomEvent<{id: string, file: File}>} btu-upload-file-added - Fired when a file passes validation and is added
|
|
28
|
+
* @fires {CustomEvent<{id: string, file: File}>} btu-upload-file-removed - Fired when a file is removed (user action, programmatic, or on disconnect for in-flight uploads)
|
|
29
|
+
* @fires {CustomEvent<{id: string, file: File}>} btu-upload-file-retry - Fired when user clicks "Try again" on a failed upload
|
|
30
|
+
* @fires {CustomEvent<{file: File, reason: 'type' | 'size' | 'count'}>} btu-upload-file-rejected - Fired when a file fails client-side validation or the queue is full
|
|
31
|
+
* @fires {CustomEvent<{id: string, file: File}>} btu-upload-file-completed - Fired when a file's status transitions into 'complete'
|
|
32
|
+
* @fires {CustomEvent<{method: string, id: string, reason: 'unknown-id' | 'invalid-transition', message: string}>} btu-upload-api-error - Fired when an imperative API call references an unknown id or an illegal status transition
|
|
33
|
+
*
|
|
34
|
+
* @cssprop --upload-dropzone-bg - Drop zone background color (default: gray-25)
|
|
35
|
+
* @cssprop --upload-dropzone-border-color - Drop zone border color (default: gray-300; gray-200 when disabled, gray-400 in high-contrast)
|
|
36
|
+
* @cssprop --upload-dropzone-border-radius - Drop zone border radius (default: borderRadius.lg)
|
|
37
|
+
* @cssprop --upload-dropzone-hover-bg - Drop zone hover background (hover default: gray-50; drag-over default: primary-25)
|
|
38
|
+
* @cssprop --upload-dropzone-hover-border-color - Drop zone hover/focus border color (default: primary-300; drag-over uses primary-400)
|
|
39
|
+
* @cssprop --upload-dropzone-focus-ring-color - Drop zone focus ring color (default: primary-100)
|
|
40
|
+
* @cssprop --upload-item-bg - Item background color (default: white)
|
|
41
|
+
* @cssprop --upload-item-border-color - Item border color (default: gray-200)
|
|
42
|
+
* @cssprop --upload-item-active-border-color - Item active/in-progress border (default: gray-300)
|
|
43
|
+
* @cssprop --upload-item-complete-border-color - Item completed border color (default: primary-500)
|
|
44
|
+
* @cssprop --upload-item-error-bg - Item error background (default: error-25)
|
|
45
|
+
* @cssprop --upload-item-error-border-color - Item error border color (default: error-300)
|
|
46
|
+
*/
|
|
47
|
+
export default class Upload extends EventEmitterMixin(ReadyMixin(LitElement)) {
|
|
48
|
+
constructor() {
|
|
49
|
+
super(...arguments);
|
|
50
|
+
/**
|
|
51
|
+
* Accepted file types, matching the HTML `<input accept>` attribute format.
|
|
52
|
+
* Client-side filter only — the browser's file picker uses this as a hint,
|
|
53
|
+
* and drag-drop is enforced by this component. Server-side validation is
|
|
54
|
+
* still required.
|
|
55
|
+
*
|
|
56
|
+
* Supported forms (comma-separated, any combination):
|
|
57
|
+
* - `image/*` — MIME wildcard (any image)
|
|
58
|
+
* - `application/pdf` — exact MIME type
|
|
59
|
+
* - `.pdf`, `.docx` — file extension (case-insensitive)
|
|
60
|
+
*
|
|
61
|
+
* Examples:
|
|
62
|
+
* - `accept="image/*"` — any image
|
|
63
|
+
* - `accept="image/*,application/pdf"` — images and PDFs
|
|
64
|
+
* - `accept=".jpg,.jpeg,.png,.heic"` — specific extensions
|
|
65
|
+
* - `accept=""` (or omitted) — allow all
|
|
66
|
+
*
|
|
67
|
+
* Note: users can bypass the file picker's filter (most browsers offer an
|
|
68
|
+
* "All Files" option), so this attribute is a UX filter, not a security
|
|
69
|
+
* boundary.
|
|
70
|
+
*
|
|
71
|
+
* @attr
|
|
72
|
+
*/
|
|
73
|
+
this.accept = '';
|
|
74
|
+
/**
|
|
75
|
+
* Maximum file size in bytes. Files exceeding this are rejected. 0 means unlimited.
|
|
76
|
+
* @attr max-file-size
|
|
77
|
+
*/
|
|
78
|
+
this.maxFileSize = 0;
|
|
79
|
+
/**
|
|
80
|
+
* Maximum number of files allowed. When omitted, uploads are unlimited.
|
|
81
|
+
* `max-files="1"` enters single-file mode (selecting a new file replaces the existing one).
|
|
82
|
+
* `max-files="0"` allows zero files. Values above 1 cap the queue at that many files.
|
|
83
|
+
* @attr max-files
|
|
84
|
+
*/
|
|
85
|
+
this.maxFiles = Infinity;
|
|
86
|
+
/**
|
|
87
|
+
* Disables all interaction — file selection, drag-and-drop, and action buttons.
|
|
88
|
+
* @attr
|
|
89
|
+
*/
|
|
90
|
+
this.disabled = false;
|
|
91
|
+
/**
|
|
92
|
+
* Disables drag-and-drop. File selection via click still works.
|
|
93
|
+
* @attr no-drag
|
|
94
|
+
*/
|
|
95
|
+
this.noDrag = false;
|
|
96
|
+
this._files = new Map();
|
|
97
|
+
this._items = new Map();
|
|
98
|
+
this._milestones = new Map();
|
|
99
|
+
this._dragOver = false;
|
|
100
|
+
this._dragCounter = 0;
|
|
101
|
+
}
|
|
102
|
+
get _inputEl() {
|
|
103
|
+
return this.querySelector('input[type="file"]');
|
|
104
|
+
}
|
|
105
|
+
createRenderRoot() {
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
connectedCallback() {
|
|
109
|
+
super.connectedCallback();
|
|
110
|
+
this.classList.add('btu-upload');
|
|
111
|
+
}
|
|
112
|
+
disconnectedCallback() {
|
|
113
|
+
super.disconnectedCallback();
|
|
114
|
+
// Notify consumers about files still in flight so they can abort their XHRs
|
|
115
|
+
// and reconcile their own state. Completed files are terminal; don't re-emit.
|
|
116
|
+
for (const state of this._files.values()) {
|
|
117
|
+
if (state.status !== 'complete') {
|
|
118
|
+
this.emit('btu-upload-file-removed', { id: state.id, file: state.file });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
this._files.clear();
|
|
122
|
+
this._items.clear();
|
|
123
|
+
this._milestones.clear();
|
|
124
|
+
this._dragCounter = 0;
|
|
125
|
+
this._dragOver = false;
|
|
126
|
+
}
|
|
127
|
+
firstUpdated() {
|
|
128
|
+
// Contain UploadItem's internal bubbling signals at this boundary so they
|
|
129
|
+
// don't leak to ancestor listeners. Consumers only see the public events.
|
|
130
|
+
this.addEventListener('btu-upload-item-remove', e => {
|
|
131
|
+
e.stopPropagation();
|
|
132
|
+
const { id } = e.detail;
|
|
133
|
+
this.removeFile(id);
|
|
134
|
+
});
|
|
135
|
+
this.addEventListener('btu-upload-item-retry', e => {
|
|
136
|
+
e.stopPropagation();
|
|
137
|
+
const { id } = e.detail;
|
|
138
|
+
const fileState = this._files.get(id);
|
|
139
|
+
if (fileState) {
|
|
140
|
+
this.emit('btu-upload-file-retry', { id: fileState.id, file: fileState.file });
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
this.emit('btu-upload-ready');
|
|
144
|
+
}
|
|
145
|
+
_handleInputChange(e) {
|
|
146
|
+
const input = e.target;
|
|
147
|
+
if (!input.files)
|
|
148
|
+
return;
|
|
149
|
+
this._processFiles(Array.from(input.files));
|
|
150
|
+
input.value = '';
|
|
151
|
+
}
|
|
152
|
+
_handleSelectClick(e) {
|
|
153
|
+
// Stop the click from bubbling to the dropzone, which would re-invoke the picker.
|
|
154
|
+
e.stopPropagation();
|
|
155
|
+
if (this._interactionBlocked)
|
|
156
|
+
return;
|
|
157
|
+
this._inputEl?.click();
|
|
158
|
+
}
|
|
159
|
+
_handleDropzoneClick() {
|
|
160
|
+
if (this._interactionBlocked)
|
|
161
|
+
return;
|
|
162
|
+
this._inputEl?.click();
|
|
163
|
+
}
|
|
164
|
+
_handleDragEnter(e) {
|
|
165
|
+
if (this._interactionBlocked || this.noDrag)
|
|
166
|
+
return;
|
|
167
|
+
e.preventDefault();
|
|
168
|
+
this._dragCounter++;
|
|
169
|
+
this._dragOver = true;
|
|
170
|
+
}
|
|
171
|
+
_handleDragOver(e) {
|
|
172
|
+
if (this._interactionBlocked || this.noDrag)
|
|
173
|
+
return;
|
|
174
|
+
e.preventDefault();
|
|
175
|
+
}
|
|
176
|
+
_handleDragLeave(e) {
|
|
177
|
+
if (this._interactionBlocked || this.noDrag)
|
|
178
|
+
return;
|
|
179
|
+
this._dragCounter--;
|
|
180
|
+
if (this._dragCounter <= 0) {
|
|
181
|
+
this._dragCounter = 0;
|
|
182
|
+
this._dragOver = false;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
_handleDrop(e) {
|
|
186
|
+
if (this._interactionBlocked || this.noDrag)
|
|
187
|
+
return;
|
|
188
|
+
e.preventDefault();
|
|
189
|
+
this._dragCounter = 0;
|
|
190
|
+
this._dragOver = false;
|
|
191
|
+
if (!e.dataTransfer?.files)
|
|
192
|
+
return;
|
|
193
|
+
this._processFiles(Array.from(e.dataTransfer.files));
|
|
194
|
+
}
|
|
195
|
+
_processFiles(files) {
|
|
196
|
+
if (this._interactionBlocked)
|
|
197
|
+
return;
|
|
198
|
+
if (this.maxFiles === 1) {
|
|
199
|
+
const file = files[0];
|
|
200
|
+
if (!file)
|
|
201
|
+
return;
|
|
202
|
+
if (this._validateFile(file)) {
|
|
203
|
+
// Replace existing file (fires btu-upload-file-removed, then btu-upload-file-added)
|
|
204
|
+
if (this._files.size > 0) {
|
|
205
|
+
const existingId = this._files.keys().next().value;
|
|
206
|
+
this.removeFile(existingId);
|
|
207
|
+
}
|
|
208
|
+
this._addFile(file);
|
|
209
|
+
}
|
|
210
|
+
// Reject any additional files the user dropped at once — single-file mode
|
|
211
|
+
// only accepts one; without this, files[1..n] would disappear silently.
|
|
212
|
+
for (const extra of files.slice(1)) {
|
|
213
|
+
this._rejectCount(extra);
|
|
214
|
+
}
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
for (const file of files) {
|
|
218
|
+
if (this._files.size >= this.maxFiles) {
|
|
219
|
+
this._rejectCount(file);
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if (!this._validateFile(file))
|
|
223
|
+
continue;
|
|
224
|
+
this._addFile(file);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
_rejectCount(file) {
|
|
228
|
+
this.emit('btu-upload-file-rejected', { file, reason: 'count' });
|
|
229
|
+
announce(l10n('upload', 'announceRejectedCount', 'File rejected: ___. Maximum file count reached.', [file.name]));
|
|
230
|
+
}
|
|
231
|
+
_validateFile(file) {
|
|
232
|
+
if (this.accept && !matchesAccept(file, this.accept)) {
|
|
233
|
+
this.emit('btu-upload-file-rejected', { file, reason: 'type' });
|
|
234
|
+
announce(l10n('upload', 'announceRejectedType', 'File rejected: ___. File type not accepted.', [file.name]));
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
if (this.maxFileSize > 0 && !validateFileSize(file, this.maxFileSize)) {
|
|
238
|
+
this.emit('btu-upload-file-rejected', { file, reason: 'size' });
|
|
239
|
+
announce(l10n('upload', 'announceRejectedSize', 'File rejected: ___. File exceeds size limit.', [file.name]));
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
_addFile(file) {
|
|
245
|
+
const id = crypto.randomUUID();
|
|
246
|
+
const fileState = {
|
|
247
|
+
id,
|
|
248
|
+
file,
|
|
249
|
+
status: 'pending',
|
|
250
|
+
progress: 0,
|
|
251
|
+
};
|
|
252
|
+
this._files.set(id, fileState);
|
|
253
|
+
this._milestones.set(id, new Set());
|
|
254
|
+
this._renderItem(fileState);
|
|
255
|
+
this.requestUpdate();
|
|
256
|
+
this.emit('btu-upload-file-added', { id, file });
|
|
257
|
+
const sizeStr = formatFileSize(file.size);
|
|
258
|
+
announce(l10n('upload', 'announceAdded', 'File added: ___, ___', [file.name, sizeStr]));
|
|
259
|
+
}
|
|
260
|
+
_reportUnknownId(method, id) {
|
|
261
|
+
const message = `no file found with id "${id}"`;
|
|
262
|
+
this.emit('btu-upload-api-error', { method, id, reason: 'unknown-id', message });
|
|
263
|
+
console.warn(`[btu-upload] ${method}: ${message}`);
|
|
264
|
+
}
|
|
265
|
+
_getOrReport(method, id) {
|
|
266
|
+
const current = this._files.get(id);
|
|
267
|
+
if (!current) {
|
|
268
|
+
this._reportUnknownId(method, id);
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
return current;
|
|
272
|
+
}
|
|
273
|
+
_renderItem(fileState) {
|
|
274
|
+
const list = this.querySelector('.btu-upload-list');
|
|
275
|
+
if (!list)
|
|
276
|
+
return;
|
|
277
|
+
const item = document.createElement('btu-upload-item');
|
|
278
|
+
item.setAttribute('role', 'listitem');
|
|
279
|
+
item._configure(fileState);
|
|
280
|
+
list.appendChild(item);
|
|
281
|
+
this._items.set(fileState.id, item);
|
|
282
|
+
}
|
|
283
|
+
/* ─── Imperative API ─── */
|
|
284
|
+
/**
|
|
285
|
+
* Update the progress of a file upload.
|
|
286
|
+
* Clamps value to 0-100 and coerces non-finite inputs to 0. Announces milestones
|
|
287
|
+
* (25%, 50%, 75%) to screen readers; 100% completion is announced by setFileStatus('complete').
|
|
288
|
+
*
|
|
289
|
+
* Status transitions:
|
|
290
|
+
* - `pending` → `uploading` (auto — first progress report starts the upload)
|
|
291
|
+
* - `uploading` → `uploading` (progress updates)
|
|
292
|
+
* - `error` → `error` (progress updates only; status is preserved so a stale late
|
|
293
|
+
* callback can't wipe the error UI. To recover from error, call
|
|
294
|
+
* `setFileStatus(id, 'uploading')` first, then report progress.)
|
|
295
|
+
* - `complete` → ignored (terminal state)
|
|
296
|
+
*/
|
|
297
|
+
setFileProgress(id, percent) {
|
|
298
|
+
const current = this._getOrReport('setFileProgress', id);
|
|
299
|
+
if (!current)
|
|
300
|
+
return;
|
|
301
|
+
if (current.status === 'complete')
|
|
302
|
+
return;
|
|
303
|
+
const safe = Number.isFinite(percent) ? Math.round(percent) : 0;
|
|
304
|
+
const clamped = Math.min(Math.max(safe, 0), 100);
|
|
305
|
+
// No-op when progress hasn't changed and no status transition is needed.
|
|
306
|
+
// Upload callbacks can fire hundreds of times per file; skipping these
|
|
307
|
+
// avoids a per-byte state copy + child re-render.
|
|
308
|
+
if (current.status !== 'pending' && clamped === current.progress)
|
|
309
|
+
return;
|
|
310
|
+
// Pending auto-transitions to uploading once progress is reported.
|
|
311
|
+
const next = current.status === 'error'
|
|
312
|
+
? { ...current, progress: clamped }
|
|
313
|
+
: { id: current.id, file: current.file, symbol: current.symbol, status: 'uploading', progress: clamped };
|
|
314
|
+
this._files.set(id, next);
|
|
315
|
+
this._items.get(id)?._configure(next);
|
|
316
|
+
const milestones = this._milestones.get(id);
|
|
317
|
+
if (milestones && milestones.size < 3) {
|
|
318
|
+
for (const milestone of [25, 50, 75]) {
|
|
319
|
+
if (clamped >= milestone && !milestones.has(milestone)) {
|
|
320
|
+
milestones.add(milestone);
|
|
321
|
+
announce(l10n('upload', 'announceProgress', '___ ___% uploaded', [current.file.name, String(milestone)]));
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Set the status of a file.
|
|
328
|
+
* Valid statuses: 'uploading', 'complete', 'error'. For 'error' status, an
|
|
329
|
+
* optional message can be provided.
|
|
330
|
+
*
|
|
331
|
+
* Transitions from 'complete' are rejected (terminal state) — a late-resolving
|
|
332
|
+
* XHR cannot overwrite a prior success. Rejected calls emit `btu-upload-api-error`
|
|
333
|
+
* with reason: 'invalid-transition'.
|
|
334
|
+
*/
|
|
335
|
+
setFileStatus(id, status, message) {
|
|
336
|
+
const current = this._getOrReport('setFileStatus', id);
|
|
337
|
+
if (!current)
|
|
338
|
+
return;
|
|
339
|
+
if (current.status === 'complete' && status !== 'complete') {
|
|
340
|
+
const msg = `cannot transition from 'complete' to '${status}' for id "${id}"`;
|
|
341
|
+
this.emit('btu-upload-api-error', { method: 'setFileStatus', id, reason: 'invalid-transition', message: msg });
|
|
342
|
+
console.warn(`[btu-upload] setFileStatus: ${msg}`);
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
const { id: _id, file, symbol, progress } = current;
|
|
346
|
+
let next;
|
|
347
|
+
switch (status) {
|
|
348
|
+
case 'uploading':
|
|
349
|
+
next = { id: _id, file, symbol, status: 'uploading', progress };
|
|
350
|
+
break;
|
|
351
|
+
case 'complete':
|
|
352
|
+
next = { id: _id, file, symbol, status: 'complete', progress: 100 };
|
|
353
|
+
break;
|
|
354
|
+
case 'error':
|
|
355
|
+
next = { id: _id, file, symbol, status: 'error', progress, errorMessage: message ?? '' };
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
this._files.set(id, next);
|
|
359
|
+
this._items.get(id)?._configure(next);
|
|
360
|
+
if (status === 'complete') {
|
|
361
|
+
announce(l10n('upload', 'announceComplete', '___ upload complete', [file.name]));
|
|
362
|
+
}
|
|
363
|
+
else if (status === 'error') {
|
|
364
|
+
// Include the detail message in the announcement so screen-reader users get
|
|
365
|
+
// the same context the visible error text shows; the global announce() live
|
|
366
|
+
// region is the only path that reaches AT, since the error text itself is
|
|
367
|
+
// not in a live region (would otherwise duplicate the announcement).
|
|
368
|
+
const detail = message?.trim();
|
|
369
|
+
announce(detail
|
|
370
|
+
? l10n('upload', 'announceErrorWithDetail', '___ upload failed: ___', [file.name, detail])
|
|
371
|
+
: l10n('upload', 'announceError', '___ upload failed', [file.name]));
|
|
372
|
+
}
|
|
373
|
+
if (current.status !== 'complete' && status === 'complete') {
|
|
374
|
+
this.emit('btu-upload-file-completed', { id: next.id, file: next.file });
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Override the icon symbol for a file.
|
|
379
|
+
*/
|
|
380
|
+
setFileSymbol(id, symbol) {
|
|
381
|
+
const current = this._getOrReport('setFileSymbol', id);
|
|
382
|
+
if (!current)
|
|
383
|
+
return;
|
|
384
|
+
if (current.symbol === symbol)
|
|
385
|
+
return;
|
|
386
|
+
const next = { ...current, symbol };
|
|
387
|
+
this._files.set(id, next);
|
|
388
|
+
this._items.get(id)?._configure(next);
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Remove a file programmatically. Fires `btu-upload-file-removed`.
|
|
392
|
+
*/
|
|
393
|
+
removeFile(id) {
|
|
394
|
+
const current = this._getOrReport('removeFile', id);
|
|
395
|
+
if (!current)
|
|
396
|
+
return;
|
|
397
|
+
this._files.delete(id);
|
|
398
|
+
this._milestones.delete(id);
|
|
399
|
+
this._items.get(id)?.remove();
|
|
400
|
+
this._items.delete(id);
|
|
401
|
+
this.requestUpdate();
|
|
402
|
+
this.emit('btu-upload-file-removed', { id, file: current.file });
|
|
403
|
+
announce(l10n('upload', 'announceRemoved', 'File removed: ___', [current.file.name]));
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Get a snapshot of all current files and their states.
|
|
407
|
+
* States are readonly; mutations on the returned array's elements are ineffective.
|
|
408
|
+
*/
|
|
409
|
+
getFiles() {
|
|
410
|
+
return Array.from(this._files.values());
|
|
411
|
+
}
|
|
412
|
+
get _dropzoneFull() {
|
|
413
|
+
// Single-file mode is replace-on-select, not capped — never treat as full,
|
|
414
|
+
// otherwise _interactionBlocked gates every handler once the first file lands.
|
|
415
|
+
if (this.maxFiles === 1)
|
|
416
|
+
return false;
|
|
417
|
+
return this._files.size >= this.maxFiles;
|
|
418
|
+
}
|
|
419
|
+
get _interactionBlocked() {
|
|
420
|
+
return this.disabled || this._dropzoneFull;
|
|
421
|
+
}
|
|
422
|
+
get _showCountPill() {
|
|
423
|
+
return Number.isFinite(this.maxFiles) && this.maxFiles !== 1;
|
|
424
|
+
}
|
|
425
|
+
_renderSelectButton(text) {
|
|
426
|
+
return html `<button
|
|
427
|
+
type="button"
|
|
428
|
+
class="btu-upload-dropzone-action"
|
|
429
|
+
?disabled="${this._interactionBlocked}"
|
|
430
|
+
@click="${this._handleSelectClick}"
|
|
431
|
+
>
|
|
432
|
+
${text}
|
|
433
|
+
</button>`;
|
|
434
|
+
}
|
|
435
|
+
render() {
|
|
436
|
+
const isFull = this._dropzoneFull;
|
|
437
|
+
const isDisabled = this.disabled;
|
|
438
|
+
const dropzoneClasses = [
|
|
439
|
+
'btu-upload-dropzone',
|
|
440
|
+
this._dragOver ? 'btu-upload-dropzone-dragover' : '',
|
|
441
|
+
isDisabled || isFull ? 'btu-upload-dropzone-disabled' : '',
|
|
442
|
+
]
|
|
443
|
+
.filter(Boolean)
|
|
444
|
+
.join(' ');
|
|
445
|
+
const dropzoneLabel = !isDisabled && isFull
|
|
446
|
+
? l10n('upload', 'dropzoneLabelFull', 'File upload, maximum reached')
|
|
447
|
+
: l10n('upload', 'dropzoneLabel', 'File upload');
|
|
448
|
+
return html `
|
|
449
|
+
<input
|
|
450
|
+
type="file"
|
|
451
|
+
class="sr-only"
|
|
452
|
+
tabindex="-1"
|
|
453
|
+
aria-hidden="true"
|
|
454
|
+
accept="${this.accept || nothing}"
|
|
455
|
+
?multiple="${this.maxFiles !== 1}"
|
|
456
|
+
?disabled="${isDisabled}"
|
|
457
|
+
@change="${this._handleInputChange}"
|
|
458
|
+
/>
|
|
459
|
+
|
|
460
|
+
<div
|
|
461
|
+
class="${dropzoneClasses}"
|
|
462
|
+
aria-label="${dropzoneLabel}"
|
|
463
|
+
aria-disabled="${isDisabled || isFull ? 'true' : 'false'}"
|
|
464
|
+
@click="${this._handleDropzoneClick}"
|
|
465
|
+
@dragenter="${this._handleDragEnter}"
|
|
466
|
+
@dragover="${this._handleDragOver}"
|
|
467
|
+
@dragleave="${this._handleDragLeave}"
|
|
468
|
+
@drop="${this._handleDrop}"
|
|
469
|
+
>
|
|
470
|
+
${this._showCountPill
|
|
471
|
+
? html `<span
|
|
472
|
+
class="btu-upload-dropzone-count"
|
|
473
|
+
aria-label="${l10n('upload', 'countOfMaxLabel', '___ of ___ files', [this._files.size, this.maxFiles])}"
|
|
474
|
+
>${l10n('upload', 'countOfMax', '___ of ___', [this._files.size, this.maxFiles])}</span
|
|
475
|
+
>`
|
|
476
|
+
: nothing}
|
|
477
|
+
<div class="btu-upload-dropzone-icon">
|
|
478
|
+
<btu-icon symbol="upload-cloud" size="md"></btu-icon>
|
|
479
|
+
</div>
|
|
480
|
+
<div class="btu-upload-dropzone-prompt">
|
|
481
|
+
<span class="btu-upload-dropzone-text" aria-hidden="${this._dragOver ? 'true' : 'false'}">
|
|
482
|
+
${this.noDrag
|
|
483
|
+
? this._renderSelectButton(l10n('upload', 'dropzoneActionNoDrag', 'Select files'))
|
|
484
|
+
: html `${l10n('upload', 'dropzonePrefix', 'Drag and drop or')}
|
|
485
|
+
${this._renderSelectButton(l10n('upload', 'dropzoneAction', 'select'))}
|
|
486
|
+
${l10n('upload', 'dropzoneSuffix', 'files')}`}
|
|
487
|
+
</span>
|
|
488
|
+
${this.noDrag
|
|
489
|
+
? nothing
|
|
490
|
+
: html `<span class="btu-upload-dropzone-drag-message" aria-hidden="${this._dragOver ? 'false' : 'true'}"
|
|
491
|
+
>${l10n('upload', 'dragOver', 'Drop Files Here')}</span
|
|
492
|
+
>`}
|
|
493
|
+
</div>
|
|
494
|
+
</div>
|
|
495
|
+
|
|
496
|
+
<div class="btu-upload-list" role="list" aria-label="${l10n('upload', 'listLabel', 'Uploaded files')}"></div>
|
|
497
|
+
`;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
__decorate([
|
|
501
|
+
property({ type: String })
|
|
502
|
+
], Upload.prototype, "accept", void 0);
|
|
503
|
+
__decorate([
|
|
504
|
+
property({ type: Number, attribute: 'max-file-size' })
|
|
505
|
+
], Upload.prototype, "maxFileSize", void 0);
|
|
506
|
+
__decorate([
|
|
507
|
+
property({
|
|
508
|
+
attribute: 'max-files',
|
|
509
|
+
converter: {
|
|
510
|
+
fromAttribute: value => {
|
|
511
|
+
if (value === null || value === '')
|
|
512
|
+
return Infinity;
|
|
513
|
+
const parsed = Number(value);
|
|
514
|
+
if (!Number.isFinite(parsed))
|
|
515
|
+
return Infinity;
|
|
516
|
+
return Math.max(0, Math.floor(parsed));
|
|
517
|
+
},
|
|
518
|
+
toAttribute: value => {
|
|
519
|
+
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
520
|
+
return null;
|
|
521
|
+
return String(value);
|
|
522
|
+
},
|
|
523
|
+
},
|
|
524
|
+
})
|
|
525
|
+
], Upload.prototype, "maxFiles", void 0);
|
|
526
|
+
__decorate([
|
|
527
|
+
property({ type: Boolean, reflect: true })
|
|
528
|
+
], Upload.prototype, "disabled", void 0);
|
|
529
|
+
__decorate([
|
|
530
|
+
property({ type: Boolean, attribute: 'no-drag' })
|
|
531
|
+
], Upload.prototype, "noDrag", void 0);
|
|
532
|
+
__decorate([
|
|
533
|
+
state()
|
|
534
|
+
], Upload.prototype, "_dragOver", void 0);
|
|
535
|
+
if (!customElements.get('btu-upload')) {
|
|
536
|
+
customElements.define('btu-upload', Upload);
|
|
537
|
+
}
|
|
538
|
+
//# sourceMappingURL=Upload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Upload.js","sourceRoot":"","sources":["../../../src/components/upload/Upload.ts"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,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;IACtC,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;AAC7C,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { LitElement, nothing } from 'lit';
|
|
2
|
+
import '../icon-button/IconButton.js';
|
|
3
|
+
import '../icon/Icon.js';
|
|
4
|
+
import '../linear-progress/LinearProgress.js';
|
|
5
|
+
export type FileStatus = 'pending' | 'uploading' | 'complete' | 'error';
|
|
6
|
+
export type FileStatusSettable = 'uploading' | 'complete' | 'error';
|
|
7
|
+
interface FileStateBase {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly file: File;
|
|
10
|
+
/** Optional icon override; when absent, derived from file.type */
|
|
11
|
+
readonly symbol?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Discriminated union on `status`. Illegal combinations (error with no message,
|
|
15
|
+
* uploading at 100% without completing, complete with an error message) are
|
|
16
|
+
* unrepresentable by construction.
|
|
17
|
+
*/
|
|
18
|
+
export type FileState = (FileStateBase & {
|
|
19
|
+
readonly status: 'pending';
|
|
20
|
+
readonly progress: 0;
|
|
21
|
+
}) | (FileStateBase & {
|
|
22
|
+
readonly status: 'uploading';
|
|
23
|
+
readonly progress: number;
|
|
24
|
+
}) | (FileStateBase & {
|
|
25
|
+
readonly status: 'complete';
|
|
26
|
+
readonly progress: 100;
|
|
27
|
+
}) | (FileStateBase & {
|
|
28
|
+
readonly status: 'error';
|
|
29
|
+
readonly progress: number;
|
|
30
|
+
readonly errorMessage: string;
|
|
31
|
+
});
|
|
32
|
+
declare const UploadItem_base: (new (...args: any[]) => import("../../util/EventEmitterMixin.js").EventEmitterMixinInterface) & (new (...args: any[]) => import("../../util/ReadyMixin.js").ReadyMixinInterface) & typeof LitElement;
|
|
33
|
+
/**
|
|
34
|
+
* Internal upload item sub-component for displaying individual file upload state.
|
|
35
|
+
*
|
|
36
|
+
* This component is not part of the public API — consumers should not create,
|
|
37
|
+
* query, or modify items directly. All interaction goes through `btu-upload` methods.
|
|
38
|
+
*
|
|
39
|
+
* @element btu-upload-item
|
|
40
|
+
*
|
|
41
|
+
* @fires {CustomEvent<{id: string}>} btu-upload-item-remove - Fired when remove button is clicked
|
|
42
|
+
* @fires {CustomEvent<{id: string}>} btu-upload-item-retry - Fired when retry link is clicked
|
|
43
|
+
*
|
|
44
|
+
* @cssprop --upload-item-bg - Item background color (default: white)
|
|
45
|
+
* @cssprop --upload-item-border-color - Item border color (default: gray-200)
|
|
46
|
+
* @cssprop --upload-item-active-border-color - Item active/in-progress border (default: gray-300)
|
|
47
|
+
* @cssprop --upload-item-complete-border-color - Item completed border color (default: primary-500)
|
|
48
|
+
* @cssprop --upload-item-error-bg - Item error background (default: error-25)
|
|
49
|
+
* @cssprop --upload-item-error-border-color - Item error border color (default: error-300)
|
|
50
|
+
*/
|
|
51
|
+
export default class UploadItem extends UploadItem_base {
|
|
52
|
+
private _state;
|
|
53
|
+
private _baseClasses;
|
|
54
|
+
private _previousStatus;
|
|
55
|
+
private _stopProgressComplete;
|
|
56
|
+
createRenderRoot(): this;
|
|
57
|
+
connectedCallback(): void;
|
|
58
|
+
disconnectedCallback(): void;
|
|
59
|
+
/** @internal Called by Upload to push file state */
|
|
60
|
+
_configure(state: FileState): void;
|
|
61
|
+
willUpdate(): void;
|
|
62
|
+
private _scheduleCelebrate;
|
|
63
|
+
private _handleRemove;
|
|
64
|
+
private _handleRetry;
|
|
65
|
+
render(): typeof nothing | import("lit-html").TemplateResult<1>;
|
|
66
|
+
}
|
|
67
|
+
declare global {
|
|
68
|
+
interface HTMLElementTagNameMap {
|
|
69
|
+
'btu-upload-item': UploadItem;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export {};
|
|
73
|
+
//# sourceMappingURL=UploadItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UploadItem.d.ts","sourceRoot":"","sources":["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