@esri/calcite-components 5.2.0-next.102 → 5.2.0-next.104

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.
Files changed (176) hide show
  1. package/dist/cdn/{PFOFT4N3.js → 264Q77D5.js} +1 -1
  2. package/dist/cdn/{ZO4SGR25.js → 2RUE4F4A.js} +1 -1
  3. package/dist/cdn/{UQ36K7AM.js → 2TXBP24L.js} +1 -1
  4. package/dist/cdn/{6HJWRJEB.js → 3BZ6M7XT.js} +1 -1
  5. package/dist/cdn/{K6EBPLLU.js → 3FX4JWQK.js} +1 -1
  6. package/dist/cdn/{YAV2P2ED.js → 4HHBO3XZ.js} +1 -1
  7. package/dist/cdn/{6YJXN6YX.js → 4LTEB4JK.js} +1 -1
  8. package/dist/cdn/{7P45SJQG.js → 4T7LEQYG.js} +1 -1
  9. package/dist/cdn/{RE76EAUQ.js → 52GUFRP5.js} +1 -1
  10. package/dist/cdn/{QWAPXTTM.js → 54U75DHP.js} +1 -1
  11. package/dist/cdn/{CVLP4SXJ.js → 5D3OONRM.js} +1 -1
  12. package/dist/cdn/{CK7MUUAK.js → 5HRYOFX5.js} +1 -1
  13. package/dist/cdn/{26BOJ3AS.js → 5I6Y46L4.js} +1 -1
  14. package/dist/cdn/5KJXJHLE.js +2 -0
  15. package/dist/cdn/{3KBOQTLS.js → 5REWXPLJ.js} +1 -1
  16. package/dist/cdn/{LX5F4GG4.js → 5XG7MJXM.js} +1 -1
  17. package/dist/cdn/6BSCY2CN.js +2 -0
  18. package/dist/cdn/{5N3X3EYM.js → 6OGJG3KA.js} +1 -1
  19. package/dist/cdn/{2AUQGJCO.js → 6SRMO7QR.js} +1 -1
  20. package/dist/cdn/{FSRXHHGZ.js → 6U3HG35E.js} +1 -1
  21. package/dist/cdn/{3D4JXGZF.js → 6YIR6UQ2.js} +1 -1
  22. package/dist/cdn/{6ARU3W4T.js → A2JEAX6B.js} +1 -1
  23. package/dist/cdn/{ZDYW6A5H.js → A46Z7TV2.js} +1 -1
  24. package/dist/cdn/{M75K6WN5.js → A6RHKWKU.js} +1 -1
  25. package/dist/cdn/{O7MD54NP.js → A7U6LXNL.js} +1 -1
  26. package/dist/cdn/{GAJFTSWJ.js → AB2AAI4P.js} +1 -1
  27. package/dist/cdn/{AVGGTI7X.js → AEOCIW6N.js} +1 -1
  28. package/dist/cdn/{MZPMJXP6.js → ALZ6O4VG.js} +1 -1
  29. package/dist/cdn/{27K5OJ2X.js → ANXCH4NM.js} +1 -1
  30. package/dist/cdn/{ICGB7OHW.js → ATIGQA43.js} +1 -1
  31. package/dist/cdn/{WHRY6PW3.js → AVBEANMP.js} +1 -1
  32. package/dist/cdn/{TYNM7NKY.js → AXLKHZF7.js} +1 -1
  33. package/dist/cdn/{XRPAIIKT.js → B6ICS4L5.js} +1 -1
  34. package/dist/cdn/{ORVBMM34.js → BBHZTJ7E.js} +1 -1
  35. package/dist/cdn/{G2QY25JG.js → BL4UJCS5.js} +1 -1
  36. package/dist/cdn/{DFEVAYBM.js → BMPLNW7Y.js} +1 -1
  37. package/dist/cdn/{K33XSTQJ.js → BR42QAF2.js} +1 -1
  38. package/dist/cdn/BUXBC2TD.js +2 -0
  39. package/dist/cdn/{7DPH4J74.js → BYJWKSPM.js} +1 -1
  40. package/dist/cdn/{4HNDYW3I.js → CB56QAVN.js} +1 -1
  41. package/dist/cdn/{RVLA67A3.js → CGKKSBUK.js} +1 -1
  42. package/dist/cdn/{IG4T7QNO.js → CJPLMHL6.js} +1 -1
  43. package/dist/cdn/{LKZVI7JX.js → CX6VMTHB.js} +1 -1
  44. package/dist/cdn/{I3UIWDLW.js → D6OXR5HH.js} +1 -1
  45. package/dist/cdn/{2CBCRLZU.js → DFJLELTS.js} +1 -1
  46. package/dist/cdn/{GIJACFRM.js → DFKGKYEF.js} +1 -1
  47. package/dist/cdn/{7FW2RVVH.js → DJD3CC5A.js} +1 -1
  48. package/dist/cdn/{CPJWJSHI.js → DUDXVLZX.js} +1 -1
  49. package/dist/cdn/{YIVWYM7O.js → DXGTCHAD.js} +1 -1
  50. package/dist/cdn/{GJIC4IIX.js → EG6PJL34.js} +1 -1
  51. package/dist/cdn/{L6STJJQX.js → EGBHDYPW.js} +1 -1
  52. package/dist/cdn/{HMDESRNL.js → F3FFPXMX.js} +1 -1
  53. package/dist/cdn/{EEU562WF.js → FDZX4WWL.js} +1 -1
  54. package/dist/cdn/{26K4W52A.js → FEMJOITB.js} +1 -1
  55. package/dist/cdn/{SAZM37N6.js → FK326MY2.js} +1 -1
  56. package/dist/cdn/{YAHYADUP.js → FPQEHXJ3.js} +1 -1
  57. package/dist/cdn/{YSOEBQ4L.js → GM5YEWMM.js} +1 -1
  58. package/dist/cdn/{M4XG6CGT.js → GMW5MPTM.js} +1 -1
  59. package/dist/cdn/{INT4F44W.js → GWQVXROY.js} +1 -1
  60. package/dist/cdn/{LNYZHXW3.js → H32SNSSX.js} +1 -1
  61. package/dist/cdn/{5ZYCAOFR.js → H4MYZ7CU.js} +1 -1
  62. package/dist/cdn/{MND5LNIL.js → H5A5N3SD.js} +1 -1
  63. package/dist/cdn/{DWOVKLPL.js → HGN6W2NJ.js} +1 -1
  64. package/dist/cdn/{HXLP2PM2.js → HISTK2ZF.js} +1 -1
  65. package/dist/cdn/{VFPAGN4M.js → HRGDUQAV.js} +1 -1
  66. package/dist/cdn/{66A27LX7.js → I3MBK6RQ.js} +1 -1
  67. package/dist/cdn/{XDY7OFJO.js → ICEQ2B2G.js} +1 -1
  68. package/dist/cdn/{YISOG3ZP.js → IISAEGKF.js} +1 -1
  69. package/dist/cdn/{HW4WSWTV.js → ILL5MCXC.js} +1 -1
  70. package/dist/cdn/{SH7KTJUK.js → ILY2U7OP.js} +1 -1
  71. package/dist/cdn/{BJ7WOEAG.js → IQ47BKLT.js} +1 -1
  72. package/dist/cdn/{L4R2PRKY.js → IXWEGLDQ.js} +1 -1
  73. package/dist/cdn/{3YTF5DX5.js → IZZHPHVF.js} +1 -1
  74. package/dist/cdn/{D3VKELYU.js → J7Z64224.js} +1 -1
  75. package/dist/cdn/{6CDUYZAO.js → JBF36T3N.js} +1 -1
  76. package/dist/cdn/{BKATIQKR.js → JDYFHYMW.js} +1 -1
  77. package/dist/cdn/{NDECAMD3.js → JIGI5ZSK.js} +1 -1
  78. package/dist/cdn/{2IKUEISB.js → JRFXKWAG.js} +1 -1
  79. package/dist/cdn/{JYI4327E.js → JRI5SUUW.js} +1 -1
  80. package/dist/cdn/{KUVPBSXE.js → JXSSREAK.js} +1 -1
  81. package/dist/cdn/{NNLUZDBR.js → JZYUW6IY.js} +1 -1
  82. package/dist/cdn/{W2RJQH3L.js → KMST6UJ3.js} +1 -1
  83. package/dist/cdn/{L4H2SS3D.js → LJKZP4QZ.js} +1 -1
  84. package/dist/cdn/{TU6RUNAV.js → LKJXWD5J.js} +1 -1
  85. package/dist/cdn/{EHNSDZ6Y.js → LRJHEYDG.js} +1 -1
  86. package/dist/cdn/{HHQX2WEL.js → LXCVGBWN.js} +1 -1
  87. package/dist/cdn/{T5HOHJA5.js → MI7EPZ72.js} +1 -1
  88. package/dist/cdn/{CRUGCAUH.js → MWEZH3M4.js} +1 -1
  89. package/dist/cdn/{OUNGWBIE.js → NEJIA7VA.js} +1 -1
  90. package/dist/cdn/{2DFC42XH.js → NIJ3A4IY.js} +1 -1
  91. package/dist/cdn/{QVPPQ5QM.js → NK2OTN4N.js} +1 -1
  92. package/dist/cdn/{BB4NCRPI.js → NLYAVVAL.js} +1 -1
  93. package/dist/cdn/NOODJZAN.js +2 -0
  94. package/dist/cdn/{JJIR6VS5.js → NPSWLXKP.js} +1 -1
  95. package/dist/cdn/{FDBT32UY.js → O3AMPVTL.js} +1 -1
  96. package/dist/cdn/{SNU6GHTA.js → OLCMMDWX.js} +1 -1
  97. package/dist/cdn/{ROOTN64V.js → P6CSCVUV.js} +1 -1
  98. package/dist/cdn/{4F67QOP2.js → PFRZKJRH.js} +1 -1
  99. package/dist/cdn/{QWNO6CDS.js → PT5BEFCD.js} +1 -1
  100. package/dist/cdn/{4YDDNPJM.js → PYBVWWY3.js} +1 -1
  101. package/dist/cdn/{7CBMIGZ5.js → QKCFDUPD.js} +1 -1
  102. package/dist/cdn/{XE6RRR4B.js → QQKSZ66Y.js} +1 -1
  103. package/dist/cdn/{HDBOSQPV.js → QXLJAGMM.js} +1 -1
  104. package/dist/cdn/{E7L3YNDJ.js → R5Q4436Z.js} +1 -1
  105. package/dist/cdn/{KPLLNKHQ.js → RKOHEWU6.js} +1 -1
  106. package/dist/cdn/{ULE74MJQ.js → RQJTT4C4.js} +1 -1
  107. package/dist/cdn/{RBZR4RB7.js → S3HX76F7.js} +1 -1
  108. package/dist/cdn/{PKAE4WC2.js → S5HTCGOP.js} +1 -1
  109. package/dist/cdn/{MSCZMCIJ.js → SFQQQ4HL.js} +1 -1
  110. package/dist/cdn/{4QLJSFIV.js → SLOE7CR3.js} +1 -1
  111. package/dist/cdn/{5QN37AAD.js → ST2D3A4C.js} +1 -1
  112. package/dist/cdn/{3NKCGC76.js → SXGTS2QT.js} +1 -1
  113. package/dist/cdn/{7SZ25WQY.js → SZDROVZZ.js} +1 -1
  114. package/dist/cdn/T2EK7M5W.js +2 -0
  115. package/dist/cdn/{S6TTJ3MN.js → TAGQIAHC.js} +1 -1
  116. package/dist/cdn/{6G2XKITX.js → TKY5V6N3.js} +1 -1
  117. package/dist/cdn/{XZGRTKR5.js → TLXTULLR.js} +1 -1
  118. package/dist/cdn/{MH3HKR7J.js → TXMIPGD7.js} +1 -1
  119. package/dist/cdn/{URJJHOZ3.js → TXQROMS6.js} +1 -1
  120. package/dist/cdn/{WRLMTTQL.js → U3NJ5OUI.js} +1 -1
  121. package/dist/cdn/{FZII3ZXY.js → UCKYBMPL.js} +1 -1
  122. package/dist/cdn/{DDTRUVZM.js → UJ7SVXW5.js} +1 -1
  123. package/dist/cdn/{43VC2RPP.js → UKCB6Z25.js} +1 -1
  124. package/dist/cdn/{4W3ES3UM.js → UNHUSMA2.js} +1 -1
  125. package/dist/cdn/{STH5JQ6U.js → UQ2CL2S6.js} +1 -1
  126. package/dist/cdn/{Y6URTI6B.js → V2XZFSTP.js} +1 -1
  127. package/dist/cdn/{KC2HWDZV.js → VHWTZ7L2.js} +1 -1
  128. package/dist/cdn/{S34XTF7D.js → VTGFMCFV.js} +1 -1
  129. package/dist/cdn/{NPYCNKHD.js → W2WQCASL.js} +1 -1
  130. package/dist/cdn/{XOP5FFXT.js → W4AT4EUP.js} +1 -1
  131. package/dist/cdn/{J7JZAIUL.js → WAH6L565.js} +1 -1
  132. package/dist/cdn/{MXZYCKP6.js → WDN7NXSE.js} +1 -1
  133. package/dist/cdn/{HQWZSX3A.js → WRRFRZSF.js} +1 -1
  134. package/dist/cdn/{OTHXF7V5.js → XXPMMKQV.js} +1 -1
  135. package/dist/cdn/{A6D64KCU.js → XZPALSDR.js} +1 -1
  136. package/dist/cdn/{FPI74P5T.js → YBIVT4F6.js} +1 -1
  137. package/dist/cdn/{ZJJHRZ3X.js → YDPXGMY2.js} +1 -1
  138. package/dist/cdn/YGPHXXML.js +2 -0
  139. package/dist/cdn/{DZ3GTNUK.js → Z5T3ZOKL.js} +1 -1
  140. package/dist/cdn/{XSLEH5ZJ.js → ZAZOB2QT.js} +1 -1
  141. package/dist/cdn/{TEARJIUB.js → ZDTD2JS7.js} +1 -1
  142. package/dist/cdn/{MRT2D5C7.js → ZN7DDJAR.js} +1 -1
  143. package/dist/cdn/{Y72UN7RT.js → ZP53YJCX.js} +1 -1
  144. package/dist/cdn/{F25BWA5S.js → ZQDBLWXZ.js} +1 -1
  145. package/dist/cdn/{UI4HTACK.js → ZQYYCBV6.js} +1 -1
  146. package/dist/cdn/{PE3SFDR6.js → ZXRTKVNU.js} +1 -1
  147. package/dist/cdn/index.js +1 -1
  148. package/dist/cdn/main.css +1 -1
  149. package/dist/chunks/dom.js +7 -1
  150. package/dist/chunks/runtime.js +4 -4
  151. package/dist/chunks/useInlineEdit.js +4 -1
  152. package/dist/components/calcite-input/customElement.js +3 -0
  153. package/dist/components/calcite-input-number/customElement.js +3 -0
  154. package/dist/components/calcite-input-text/customElement.js +3 -0
  155. package/dist/components/calcite-input-time-zone/customElement.d.ts +2 -0
  156. package/dist/components/calcite-input-time-zone/customElement.js +2 -2
  157. package/dist/components/calcite-text/customElement.d.ts +19 -0
  158. package/dist/components/calcite-text/customElement.js +174 -0
  159. package/dist/components/calcite-text/index.d.ts +1 -0
  160. package/dist/components/calcite-text/index.js +1 -0
  161. package/dist/docs/api.json +1 -1
  162. package/dist/docs/docs.json +1 -1
  163. package/dist/docs/vscode.html-custom-data.json +1 -1
  164. package/dist/docs/web-types.json +1 -1
  165. package/dist/index.d.ts +4 -0
  166. package/dist/loader.js +2 -1
  167. package/dist/types/lumina.d.ts +6 -1
  168. package/dist/types/preact.d.ts +7 -1
  169. package/dist/types/react.d.ts +8 -1
  170. package/dist/types/stencil.d.ts +6 -1
  171. package/package.json +1 -1
  172. package/dist/cdn/3JHXZ2IW.js +0 -2
  173. package/dist/cdn/5EYLSRG6.js +0 -2
  174. package/dist/cdn/CX2QTIR3.js +0 -2
  175. package/dist/cdn/IMC5455V.js +0 -2
  176. package/dist/cdn/OFYS2GLL.js +0 -2
