@viasat/beam-web-components 2.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/Accordion/Accordion.d.ts +56 -0
- package/Accordion/Accordion.js +12 -0
- package/Accordion/AccordionGroup.context.d.ts +10 -0
- package/Accordion/AccordionGroup.context.js +8 -0
- package/Accordion/AccordionGroup.d.ts +33 -0
- package/Accordion/AccordionGroup.js +79 -0
- package/Accordion/index.d.ts +3 -0
- package/Accordion/index.js +6 -0
- package/Alert/Alert.d.ts +64 -0
- package/Alert/Alert.js +300 -0
- package/Alert/index.d.ts +2 -0
- package/Alert/index.js +4 -0
- package/Avatar/Avatar.d.ts +60 -0
- package/Avatar/Avatar.js +12 -0
- package/Avatar/AvatarGroup.context.d.ts +11 -0
- package/Avatar/AvatarGroup.context.js +8 -0
- package/Avatar/AvatarGroup.d.ts +43 -0
- package/Avatar/AvatarGroup.js +181 -0
- package/Avatar/index.d.ts +3 -0
- package/Avatar/index.js +6 -0
- package/Badge/Badge.d.ts +40 -0
- package/Badge/Badge.js +125 -0
- package/Badge/index.d.ts +2 -0
- package/Badge/index.js +4 -0
- package/BadgeDot/BadgeDot.d.ts +38 -0
- package/BadgeDot/BadgeDot.js +59 -0
- package/BadgeDot/index.d.ts +2 -0
- package/BadgeDot/index.js +4 -0
- package/Box/Box.d.ts +99 -0
- package/Box/Box.js +115 -0
- package/Box/index.d.ts +2 -0
- package/Box/index.js +4 -0
- package/Breadcrumbs/Breadcrumbs.context.d.ts +10 -0
- package/Breadcrumbs/Breadcrumbs.context.js +8 -0
- package/Breadcrumbs/Breadcrumbs.d.ts +38 -0
- package/Breadcrumbs/Breadcrumbs.js +115 -0
- package/Breadcrumbs/BreadcrumbsItem.d.ts +39 -0
- package/Breadcrumbs/BreadcrumbsItem.js +13 -0
- package/Breadcrumbs/index.d.ts +3 -0
- package/Breadcrumbs/index.js +6 -0
- package/Button/Button.d.ts +73 -0
- package/Button/Button.js +125 -0
- package/Button/index.d.ts +2 -0
- package/Button/index.js +4 -0
- package/CloseButton/CloseButton.d.ts +25 -0
- package/CloseButton/CloseButton.js +60 -0
- package/CloseButton/index.d.ts +2 -0
- package/CloseButton/index.js +4 -0
- package/Divider/Divider.d.ts +56 -0
- package/Divider/Divider.js +111 -0
- package/Divider/index.d.ts +2 -0
- package/Divider/index.js +4 -0
- package/EmptyState/EmptyState.d.ts +36 -0
- package/EmptyState/EmptyState.js +56 -0
- package/EmptyState/index.d.ts +2 -0
- package/EmptyState/index.js +4 -0
- package/HelperText/HelperText.d.ts +45 -0
- package/HelperText/HelperText.js +11 -0
- package/HelperText/index.d.ts +2 -0
- package/HelperText/index.js +4 -0
- package/Icon/Icon.d.ts +35 -0
- package/Icon/Icon.js +62 -0
- package/Icon/index.d.ts +2 -0
- package/Icon/index.js +4 -0
- package/InputChoiceGroup/InputChoiceGroup.context.d.ts +13 -0
- package/InputChoiceGroup/InputChoiceGroup.context.js +8 -0
- package/InputChoiceGroup/InputChoiceGroup.d.ts +87 -0
- package/InputChoiceGroup/InputChoiceGroup.js +205 -0
- package/InputChoiceGroup/index.d.ts +2 -0
- package/InputChoiceGroup/index.js +4 -0
- package/Link/Link.d.ts +48 -0
- package/Link/Link.js +77 -0
- package/Link/index.d.ts +2 -0
- package/Link/index.js +4 -0
- package/List/List.context.d.ts +15 -0
- package/List/List.context.js +8 -0
- package/List/List.d.ts +43 -0
- package/List/List.js +101 -0
- package/List/ListItem.d.ts +23 -0
- package/List/ListItem.js +90 -0
- package/List/index.d.ts +3 -0
- package/List/index.js +6 -0
- package/ProgressBar/ProgressBar.d.ts +52 -0
- package/ProgressBar/ProgressBar.js +128 -0
- package/ProgressBar/index.d.ts +2 -0
- package/ProgressBar/index.js +4 -0
- package/README.md +360 -0
- package/SegmentedControl/SegmentedControl.context.d.ts +16 -0
- package/SegmentedControl/SegmentedControl.context.js +8 -0
- package/SegmentedControl/SegmentedControl.d.ts +41 -0
- package/SegmentedControl/SegmentedControl.js +103 -0
- package/SegmentedControl/SegmentedControlItem.d.ts +54 -0
- package/SegmentedControl/SegmentedControlItem.js +284 -0
- package/SegmentedControl/SegmentedControlList.d.ts +23 -0
- package/SegmentedControl/SegmentedControlList.js +61 -0
- package/SegmentedControl/SegmentedControlPanel.d.ts +21 -0
- package/SegmentedControl/SegmentedControlPanel.js +43 -0
- package/SegmentedControl/index.d.ts +5 -0
- package/SegmentedControl/index.js +10 -0
- package/Spinner/Spinner.d.ts +50 -0
- package/Spinner/Spinner.js +186 -0
- package/Spinner/index.d.ts +2 -0
- package/Spinner/index.js +4 -0
- package/StateLayer/StateLayer.d.ts +17 -0
- package/StateLayer/StateLayer.js +6 -0
- package/StateLayer/index.d.ts +2 -0
- package/StateLayer/index.js +5 -0
- package/Text/Text.d.ts +85 -0
- package/Text/Text.js +103 -0
- package/Text/index.d.ts +2 -0
- package/Text/index.js +4 -0
- package/Tooltip/Tooltip.d.ts +139 -0
- package/Tooltip/Tooltip.js +1827 -0
- package/Tooltip/index.d.ts +2 -0
- package/Tooltip/index.js +5 -0
- package/chunks/Accordion.DYD3XcAx.js +161 -0
- package/chunks/Avatar.C2rfzUGP.js +174 -0
- package/chunks/BreadcrumbsItem.4ZR6wbMz.js +121 -0
- package/chunks/CSSLookup.BdqZ5Li9.js +106 -0
- package/chunks/HelperText.CcVVOtA3.js +108 -0
- package/chunks/Upload.B9YEyp7b.js +12 -0
- package/chunks/WarningOutlined.DPfQnPPj.js +12 -0
- package/chunks/classNames.Cq_tbDRp.js +94 -0
- package/chunks/constants.jOWREYQE.js +30 -0
- package/chunks/delegate.baxDQosr.js +63 -0
- package/chunks/dom.C98AFbJh.js +22 -0
- package/chunks/fileUpload.module.kN6o64aL.js +4 -0
- package/chunks/globals.Bz4SVF2g.js +4 -0
- package/chunks/helpers.AwJwaZvv.js +53 -0
- package/chunks/list.module.CZRPBLzy.js +4 -0
- package/chunks/register-custom-element.DHGKOhmA.js +17 -0
- package/chunks/segmentedControl.module.BPXEWodj.js +4 -0
- package/chunks/tokens.CTW8Tt94.js +9 -0
- package/custom-elements.json +11341 -0
- package/local/Accordion/Accordion.js +12 -0
- package/local/Accordion/AccordionGroup.context.js +8 -0
- package/local/Accordion/AccordionGroup.js +78 -0
- package/local/Accordion/index.js +6 -0
- package/local/Alert/Alert.js +301 -0
- package/local/Alert/index.js +4 -0
- package/local/Avatar/Avatar.js +11 -0
- package/local/Avatar/AvatarGroup.context.js +8 -0
- package/local/Avatar/AvatarGroup.js +180 -0
- package/local/Avatar/index.js +6 -0
- package/local/Badge/Badge.js +123 -0
- package/local/Badge/index.js +4 -0
- package/local/BadgeDot/BadgeDot.js +57 -0
- package/local/BadgeDot/index.js +4 -0
- package/local/Box/Box.js +113 -0
- package/local/Box/index.js +4 -0
- package/local/Breadcrumbs/Breadcrumbs.context.js +8 -0
- package/local/Breadcrumbs/Breadcrumbs.js +113 -0
- package/local/Breadcrumbs/BreadcrumbsItem.js +13 -0
- package/local/Breadcrumbs/index.js +6 -0
- package/local/Button/Button.js +154 -0
- package/local/Button/index.js +4 -0
- package/local/CloseButton/CloseButton.js +58 -0
- package/local/CloseButton/index.js +4 -0
- package/local/Divider/Divider.js +111 -0
- package/local/Divider/index.js +4 -0
- package/local/EmptyState/EmptyState.js +54 -0
- package/local/EmptyState/index.js +4 -0
- package/local/HelperText/HelperText.js +9 -0
- package/local/HelperText/index.js +4 -0
- package/local/Icon/Icon.js +60 -0
- package/local/Icon/index.js +4 -0
- package/local/InputChoiceGroup/InputChoiceGroup.context.js +8 -0
- package/local/InputChoiceGroup/InputChoiceGroup.js +205 -0
- package/local/InputChoiceGroup/index.js +4 -0
- package/local/Link/Link.js +75 -0
- package/local/Link/index.js +4 -0
- package/local/List/List.context.js +8 -0
- package/local/List/List.js +101 -0
- package/local/List/ListItem.js +90 -0
- package/local/List/index.js +6 -0
- package/local/ProgressBar/ProgressBar.js +126 -0
- package/local/ProgressBar/index.js +4 -0
- package/local/SegmentedControl/SegmentedControl.context.js +8 -0
- package/local/SegmentedControl/SegmentedControl.js +103 -0
- package/local/SegmentedControl/SegmentedControlItem.js +284 -0
- package/local/SegmentedControl/SegmentedControlList.js +59 -0
- package/local/SegmentedControl/SegmentedControlPanel.js +41 -0
- package/local/SegmentedControl/index.js +10 -0
- package/local/Spinner/Spinner.js +185 -0
- package/local/Spinner/index.js +4 -0
- package/local/StateLayer/StateLayer.js +6 -0
- package/local/StateLayer/index.js +5 -0
- package/local/Text/Text.js +121 -0
- package/local/Text/index.js +4 -0
- package/local/Tooltip/Tooltip.js +1826 -0
- package/local/Tooltip/index.js +5 -0
- package/local/chunks/Accordion.PGU7OILE.js +161 -0
- package/local/chunks/Avatar.CvTOzaRT.js +172 -0
- package/local/chunks/BreadcrumbsItem.GM6sBp_o.js +121 -0
- package/local/chunks/CSSLookup.BdqZ5Li9.js +106 -0
- package/local/chunks/Upload.B9YEyp7b.js +12 -0
- package/local/chunks/WarningOutlined.DPfQnPPj.js +12 -0
- package/local/chunks/base.D76d76ww.js +9 -0
- package/local/chunks/classNames.C6fNrXWF.js +106 -0
- package/local/chunks/constants.jOWREYQE.js +30 -0
- package/local/chunks/consume.Ce9k1-wN.js +47 -0
- package/local/chunks/context-request-event.Bl9Vpkzl.js +13 -0
- package/local/chunks/create-context.DS1OG3vJ.js +11 -0
- package/local/chunks/delegate.baxDQosr.js +63 -0
- package/local/chunks/directive.kLG6oqUu.js +27 -0
- package/local/chunks/dom.C98AFbJh.js +22 -0
- package/local/chunks/fileUpload.module.kN6o64aL.js +4 -0
- package/local/chunks/globals.Bz4SVF2g.js +4 -0
- package/local/chunks/helpers.BWcXAteC.js +53 -0
- package/local/chunks/index.Bz1Jq4c2.js +106 -0
- package/local/chunks/list.module.CZRPBLzy.js +4 -0
- package/local/chunks/lit-element.CJtt9wj5.js +557 -0
- package/local/chunks/provide.i2FlUkOu.js +110 -0
- package/local/chunks/query-assigned-elements.Drkgpk9q.js +19 -0
- package/local/chunks/query-assigned-nodes.Dgvsf6BR.js +19 -0
- package/local/chunks/query.lbpOn5CD.js +20 -0
- package/local/chunks/ref.B7e1Hu4F.js +107 -0
- package/local/chunks/register-custom-element.vod7zfGv.js +51 -0
- package/local/chunks/segmentedControl.module.BPXEWodj.js +4 -0
- package/local/chunks/state.CqiuSzAl.js +12 -0
- package/local/chunks/tokens.CTW8Tt94.js +9 -0
- package/local/chunks/unsafe-html.BzhXEygn.js +27 -0
- package/local/chunks/unsafe-svg.HSGf1NCU.js +14 -0
- package/local/wip/Checkbox/Checkbox.js +102 -0
- package/local/wip/Checkbox/CheckboxGroup/CheckboxGroup.js +27 -0
- package/local/wip/Checkbox/index.js +6 -0
- package/local/wip/FileUpload/FileUpload.Button.js +75 -0
- package/local/wip/FileUpload/FileUpload.Dropzone.js +149 -0
- package/local/wip/FileUpload/FileUpload.List.Item.js +201 -0
- package/local/wip/FileUpload/FileUpload.List.js +105 -0
- package/local/wip/FileUpload/FileUpload.js +452 -0
- package/local/wip/FileUpload/FileUploadContext.js +8 -0
- package/local/wip/FileUpload/FileUploadListContext.js +8 -0
- package/local/wip/FileUpload/index.js +13 -0
- package/local/wip/Form/Form.context.js +20 -0
- package/local/wip/Form/Form.decorator.js +145 -0
- package/local/wip/Form/Form.js +288 -0
- package/local/wip/Form/Form.utils.js +8 -0
- package/local/wip/Form/index.js +7 -0
- package/local/wip/Label/Label.js +86 -0
- package/local/wip/Label/index.js +4 -0
- package/local/wip/NativeSelect/NativeSelect.js +162 -0
- package/local/wip/NativeSelect/index.js +4 -0
- package/local/wip/RadioButton/RadioButton.js +123 -0
- package/local/wip/RadioButton/RadioButtonGroup/RadioButtonGroup.js +96 -0
- package/local/wip/RadioButton/index.js +6 -0
- package/local/wip/Switch/Switch.js +153 -0
- package/local/wip/Switch/SwitchGroup/SwitchGroup.js +15 -0
- package/local/wip/Switch/index.js +6 -0
- package/local/wip/TextArea/TextArea.js +192 -0
- package/local/wip/TextArea/index.js +4 -0
- package/local/wip/TextField/TextField.js +169 -0
- package/local/wip/TextField/index.js +4 -0
- package/package.json +78 -0
- package/vscode.css-custom-data.json +6 -0
- package/vscode.html-custom-data.json +2704 -0
- package/wip/Checkbox/Checkbox.d.ts +55 -0
- package/wip/Checkbox/Checkbox.js +104 -0
- package/wip/Checkbox/CheckboxGroup/CheckboxGroup.d.ts +11 -0
- package/wip/Checkbox/CheckboxGroup/CheckboxGroup.js +27 -0
- package/wip/Checkbox/index.d.ts +3 -0
- package/wip/Checkbox/index.js +6 -0
- package/wip/FileUpload/FileUpload.Button.d.ts +36 -0
- package/wip/FileUpload/FileUpload.Button.js +77 -0
- package/wip/FileUpload/FileUpload.Dropzone.d.ts +55 -0
- package/wip/FileUpload/FileUpload.Dropzone.js +150 -0
- package/wip/FileUpload/FileUpload.List.Item.d.ts +62 -0
- package/wip/FileUpload/FileUpload.List.Item.js +203 -0
- package/wip/FileUpload/FileUpload.List.d.ts +46 -0
- package/wip/FileUpload/FileUpload.List.js +106 -0
- package/wip/FileUpload/FileUpload.d.ts +101 -0
- package/wip/FileUpload/FileUpload.js +451 -0
- package/wip/FileUpload/FileUploadContext.d.ts +5 -0
- package/wip/FileUpload/FileUploadContext.js +8 -0
- package/wip/FileUpload/FileUploadListContext.d.ts +5 -0
- package/wip/FileUpload/FileUploadListContext.js +8 -0
- package/wip/FileUpload/index.d.ts +6 -0
- package/wip/FileUpload/index.js +13 -0
- package/wip/Form/Form.context.d.ts +19 -0
- package/wip/Form/Form.context.js +20 -0
- package/wip/Form/Form.d.ts +50 -0
- package/wip/Form/Form.decorator.d.ts +47 -0
- package/wip/Form/Form.decorator.js +144 -0
- package/wip/Form/Form.js +288 -0
- package/wip/Form/Form.utils.d.ts +2 -0
- package/wip/Form/Form.utils.js +8 -0
- package/wip/Form/index.d.ts +3 -0
- package/wip/Form/index.js +7 -0
- package/wip/Label/Label.d.ts +43 -0
- package/wip/Label/Label.js +87 -0
- package/wip/Label/index.d.ts +2 -0
- package/wip/Label/index.js +4 -0
- package/wip/NativeSelect/NativeSelect.d.ts +69 -0
- package/wip/NativeSelect/NativeSelect.js +163 -0
- package/wip/NativeSelect/index.d.ts +2 -0
- package/wip/NativeSelect/index.js +4 -0
- package/wip/RadioButton/RadioButton.d.ts +56 -0
- package/wip/RadioButton/RadioButton.js +125 -0
- package/wip/RadioButton/RadioButtonGroup/RadioButtonGroup.d.ts +23 -0
- package/wip/RadioButton/RadioButtonGroup/RadioButtonGroup.js +96 -0
- package/wip/RadioButton/index.d.ts +3 -0
- package/wip/RadioButton/index.js +6 -0
- package/wip/Switch/Switch.d.ts +62 -0
- package/wip/Switch/Switch.js +155 -0
- package/wip/Switch/SwitchGroup/SwitchGroup.d.ts +15 -0
- package/wip/Switch/SwitchGroup/SwitchGroup.js +15 -0
- package/wip/Switch/index.d.ts +3 -0
- package/wip/Switch/index.js +6 -0
- package/wip/TextArea/TextArea.d.ts +89 -0
- package/wip/TextArea/TextArea.js +193 -0
- package/wip/TextArea/index.d.ts +2 -0
- package/wip/TextArea/index.js +4 -0
- package/wip/TextField/TextField.d.ts +70 -0
- package/wip/TextField/TextField.js +169 -0
- package/wip/TextField/index.d.ts +2 -0
- package/wip/TextField/index.js +4 -0
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
import { e as G } from "../../chunks/provide.i2FlUkOu.js";
|
|
2
|
+
import { c as K } from "../../chunks/consume.Ce9k1-wN.js";
|
|
3
|
+
import { r as J, E as b, x } from "../../chunks/lit-element.CJtt9wj5.js";
|
|
4
|
+
import { n as c, c as Q } from "../../chunks/register-custom-element.vod7zfGv.js";
|
|
5
|
+
import { r as P } from "../../chunks/state.CqiuSzAl.js";
|
|
6
|
+
import { o as N } from "../../chunks/query-assigned-elements.Drkgpk9q.js";
|
|
7
|
+
import { e as X } from "../../chunks/ref.B7e1Hu4F.js";
|
|
8
|
+
import { p as Y, a as z, c as Z, g as ee, d as q } from "../../chunks/classNames.C6fNrXWF.js";
|
|
9
|
+
import { t as te } from "../../chunks/constants.jOWREYQE.js";
|
|
10
|
+
import { f as ie } from "../../chunks/fileUpload.module.kN6o64aL.js";
|
|
11
|
+
import { d as re } from "../../chunks/tokens.CTW8Tt94.js";
|
|
12
|
+
import { r as se } from "../../chunks/delegate.baxDQosr.js";
|
|
13
|
+
import { bmFormContext as oe, bmFormInitials as H } from "../Form/Form.context.js";
|
|
14
|
+
import { FormField as ae } from "../Form/Form.decorator.js";
|
|
15
|
+
import { fileUploadContext as le } from "./FileUploadContext.js";
|
|
16
|
+
import "../../chunks/index.Bz1Jq4c2.js";
|
|
17
|
+
import "./FileUpload.Dropzone.js";
|
|
18
|
+
import "./FileUpload.List.js";
|
|
19
|
+
var ne = function(e, t) {
|
|
20
|
+
if (e && t) {
|
|
21
|
+
var i = Array.isArray(t) ? t : t.split(",");
|
|
22
|
+
if (i.length === 0)
|
|
23
|
+
return !0;
|
|
24
|
+
var r = e.name || "", s = (e.type || "").toLowerCase(), n = s.replace(/\/.*$/, "");
|
|
25
|
+
return i.some(function(p) {
|
|
26
|
+
var d = p.trim().toLowerCase();
|
|
27
|
+
return d.charAt(0) === "." ? r.toLowerCase().endsWith(d) : d.endsWith("/*") ? n === d.replace(/\/.*$/, "") : s === d;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return !0;
|
|
31
|
+
};
|
|
32
|
+
const de = (e, t) => {
|
|
33
|
+
const i = new FormData();
|
|
34
|
+
return t.files.forEach((r, s) => {
|
|
35
|
+
t.shouldAddToFormData[s] && i.append(e, r);
|
|
36
|
+
}), i;
|
|
37
|
+
}, he = {
|
|
38
|
+
fileItems: [],
|
|
39
|
+
abortControllers: [],
|
|
40
|
+
files: [],
|
|
41
|
+
shouldAddToFormData: [],
|
|
42
|
+
validFileCount: 0
|
|
43
|
+
};
|
|
44
|
+
function pe(e) {
|
|
45
|
+
return e < 6 ? `${e} B` : e < 1048576 / 2 ? `${(e / 1024).toFixed(2)} KB` : e < 1073741824 / 2 ? `${(e / 1048576).toFixed(2)} MB` : e < 1099511627776 / 2 ? `${(e / 1073741824).toFixed(2)} GB` : `${(e / 1099511627776 / 2).toFixed(2)} TB`;
|
|
46
|
+
}
|
|
47
|
+
const ce = (e, t, { accept: i, fileLimit: r, maxFileSize: s }) => {
|
|
48
|
+
if (i && !ne(e, i))
|
|
49
|
+
return "Incorrect file type";
|
|
50
|
+
if (r && t >= r)
|
|
51
|
+
return "Attachment limit reached";
|
|
52
|
+
if (s && e.size > s)
|
|
53
|
+
return "File size exceeds limit";
|
|
54
|
+
}, me = (e, {
|
|
55
|
+
state: t,
|
|
56
|
+
error: i
|
|
57
|
+
}) => ({
|
|
58
|
+
id: URL.createObjectURL(e),
|
|
59
|
+
fileName: e.name,
|
|
60
|
+
fileSize: pe(e.size),
|
|
61
|
+
state: t ?? "uploaded",
|
|
62
|
+
progress: 0,
|
|
63
|
+
error: i
|
|
64
|
+
}), ue = (e, t) => {
|
|
65
|
+
const i = new Image();
|
|
66
|
+
i.src = URL.createObjectURL(e), i.onload = () => {
|
|
67
|
+
const r = document.createElement("canvas"), s = r.getContext("2d");
|
|
68
|
+
s && (r.width = i.width, r.height = i.height, s.drawImage(i, 0, 0), t(r.toDataURL("image/jpeg")));
|
|
69
|
+
};
|
|
70
|
+
}, fe = (e) => URL.createObjectURL(e), xe = (e, t) => {
|
|
71
|
+
const i = document.createElement("video"), r = document.createElement("source"), s = document.createElement("canvas"), n = s.getContext("2d");
|
|
72
|
+
if (!n)
|
|
73
|
+
return;
|
|
74
|
+
i.crossOrigin = "anonymous", i.preload = "metadata", i.appendChild(r), r.src = URL.createObjectURL(e), i.currentTime = 0, i.load(), i.addEventListener("loadedmetadata", () => {
|
|
75
|
+
s.width = i.videoWidth, s.height = i.videoHeight;
|
|
76
|
+
});
|
|
77
|
+
const p = () => {
|
|
78
|
+
n.drawImage(i, 0, 0, s.width, s.height), t(s.toDataURL("image/jpeg"));
|
|
79
|
+
};
|
|
80
|
+
if (typeof i.requestVideoFrameCallback < "u")
|
|
81
|
+
i.requestVideoFrameCallback(p);
|
|
82
|
+
else {
|
|
83
|
+
const d = () => {
|
|
84
|
+
setTimeout(p, 0), i.removeEventListener("seeked", d);
|
|
85
|
+
};
|
|
86
|
+
i.addEventListener("seeked", d);
|
|
87
|
+
}
|
|
88
|
+
}, ye = (e, t) => {
|
|
89
|
+
if (e.type === "image/gif")
|
|
90
|
+
return ue(e, t);
|
|
91
|
+
if (e.type.startsWith("image/"))
|
|
92
|
+
return fe(e);
|
|
93
|
+
if (e.type.startsWith("video/"))
|
|
94
|
+
return xe(e, t);
|
|
95
|
+
};
|
|
96
|
+
function ve(e, t) {
|
|
97
|
+
t({ type: "remove", payload: e });
|
|
98
|
+
}
|
|
99
|
+
function Fe(e, t, i, r, s, n, p, d) {
|
|
100
|
+
if (!e)
|
|
101
|
+
return;
|
|
102
|
+
let f = i;
|
|
103
|
+
const k = Array.from(e).map((y) => {
|
|
104
|
+
const C = ce(y, f, {
|
|
105
|
+
accept: r,
|
|
106
|
+
fileLimit: s,
|
|
107
|
+
maxFileSize: n
|
|
108
|
+
}), m = me(y, {
|
|
109
|
+
error: C,
|
|
110
|
+
state: C ? "error" : p
|
|
111
|
+
}), V = new AbortController();
|
|
112
|
+
m.thumbnail = ye(y, (v) => {
|
|
113
|
+
t({
|
|
114
|
+
type: "update",
|
|
115
|
+
payload: { fileItem: m, updates: { thumbnail: v } }
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
let $ = !C;
|
|
119
|
+
return C || (f++, d ? $ = (d == null ? void 0 : d(
|
|
120
|
+
y,
|
|
121
|
+
{
|
|
122
|
+
progress(v) {
|
|
123
|
+
t({
|
|
124
|
+
type: "update",
|
|
125
|
+
payload: { fileItem: m, updates: { state: "uploading", progress: v } }
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
success() {
|
|
129
|
+
t({
|
|
130
|
+
type: "update",
|
|
131
|
+
payload: { fileItem: m, updates: { state: "success" } }
|
|
132
|
+
}), setTimeout(() => {
|
|
133
|
+
t({
|
|
134
|
+
type: "update",
|
|
135
|
+
payload: { fileItem: m, updates: { state: "uploaded" } }
|
|
136
|
+
});
|
|
137
|
+
}, 3e3);
|
|
138
|
+
},
|
|
139
|
+
error(v) {
|
|
140
|
+
t({
|
|
141
|
+
type: "update",
|
|
142
|
+
payload: { fileItem: m, updates: { state: "error", error: v } }
|
|
143
|
+
});
|
|
144
|
+
},
|
|
145
|
+
dismiss() {
|
|
146
|
+
t({ type: "remove", payload: m });
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
V.signal
|
|
150
|
+
)) ?? !1 : $ = !0), { file: y, fileItem: m, abortController: V, shouldAddToFormData: $ };
|
|
151
|
+
});
|
|
152
|
+
t({ type: "add", payload: k });
|
|
153
|
+
}
|
|
154
|
+
function Ce(e, t) {
|
|
155
|
+
var i;
|
|
156
|
+
switch (t.type) {
|
|
157
|
+
case "add":
|
|
158
|
+
return {
|
|
159
|
+
fileItems: [
|
|
160
|
+
...e.fileItems,
|
|
161
|
+
...t.payload.map(({ fileItem: r }) => r)
|
|
162
|
+
],
|
|
163
|
+
abortControllers: [
|
|
164
|
+
...e.abortControllers,
|
|
165
|
+
...t.payload.map(({ abortController: r }) => r)
|
|
166
|
+
],
|
|
167
|
+
files: [...e.files, ...t.payload.map(({ file: r }) => r)],
|
|
168
|
+
shouldAddToFormData: [
|
|
169
|
+
...e.shouldAddToFormData,
|
|
170
|
+
...t.payload.map(({ shouldAddToFormData: r }) => r)
|
|
171
|
+
],
|
|
172
|
+
validFileCount: t.payload.reduce(
|
|
173
|
+
(r, { fileItem: s }) => s.state !== "error" ? r + 1 : r,
|
|
174
|
+
e.validFileCount
|
|
175
|
+
)
|
|
176
|
+
};
|
|
177
|
+
case "remove": {
|
|
178
|
+
const { payload: r } = t, s = e.fileItems.findIndex((n) => n.id === r.id);
|
|
179
|
+
return s < 0 ? e : ((i = e.abortControllers[s]) == null || i.abort(), {
|
|
180
|
+
fileItems: [
|
|
181
|
+
...e.fileItems.slice(0, s),
|
|
182
|
+
...e.fileItems.slice(s + 1)
|
|
183
|
+
],
|
|
184
|
+
abortControllers: [
|
|
185
|
+
...e.abortControllers.slice(0, s),
|
|
186
|
+
...e.abortControllers.slice(s + 1)
|
|
187
|
+
],
|
|
188
|
+
files: [...e.files.slice(0, s), ...e.files.slice(s + 1)],
|
|
189
|
+
shouldAddToFormData: [
|
|
190
|
+
...e.shouldAddToFormData.slice(0, s),
|
|
191
|
+
...e.shouldAddToFormData.slice(s + 1)
|
|
192
|
+
],
|
|
193
|
+
validFileCount: e.validFileCount - (r.state !== "error" ? 1 : 0)
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
case "update": {
|
|
197
|
+
const { fileItem: r, updates: s } = t.payload, n = e.fileItems.findIndex((k) => k.id === r.id);
|
|
198
|
+
if (n < 0)
|
|
199
|
+
return e;
|
|
200
|
+
const p = e.fileItems[n].state, d = s.state ?? p;
|
|
201
|
+
let f = e.validFileCount;
|
|
202
|
+
return p !== "error" && d === "error" && (f -= 1), p === "error" && d !== "error" && (f += 1), {
|
|
203
|
+
...e,
|
|
204
|
+
fileItems: [
|
|
205
|
+
...e.fileItems.slice(0, n),
|
|
206
|
+
{ ...e.fileItems[n], ...s },
|
|
207
|
+
...e.fileItems.slice(n + 1)
|
|
208
|
+
],
|
|
209
|
+
validFileCount: f
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
default:
|
|
213
|
+
return e;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
var be = Object.defineProperty, we = Object.getOwnPropertyDescriptor, j = (e) => {
|
|
217
|
+
throw TypeError(e);
|
|
218
|
+
}, l = (e, t, i, r) => {
|
|
219
|
+
for (var s = r > 1 ? void 0 : r ? we(t, i) : t, n = e.length - 1, p; n >= 0; n--)
|
|
220
|
+
(p = e[n]) && (s = (r ? p(t, i, s) : p(s)) || s);
|
|
221
|
+
return r && s && be(t, i, s), s;
|
|
222
|
+
}, ge = (e, t, i) => t.has(e) || j("Cannot " + i), o = (e, t, i) => (ge(e, t, "read from private field"), i ? i.call(e) : t.get(e)), h = (e, t, i) => t.has(e) ? j("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, i), u, L, T, S, W, A, E, _, I, F, M, R, D, B, U, O;
|
|
223
|
+
const { baseClassNamePrefix: Se, classModifierPrefix: w, subElementClassPrefix: g } = ee("file-upload");
|
|
224
|
+
class _e extends CustomEvent {
|
|
225
|
+
constructor(t, i, r) {
|
|
226
|
+
super("bm-selected", {
|
|
227
|
+
detail: { file: t, actions: i, abortSignal: r },
|
|
228
|
+
cancelable: !0,
|
|
229
|
+
bubbles: !0,
|
|
230
|
+
composed: !0
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
let a = class extends ae {
|
|
235
|
+
constructor() {
|
|
236
|
+
super(...arguments), this.disabled = !1, this.validationRules = [], this.fileUploadContext = {}, this.pickerRef = X(), h(this, u, () => {
|
|
237
|
+
var e;
|
|
238
|
+
return !!(this.disabled || (e = this.formContext) != null && e.disabled);
|
|
239
|
+
}), h(this, L, () => {
|
|
240
|
+
var e;
|
|
241
|
+
return !!(this.readOnly || (e = this.formContext) != null && e.readOnly);
|
|
242
|
+
}), h(this, T, () => {
|
|
243
|
+
var e;
|
|
244
|
+
return !!(this.required || (e = this.formContext) != null && e.required);
|
|
245
|
+
}), this.filesState = he, h(this, S, (e) => {
|
|
246
|
+
this.filesState = Ce(this.filesState, e), this.fileUploadContext = {
|
|
247
|
+
...this.fileUploadContext,
|
|
248
|
+
ctxFileItems: this.filesState.fileItems
|
|
249
|
+
}, this.setAssociatedValue(o(this, I).call(this));
|
|
250
|
+
}), h(this, W, (e, t, i) => {
|
|
251
|
+
const r = new _e(e, t, i);
|
|
252
|
+
return this.dispatchEvent(r);
|
|
253
|
+
}), h(this, A, (e) => {
|
|
254
|
+
Fe(
|
|
255
|
+
e,
|
|
256
|
+
o(this, S),
|
|
257
|
+
this.filesState.validFileCount,
|
|
258
|
+
this.accept,
|
|
259
|
+
this.fileLimit,
|
|
260
|
+
this.maxFileSize,
|
|
261
|
+
"uploaded",
|
|
262
|
+
o(this, W)
|
|
263
|
+
);
|
|
264
|
+
}), h(this, E, (e) => {
|
|
265
|
+
ve(e, o(this, S));
|
|
266
|
+
}), h(this, _, new CSSStyleSheet()), h(this, I, () => de(this.name, this.filesState)), h(this, F, () => {
|
|
267
|
+
const { initialValues: e } = this.formContext || H, { [this.name]: t } = e || {};
|
|
268
|
+
this.setAssociatedValue(
|
|
269
|
+
t instanceof FormData ? t : new FormData()
|
|
270
|
+
);
|
|
271
|
+
}), h(this, M, () => {
|
|
272
|
+
var e;
|
|
273
|
+
(e = this.pickerRef.value) == null || e.focus();
|
|
274
|
+
}), h(this, R, (e) => this.error ? x`
|
|
275
|
+
<bm-helper-text
|
|
276
|
+
id="${e}"
|
|
277
|
+
text="${this.error}"
|
|
278
|
+
appearance="negative"
|
|
279
|
+
.disabled="${o(this, u).call(this)}"
|
|
280
|
+
class="${g}helper-text"
|
|
281
|
+
></bm-helper-text>
|
|
282
|
+
` : b), this._hasPickerSlot = !1, h(this, D, () => !!this._hasPickerSlot), h(this, B, () => x`
|
|
283
|
+
<slot name="picker" @slotchange=${(t) => {
|
|
284
|
+
this._hasPickerSlot = q(t);
|
|
285
|
+
}}></slot>
|
|
286
|
+
${o(this, D).call(this) ? b : x`<bm-file-upload-dropzone></bm-file-upload-dropzone>`}
|
|
287
|
+
`), this._hasFilesListSlot = !1, h(this, U, () => !!this._hasFilesListSlot), h(this, O, () => x`
|
|
288
|
+
<div class="${g}files-list">
|
|
289
|
+
<slot name="files-list" @slotchange=${(t) => {
|
|
290
|
+
this._hasFilesListSlot = q(t);
|
|
291
|
+
}}></slot>
|
|
292
|
+
${o(this, U).call(this) ? b : x`<bm-file-upload-list thumbnail="false"></bm-file-upload-list>`}
|
|
293
|
+
</div>
|
|
294
|
+
`);
|
|
295
|
+
}
|
|
296
|
+
willUpdate() {
|
|
297
|
+
this.fileUploadContext = {
|
|
298
|
+
ctxAccept: this.accept,
|
|
299
|
+
ctxMultiple: this.multiple,
|
|
300
|
+
ctxFileLimit: this.fileLimit,
|
|
301
|
+
ctxMaxFileSize: this.maxFileSize,
|
|
302
|
+
ctxFileItems: this.filesState.fileItems,
|
|
303
|
+
ctxAddFiles: o(this, A),
|
|
304
|
+
ctxDismissFile: o(this, E),
|
|
305
|
+
ctxError: !!this.error,
|
|
306
|
+
ctxDisabled: o(this, u).call(this)
|
|
307
|
+
};
|
|
308
|
+
const e = this.fluid ? "100%" : this.width ?? re;
|
|
309
|
+
o(this, _).replace(`:host { width: ${e}; }`);
|
|
310
|
+
}
|
|
311
|
+
firstUpdated() {
|
|
312
|
+
var i, r;
|
|
313
|
+
(r = (i = this.shadowRoot) == null ? void 0 : i.adoptedStyleSheets) == null || r.push(o(this, _));
|
|
314
|
+
const { value: e } = this.pickerRef, { registerField: t } = this.formContext || H;
|
|
315
|
+
!e || o(this, u).call(this) || t({
|
|
316
|
+
validators: this.validationRules,
|
|
317
|
+
initializer: o(this, F),
|
|
318
|
+
field: e,
|
|
319
|
+
errorSetter: this.setValidationErrors.bind(this)
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
updated(e) {
|
|
323
|
+
const [t] = this._textFieldLabel, [i] = this._textFieldHelperText, { decorate: r } = z(t), { decorate: s } = z(i);
|
|
324
|
+
Y(e, ["formContext"]) && this.ctxValueChanged(this.formContext, this.pickerRef) && o(this, F).call(this), s({ disabled: o(this, u).call(this) }), r({
|
|
325
|
+
disabled: o(this, u).call(this),
|
|
326
|
+
required: o(this, T).call(this) && !this.hideRequiredMarker
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
formAssociatedCallback() {
|
|
330
|
+
this.setAssociatedValue(o(this, I).call(this));
|
|
331
|
+
}
|
|
332
|
+
formResetCallback() {
|
|
333
|
+
o(this, F).call(this);
|
|
334
|
+
}
|
|
335
|
+
render() {
|
|
336
|
+
const { length: e } = this.validationErrors(), t = !!this.error || !!e, i = Z(
|
|
337
|
+
Se,
|
|
338
|
+
t && `${w}error`,
|
|
339
|
+
this.theme && te(this.theme),
|
|
340
|
+
this.fluid && `${w}fluid`,
|
|
341
|
+
o(this, u).call(this) && `${w}disabled`,
|
|
342
|
+
o(this, L).call(this) && `${w}read-only`
|
|
343
|
+
);
|
|
344
|
+
return x`
|
|
345
|
+
<div class=${i} style="max-width: ${this.width ?? b}">
|
|
346
|
+
<div class="${g}uploader">
|
|
347
|
+
<slot
|
|
348
|
+
name="label"
|
|
349
|
+
id=${this.labelId}
|
|
350
|
+
@bm-label-clicked=${o(this, M)}
|
|
351
|
+
></slot>
|
|
352
|
+
<div class="${g}field">${o(this, B).call(this)}</div>
|
|
353
|
+
<slot name="helper-text" id="${this.helperTextId}"></slot>
|
|
354
|
+
${o(this, R).call(this, this.errorId)} ${this.renderValidationErrors()}
|
|
355
|
+
</div>
|
|
356
|
+
|
|
357
|
+
${o(this, O).call(this)}
|
|
358
|
+
</div>
|
|
359
|
+
`;
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
u = /* @__PURE__ */ new WeakMap();
|
|
363
|
+
L = /* @__PURE__ */ new WeakMap();
|
|
364
|
+
T = /* @__PURE__ */ new WeakMap();
|
|
365
|
+
S = /* @__PURE__ */ new WeakMap();
|
|
366
|
+
W = /* @__PURE__ */ new WeakMap();
|
|
367
|
+
A = /* @__PURE__ */ new WeakMap();
|
|
368
|
+
E = /* @__PURE__ */ new WeakMap();
|
|
369
|
+
_ = /* @__PURE__ */ new WeakMap();
|
|
370
|
+
I = /* @__PURE__ */ new WeakMap();
|
|
371
|
+
F = /* @__PURE__ */ new WeakMap();
|
|
372
|
+
M = /* @__PURE__ */ new WeakMap();
|
|
373
|
+
R = /* @__PURE__ */ new WeakMap();
|
|
374
|
+
D = /* @__PURE__ */ new WeakMap();
|
|
375
|
+
B = /* @__PURE__ */ new WeakMap();
|
|
376
|
+
U = /* @__PURE__ */ new WeakMap();
|
|
377
|
+
O = /* @__PURE__ */ new WeakMap();
|
|
378
|
+
a.styles = J(ie);
|
|
379
|
+
se(a);
|
|
380
|
+
l([
|
|
381
|
+
c({ type: String })
|
|
382
|
+
], a.prototype, "accept", 2);
|
|
383
|
+
l([
|
|
384
|
+
c({
|
|
385
|
+
type: String,
|
|
386
|
+
converter(e) {
|
|
387
|
+
return e === "true" ? !0 : e === "false" ? !1 : e;
|
|
388
|
+
}
|
|
389
|
+
})
|
|
390
|
+
], a.prototype, "error", 2);
|
|
391
|
+
l([
|
|
392
|
+
c({ type: Boolean })
|
|
393
|
+
], a.prototype, "disabled", 2);
|
|
394
|
+
l([
|
|
395
|
+
c({ type: Boolean })
|
|
396
|
+
], a.prototype, "multiple", 2);
|
|
397
|
+
l([
|
|
398
|
+
c({ type: Number })
|
|
399
|
+
], a.prototype, "fileLimit", 2);
|
|
400
|
+
l([
|
|
401
|
+
c({ type: Number })
|
|
402
|
+
], a.prototype, "maxFileSize", 2);
|
|
403
|
+
l([
|
|
404
|
+
c({ type: Boolean })
|
|
405
|
+
], a.prototype, "required", 2);
|
|
406
|
+
l([
|
|
407
|
+
c({ type: Boolean })
|
|
408
|
+
], a.prototype, "readOnly", 2);
|
|
409
|
+
l([
|
|
410
|
+
c({ type: Boolean })
|
|
411
|
+
], a.prototype, "hideRequiredMarker", 2);
|
|
412
|
+
l([
|
|
413
|
+
c({ type: Array })
|
|
414
|
+
], a.prototype, "validationRules", 2);
|
|
415
|
+
l([
|
|
416
|
+
c({ type: Boolean })
|
|
417
|
+
], a.prototype, "fluid", 2);
|
|
418
|
+
l([
|
|
419
|
+
c({ type: String })
|
|
420
|
+
], a.prototype, "width", 2);
|
|
421
|
+
l([
|
|
422
|
+
c({ type: String })
|
|
423
|
+
], a.prototype, "theme", 2);
|
|
424
|
+
l([
|
|
425
|
+
K({ context: oe, subscribe: !0 }),
|
|
426
|
+
c({ attribute: !1 })
|
|
427
|
+
], a.prototype, "formContext", 2);
|
|
428
|
+
l([
|
|
429
|
+
G({ context: le })
|
|
430
|
+
], a.prototype, "fileUploadContext", 2);
|
|
431
|
+
l([
|
|
432
|
+
N({ slot: "label" })
|
|
433
|
+
], a.prototype, "_textFieldLabel", 2);
|
|
434
|
+
l([
|
|
435
|
+
N({ slot: "helper-text" })
|
|
436
|
+
], a.prototype, "_textFieldHelperText", 2);
|
|
437
|
+
l([
|
|
438
|
+
P()
|
|
439
|
+
], a.prototype, "filesState", 2);
|
|
440
|
+
l([
|
|
441
|
+
P()
|
|
442
|
+
], a.prototype, "_hasPickerSlot", 2);
|
|
443
|
+
l([
|
|
444
|
+
P()
|
|
445
|
+
], a.prototype, "_hasFilesListSlot", 2);
|
|
446
|
+
a = l([
|
|
447
|
+
Q("bm-file-upload")
|
|
448
|
+
], a);
|
|
449
|
+
export {
|
|
450
|
+
a as BmFileUpload,
|
|
451
|
+
_e as BmFileUploadFileSelectedEvent
|
|
452
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BmFileUpload as l, BmFileUploadFileSelectedEvent as m } from "./FileUpload.js";
|
|
2
|
+
import { BmFileUploadButton as t } from "./FileUpload.Button.js";
|
|
3
|
+
import { BmFileUploadDropzone as i } from "./FileUpload.Dropzone.js";
|
|
4
|
+
import { BmFileUploadList as B } from "./FileUpload.List.js";
|
|
5
|
+
import { BmFileUploadListItem as a } from "./FileUpload.List.Item.js";
|
|
6
|
+
export {
|
|
7
|
+
l as BmFileUpload,
|
|
8
|
+
t as BmFileUploadButton,
|
|
9
|
+
i as BmFileUploadDropzone,
|
|
10
|
+
m as BmFileUploadFileSelectedEvent,
|
|
11
|
+
B as BmFileUploadList,
|
|
12
|
+
a as BmFileUploadListItem
|
|
13
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { n as r } from "../../chunks/create-context.DS1OG3vJ.js";
|
|
2
|
+
import { p as e } from "../../chunks/constants.jOWREYQE.js";
|
|
3
|
+
const l = {
|
|
4
|
+
required: !1,
|
|
5
|
+
disabled: !1,
|
|
6
|
+
readOnly: !1,
|
|
7
|
+
initialValues: {},
|
|
8
|
+
registerField: () => {
|
|
9
|
+
},
|
|
10
|
+
formBlurHandler: () => {
|
|
11
|
+
},
|
|
12
|
+
formChangeHandler: () => {
|
|
13
|
+
}
|
|
14
|
+
}, a = r(
|
|
15
|
+
Symbol(`${e}form-context`)
|
|
16
|
+
);
|
|
17
|
+
export {
|
|
18
|
+
a as bmFormContext,
|
|
19
|
+
l as bmFormInitials
|
|
20
|
+
};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
var x = (a) => {
|
|
2
|
+
throw TypeError(a);
|
|
3
|
+
};
|
|
4
|
+
var C = (a, r, t) => r.has(a) || x("Cannot " + t);
|
|
5
|
+
var u = (a, r, t) => (C(a, r, "read from private field"), t ? t.call(a) : r.get(a)), g = (a, r, t) => r.has(a) ? x("Cannot add the same private member more than once") : r instanceof WeakSet ? r.add(a) : r.set(a, t), V = (a, r, t, e) => (C(a, r, "write to private field"), e ? e.call(a, t) : r.set(a, t), t);
|
|
6
|
+
import { c as E } from "../../chunks/consume.Ce9k1-wN.js";
|
|
7
|
+
import { a as y, E as f, x as p } from "../../chunks/lit-element.CJtt9wj5.js";
|
|
8
|
+
import { n as h } from "../../chunks/register-custom-element.vod7zfGv.js";
|
|
9
|
+
import { r as k } from "../../chunks/state.CqiuSzAl.js";
|
|
10
|
+
import { e as A } from "../../chunks/ref.B7e1Hu4F.js";
|
|
11
|
+
import { b as F } from "../../chunks/tokens.CTW8Tt94.js";
|
|
12
|
+
import { bmFormInitials as c, bmFormContext as I } from "./Form.context.js";
|
|
13
|
+
import { createId as m } from "./Form.utils.js";
|
|
14
|
+
import "../../chunks/index.Bz1Jq4c2.js";
|
|
15
|
+
var S = Object.defineProperty, n = (a, r, t, e) => {
|
|
16
|
+
for (var i = void 0, o = a.length - 1, d; o >= 0; o--)
|
|
17
|
+
(d = a[o]) && (i = d(r, t, i) || i);
|
|
18
|
+
return i && S(r, t, i), i;
|
|
19
|
+
}, l;
|
|
20
|
+
const b = class b extends y {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
g(this, l);
|
|
24
|
+
this.labelId = m(), this.errorId = m(), this.helperTextId = m(), this.validationErrorsId = m(), this.internals = this.attachInternals(), this.formFieldRef = A(), this.id = "", this.name = "", this.value = "", this.validationRules = [], this._validationErrors = [], this.validationErrors = () => this._validationErrors, this.setValidationErrors = (t) => {
|
|
25
|
+
this._validationErrors = t;
|
|
26
|
+
}, this.validationErrorShown = () => this.validationErrors().some((t) => !!(t != null && t.length)), V(this, l, /* @__PURE__ */ new WeakMap()), this.submitFormByEnter = ({ key: t }) => {
|
|
27
|
+
t === "Enter" && this.requestAssociatedSubmit();
|
|
28
|
+
}, this.forwardLabelFocus = () => {
|
|
29
|
+
const { value: t } = this.formFieldRef;
|
|
30
|
+
t.focus();
|
|
31
|
+
}, this.validateFieldOnBlur = (t) => {
|
|
32
|
+
const { formBlurHandler: e } = this.formContext || c;
|
|
33
|
+
e(t);
|
|
34
|
+
}, this.validateFieldOnChange = (t) => {
|
|
35
|
+
const { value: e } = t.target, { formChangeHandler: i } = this.formContext || c;
|
|
36
|
+
i(t), this.setAssociatedValue(e);
|
|
37
|
+
}, this.getContextValue = () => {
|
|
38
|
+
const { initialValues: t } = this.formContext || c;
|
|
39
|
+
return (t == null ? void 0 : t[this.name]) || this.value;
|
|
40
|
+
}, this.setContextValue = () => {
|
|
41
|
+
const { value: t } = this.formFieldRef, { ctxValue: e, finalizeCallback: i = () => {
|
|
42
|
+
} } = this.finalizeAssociatedCallback(this.getContextValue());
|
|
43
|
+
t.value = e, this.setAssociatedValue(e), i();
|
|
44
|
+
}, this.setContextValidation = () => {
|
|
45
|
+
const { value: t } = this.formFieldRef, { registerField: e } = this.formContext || c;
|
|
46
|
+
e({
|
|
47
|
+
field: t,
|
|
48
|
+
validators: this.validationRules,
|
|
49
|
+
initializer: this.setContextValue,
|
|
50
|
+
errorSetter: this.setValidationErrors
|
|
51
|
+
});
|
|
52
|
+
}, this.contextInitialsChanged = () => {
|
|
53
|
+
const { initialValues: t } = this.formContext || c, e = t == null ? void 0 : t[this.name], i = e !== this.contextInitialValue;
|
|
54
|
+
return i && (this.contextInitialValue = e), i;
|
|
55
|
+
}, this.renderError = (t, e) => t ? p`
|
|
56
|
+
<bm-helper-text
|
|
57
|
+
text="${t}"
|
|
58
|
+
id="${this.errorId}"
|
|
59
|
+
appearance="negative"
|
|
60
|
+
.disabled="${e}"
|
|
61
|
+
></bm-helper-text>
|
|
62
|
+
` : f, this.renderValidationErrors = () => this.validationErrorShown() ? p`
|
|
63
|
+
<div
|
|
64
|
+
role="log"
|
|
65
|
+
aria-live="polite"
|
|
66
|
+
aria-atomic="true"
|
|
67
|
+
aria-relevant="additions"
|
|
68
|
+
id="${this.validationErrorsId}"
|
|
69
|
+
>
|
|
70
|
+
${this.validationErrors().map(
|
|
71
|
+
(t) => t ? p`
|
|
72
|
+
<bm-helper-text
|
|
73
|
+
text="${t}"
|
|
74
|
+
appearance="negative"
|
|
75
|
+
style="display: block; margin-top: ${F};"
|
|
76
|
+
></bm-helper-text>
|
|
77
|
+
` : f
|
|
78
|
+
)}
|
|
79
|
+
</div>
|
|
80
|
+
` : f;
|
|
81
|
+
}
|
|
82
|
+
setAssociatedValue(t) {
|
|
83
|
+
let e = null;
|
|
84
|
+
if (typeof t == "boolean")
|
|
85
|
+
e = t ? "on" : null;
|
|
86
|
+
else if (typeof t == "number")
|
|
87
|
+
e = t.toString();
|
|
88
|
+
else if (Array.isArray(t)) {
|
|
89
|
+
const i = new FormData();
|
|
90
|
+
t.forEach((o) => i.append(this.name, o.toString())), e = i;
|
|
91
|
+
} else
|
|
92
|
+
e = t;
|
|
93
|
+
this.internals.form && this.internals.setFormValue(e);
|
|
94
|
+
}
|
|
95
|
+
requestAssociatedSubmit() {
|
|
96
|
+
this.internals.form && this.internals.form.requestSubmit();
|
|
97
|
+
}
|
|
98
|
+
connectedCallback() {
|
|
99
|
+
super.connectedCallback(), this.addEventListener("bm-label-click", this.forwardLabelFocus);
|
|
100
|
+
}
|
|
101
|
+
ctxValueChanged(t, e) {
|
|
102
|
+
const { value: i } = e, o = u(this, l).get(i), { initialValues: { [this.name]: d } = {} } = t, v = d !== o;
|
|
103
|
+
return v && u(this, l).set(i, d), v;
|
|
104
|
+
}
|
|
105
|
+
disconnectedCallback() {
|
|
106
|
+
super.disconnectedCallback(), this.removeEventListener("bm-label-click", this.forwardLabelFocus);
|
|
107
|
+
}
|
|
108
|
+
formAssociatedCallback() {
|
|
109
|
+
this.setAssociatedValue(this.value);
|
|
110
|
+
}
|
|
111
|
+
formResetCallback() {
|
|
112
|
+
this.setContextValue();
|
|
113
|
+
}
|
|
114
|
+
finalizeAssociatedCallback(t) {
|
|
115
|
+
return { ctxValue: t, finalizeCallback: () => {
|
|
116
|
+
} };
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
l = new WeakMap(), b.formAssociated = !0;
|
|
120
|
+
let s = b;
|
|
121
|
+
n([
|
|
122
|
+
h({ type: String })
|
|
123
|
+
], s.prototype, "id");
|
|
124
|
+
n([
|
|
125
|
+
h({ type: String })
|
|
126
|
+
], s.prototype, "name");
|
|
127
|
+
n([
|
|
128
|
+
h({ type: String })
|
|
129
|
+
], s.prototype, "value");
|
|
130
|
+
n([
|
|
131
|
+
h({ type: Array })
|
|
132
|
+
], s.prototype, "validationRules");
|
|
133
|
+
n([
|
|
134
|
+
h({ type: String, attribute: "input-aria-label" })
|
|
135
|
+
], s.prototype, "inputAriaLabel");
|
|
136
|
+
n([
|
|
137
|
+
E({ context: I, subscribe: !0 }),
|
|
138
|
+
h({ attribute: !1 })
|
|
139
|
+
], s.prototype, "formContext");
|
|
140
|
+
n([
|
|
141
|
+
k()
|
|
142
|
+
], s.prototype, "_validationErrors");
|
|
143
|
+
export {
|
|
144
|
+
s as FormField
|
|
145
|
+
};
|