@esri/calcite-components 5.1.0-next.7 → 5.1.0-next.8
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/cdn/{R72JHGCT.js → 222PZZVE.js} +1 -1
- package/dist/cdn/{V3YAFJPI.js → 23OTAQAT.js} +1 -1
- package/dist/cdn/{RPXB3OIR.js → 24AJZ7NF.js} +1 -1
- package/dist/cdn/{3JNFU6KC.js → 2G4JQYU3.js} +1 -1
- package/dist/cdn/{EUTZTNZS.js → 2HAZSBOB.js} +1 -1
- package/dist/cdn/{NEP2GKTJ.js → 2IVE7ZEH.js} +1 -1
- package/dist/cdn/{7GGO2CZM.js → 2KWDJDMW.js} +1 -1
- package/dist/cdn/{HMXVJFQG.js → 2MN63CPE.js} +1 -1
- package/dist/cdn/{RL55PUKO.js → 2MVB66KM.js} +1 -1
- package/dist/cdn/{CWCZZTTC.js → 3KC2E42Z.js} +1 -1
- package/dist/cdn/{FZX5RPOG.js → 3KDUSL55.js} +1 -1
- package/dist/cdn/{5BL7R465.js → 47YWJRMK.js} +1 -1
- package/dist/cdn/{72UQHKZB.js → 4C3MDIBF.js} +1 -1
- package/dist/cdn/{XU6Y5UJM.js → 4KMSHV4T.js} +1 -1
- package/dist/cdn/{YELDC3QJ.js → 4OYHP3ZM.js} +1 -1
- package/dist/cdn/{K6ZO6PJL.js → 5XX7HCEA.js} +1 -1
- package/dist/cdn/{PFVIFFID.js → 6LSU4JVT.js} +1 -1
- package/dist/cdn/{JSRHPQ52.js → 6LVCAJSU.js} +1 -1
- package/dist/cdn/{6PPA5ENT.js → 6UFBJC4N.js} +1 -1
- package/dist/cdn/{PYIFXBJK.js → 6UI3PKF5.js} +1 -1
- package/dist/cdn/{6EIEBFGZ.js → 6WOFQ5YL.js} +1 -1
- package/dist/cdn/{LD7LTIBH.js → 7BCKEAN4.js} +1 -1
- package/dist/cdn/{BFOWFEX3.js → 7J54SLPG.js} +1 -1
- package/dist/cdn/{ZGL65NS5.js → 7JKP2OCF.js} +1 -1
- package/dist/cdn/{VLRV4R6U.js → 7MOAOZLZ.js} +1 -1
- package/dist/cdn/{GFUL7D7M.js → 7PY56QMA.js} +1 -1
- package/dist/cdn/{B74N65HB.js → 7Q6OKLFD.js} +1 -1
- package/dist/cdn/{DRDD2NOI.js → 7SJGHMRM.js} +1 -1
- package/dist/cdn/{WPVR4P6L.js → A5U47A46.js} +1 -1
- package/dist/cdn/{IX7RXOMC.js → AKHHJLNI.js} +1 -1
- package/dist/cdn/{VLKT7UVD.js → AQRFO7EB.js} +1 -1
- package/dist/cdn/{PUI672KC.js → B6PZTEUN.js} +1 -1
- package/dist/cdn/{4YVKX7KL.js → BH25NEU3.js} +1 -1
- package/dist/cdn/{GHLGH22R.js → BLZ5Z3L3.js} +1 -1
- package/dist/cdn/{TG2Q5JYE.js → BWVI7Y36.js} +1 -1
- package/dist/cdn/{PBYPABMK.js → BYFOQ5L7.js} +1 -1
- package/dist/cdn/{3OKBFBPD.js → C6PZ6UXS.js} +1 -1
- package/dist/cdn/{6PUUPFDX.js → CFOEAERZ.js} +1 -1
- package/dist/cdn/{ECD3C5ZE.js → CMJEMF3I.js} +1 -1
- package/dist/cdn/{55SG4TFB.js → CW3BSFXN.js} +1 -1
- package/dist/cdn/{GC4LUWE2.js → CZLSVHDA.js} +1 -1
- package/dist/cdn/{WGALRMGQ.js → DML4UYSR.js} +1 -1
- package/dist/cdn/{Z5RVFQRM.js → DOWM2T5Z.js} +1 -1
- package/dist/cdn/{JSPE4OG7.js → DY2ED436.js} +1 -1
- package/dist/cdn/{A5BBQLSY.js → EBTV6BQC.js} +1 -1
- package/dist/cdn/{FZUCWEY4.js → EDTUYGTH.js} +1 -1
- package/dist/cdn/EXQURJYX.js +2 -0
- package/dist/cdn/{PZMLAOBO.js → FA4JJMDD.js} +1 -1
- package/dist/cdn/{MCTFB7GO.js → FE36XWQT.js} +1 -1
- package/dist/cdn/{IIZ3STBY.js → FEK3PIOE.js} +1 -1
- package/dist/cdn/{ETLJSBPM.js → FHTREWRA.js} +1 -1
- package/dist/cdn/{GNJJTXA5.js → FP7RUVVK.js} +1 -1
- package/dist/cdn/{PIAOVZIP.js → FZIKVG4Q.js} +1 -1
- package/dist/cdn/{2YZJ5SK5.js → G3LIWIPW.js} +1 -1
- package/dist/cdn/{I6I5D5MI.js → G5PEBD22.js} +1 -1
- package/dist/cdn/GBD3L2UH.js +2 -0
- package/dist/cdn/{UFKZPJGX.js → GOV5YXBE.js} +1 -1
- package/dist/cdn/{MIHUMK4H.js → H5CLLKA7.js} +1 -1
- package/dist/cdn/{UHGCQVOL.js → H6GZBNAP.js} +1 -1
- package/dist/cdn/{3YNOEWLR.js → H764MK3H.js} +1 -1
- package/dist/cdn/{CFN4BIZL.js → HFAM5MEC.js} +1 -1
- package/dist/cdn/{EZCA7WQG.js → I3AH3MF6.js} +1 -1
- package/dist/cdn/{QKCQY33W.js → I7TFCBQO.js} +1 -1
- package/dist/cdn/{GS2OPY5B.js → IMFR5NEO.js} +1 -1
- package/dist/cdn/{7BJTVAGJ.js → ISXEEXKP.js} +1 -1
- package/dist/cdn/{S6Q2RWZQ.js → ITDGV5OO.js} +1 -1
- package/dist/cdn/{V7UCCXSG.js → ITZTBZ6D.js} +1 -1
- package/dist/cdn/{KME7ZZCF.js → KB33IA7A.js} +1 -1
- package/dist/cdn/KONOZFYK.js +2 -0
- package/dist/cdn/{7MBOUDMI.js → L36EVTCL.js} +1 -1
- package/dist/cdn/{77ZP6SXN.js → LESJQSHY.js} +1 -1
- package/dist/cdn/{BCLXCJEM.js → LS6DCTIG.js} +1 -1
- package/dist/cdn/{MOO6RSVL.js → LWQNBQLX.js} +1 -1
- package/dist/cdn/M5HMGRI3.js +2 -0
- package/dist/cdn/{M2EEQG72.js → M7DW3FTJ.js} +1 -1
- package/dist/cdn/{B6HWVI4Y.js → MIZ37SIW.js} +1 -1
- package/dist/cdn/{CWAS32KR.js → MMKBWG37.js} +1 -1
- package/dist/cdn/{W7C3ZKLA.js → N4R7WBTP.js} +1 -1
- package/dist/cdn/{QTH6ZO2M.js → N6UQ2IN3.js} +1 -1
- package/dist/cdn/{AOSKB4O3.js → NKB7CA3Y.js} +1 -1
- package/dist/cdn/{BF5X3NKJ.js → NRP3ANIH.js} +1 -1
- package/dist/cdn/{SYSRTPLT.js → O64Y2APR.js} +1 -1
- package/dist/cdn/{J7B4VKUB.js → OGR5ARIW.js} +1 -1
- package/dist/cdn/{BYWKKEUK.js → OHI6NELF.js} +1 -1
- package/dist/cdn/{Q6OXR72I.js → OI35UHBC.js} +1 -1
- package/dist/cdn/{B6LFHYRQ.js → OI5C3DZQ.js} +1 -1
- package/dist/cdn/{IOTVOWSQ.js → OLJ3NCJ2.js} +1 -1
- package/dist/cdn/{XGQPFD4F.js → OOITRFLJ.js} +1 -1
- package/dist/cdn/OXIEI7FU.js +2 -0
- package/dist/cdn/OZVZ5LCR.js +2 -0
- package/dist/cdn/{J435BGYU.js → P76VFMZV.js} +1 -1
- package/dist/cdn/{6ASYMYYE.js → PUV74SQM.js} +1 -1
- package/dist/cdn/{N3AYJLQ3.js → PWPVALIF.js} +1 -1
- package/dist/cdn/{K3YSAFRD.js → PXNLTA7Q.js} +1 -1
- package/dist/cdn/{MRGLBHY6.js → QHJ5GHM6.js} +1 -1
- package/dist/cdn/{PPZ47NEL.js → QKC2XFP5.js} +1 -1
- package/dist/cdn/{NIOMLRZP.js → QLMMEMXZ.js} +1 -1
- package/dist/cdn/{BDV62ZVL.js → QO4WS7CE.js} +1 -1
- package/dist/cdn/{RABVM5D7.js → QZKM3D6F.js} +1 -1
- package/dist/cdn/{6HLSG3XA.js → R7ZYHFUG.js} +1 -1
- package/dist/cdn/{FS6JTDJK.js → RLE4LAGP.js} +1 -1
- package/dist/cdn/{MXIVUGX2.js → SDD3P4XX.js} +1 -1
- package/dist/cdn/{YVLGTYKI.js → SJMZTW3M.js} +1 -1
- package/dist/cdn/{7FWJSF56.js → SZBL6UYR.js} +1 -1
- package/dist/cdn/{WOUDT7QM.js → T2ZN7HPU.js} +1 -1
- package/dist/cdn/{ODAPCLKU.js → T72X6C55.js} +1 -1
- package/dist/cdn/{S6HRAHQS.js → TRQXVBXU.js} +1 -1
- package/dist/cdn/{7JU6PR2F.js → TWMPNHXY.js} +1 -1
- package/dist/cdn/{O6DG6EWV.js → UPCUFECO.js} +1 -1
- package/dist/cdn/{CJGFEG4P.js → UW2OIFN6.js} +1 -1
- package/dist/cdn/{5Q5XOD7Y.js → UW5IDOUT.js} +1 -1
- package/dist/cdn/{YCCYLLDK.js → UWFSTP6H.js} +1 -1
- package/dist/cdn/{RGTWEZAQ.js → V6KMTSY3.js} +1 -1
- package/dist/cdn/{II65AX2Y.js → V6PUXCHJ.js} +1 -1
- package/dist/cdn/{CEKWE7MI.js → VAIV6TN5.js} +1 -1
- package/dist/cdn/{LZ5FKMVP.js → VS2M3PA6.js} +1 -1
- package/dist/cdn/{RPTMX4W3.js → VSGEBKJL.js} +1 -1
- package/dist/cdn/{LTPGJM6S.js → VZBGQAPM.js} +1 -1
- package/dist/cdn/{IJLVEBB7.js → W26FRFX7.js} +1 -1
- package/dist/cdn/{K3MWE3BD.js → WDKSZZPO.js} +1 -1
- package/dist/cdn/{3ARW44US.js → WGLBPXGA.js} +1 -1
- package/dist/cdn/{4FGXGSCS.js → WVFJMOTI.js} +1 -1
- package/dist/cdn/{KF4IOR4S.js → X7WG3NQR.js} +1 -1
- package/dist/cdn/{TCCEQ7MN.js → XHL646A2.js} +1 -1
- package/dist/cdn/{GRA7E3RF.js → XIHNK7BL.js} +1 -1
- package/dist/cdn/{PP3ZYBZZ.js → XMUU3UTU.js} +1 -1
- package/dist/cdn/{3WREYYM5.js → XWSZOGW5.js} +1 -1
- package/dist/cdn/{ZPR4DBFS.js → YCAYW3ES.js} +1 -1
- package/dist/cdn/{QDHV7HSF.js → YCIXRDI4.js} +1 -1
- package/dist/cdn/{3L54WMSL.js → YCTMZBN3.js} +1 -1
- package/dist/cdn/{T7KRQA2S.js → YDUAJXOW.js} +1 -1
- package/dist/cdn/{LWILKWNQ.js → YJRANKFJ.js} +1 -1
- package/dist/cdn/{JJVYITPX.js → YOWRCPCO.js} +1 -1
- package/dist/cdn/YRXMN6UU.js +2 -0
- package/dist/cdn/{2QXTLDZ6.js → YWGODKAA.js} +1 -1
- package/dist/cdn/{NRBJ3VOF.js → Z5H3SBF4.js} +1 -1
- package/dist/cdn/{OOTSFWEM.js → ZNRHT3KC.js} +1 -1
- package/dist/cdn/{HIOWL6WU.js → ZQO6FYUW.js} +1 -1
- package/dist/cdn/{YHMDHOC5.js → ZTRVZ3XB.js} +1 -1
- package/dist/cdn/{4RM7IDEC.js → ZWUAND2V.js} +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/input.js +2 -2
- package/dist/chunks/runtime.js +4 -4
- package/dist/chunks/useForm.js +165 -0
- package/dist/components/calcite-checkbox/customElement.d.ts +1 -1
- package/dist/components/calcite-checkbox/customElement.js +6 -7
- package/dist/components/calcite-combobox/customElement.d.ts +1 -1
- package/dist/components/calcite-combobox/customElement.js +11 -12
- package/dist/components/calcite-input/customElement.js +1 -1
- package/dist/components/calcite-input-date-picker/customElement.js +1 -1
- package/dist/components/calcite-input-number/customElement.js +1 -1
- package/dist/components/calcite-input-text/customElement.js +2 -161
- package/dist/components/calcite-input-time-picker/customElement.js +1 -1
- package/dist/components/calcite-list/customElement.js +25 -3
- package/dist/components/calcite-list-item-group/customElement.js +1 -1
- package/dist/components/calcite-meter/customElement.d.ts +7 -1
- package/dist/components/calcite-meter/customElement.js +0 -4
- package/dist/components/calcite-text-area/customElement.js +1 -1
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/vscode.html-custom-data.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/loader.js +2 -2
- package/package.json +2 -2
- package/dist/cdn/6AYITVWB.js +0 -2
- package/dist/cdn/CFGMG4DH.js +0 -2
- package/dist/cdn/DAUSY6FZ.js +0 -2
- package/dist/cdn/SHGMG2W2.js +0 -2
- package/dist/cdn/V5MTQXYJ.js +0 -2
- package/dist/cdn/WKUBLKRJ.js +0 -2
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
+
import { makeGenericController } from "@arcgis/lumina/controllers";
|
|
3
|
+
import { uncapitalize, kebabToPascal } from "@arcgis/toolkit/string";
|
|
4
|
+
import { s as syncInputDelegate, i as isSupportedType } from "./input.js";
|
|
5
|
+
const componentsWithInputEvent = [
|
|
6
|
+
"calcite-input",
|
|
7
|
+
"calcite-input-number",
|
|
8
|
+
"calcite-input-text",
|
|
9
|
+
"calcite-text-area"
|
|
10
|
+
];
|
|
11
|
+
function getClearValidationEventName(componentTag) {
|
|
12
|
+
const componentTagCamelCase = uncapitalize(kebabToPascal(componentTag));
|
|
13
|
+
return `${componentTagCamelCase}${componentsWithInputEvent.includes(componentTag) ? "Input" : "Change"}`;
|
|
14
|
+
}
|
|
15
|
+
function displayValidationMessage(component, { status, message, icon }) {
|
|
16
|
+
if ("status" in component) {
|
|
17
|
+
component.status = status;
|
|
18
|
+
}
|
|
19
|
+
if ("validationIcon" in component && typeof component.validationIcon !== "string") {
|
|
20
|
+
component.validationIcon = icon;
|
|
21
|
+
}
|
|
22
|
+
if ("validationMessage" in component && !component.validationMessage) {
|
|
23
|
+
component.validationMessage = message;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function syncInternalInput(component, input) {
|
|
27
|
+
const { disabled, required } = component;
|
|
28
|
+
input.disabled = disabled;
|
|
29
|
+
input.required = !!required;
|
|
30
|
+
if (isCheckable(component)) {
|
|
31
|
+
input.checked = component.checked;
|
|
32
|
+
} else if (isInputComponent(component, input)) {
|
|
33
|
+
syncInputDelegate(input.type, component, input);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function isCheckable(component) {
|
|
37
|
+
return "checked" in component;
|
|
38
|
+
}
|
|
39
|
+
function isInputComponent(component, input) {
|
|
40
|
+
return component && isSupportedType(input.type);
|
|
41
|
+
}
|
|
42
|
+
const useForm = (options) => {
|
|
43
|
+
return makeGenericController((component, controller) => {
|
|
44
|
+
let defaultValueDirty = false;
|
|
45
|
+
let defaultCheckedDirty = false;
|
|
46
|
+
let inputDelegate;
|
|
47
|
+
let lastAssociatedForm = null;
|
|
48
|
+
if (options.inputType) {
|
|
49
|
+
inputDelegate = document.createElement("input");
|
|
50
|
+
inputDelegate.type = options.inputType;
|
|
51
|
+
}
|
|
52
|
+
function invalidFormHandler(event) {
|
|
53
|
+
event?.preventDefault();
|
|
54
|
+
}
|
|
55
|
+
function onFormReset() {
|
|
56
|
+
if ("status" in component) {
|
|
57
|
+
component.status = "idle";
|
|
58
|
+
}
|
|
59
|
+
if ("validationIcon" in component) {
|
|
60
|
+
component.validationIcon = false;
|
|
61
|
+
}
|
|
62
|
+
if ("validationMessage" in component) {
|
|
63
|
+
component.validationMessage = "";
|
|
64
|
+
}
|
|
65
|
+
if (isCheckable(component)) {
|
|
66
|
+
component.checked = defaultCheckedDirty ? component.defaultChecked : component.checked;
|
|
67
|
+
}
|
|
68
|
+
component.value = defaultValueDirty ? component.defaultValue : component.value;
|
|
69
|
+
defaultValueDirty = false;
|
|
70
|
+
defaultCheckedDirty = false;
|
|
71
|
+
}
|
|
72
|
+
component.listen("luminaFormResetCallback", () => {
|
|
73
|
+
onFormReset();
|
|
74
|
+
});
|
|
75
|
+
component.listen("luminaFormAssociatedCallback", ({ detail: [form] }) => {
|
|
76
|
+
if (form) {
|
|
77
|
+
form.addEventListener("invalid", invalidFormHandler, { capture: true });
|
|
78
|
+
} else {
|
|
79
|
+
lastAssociatedForm?.removeEventListener("invalid", invalidFormHandler, { capture: true });
|
|
80
|
+
}
|
|
81
|
+
lastAssociatedForm = form;
|
|
82
|
+
});
|
|
83
|
+
function handleInvalidInput() {
|
|
84
|
+
const validationMsg = inputDelegate?.validationMessage || "";
|
|
85
|
+
component.el.dispatchEvent(
|
|
86
|
+
// allows users to set custom validation messages
|
|
87
|
+
new CustomEvent("calciteInvalid", { bubbles: true, composed: true })
|
|
88
|
+
);
|
|
89
|
+
displayValidationMessage(component, {
|
|
90
|
+
message: validationMsg,
|
|
91
|
+
icon: true,
|
|
92
|
+
status: "invalid"
|
|
93
|
+
});
|
|
94
|
+
const clearValidationEvent = getClearValidationEventName(component.el.tagName.toLowerCase());
|
|
95
|
+
component.listen(
|
|
96
|
+
clearValidationEvent,
|
|
97
|
+
() => {
|
|
98
|
+
if ("status" in component) {
|
|
99
|
+
component.status = "idle";
|
|
100
|
+
}
|
|
101
|
+
if ("validationIcon" in component && (!component.validationIcon || component.validationIcon === true)) {
|
|
102
|
+
component.validationIcon = false;
|
|
103
|
+
}
|
|
104
|
+
if ("validationMessage" in component && component.validationMessage === validationMsg) {
|
|
105
|
+
component.validationMessage = "";
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{ once: true }
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
controller.onConnected(() => {
|
|
112
|
+
component.el.addEventListener("invalid", handleInvalidInput);
|
|
113
|
+
});
|
|
114
|
+
controller.onDisconnected(() => {
|
|
115
|
+
component.el.removeEventListener("invalid", handleInvalidInput);
|
|
116
|
+
});
|
|
117
|
+
controller.onUpdate((changes) => {
|
|
118
|
+
if (changes.has("value") && !defaultValueDirty) {
|
|
119
|
+
defaultValueDirty = true;
|
|
120
|
+
component.defaultValue = component.value;
|
|
121
|
+
}
|
|
122
|
+
if (isCheckable(component) && changes.has("checked") && !defaultCheckedDirty) {
|
|
123
|
+
defaultCheckedDirty = true;
|
|
124
|
+
component.defaultChecked = component.checked;
|
|
125
|
+
}
|
|
126
|
+
if (changes.has("value") || isCheckable(component) && changes.has("checked")) {
|
|
127
|
+
component.elementInternals.setFormValue(getFormValue());
|
|
128
|
+
}
|
|
129
|
+
if (inputDelegate) {
|
|
130
|
+
inputDelegate.value = component.value;
|
|
131
|
+
syncInternalInput(component, inputDelegate);
|
|
132
|
+
inputDelegate.checkValidity();
|
|
133
|
+
component.elementInternals.setValidity(inputDelegate.validity, inputDelegate.validationMessage);
|
|
134
|
+
if ("validity" in component) {
|
|
135
|
+
component.validity = component.elementInternals.validity;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
function getFormValue() {
|
|
140
|
+
if (Array.isArray(component.value)) {
|
|
141
|
+
const formData = new FormData();
|
|
142
|
+
component.value.forEach((value) => formData.append(component.name, value));
|
|
143
|
+
return formData;
|
|
144
|
+
}
|
|
145
|
+
if (isCheckable(component)) {
|
|
146
|
+
if (component.checked) {
|
|
147
|
+
return component.defaultValue === void 0 && !defaultValueDirty && component.value === void 0 ? "on" : component.value;
|
|
148
|
+
}
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
return component.value;
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
get active() {
|
|
155
|
+
return !!component.elementInternals.form;
|
|
156
|
+
},
|
|
157
|
+
requestSubmit: () => {
|
|
158
|
+
component.elementInternals.form?.requestSubmit();
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
export {
|
|
164
|
+
useForm as u
|
|
165
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference path="../../index.d.ts" />
|
|
2
2
|
import type { PublicLitElement as LitElement } from "@arcgis/lumina";
|
|
3
|
-
import type { MutableValidityState } from "../../utils/form.js";
|
|
4
3
|
import type { Scale, Status } from "../interfaces.js";
|
|
4
|
+
import type { MutableValidityState } from "../../controllers/useForm.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @cssproperty [--calcite-checkbox-size] - Specifies the component's height and width.
|
|
@@ -4,13 +4,13 @@ import { css, svg, html } from "lit";
|
|
|
4
4
|
import { createRef, ref } from "lit/directives/ref.js";
|
|
5
5
|
import { LitElement, createEvent, safeClassMap, nothing } from "@arcgis/lumina";
|
|
6
6
|
import { useDirection } from "@arcgis/lumina/controllers";
|
|
7
|
-
import { c as connectForm, d as disconnectForm, H as HiddenFormInputSlot } from "../../chunks/form.js";
|
|
8
7
|
import { i as isActivationKey } from "../../chunks/key.js";
|
|
9
8
|
import { c as connectLabel, d as disconnectLabel, g as getLabelText } from "../../chunks/label.js";
|
|
10
9
|
import { I as InternalLabel } from "../../chunks/InternalLabel.js";
|
|
11
10
|
import { u as useT9n } from "../../chunks/useT9n.js";
|
|
12
11
|
import { u as useSetFocus } from "../../chunks/useSetFocus.js";
|
|
13
12
|
import { u as useInteractive } from "../../chunks/useInteractive.js";
|
|
13
|
+
import { u as useForm } from "../../chunks/useForm.js";
|
|
14
14
|
const CSS = {
|
|
15
15
|
toggle: "toggle",
|
|
16
16
|
check: "check-svg"
|
|
@@ -21,6 +21,7 @@ class Checkbox extends LitElement {
|
|
|
21
21
|
super();
|
|
22
22
|
this.checkedPath = "M5.5 12L2 8.689l.637-.636L5.5 10.727l8.022-7.87.637.637z";
|
|
23
23
|
this.direction = useDirection();
|
|
24
|
+
this.formSupport = useForm({ inputType: "checkbox" })(this);
|
|
24
25
|
this.indeterminatePath = "M13 8v1H3V8z";
|
|
25
26
|
this.onLabelClick = () => {
|
|
26
27
|
this.toggle();
|
|
@@ -58,6 +59,9 @@ class Checkbox extends LitElement {
|
|
|
58
59
|
static {
|
|
59
60
|
this.properties = { checked: [7, {}, { reflect: true, type: Boolean }], disabled: [7, {}, { reflect: true, type: Boolean }], form: [3, {}, { reflect: true }], hovered: [7, {}, { reflect: true, type: Boolean }], indeterminate: [7, {}, { reflect: true, type: Boolean }], label: 1, labelText: 1, messageOverrides: [0, {}, { attribute: false }], name: [3, {}, { reflect: true }], required: [7, {}, { reflect: true, type: Boolean }], scale: [3, {}, { reflect: true }], status: [3, {}, { reflect: true }], validity: [0, {}, { attribute: false }], value: 1 };
|
|
60
61
|
}
|
|
62
|
+
static {
|
|
63
|
+
this.formAssociated = true;
|
|
64
|
+
}
|
|
61
65
|
static {
|
|
62
66
|
this.styles = styles;
|
|
63
67
|
}
|
|
@@ -67,15 +71,10 @@ class Checkbox extends LitElement {
|
|
|
67
71
|
connectedCallback() {
|
|
68
72
|
super.connectedCallback();
|
|
69
73
|
connectLabel(this);
|
|
70
|
-
connectForm(this);
|
|
71
74
|
}
|
|
72
75
|
disconnectedCallback() {
|
|
73
76
|
super.disconnectedCallback();
|
|
74
77
|
disconnectLabel(this);
|
|
75
|
-
disconnectForm(this);
|
|
76
|
-
}
|
|
77
|
-
syncHiddenFormInput(input) {
|
|
78
|
-
input.type = "checkbox";
|
|
79
78
|
}
|
|
80
79
|
getPath() {
|
|
81
80
|
return this.indeterminate ? this.indeterminatePath : this.checked ? this.checkedPath : "";
|
|
@@ -108,7 +107,7 @@ class Checkbox extends LitElement {
|
|
|
108
107
|
return this.interactiveContainer({ disabled: this.disabled, children: html`<div .ariaChecked=${this.checked} .ariaLabel=${getLabelText(this)} .ariaRequired=${this.required} class=${safeClassMap({
|
|
109
108
|
[CSS.toggle]: true,
|
|
110
109
|
[CSS_UTILITY.rtl]: rtl
|
|
111
|
-
})} @blur=${this.onToggleBlur} @focus=${this.onToggleFocus} role=checkbox tabindex=${(this.disabled ? void 0 : 0) ?? nothing} ${ref(this.toggleRef)}><svg aria-hidden=true class=${safeClassMap(CSS.check)} viewBox="0 0 16 16">${svg`<path d=${this.getPath() ?? nothing} />`}</svg><slot></slot></div>${this.labelText && InternalLabel({ bottomSpacingDisabled: true, labelText: this.labelText, required: this.required, spacingInlineStart: true, tooltipText: this.messages.required }) || ""}
|
|
110
|
+
})} @blur=${this.onToggleBlur} @focus=${this.onToggleFocus} role=checkbox tabindex=${(this.disabled ? void 0 : 0) ?? nothing} ${ref(this.toggleRef)}><svg aria-hidden=true class=${safeClassMap(CSS.check)} viewBox="0 0 16 16">${svg`<path d=${this.getPath() ?? nothing} />`}</svg><slot></slot></div>${this.labelText && InternalLabel({ bottomSpacingDisabled: true, labelText: this.labelText, required: this.required, spacingInlineStart: true, tooltipText: this.messages.required }) || ""}` });
|
|
112
111
|
}
|
|
113
112
|
}
|
|
114
113
|
customElement("calcite-checkbox", Checkbox);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference path="../../index.d.ts" />
|
|
2
2
|
import type { PublicLitElement as LitElement } from "@arcgis/lumina";
|
|
3
3
|
import type { FlipPlacement, LogicalPlacement, OverlayPositioning } from "../../utils/floating-ui.js";
|
|
4
|
-
import type { MutableValidityState } from "../../utils/form.js";
|
|
5
4
|
import type { Scale, SelectionAppearance, SelectionMode, Status } from "../interfaces.js";
|
|
6
5
|
import type { IconName } from "../calcite-icon/interfaces.js";
|
|
7
6
|
import type { ComboboxItem as HTMLCalciteComboboxItemElement } from "../calcite-combobox-item/customElement.js";
|
|
7
|
+
import type { MutableValidityState } from "../../controllers/useForm.js";
|
|
8
8
|
import type { SelectionDisplay } from "./interfaces.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -12,7 +12,6 @@ import { useDirection } from "@arcgis/lumina/controllers";
|
|
|
12
12
|
import { f as filter } from "../../chunks/filter.js";
|
|
13
13
|
import { k as getElementWidth, l as getTextWidth, i as focusElement } from "../../chunks/dom.js";
|
|
14
14
|
import { d as defaultMenuPlacement, r as reposition, c as connectFloatingUI, a as disconnectFloatingUI, f as filterValidFlipPlacements, h as hideFloatingUI, F as FloatingCSS } from "../../chunks/floating-ui.js";
|
|
15
|
-
import { c as connectForm, a as afterConnectDefaultValueSet, d as disconnectForm, s as submitForm, H as HiddenFormInputSlot } from "../../chunks/form.js";
|
|
16
15
|
import { g as guid } from "../../chunks/guid.js";
|
|
17
16
|
import { c as connectLabel, d as disconnectLabel, g as getLabelText } from "../../chunks/label.js";
|
|
18
17
|
import { c as createObserver, u as updateRefObserver } from "../../chunks/observers.js";
|
|
@@ -26,6 +25,7 @@ import { u as useSetFocus } from "../../chunks/useSetFocus.js";
|
|
|
26
25
|
import { u as useCancelable } from "../../chunks/useCancelable.js";
|
|
27
26
|
import { u as useInteractive } from "../../chunks/useInteractive.js";
|
|
28
27
|
import { u as useTopLayer } from "../../chunks/useTopLayer.js";
|
|
28
|
+
import { u as useForm } from "../../chunks/useForm.js";
|
|
29
29
|
import { I as IDS, C as CSS$1, a as ComboboxItemSelector, b as ComboboxItemGroupSelector, c as ICONS } from "../../chunks/resources5.js";
|
|
30
30
|
import { h as hasActiveChildren, i as isSingleLike, g as getLabel, a as getItemAncestors, b as getItemChildren } from "../../chunks/utils2.js";
|
|
31
31
|
const CSS = {
|
|
@@ -43,6 +43,9 @@ class Combobox extends LitElement {
|
|
|
43
43
|
super();
|
|
44
44
|
this.closeButtonRef = createRef();
|
|
45
45
|
this.direction = useDirection();
|
|
46
|
+
this.formSupport = useForm({
|
|
47
|
+
inputType: "text"
|
|
48
|
+
})(this);
|
|
46
49
|
this.selectAllComboboxItemRef = createRef();
|
|
47
50
|
this.allSelectedIndicatorChipRef = createRef();
|
|
48
51
|
this.cancelable = useCancelable()(this);
|
|
@@ -172,6 +175,9 @@ class Combobox extends LitElement {
|
|
|
172
175
|
static {
|
|
173
176
|
this.properties = { activeChipIndex: [16, {}, { state: true }], activeDescendant: [16, {}, { state: true }], activeItemIndex: [16, {}, { state: true }], compactSelectionDisplay: [16, {}, { state: true }], selectedHiddenChipsCount: [16, {}, { state: true }], selectedVisibleChipsCount: [16, {}, { state: true }], items: [16, {}, { state: true }], noMatchesFound: [16, {}, { state: true }], allowCustomValues: [7, {}, { reflect: true, type: Boolean }], clearDisabled: [7, {}, { reflect: true, type: Boolean }], disabled: [7, {}, { reflect: true, type: Boolean }], filterText: [3, {}, { reflect: true }], filterProps: [0, {}, { attribute: false }], filteredItems: [32, {}, { attribute: false, readOnly: true }], flipPlacements: [0, {}, { attribute: false }], form: [3, {}, { reflect: true }], label: 1, labelText: 1, maxItems: [11, {}, { reflect: true, type: Number }], messageOverrides: [0, {}, { attribute: false }], name: [3, {}, { reflect: true }], open: [7, {}, { reflect: true, type: Boolean }], overlayPositioning: [3, {}, { reflect: true }], placeholder: 1, placeholderIcon: [3, { type: String }, { reflect: true }], placeholderIconFlipRtl: [7, {}, { reflect: true, type: Boolean }], placement: [3, {}, { reflect: true }], readOnly: [7, {}, { reflect: true, type: Boolean }], required: [7, {}, { reflect: true, type: Boolean }], scale: [3, {}, { reflect: true }], selectAllEnabled: [7, {}, { reflect: true, type: Boolean }], selectedItems: [0, {}, { attribute: false }], selectionDisplay: [3, {}, { reflect: true }], selectionAppearance: [3, {}, { reflect: true }], selectionMode: [3, {}, { reflect: true }], status: [3, {}, { reflect: true }], topLayerDisabled: [7, {}, { reflect: true, type: Boolean }], validationIcon: [3, { converter: stringOrBoolean, type: String }, { reflect: true }], validationMessage: 1, validity: [0, {}, { attribute: false }], value: 1 };
|
|
174
177
|
}
|
|
178
|
+
static {
|
|
179
|
+
this.formAssociated = true;
|
|
180
|
+
}
|
|
175
181
|
static {
|
|
176
182
|
this.styles = styles;
|
|
177
183
|
}
|
|
@@ -257,10 +263,6 @@ class Combobox extends LitElement {
|
|
|
257
263
|
connectedCallback() {
|
|
258
264
|
super.connectedCallback();
|
|
259
265
|
connectLabel(this);
|
|
260
|
-
connectForm(this);
|
|
261
|
-
this.internalValueChangeFlag = true;
|
|
262
|
-
this.value = this.getValue();
|
|
263
|
-
this.internalValueChangeFlag = false;
|
|
264
266
|
this.mutationObserver?.observe(this.el, { childList: true, subtree: true });
|
|
265
267
|
this.setFilteredPlacements();
|
|
266
268
|
connectFloatingUI(this);
|
|
@@ -290,7 +292,6 @@ class Combobox extends LitElement {
|
|
|
290
292
|
}
|
|
291
293
|
}
|
|
292
294
|
loaded() {
|
|
293
|
-
afterConnectDefaultValueSet(this, this.getValue());
|
|
294
295
|
connectFloatingUI(this);
|
|
295
296
|
this.updateItems();
|
|
296
297
|
this.filterItems(this.filterText, false, false);
|
|
@@ -300,7 +301,6 @@ class Combobox extends LitElement {
|
|
|
300
301
|
this.mutationObserver?.disconnect();
|
|
301
302
|
this.resizeObserver?.disconnect();
|
|
302
303
|
disconnectLabel(this);
|
|
303
|
-
disconnectForm(this);
|
|
304
304
|
disconnectFloatingUI(this);
|
|
305
305
|
}
|
|
306
306
|
emitComboboxChange() {
|
|
@@ -532,10 +532,9 @@ class Combobox extends LitElement {
|
|
|
532
532
|
} else if (this.allowCustomValues && this.filterText) {
|
|
533
533
|
this.addCustomChip(this.filterText, true);
|
|
534
534
|
event.preventDefault();
|
|
535
|
-
} else if (!event.defaultPrevented) {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
}
|
|
535
|
+
} else if (!event.defaultPrevented && this.formSupport.active) {
|
|
536
|
+
event.preventDefault();
|
|
537
|
+
this.formSupport.requestSubmit();
|
|
539
538
|
}
|
|
540
539
|
break;
|
|
541
540
|
case "Delete":
|
|
@@ -1134,7 +1133,7 @@ class Combobox extends LitElement {
|
|
|
1134
1133
|
this.renderSelectedIndicatorChip(),
|
|
1135
1134
|
this.renderSelectedIndicatorChipCompact(),
|
|
1136
1135
|
this.renderAllSelectedIndicatorChip()
|
|
1137
|
-
] || ""}<label class=${safeClassMap(CSS$1.screenReadersOnly)} .htmlFor=${`${IDS.input(guid2)}`} .id=${`${IDS.label(guid2)}`}>${label}</label>${this.renderInput()}</div>`)}${!readOnly && isClearable ? keyed("close-button", XButton({ disabled: this.disabled, label: this.messages.clear, ref: this.closeButtonRef, scale: this.scale })) : null}${!readOnly && this.renderChevronIcon() || ""}</div><ul aria-labelledby=${`${IDS.label(guid2)}`} aria-multiselectable=true class=${safeClassMap(CSS$1.screenReadersOnly)} .id=${`${IDS.listbox(guid2)}`} role=listbox tabindex=-1>${this.renderListBoxOptions()}</ul>${this.renderFloatingUIContainer()}${
|
|
1136
|
+
] || ""}<label class=${safeClassMap(CSS$1.screenReadersOnly)} .htmlFor=${`${IDS.input(guid2)}`} .id=${`${IDS.label(guid2)}`}>${label}</label>${this.renderInput()}</div>`)}${!readOnly && isClearable ? keyed("close-button", XButton({ disabled: this.disabled, label: this.messages.clear, ref: this.closeButtonRef, scale: this.scale })) : null}${!readOnly && this.renderChevronIcon() || ""}</div><ul aria-labelledby=${`${IDS.label(guid2)}`} aria-multiselectable=true class=${safeClassMap(CSS$1.screenReadersOnly)} .id=${`${IDS.listbox(guid2)}`} role=listbox tabindex=-1>${this.renderListBoxOptions()}</ul>${this.renderFloatingUIContainer()}${this.validationMessage && this.status === "invalid" ? Validation({ icon: this.validationIcon, id: IDS.validationMessage, message: this.validationMessage, scale: this.scale, status: this.status }) : null}` });
|
|
1138
1137
|
}
|
|
1139
1138
|
}
|
|
1140
1139
|
customElement("calcite-combobox", Combobox);
|
|
@@ -17,7 +17,7 @@ import { V as Validation } from "../../chunks/Validation.js";
|
|
|
17
17
|
import { u as useT9n } from "../../chunks/useT9n.js";
|
|
18
18
|
import { u as useSetFocus } from "../../chunks/useSetFocus.js";
|
|
19
19
|
import { u as useInteractive } from "../../chunks/useInteractive.js";
|
|
20
|
-
import {
|
|
20
|
+
import { a as syncHiddenFormInput } from "../../chunks/input.js";
|
|
21
21
|
const CSS = {
|
|
22
22
|
loader: "loader",
|
|
23
23
|
clearButton: "clear-button",
|
|
@@ -17,7 +17,7 @@ import { g as getValueAsDateRange, a as applyLocaleOverride, b as getLocaleData
|
|
|
17
17
|
import { g as guid } from "../../chunks/guid.js";
|
|
18
18
|
import { I as InternalLabel } from "../../chunks/InternalLabel.js";
|
|
19
19
|
import { V as Validation } from "../../chunks/Validation.js";
|
|
20
|
-
import {
|
|
20
|
+
import { a as syncHiddenFormInput } from "../../chunks/input.js";
|
|
21
21
|
import { u as useT9n } from "../../chunks/useT9n.js";
|
|
22
22
|
import { u as useSetFocus } from "../../chunks/useSetFocus.js";
|
|
23
23
|
import { u as useInteractive } from "../../chunks/useInteractive.js";
|
|
@@ -14,7 +14,7 @@ import { i as isValidNumber, n as numberStringFormatter, B as BigDecimal, p as p
|
|
|
14
14
|
import { g as getIconScale } from "../../chunks/component.js";
|
|
15
15
|
import { I as InternalLabel } from "../../chunks/InternalLabel.js";
|
|
16
16
|
import { V as Validation } from "../../chunks/Validation.js";
|
|
17
|
-
import {
|
|
17
|
+
import { a as syncHiddenFormInput } from "../../chunks/input.js";
|
|
18
18
|
import { u as useT9n } from "../../chunks/useT9n.js";
|
|
19
19
|
import { u as useSetFocus } from "../../chunks/useSetFocus.js";
|
|
20
20
|
import { u as useInteractive } from "../../chunks/useInteractive.js";
|
|
@@ -4,10 +4,9 @@ import { live } from "lit/directives/live.js";
|
|
|
4
4
|
import { css, html, nothing } from "lit";
|
|
5
5
|
import { createRef, ref } from "lit/directives/ref.js";
|
|
6
6
|
import { LitElement, createEvent, stringOrBoolean, safeClassMap } from "@arcgis/lumina";
|
|
7
|
-
import {
|
|
7
|
+
import { useWatchAttributes, useDirection } from "@arcgis/lumina/controllers";
|
|
8
8
|
import { b as setRequestedIcon } from "../../chunks/dom.js";
|
|
9
|
-
import {
|
|
10
|
-
import { a as syncInputDelegate, i as isSupportedType } from "../../chunks/input.js";
|
|
9
|
+
import { u as useForm } from "../../chunks/useForm.js";
|
|
11
10
|
import { c as connectLabel, d as disconnectLabel, g as getLabelText } from "../../chunks/label.js";
|
|
12
11
|
import { g as getIconScale } from "../../chunks/component.js";
|
|
13
12
|
import { I as InternalLabel } from "../../chunks/InternalLabel.js";
|
|
@@ -15,164 +14,6 @@ import { V as Validation } from "../../chunks/Validation.js";
|
|
|
15
14
|
import { u as useT9n } from "../../chunks/useT9n.js";
|
|
16
15
|
import { u as useSetFocus } from "../../chunks/useSetFocus.js";
|
|
17
16
|
import { u as useInteractive } from "../../chunks/useInteractive.js";
|
|
18
|
-
const componentsWithInputEvent = [
|
|
19
|
-
"calcite-input",
|
|
20
|
-
"calcite-input-number",
|
|
21
|
-
"calcite-input-text",
|
|
22
|
-
"calcite-text-area"
|
|
23
|
-
];
|
|
24
|
-
function getClearValidationEventName(componentTag) {
|
|
25
|
-
const componentTagCamelCase = uncapitalize(kebabToPascal(componentTag));
|
|
26
|
-
return `${componentTagCamelCase}${componentsWithInputEvent.includes(componentTag) ? "Input" : "Change"}`;
|
|
27
|
-
}
|
|
28
|
-
function displayValidationMessage(component, { status, message, icon }) {
|
|
29
|
-
if ("status" in component) {
|
|
30
|
-
component.status = status;
|
|
31
|
-
}
|
|
32
|
-
if ("validationIcon" in component && typeof component.validationIcon !== "string") {
|
|
33
|
-
component.validationIcon = icon;
|
|
34
|
-
}
|
|
35
|
-
if ("validationMessage" in component && !component.validationMessage) {
|
|
36
|
-
component.validationMessage = message;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
function syncInternalInput(component, input) {
|
|
40
|
-
const { disabled, required } = component;
|
|
41
|
-
input.disabled = disabled;
|
|
42
|
-
input.required = !!required;
|
|
43
|
-
if (isCheckable(component)) {
|
|
44
|
-
input.checked = component.checked;
|
|
45
|
-
} else if (isInputComponent(component, input)) {
|
|
46
|
-
syncInputDelegate(input.type, component, input);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function isCheckable(component) {
|
|
50
|
-
return "checked" in component;
|
|
51
|
-
}
|
|
52
|
-
function isInputComponent(component, input) {
|
|
53
|
-
return component && isSupportedType(input.type);
|
|
54
|
-
}
|
|
55
|
-
const useForm = (options) => {
|
|
56
|
-
return makeGenericController((component, controller) => {
|
|
57
|
-
let defaultValueDirty = false;
|
|
58
|
-
let defaultCheckedDirty = false;
|
|
59
|
-
let inputDelegate;
|
|
60
|
-
let lastAssociatedForm = null;
|
|
61
|
-
if (options.inputType) {
|
|
62
|
-
inputDelegate = document.createElement("input");
|
|
63
|
-
inputDelegate.type = options.inputType;
|
|
64
|
-
}
|
|
65
|
-
function invalidFormHandler(event) {
|
|
66
|
-
event?.preventDefault();
|
|
67
|
-
}
|
|
68
|
-
function onFormReset() {
|
|
69
|
-
if ("status" in component) {
|
|
70
|
-
component.status = "idle";
|
|
71
|
-
}
|
|
72
|
-
if ("validationIcon" in component) {
|
|
73
|
-
component.validationIcon = false;
|
|
74
|
-
}
|
|
75
|
-
if ("validationMessage" in component) {
|
|
76
|
-
component.validationMessage = "";
|
|
77
|
-
}
|
|
78
|
-
if (isCheckable(component)) {
|
|
79
|
-
component.checked = defaultCheckedDirty ? component.defaultChecked : component.checked;
|
|
80
|
-
}
|
|
81
|
-
component.value = defaultValueDirty ? component.defaultValue : component.value;
|
|
82
|
-
defaultValueDirty = false;
|
|
83
|
-
defaultCheckedDirty = false;
|
|
84
|
-
}
|
|
85
|
-
component.listen("luminaFormResetCallback", () => {
|
|
86
|
-
onFormReset();
|
|
87
|
-
});
|
|
88
|
-
component.listen("luminaFormAssociatedCallback", ({ detail: [form] }) => {
|
|
89
|
-
if (form) {
|
|
90
|
-
form.addEventListener("invalid", invalidFormHandler, { capture: true });
|
|
91
|
-
} else {
|
|
92
|
-
lastAssociatedForm?.removeEventListener("invalid", invalidFormHandler, { capture: true });
|
|
93
|
-
}
|
|
94
|
-
lastAssociatedForm = form;
|
|
95
|
-
});
|
|
96
|
-
function handleInvalidInput() {
|
|
97
|
-
const validationMsg = inputDelegate?.validationMessage || "";
|
|
98
|
-
component.el.dispatchEvent(
|
|
99
|
-
// allows users to set custom validation messages
|
|
100
|
-
new CustomEvent("calciteInvalid", { bubbles: true, composed: true })
|
|
101
|
-
);
|
|
102
|
-
displayValidationMessage(component, {
|
|
103
|
-
message: validationMsg,
|
|
104
|
-
icon: true,
|
|
105
|
-
status: "invalid"
|
|
106
|
-
});
|
|
107
|
-
const clearValidationEvent = getClearValidationEventName(component.el.tagName.toLowerCase());
|
|
108
|
-
component.listen(
|
|
109
|
-
clearValidationEvent,
|
|
110
|
-
() => {
|
|
111
|
-
if ("status" in component) {
|
|
112
|
-
component.status = "idle";
|
|
113
|
-
}
|
|
114
|
-
if ("validationIcon" in component && (!component.validationIcon || component.validationIcon === true)) {
|
|
115
|
-
component.validationIcon = false;
|
|
116
|
-
}
|
|
117
|
-
if ("validationMessage" in component && component.validationMessage === validationMsg) {
|
|
118
|
-
component.validationMessage = "";
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
{ once: true }
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
controller.onConnected(() => {
|
|
125
|
-
component.el.addEventListener("invalid", handleInvalidInput);
|
|
126
|
-
});
|
|
127
|
-
controller.onDisconnected(() => {
|
|
128
|
-
component.el.removeEventListener("invalid", handleInvalidInput);
|
|
129
|
-
});
|
|
130
|
-
controller.onUpdate((changes) => {
|
|
131
|
-
if (changes.has("value") && !defaultValueDirty) {
|
|
132
|
-
defaultValueDirty = true;
|
|
133
|
-
component.defaultValue = component.value;
|
|
134
|
-
}
|
|
135
|
-
if (isCheckable(component) && changes.has("checked") && !defaultCheckedDirty) {
|
|
136
|
-
defaultCheckedDirty = true;
|
|
137
|
-
component.defaultChecked = component.checked;
|
|
138
|
-
}
|
|
139
|
-
if (changes.has("value") || isCheckable(component) && changes.has("checked")) {
|
|
140
|
-
component.elementInternals.setFormValue(getFormValue());
|
|
141
|
-
}
|
|
142
|
-
if (inputDelegate) {
|
|
143
|
-
inputDelegate.value = component.value;
|
|
144
|
-
syncInternalInput(component, inputDelegate);
|
|
145
|
-
inputDelegate.checkValidity();
|
|
146
|
-
component.elementInternals.setValidity(inputDelegate.validity, inputDelegate.validationMessage);
|
|
147
|
-
if ("validity" in component) {
|
|
148
|
-
component.validity = component.elementInternals.validity;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
function getFormValue() {
|
|
153
|
-
if (Array.isArray(component.value)) {
|
|
154
|
-
const formData = new FormData();
|
|
155
|
-
component.value.forEach((value) => formData.append(component.name, value));
|
|
156
|
-
return formData;
|
|
157
|
-
}
|
|
158
|
-
if (isCheckable(component)) {
|
|
159
|
-
if (component.checked) {
|
|
160
|
-
return component.defaultValue === void 0 && !defaultValueDirty && component.value === void 0 ? "on" : component.value;
|
|
161
|
-
}
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
164
|
-
return component.value;
|
|
165
|
-
}
|
|
166
|
-
return {
|
|
167
|
-
get active() {
|
|
168
|
-
return !!component.elementInternals.form;
|
|
169
|
-
},
|
|
170
|
-
requestSubmit: () => {
|
|
171
|
-
component.elementInternals.form?.requestSubmit();
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
});
|
|
175
|
-
};
|
|
176
17
|
const CSS = {
|
|
177
18
|
loader: "loader",
|
|
178
19
|
clearable: "clearable",
|
|
@@ -10,7 +10,7 @@ import { d as decimalPlaces } from "../../chunks/math.js";
|
|
|
10
10
|
import { g as getIconScale } from "../../chunks/component.js";
|
|
11
11
|
import { I as InternalLabel } from "../../chunks/InternalLabel.js";
|
|
12
12
|
import { V as Validation } from "../../chunks/Validation.js";
|
|
13
|
-
import {
|
|
13
|
+
import { a as syncHiddenFormInput } from "../../chunks/input.js";
|
|
14
14
|
import { u as useT9n } from "../../chunks/useT9n.js";
|
|
15
15
|
import { i as isValidNumber } from "../../chunks/locale.js";
|
|
16
16
|
import { u as useSetFocus } from "../../chunks/useSetFocus.js";
|
|
@@ -4,7 +4,7 @@ import { ref } from "lit/directives/ref.js";
|
|
|
4
4
|
import { keyed } from "lit/directives/keyed.js";
|
|
5
5
|
import { debounce } from "es-toolkit";
|
|
6
6
|
import { css, html } from "lit";
|
|
7
|
-
import { LitElement, createEvent, safeClassMap } from "@arcgis/lumina";
|
|
7
|
+
import { LitElement, createEvent, safeClassMap, safeStyleMap } from "@arcgis/lumina";
|
|
8
8
|
import { m as slotChangeHasContent, s as slotChangeHasAssignedElement, e as getRootNode } from "../../chunks/dom.js";
|
|
9
9
|
import { c as createObserver } from "../../chunks/observers.js";
|
|
10
10
|
import { l as listItemSelector, i as isListItem, a as listSelector, u as updateListItemChildren, b as listItemGroupSelector, e as expandedAncestors } from "../../chunks/utils4.js";
|
|
@@ -54,6 +54,11 @@ class List extends LitElement {
|
|
|
54
54
|
this.messages = useT9n({ blocking: true });
|
|
55
55
|
this.focusSetter = useSetFocus()(this);
|
|
56
56
|
this.interactiveContainer = useInteractive(this);
|
|
57
|
+
this.filterRowResizeObserver = createObserver("resize", () => this.updateFilterRowHeight());
|
|
58
|
+
this.setFilterContainerEl = (el) => {
|
|
59
|
+
this.filterContainerEl = el;
|
|
60
|
+
this.observeFilterRow();
|
|
61
|
+
};
|
|
57
62
|
this.dataForFilter = [];
|
|
58
63
|
this.hasFilterActionsEnd = false;
|
|
59
64
|
this.hasFilterActionsStart = false;
|
|
@@ -61,6 +66,7 @@ class List extends LitElement {
|
|
|
61
66
|
this.sortHandleMenuItems = [];
|
|
62
67
|
this.hasContent = false;
|
|
63
68
|
this.hasEmptyContent = false;
|
|
69
|
+
this.filterRowHeight = 0;
|
|
64
70
|
this.disabled = false;
|
|
65
71
|
this.dragEnabled = false;
|
|
66
72
|
this.filterEnabled = false;
|
|
@@ -97,7 +103,7 @@ class List extends LitElement {
|
|
|
97
103
|
this.listen("calciteInternalListItemGroupDefaultSlotChange", this.handleCalciteInternalListItemGroupDefaultSlotChange);
|
|
98
104
|
}
|
|
99
105
|
static {
|
|
100
|
-
this.properties = { assistiveText: [16, {}, { state: true }], dataForFilter: [16, {}, { state: true }], hasFilterActionsEnd: [16, {}, { state: true }], hasFilterActionsStart: [16, {}, { state: true }], hasFilterNoResults: [16, {}, { state: true }], sortHandleMenuItems: [16, {}, { state: true }], hasContent: [16, {}, { state: true }], hasEmptyContent: [16, {}, { state: true }], canPull: [0, {}, { attribute: false }], canPut: [0, {}, { attribute: false }], disabled: [7, {}, { reflect: true, type: Boolean }], dragEnabled: [7, {}, { reflect: true, type: Boolean }], filterEnabled: [7, {}, { reflect: true, type: Boolean }], filterPredicate: [0, {}, { attribute: false }], filterLabel: [3, {}, { reflect: true }], filterPlaceholder: [3, {}, { reflect: true }], filterProps: [0, {}, { attribute: false }], filterText: [3, {}, { reflect: true }], filteredData: [0, {}, { attribute: false }], filteredItems: [0, {}, { attribute: false }], group: [3, {}, { reflect: true }], interactionMode: [3, {}, { reflect: true }], label: 1, loading: [7, {}, { reflect: true, type: Boolean }], messageOverrides: [0, {}, { attribute: false }], displayMode: [3, {}, { reflect: true }], numberingSystem: 1, scale: [3, {}, { reflect: true }], selectedItems: [0, {}, { attribute: false }], selectionAppearance: [3, {}, { reflect: true }], selectionMode: [3, {}, { reflect: true }], sortDisabled: [7, {}, { reflect: true, type: Boolean }] };
|
|
106
|
+
this.properties = { assistiveText: [16, {}, { state: true }], dataForFilter: [16, {}, { state: true }], hasFilterActionsEnd: [16, {}, { state: true }], hasFilterActionsStart: [16, {}, { state: true }], hasFilterNoResults: [16, {}, { state: true }], sortHandleMenuItems: [16, {}, { state: true }], hasContent: [16, {}, { state: true }], hasEmptyContent: [16, {}, { state: true }], filterRowHeight: [16, {}, { state: true }], canPull: [0, {}, { attribute: false }], canPut: [0, {}, { attribute: false }], disabled: [7, {}, { reflect: true, type: Boolean }], dragEnabled: [7, {}, { reflect: true, type: Boolean }], filterEnabled: [7, {}, { reflect: true, type: Boolean }], filterPredicate: [0, {}, { attribute: false }], filterLabel: [3, {}, { reflect: true }], filterPlaceholder: [3, {}, { reflect: true }], filterProps: [0, {}, { attribute: false }], filterText: [3, {}, { reflect: true }], filteredData: [0, {}, { attribute: false }], filteredItems: [0, {}, { attribute: false }], group: [3, {}, { reflect: true }], interactionMode: [3, {}, { reflect: true }], label: 1, loading: [7, {}, { reflect: true, type: Boolean }], messageOverrides: [0, {}, { attribute: false }], displayMode: [3, {}, { reflect: true }], numberingSystem: 1, scale: [3, {}, { reflect: true }], selectedItems: [0, {}, { attribute: false }], selectionAppearance: [3, {}, { reflect: true }], selectionMode: [3, {}, { reflect: true }], sortDisabled: [7, {}, { reflect: true, type: Boolean }] };
|
|
101
107
|
}
|
|
102
108
|
static {
|
|
103
109
|
this.styles = styles;
|
|
@@ -147,6 +153,7 @@ class List extends LitElement {
|
|
|
147
153
|
disconnectedCallback() {
|
|
148
154
|
super.disconnectedCallback();
|
|
149
155
|
this.disconnectObserver();
|
|
156
|
+
this.unobserveFilterRow();
|
|
150
157
|
disconnectSortableComponent(this);
|
|
151
158
|
}
|
|
152
159
|
updateListItems() {
|
|
@@ -203,6 +210,19 @@ class List extends LitElement {
|
|
|
203
210
|
this.updateSelectedItems();
|
|
204
211
|
this.setUpSorting();
|
|
205
212
|
}
|
|
213
|
+
unobserveFilterRow() {
|
|
214
|
+
this.filterRowResizeObserver?.disconnect();
|
|
215
|
+
}
|
|
216
|
+
observeFilterRow() {
|
|
217
|
+
this.unobserveFilterRow();
|
|
218
|
+
const filterRowEl = this.filterContainerEl;
|
|
219
|
+
if (filterRowEl) {
|
|
220
|
+
this.filterRowResizeObserver?.observe(filterRowEl);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
updateFilterRowHeight() {
|
|
224
|
+
this.filterRowHeight = this.filterContainerEl?.clientHeight ?? 0;
|
|
225
|
+
}
|
|
206
226
|
handleListItemChange() {
|
|
207
227
|
this.willPerformFilter = true;
|
|
208
228
|
this.updateListItemsDebounced();
|
|
@@ -662,7 +682,9 @@ class List extends LitElement {
|
|
|
662
682
|
return this.interactiveContainer({ disabled: this.disabled, children: html`<div class=${safeClassMap({
|
|
663
683
|
[CSS.container]: true,
|
|
664
684
|
[CSS.containerHeight]: this.listItems.length < 1 && loading
|
|
665
|
-
})}
|
|
685
|
+
})} style=${safeStyleMap({
|
|
686
|
+
["--calcite-internal-filter-enabled-offset"]: `${this.filterRowHeight}px`
|
|
687
|
+
})}>${this.dragEnabled ? html`<span aria-live=assertive class=${safeClassMap(CSS.assistiveText)}>${this.assistiveText}</span>` : null}${this.renderItemAriaLive()}${loading ? html`<calcite-scrim class=${safeClassMap(CSS.scrim)} .loading=${loading}></calcite-scrim>` : null}<div .ariaBusy=${loading} .ariaLabel=${label || ""} class=${safeClassMap(CSS.table)} @keydown=${this.handleListKeydown} role=treegrid>${filterEnabled || hasFilterActionsStart || hasFilterActionsEnd ? html`<div class=${safeClassMap(CSS.sticky)} role=rowgroup ${ref(this.setFilterContainerEl)}><div role=row><div role=columnheader><calcite-stack class=${safeClassMap(CSS.stack)}><slot name=${SLOTS.filterActionsStart} @slotchange=${this.handleFilterActionsStartSlotChange} slot=${SLOTS$1.actionsStart}></slot><calcite-filter .ariaLabel=${filterPlaceholder} .disabled=${disabled} .filterProps=${effectiveFilterProps} .items=${dataForFilter} .label=${filterLabel} @calciteFilterChange=${this.handleFilterChange} .placeholder=${filterPlaceholder} .scale=${this.scale} .value=${filterText} ${ref(this.setFilterEl)}></calcite-filter><slot name=${SLOTS.filterActionsEnd} @slotchange=${this.handleFilterActionsEndSlotChange} slot=${SLOTS$1.actionsEnd}></slot></calcite-stack></div></div></div>` : null}<div class=${safeClassMap(CSS.tableContainer)} role=rowgroup><div .hidden=${!this.showEmptyContentContainer}><slot name=${SLOTS.emptyContent} @slotchange=${this.handleEmptyContentSlotChange}></slot></div><slot @slotchange=${this.handleDefaultSlotChange} ${ref(this.setDefaultSlotEl)}></slot></div></div><div aria-live=polite .hidden=${!this.showNoResultsContainer}><slot name=${SLOTS.filterNoResults} @slotchange=${this.handleFilterNoResultsSlotChange}></slot></div></div>` });
|
|
666
688
|
}
|
|
667
689
|
renderItemAriaLive() {
|
|
668
690
|
const { messages, filteredItems, parentListEl, messages: { _lang: effectiveLocale }, numberingSystem } = this;
|
|
@@ -8,7 +8,7 @@ const CSS = {
|
|
|
8
8
|
container: "container",
|
|
9
9
|
heading: "heading"
|
|
10
10
|
};
|
|
11
|
-
const styles = css`:host([disabled]){cursor:default;-webkit-user-select:none;user-select:none;opacity:var(--calcite-opacity-disabled)}:host([disabled]) *,:host([disabled]) ::slotted(*){pointer-events:none}:host{display:flex;flex-direction:column}:host([filter-hidden]){display:none}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.interaction-container{display:contents}.container{margin:0;display:flex;flex:1 1 0%;background-color:var(--calcite-list-background-color, var(--calcite-color-foreground-1));color:var(--calcite-list-color, var(--calcite-color-text-1))}.heading{font-weight:var(--calcite-font-weight-bold)}:host([scale=s]) .container{padding-inline:var(--calcite-spacing-sm)}:host([scale=s]) .heading{font-size:var(--calcite-font-size-sm);line-height:var(--calcite-font-line-height-fixed-base);padding-block:var(--calcite-spacing-sm) var(--calcite-spacing-xxs)}:host([scale=s]:not(:first-child)) .container{padding-block-start:var(--calcite-spacing-sm)}:host([scale=m]) .container{padding-inline:var(--calcite-spacing-md)}:host([scale=m]) .heading{font-size:var(--calcite-font-size);line-height:var(--calcite-font-line-height-fixed-base);padding-block:var(--calcite-spacing-lg) var(--calcite-spacing-sm)}:host([scale=m]:not(:first-child)) .container{padding-block-start:var(--calcite-spacing-md)}:host([scale=l]) .container{padding-inline:var(--calcite-spacing-lg)}:host([scale=l]) .heading{font-size:var(--calcite-font-size-md);line-height:var(--calcite-font-line-height-fixed-lg);padding-block:var(--calcite-spacing-xl) var(--calcite-spacing-sm-plus, .625rem)}:host([scale=l]:not(:first-child)) .container{padding-block-start:var(--calcite-spacing-md-plus, .875rem)}.heading{padding:0}:host([hidden]){display:none}[hidden]{display:none}`;
|
|
11
|
+
const styles = css`:host([disabled]){cursor:default;-webkit-user-select:none;user-select:none;opacity:var(--calcite-opacity-disabled)}:host([disabled]) *,:host([disabled]) ::slotted(*){pointer-events:none}:host{display:flex;flex-direction:column}:host([filter-hidden]){display:none}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.interaction-container{display:contents}.container{margin:0;display:flex;flex:1 1 0%;position:sticky;inset-block-start:var(--calcite-internal-filter-enabled-offset, 0);z-index:var(--calcite-z-index-sticky);background-color:var(--calcite-list-background-color, var(--calcite-color-foreground-1));color:var(--calcite-list-color, var(--calcite-color-text-1))}.heading{font-weight:var(--calcite-font-weight-bold)}:host([scale=s]) .container{padding-inline:var(--calcite-spacing-sm)}:host([scale=s]) .heading{font-size:var(--calcite-font-size-sm);line-height:var(--calcite-font-line-height-fixed-base);padding-block:var(--calcite-spacing-sm) var(--calcite-spacing-xxs)}:host([scale=s]:not(:first-child)) .container{padding-block-start:var(--calcite-spacing-sm)}:host([scale=m]) .container{padding-inline:var(--calcite-spacing-md)}:host([scale=m]) .heading{font-size:var(--calcite-font-size);line-height:var(--calcite-font-line-height-fixed-base);padding-block:var(--calcite-spacing-lg) var(--calcite-spacing-sm)}:host([scale=m]:not(:first-child)) .container{padding-block-start:var(--calcite-spacing-md)}:host([scale=l]) .container{padding-inline:var(--calcite-spacing-lg)}:host([scale=l]) .heading{font-size:var(--calcite-font-size-md);line-height:var(--calcite-font-line-height-fixed-lg);padding-block:var(--calcite-spacing-xl) var(--calcite-spacing-sm-plus, .625rem)}:host([scale=l]:not(:first-child)) .container{padding-block-start:var(--calcite-spacing-md-plus, .875rem)}.heading{padding:0}:host([hidden]){display:none}[hidden]{display:none}`;
|
|
12
12
|
class ListItemGroup extends LitElement {
|
|
13
13
|
constructor() {
|
|
14
14
|
super(...arguments);
|