@@ -18,13 +18,16 @@ class UseInlineEdit {
18
18
  this.valuePriorToEditing = "";
19
19
  }
20
20
  enable() {
21
- this.valuePriorToEditing = this.options.getValue();
21
+ this.captureValuePriorToEditing();
22
22
  this.options.setInlineEditing(true);
23
23
  requestAnimationFrame(() => {
24
24
  this.options.setFocus();
25
25
  });
26
26
  this.options.emitEnableEditingChange();
27
27
  }
28
+ captureValuePriorToEditing() {
29
+ this.valuePriorToEditing = this.options.getValue();
30
+ }
28
31
  disable() {
29
32
  this.options.setInlineEditing(false);
30
33
  }
@@ -213,6 +213,9 @@ class Input extends LitElement {
213
213
  }
214
214
  }
215
215
  willUpdate(changes) {
216
+ if (changes.has("inlineEditing") && this.inlineEditing) {
217
+ this.inlineEditManager.captureValuePriorToEditing();
218
+ }
216
219
  if (changes.has("max")) {
217
220
  this.maxString = this.max?.toString() ?? void 0;
218
221
  }
@@ -200,6 +200,9 @@ class InputNumber extends LitElement {
200
200
  }
201
201
  }
202
202
  willUpdate(changes) {
203
+ if (changes.has("inlineEditing") && this.inlineEditing) {
204
+ this.inlineEditManager.captureValuePriorToEditing();
205
+ }
203
206
  if (changes.has("max")) {
204
207
  this.maxString = this.max?.toString() || void 0;
205
208
  }
@@ -163,6 +163,9 @@ class InputText extends LitElement {
163
163
  this.setPreviousValue(this.value);
164
164
  }
165
165
  willUpdate(changes) {
166
+ if (changes.has("inlineEditing") && this.inlineEditing) {
167
+ this.inlineEditManager.captureValuePriorToEditing();
168
+ }
166
169
  if (changes.has("icon")) {
167
170
  this.requestedIcon = setRequestedIcon({}, this.icon, "text");
168
171
  }
@@ -30,6 +30,8 @@ export abstract class InputTimeZone extends LitElement {
30
30
  accessor disabled: boolean;
31
31
  /** Specifies the `id` of the component's associated form. When not set, the component is associated with its ancestor form element, if one exists. */
32
32
  accessor form: string | undefined;
33
+ /** Specifies an accessible label for the component. */
34
+ accessor label: string | undefined;
33
35
  /** Specifies the component's label text. */
34
36
  accessor labelText: string | undefined;
35
37
  /**
@@ -233,7 +233,7 @@ class InputTimeZone extends LitElement {
233
233
  useLabel(this);
234
234
  }
235
235
  static {
236
- this.properties = { selectedTimeZoneItem: [16, {}, { state: true }], timeZoneItems: [16, {}, { state: true }], clearable: [7, {}, { reflect: true, type: Boolean }], disabled: [7, {}, { reflect: true, type: Boolean }], form: [3, {}, { reflect: true }], labelText: 1, maxItems: [11, {}, { reflect: true, type: Number }], messageOverrides: [0, {}, { attribute: false }], mode: [3, {}, { reflect: true }], name: [3, {}, { reflect: true }], offsetStyle: [3, {}, { reflect: true }], open: [7, {}, { reflect: true, type: Boolean }], overlayPositioning: [3, {}, { reflect: true }], placeholder: 1, readOnly: [7, {}, { reflect: true, type: Boolean }], referenceDate: 1, required: [7, {}, { reflect: true, type: Boolean }], scale: [3, {}, { reflect: true }], status: [3, {}, { reflect: true }], topLayerDisabled: [7, {}, { reflect: true, type: Boolean }], validationIcon: [3, { converter: stringOrBoolean }, { reflect: true }], validationMessage: 1, validity: [32, {}, { readOnly: true, attribute: false }], value: 1 };
236
+ this.properties = { selectedTimeZoneItem: [16, {}, { state: true }], timeZoneItems: [16, {}, { state: true }], clearable: [7, {}, { reflect: true, type: Boolean }], disabled: [7, {}, { reflect: true, type: Boolean }], form: [3, {}, { reflect: true }], label: 1, labelText: 1, maxItems: [11, {}, { reflect: true, type: Number }], messageOverrides: [0, {}, { attribute: false }], mode: [3, {}, { reflect: true }], name: [3, {}, { reflect: true }], offsetStyle: [3, {}, { reflect: true }], open: [7, {}, { reflect: true, type: Boolean }], overlayPositioning: [3, {}, { reflect: true }], placeholder: 1, readOnly: [7, {}, { reflect: true, type: Boolean }], referenceDate: 1, required: [7, {}, { reflect: true, type: Boolean }], scale: [3, {}, { reflect: true }], status: [3, {}, { reflect: true }], topLayerDisabled: [7, {}, { reflect: true, type: Boolean }], validationIcon: [3, { converter: stringOrBoolean }, { reflect: true }], validationMessage: 1, validity: [32, {}, { readOnly: true, attribute: false }], value: 1 };
237
237
  }
238
238
  static {
239
239
  this.formAssociated = true;
@@ -404,7 +404,7 @@ class InputTimeZone extends LitElement {
404
404
  return !metadata.country || open || !selected ? label : getSelectedRegionTimeZoneLabel(label, metadata.country, this.messages);
405
405
  }
406
406
  render() {
407
- return this.interactiveContainer({ disabled: this.disabled, children: html`<calcite-combobox .clearDisabled=${!this.clearable} .disabled=${this.disabled} .label=${this.messages.chooseTimeZone} .labelText=${this.labelText} lang=${this.messages._lang ?? nothing} .maxItems=${this.maxItems} @calciteComboboxBeforeClose=${this.onComboboxBeforeClose} @calciteComboboxBeforeOpen=${this.onComboboxBeforeOpen} @calciteComboboxChange=${this.onComboboxChange} @calciteComboboxClose=${this.onComboboxClose} @calciteComboboxOpen=${this.onComboboxOpen} .overlayPositioning=${this.overlayPositioning} .placeholder=${this.placeholder || this.messages[`${this.mode}Placeholder`]} placeholder-icon=search .readOnly=${this.readOnly} .required=${this.required} .scale=${this.scale} .selectionMode=${this.clearable ? "single" : "single-persist"} .status=${this.status} .topLayerDisabled=${this.topLayerDisabled} .validationIcon=${this.validationIcon} .validationMessage=${this.validationMessage} ${ref(this.comboboxRef)}>${this.renderItems()}<slot name=${SLOTS.labelContent} slot=${SLOTS$1.labelContent}></slot></calcite-combobox>` });
407
+ return this.interactiveContainer({ disabled: this.disabled, children: html`<calcite-combobox .clearDisabled=${!this.clearable} .disabled=${this.disabled} .label=${this.label || this.messages.chooseTimeZone} .labelText=${this.labelText} lang=${this.messages._lang ?? nothing} .maxItems=${this.maxItems} @calciteComboboxBeforeClose=${this.onComboboxBeforeClose} @calciteComboboxBeforeOpen=${this.onComboboxBeforeOpen} @calciteComboboxChange=${this.onComboboxChange} @calciteComboboxClose=${this.onComboboxClose} @calciteComboboxOpen=${this.onComboboxOpen} .overlayPositioning=${this.overlayPositioning} .placeholder=${this.placeholder || this.messages[`${this.mode}Placeholder`]} placeholder-icon=search .readOnly=${this.readOnly} .required=${this.required} .scale=${this.scale} .selectionMode=${this.clearable ? "single" : "single-persist"} .status=${this.status} .topLayerDisabled=${this.topLayerDisabled} .validationIcon=${this.validationIcon} .validationMessage=${this.validationMessage} ${ref(this.comboboxRef)}>${this.renderItems()}<slot name=${SLOTS.labelContent} slot=${SLOTS$1.labelContent}></slot></calcite-combobox>` });
408
408
  }
409
409
  renderItems() {
410
410
  if (this.mode === "region") {
@@ -0,0 +1,19 @@
1
+ /// <reference path="../../index.d.ts" />
2
+ import type { PublicLitElement as LitElement } from "@arcgis/lumina";
3
+
4
+ /** @slot - A slot for adding text. */
5
+ export abstract class Text extends LitElement {
6
+ /**
7
+ * Specifies the maximum number of lines to display before truncating the text with an ellipsis.
8
+ *
9
+ * @mdn [maxLines](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/line-clamp)
10
+ */
11
+ accessor maxLines: number | undefined;
12
+ /**
13
+ * Specifies the position of truncation ellipsis when text overflows.
14
+ * `truncatePosition` is ignored when `maxLines` is configured, as multi-line truncation always occurs at the end.
15
+ */
16
+ accessor truncatePosition: TruncatePosition | undefined;
17
+ }
18
+
19
+ export type TruncatePosition = "middle" | "end";
@@ -0,0 +1,174 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import { c as customElement } from "../../chunks/runtime.js";
3
+ import { LitElement, safeClassMap } from "@arcgis/lumina";
4
+ import { createRef, ref } from "lit/directives/ref.js";
5
+ import { D as getAssignedTextNodesFromSlotEl, k as getTextWidth, E as slotChangeGetTextContent } from "../../chunks/dom.js";
6
+ import { c as createObserver, u as updateRefObserver } from "../../chunks/observers.js";
7
+ import { css, html } from "lit";
8
+ const styles = css`:host{display:block;overflow-wrap:break-word;overflow:hidden;white-space:normal}:host([truncate-position=end]){text-overflow:ellipsis;white-space:nowrap}:host([truncate-position=middle]){white-space:nowrap}.text-container{overflow:inherit;text-overflow:inherit}:host([truncate-position=middle]:not([max-lines])) slot{display:none}:host(:not([truncate-position=middle])) .middle-truncated-text,:host([max-lines]) .middle-truncated-text{display:none}:host([max-lines]) .text-container{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:var(--calcite-internal-text-max-lines, none);white-space:normal}:host([hidden]){display:none}[hidden]{display:none}.assistive-text{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}`;
9
+ const ELLIPSIS_CHAR = "…";
10
+ const CSS = {
11
+ middleTruncatedText: "middle-truncated-text",
12
+ textContainer: "text-container",
13
+ assistiveText: "assistive-text"
14
+ };
15
+ class Text extends LitElement {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.assistiveTextSpanRef = createRef();
19
+ this.defaultSlotRef = createRef();
20
+ this.middleTruncatedSpanRef = createRef();
21
+ this.mutationObserver = createObserver("mutation", (mutations) => {
22
+ const assignedTextNodes = getAssignedTextNodesFromSlotEl(this.defaultSlotRef.value);
23
+ if (mutations.some(({ target }) => assignedTextNodes.includes(target))) {
24
+ this.setValue(assignedTextNodes.map((node) => node.textContent).join("").trim());
25
+ }
26
+ });
27
+ this.resizeObserver = createObserver("resize", () => {
28
+ this.handleTruncation();
29
+ });
30
+ this.renderedText = "";
31
+ }
32
+ static {
33
+ this.properties = { maxLines: [11, {}, { type: Number, reflect: true }], truncatePosition: [3, {}, { reflect: true }] };
34
+ }
35
+ static {
36
+ this.styles = styles;
37
+ }
38
+ connectedCallback() {
39
+ super.connectedCallback();
40
+ this.mutationObserver?.observe(this.el, {
41
+ characterData: true,
42
+ subtree: true
43
+ });
44
+ }
45
+ willUpdate(changes) {
46
+ if (changes.has("maxLines") && this.hasUpdated) {
47
+ if (!this.maxLines) {
48
+ this.clearTooltipTitle();
49
+ }
50
+ this.updateMaxLinesToken();
51
+ }
52
+ }
53
+ updated(changes) {
54
+ if (changes.has("truncatePosition") && !this.maxLines) {
55
+ this.handleTruncatePositionChange(changes.get("truncatePosition"));
56
+ }
57
+ }
58
+ disconnectedCallback() {
59
+ super.disconnectedCallback();
60
+ this.resizeObserver?.disconnect();
61
+ this.mutationObserver?.disconnect();
62
+ }
63
+ clearTooltipTitle() {
64
+ this.textContainerEl.title = "";
65
+ }
66
+ getTruncatedText(text, maxWidth, font, letterSpacing) {
67
+ let startIndex = 0;
68
+ let endIndex = text.length;
69
+ const truncatedString = (index) => {
70
+ const leftCount = Math.ceil(index / 2);
71
+ const rightCount = Math.floor(index / 2);
72
+ return text.slice(0, leftCount) + ELLIPSIS_CHAR + text.slice(text.length - rightCount);
73
+ };
74
+ while (startIndex < endIndex) {
75
+ const mid = Math.ceil((startIndex + endIndex) / 2);
76
+ const optimalText = truncatedString(mid);
77
+ if (getTextWidth(optimalText, font, letterSpacing) <= maxWidth) {
78
+ startIndex = mid;
79
+ } else {
80
+ endIndex = mid - 1;
81
+ }
82
+ }
83
+ const optimalIndex = Math.max(0, startIndex);
84
+ if (optimalIndex <= 1) {
85
+ return ELLIPSIS_CHAR;
86
+ }
87
+ return truncatedString(optimalIndex);
88
+ }
89
+ handleDefaultSlotChange(event) {
90
+ this.setValue(slotChangeGetTextContent(event));
91
+ }
92
+ setValue(value) {
93
+ this.value = value;
94
+ this.renderedText = value;
95
+ this.handleTruncation();
96
+ }
97
+ handleTruncation() {
98
+ if (!this.textContainerEl) {
99
+ return;
100
+ }
101
+ const { truncatePosition, maxLines } = this;
102
+ if (this.isTruncatePositionMiddle()) {
103
+ this.truncateMiddleText();
104
+ this.assistiveTextSpanRef.value.textContent = this.value || "";
105
+ } else if (truncatePosition === "end" || maxLines && maxLines >= 1) {
106
+ this.syncTooltipState();
107
+ }
108
+ }
109
+ hasOverflow() {
110
+ return this.textContainerEl.scrollWidth > this.textContainerEl.clientWidth || this.textContainerEl.scrollHeight > this.textContainerEl.clientHeight;
111
+ }
112
+ syncTooltipState() {
113
+ if (this.hasOverflow()) {
114
+ this.setTooltipTitle();
115
+ } else {
116
+ this.clearTooltipTitle();
117
+ }
118
+ }
119
+ handleTruncatePositionChange(oldValue) {
120
+ const newValue = this.truncatePosition;
121
+ if (oldValue && !newValue) {
122
+ this.clearTooltipTitle();
123
+ } else {
124
+ this.handleTruncation();
125
+ }
126
+ }
127
+ setTooltipTitle() {
128
+ this.textContainerEl.title = this.value || "";
129
+ }
130
+ setMiddleTruncatedText(value) {
131
+ const middleTruncatedTextEl = this.middleTruncatedSpanRef.value;
132
+ if (!middleTruncatedTextEl) {
133
+ return;
134
+ }
135
+ middleTruncatedTextEl.textContent = value || "";
136
+ }
137
+ truncateMiddleText() {
138
+ requestAnimationFrame(() => {
139
+ if (!this.textContainerEl || !this.textContainerEl.clientWidth || this.maxLines || this.truncatePosition !== "middle") {
140
+ return;
141
+ }
142
+ const clientWidth = this.textContainerEl.clientWidth;
143
+ const computedStyle = getComputedStyle(this.el);
144
+ const font = computedStyle.font || `${computedStyle.fontSize} ${computedStyle.fontFamily}`;
145
+ const textWidth = getTextWidth(this.value, font, computedStyle.letterSpacing);
146
+ if (textWidth <= clientWidth) {
147
+ this.setMiddleTruncatedText(this.value);
148
+ this.clearTooltipTitle();
149
+ } else {
150
+ const middleTruncatedText = this.getTruncatedText(this.renderedText, clientWidth, font, computedStyle.letterSpacing);
151
+ this.setMiddleTruncatedText(middleTruncatedText);
152
+ this.setTooltipTitle();
153
+ }
154
+ });
155
+ }
156
+ updateMaxLinesToken() {
157
+ this.textContainerEl?.style.setProperty("--calcite-internal-text-max-lines", this.maxLines?.toString() || null);
158
+ }
159
+ setTextContainerRef(el) {
160
+ updateRefObserver(this.resizeObserver, this.textContainerEl, el);
161
+ this.textContainerEl = el;
162
+ this.updateMaxLinesToken();
163
+ }
164
+ isTruncatePositionMiddle() {
165
+ return this.truncatePosition === "middle" && !this.maxLines;
166
+ }
167
+ render() {
168
+ return html`<div class=${safeClassMap(CSS.textContainer)} ${ref(this.setTextContainerRef)}><slot @slotchange=${this.handleDefaultSlotChange} ${ref(this.defaultSlotRef)}></slot><span aria-hidden=true class=${safeClassMap(CSS.middleTruncatedText)} ${ref(this.middleTruncatedSpanRef)}></span>${this.isTruncatePositionMiddle() && html`<span aria-live=polite class=${safeClassMap(CSS.assistiveText)} ${ref(this.assistiveTextSpanRef)}></span>` || ""}</div>`;
169
+ }
170
+ }
171
+ customElement("calcite-text", Text);
172
+ export {
173
+ Text
174
+ };
@@ -0,0 +1 @@
1
+ export * from "./customElement.js";
@@ -0,0 +1 @@
1
+ export * from "./customElement.js";