@wix/form-elements 1.108.0 → 1.110.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.
Files changed (107) hide show
  1. package/dist/component/{appointment-rac-ZAp8oWbK.js → appointment-rac-CfPs6AsU.js} +60 -60
  2. package/dist/component/{bookings-address-rac-x-Az7vHf.js → bookings-address-rac-XkgsBu8i.js} +1 -1
  3. package/dist/component/{bookings-email-rac-MoF_CaqB.js → bookings-email-rac-CyESeQLD.js} +1 -1
  4. package/dist/component/{bookings-first-name-rac-CWh3Rb0M.js → bookings-first-name-rac-CFY5Qwk9.js} +1 -1
  5. package/dist/component/{bookings-header-rac-BVTiXUWk.js → bookings-header-rac-lRsebspV.js} +1 -1
  6. package/dist/component/{bookings-last-name-rac-kXRRlyHl.js → bookings-last-name-rac-B7J2K4oK.js} +1 -1
  7. package/dist/component/{bookings-login-bar-rac-C4Zr6kXE.js → bookings-login-bar-rac-BD97U76_.js} +3 -3
  8. package/dist/component/{bookings-phone-rac-2rz1m_xi.js → bookings-phone-rac-CpgDCLTp.js} +1 -1
  9. package/dist/component/{bookings-rich-text-rac-BEjGypQw.js → bookings-rich-text-rac-DQUQMN3s.js} +1 -1
  10. package/dist/component/{checkbox-field-rac-DwEQLIaz.js → checkbox-field-rac-CcOW4yol.js} +43 -43
  11. package/dist/component/{checkbox-group-field-headless-BsOww_QB.js → checkbox-group-field-headless-DiBxnwOj.js} +8 -8
  12. package/dist/component/{checkbox-group-field-rac-DTcZcVS6.js → checkbox-group-field-rac-BCzS44NM.js} +4 -4
  13. package/dist/component/{checkbox-group-rac-DQsML-pW.js → checkbox-group-rac-C2oHVikX.js} +1 -1
  14. package/dist/component/{checkbox-rac-irEBBOxP.js → checkbox-rac-DPhswfJ9.js} +1 -1
  15. package/dist/component/{contacts-address-rac-B5bSAYrm.js → contacts-address-rac-Cjqot4Vo.js} +1 -1
  16. package/dist/component/{contacts-birthdate-rac-DyScj8f4.js → contacts-birthdate-rac-C3uYlFa3.js} +1 -1
  17. package/dist/component/{contacts-company-rac-C5X9-jXa.js → contacts-company-rac-BDmDrlJm.js} +1 -1
  18. package/dist/component/{contacts-email-rac-B0vkfmrS.js → contacts-email-rac-9NI8430K.js} +1 -1
  19. package/dist/component/{contacts-first-name-rac-Cfil3U_e.js → contacts-first-name-rac-PNgDNwXZ.js} +1 -1
  20. package/dist/component/{contacts-last-name-rac-CtPLE-7-.js → contacts-last-name-rac-Dkf8oYRe.js} +1 -1
  21. package/dist/component/{contacts-phone-rac-YkzsAoBZ.js → contacts-phone-rac-BefG0umR.js} +1 -1
  22. package/dist/component/{contacts-position-rac-BS4j8QC-.js → contacts-position-rac-8ZWMa74Q.js} +1 -1
  23. package/dist/component/{contacts-subscribe-rac-z_9VsEZL.js → contacts-subscribe-rac-Dj0k_O2C.js} +1 -1
  24. package/dist/component/{contacts-tax-id-rac-WFkmKyZv.js → contacts-tax-id-rac-Dbz0SEH9.js} +1 -1
  25. package/dist/component/{date-availability-NN3rxosk.js → date-availability-CpZYBX1d.js} +1 -1
  26. package/dist/component/{date-input-field-rac-mdhEC3oq.js → date-input-field-rac-8CkusNEQ.js} +64 -64
  27. package/dist/component/{date-input-rac-CGciuoTx.js → date-input-rac-CH1ke9-c.js} +1 -1
  28. package/dist/component/{date-picker-field-rac-CRZVODfF.js → date-picker-field-rac-pZQhHvZc.js} +31 -31
  29. package/dist/component/{date-picker-rac-Bfbvjy8W.js → date-picker-rac-BOdzNgu6.js} +1 -1
  30. package/dist/component/{date-time-input-field-rac-TDWBXZ44.js → date-time-input-field-rac-DDUZvi8G.js} +70 -70
  31. package/dist/component/{date-time-input-rac-DY0qdSix.js → date-time-input-rac-DkjW7KId.js} +1 -1
  32. package/dist/component/{dext-checkbox-group-rac-BFGM7SOt.js → dext-checkbox-group-rac-Cjx062TO.js} +2 -2
  33. package/dist/component/{dext-checkbox-rac-DPZvTeUZ.js → dext-checkbox-rac-CIqsZ8Cf.js} +1 -1
  34. package/dist/component/{dext-date-picker-rac-Xd5kojsQ.js → dext-date-picker-rac-BYQN00yy.js} +1 -1
  35. package/dist/component/{dext-date-time-input-rac-C0RIdxJW.js → dext-date-time-input-rac-Bh-HYZ_X.js} +1 -1
  36. package/dist/component/{dext-dropdown-rac-D1m8vJvm.js → dext-dropdown-rac-rnkUqsSx.js} +1 -1
  37. package/dist/component/{dext-email-rac-BC81RFYY.js → dext-email-rac-DtW_DadC.js} +1 -1
  38. package/dist/component/{dext-number-input-rac-Z_ih9FfX.js → dext-number-input-rac-DTfdLXFG.js} +1 -1
  39. package/dist/component/{dext-phone-rac-s3BOnXuI.js → dext-phone-rac-D3anV8iB.js} +1 -1
  40. package/dist/component/{dext-radio-group-rac-CL3jcezs.js → dext-radio-group-rac-CIO_2H7F.js} +4 -4
  41. package/dist/component/{dext-rating-input-rac-wz1EyP5b.js → dext-rating-input-rac-Bdtbwo1W.js} +1 -1
  42. package/dist/component/{dext-tags-rac-BY4Rf2BP.js → dext-tags-rac-DT4_lRM0.js} +4 -4
  43. package/dist/component/{dext-text-area-rac-DRJzlsq8.js → dext-text-area-rac-BgMlIgik.js} +1 -1
  44. package/dist/component/{dext-text-input-rac-BGcRNNAi.js → dext-text-input-rac-DDc6-lsN.js} +1 -1
  45. package/dist/component/{dext-url-input-rac-CRAIm8yp.js → dext-url-input-rac-CrOT7XQf.js} +1 -1
  46. package/dist/component/{donation-rac-BlTfOIlE.js → donation-rac-CORUAfww.js} +74 -74
  47. package/dist/component/{dropdown-field-headless-DhzRAMcM.js → dropdown-field-headless-B-82vlHV.js} +10 -10
  48. package/dist/component/{dropdown-field-rac-DXyY5we-.js → dropdown-field-rac-AYGyhYSH.js} +3 -3
  49. package/dist/component/{dropdown-rac-C6YM6qxm.js → dropdown-rac-g-zqV-y4.js} +1 -1
  50. package/dist/component/{ecom-address-rac-CAdr7wya.js → ecom-address-rac-BQqh4QrW.js} +1 -1
  51. package/dist/component/{ecom-subscription-checkbox-rac-Z2VMuCbt.js → ecom-subscription-checkbox-rac-Cf7Ou6Om.js} +2 -2
  52. package/dist/component/{email-input-field-rac-DpkfunVK.js → email-input-field-rac-BFrfF6TW.js} +47 -47
  53. package/dist/component/{events-repeater-rac-CuJkdrPo.js → events-repeater-rac-CNifjThM.js} +8 -8
  54. package/dist/component/{events-rsvp-rac-BKWlSeQ9.js → events-rsvp-rac-CnW7CNdo.js} +10 -10
  55. package/dist/component/{field-error-headless-tsg9FQ-_.js → field-error-headless-BLgaEh1d.js} +11 -11
  56. package/dist/component/{field-label-headless-CB8dEat8.js → field-label-headless-C8NbnF9M.js} +4 -4
  57. package/dist/component/file-upload-rac-Yk44koqY.js +561 -0
  58. package/dist/component/{fixed-payment-rac-CuIQEeHh.js → fixed-payment-rac-r_OUP_KD.js} +15 -15
  59. package/dist/component/{form-0jt4L5xo.js → form-DC8xFBa_.js} +6178 -5729
  60. package/dist/component/form.css +1 -1
  61. package/dist/component/form.js +3 -3
  62. package/dist/component/{header-field-rac-CWVGzxKb.js → header-field-rac-6NOymbBc.js} +4 -4
  63. package/dist/component/{header-rac-D6KsV-ko.js → header-rac-DzK8Cg5s.js} +1 -1
  64. package/dist/component/{image-choice-rac-CUCyVS8c.js → image-choice-rac-CcCInqrr.js} +9 -9
  65. package/dist/component/{index-iOqQidgV.js → index-B_72TOzS.js} +2 -2
  66. package/dist/component/{index-TJSnVtCO.js → index-CGbawBGb.js} +43 -43
  67. package/dist/component/{isObjectLike-DQbx8r1c.js → isObjectLike-BziKAUTi.js} +1 -1
  68. package/dist/component/{multiline-address-field-rac-DtZ1NTfD.js → multiline-address-field-rac-CJw6HvHY.js} +78 -78
  69. package/dist/component/{multiline-address-rac-ub-_XzHU.js → multiline-address-rac-B_GR1nkJ.js} +1 -1
  70. package/dist/component/{number-input-field-rac-DLItn4DK.js → number-input-field-rac-CXFmpNWL.js} +13 -13
  71. package/dist/component/{number-input-rac-UuxJzqEx.js → number-input-rac-sr4Dhnxa.js} +1 -1
  72. package/dist/component/{password-rac-Di6q96Rn.js → password-rac-BwBEPYo3.js} +15 -15
  73. package/dist/component/{payment-input-rac-CG6c4-Ge.js → payment-input-rac-BcLSkgtK.js} +44 -44
  74. package/dist/component/{phone-input-field-rac-D4JphCuT.js → phone-input-field-rac-4kp5xRJZ.js} +50 -50
  75. package/dist/component/{phone-rac-_vDw2usa.js → phone-rac-B_QYTg28.js} +1 -1
  76. package/dist/component/{product-list-rac-CgxRlj1f.js → product-list-rac-C7YDHPj_.js} +50 -50
  77. package/dist/component/{quiz-radio-group-rac-bi26aGxN.js → quiz-radio-group-rac-Be1v1PyS.js} +1 -1
  78. package/dist/component/{radio-button-module-classes-DDJq2ESf.js → radio-button-module-classes-k9DhZ1Fd.js} +14 -14
  79. package/dist/component/{radio-group-field-rac-D1aMVO6l.js → radio-group-field-rac-BDEAYQH5.js} +6 -6
  80. package/dist/component/{radio-group-rac-HKC85M6t.js → radio-group-rac-DcmSrcGy.js} +1 -1
  81. package/dist/component/{rating-input-field-rac-CpRehxFB.js → rating-input-field-rac-CcO3-3O3.js} +20 -20
  82. package/dist/component/{rating-input-rac-BMuCZ3oj.js → rating-input-rac-wl8G35Xv.js} +1 -1
  83. package/dist/component/{rich-content-rac.module-mZ6xoAOd.js → rich-content-rac.module-CzZ6x_Yf.js} +1 -1
  84. package/dist/component/{rich-text-field-rac-CUK8V8Kf.js → rich-text-field-rac-B4l_YgG7.js} +4 -4
  85. package/dist/component/{rich-text-rac-B-7sR2FJ.js → rich-text-rac-BlW4v4gg.js} +1 -1
  86. package/dist/component/{service-dropdown-rac-1DDNT5bn.js → service-dropdown-rac-CJTrm0iL.js} +33 -33
  87. package/dist/component/{services-multi-choice-rac-CB-6dwxz.js → services-multi-choice-rac-BkiL2Pct.js} +13 -13
  88. package/dist/component/{signature-rac-7XBci6P2.js → signature-rac-_fTng53p.js} +133 -133
  89. package/dist/component/{submit-button-rac-B1-Mk8Gg.js → submit-button-rac-EmqyRMuE.js} +17 -17
  90. package/dist/component/{tags-field-rac-CQ9Y7mq-.js → tags-field-rac-CTlZZLdv.js} +32 -32
  91. package/dist/component/{tags-rac-Visic-Ml.js → tags-rac-xd-CpByf.js} +1 -1
  92. package/dist/component/{text-area-field-rac-C8fP1g-w.js → text-area-field-rac-Dap_aF4j.js} +14 -14
  93. package/dist/component/{text-area-rac-B6yZxzxm.js → text-area-rac-rKSZi3gu.js} +1 -1
  94. package/dist/component/{text-input-field-rac-CNjbOxD1.js → text-input-field-rac-GBsaUY0A.js} +5 -5
  95. package/dist/component/{text-input-headless-Bm8PJGep.js → text-input-headless-SHtvSa6y.js} +3 -3
  96. package/dist/component/{text-input-rac-BEPC1Z-4.js → text-input-rac-v4R17Vxm.js} +1 -1
  97. package/dist/component/{time-input-rac-3m6C_Jp5.js → time-input-rac-DgnhZSjV.js} +27 -27
  98. package/dist/component/{url-input-field-rac-CIk_6Lf6.js → url-input-field-rac-BuTadRMy.js} +19 -19
  99. package/dist/component/{url-input-rac-DyVoygXH.js → url-input-rac-BpVSwqpz.js} +1 -1
  100. package/dist/component/{use-dropdown-option-class-name-McG3ayOT.js → use-dropdown-option-class-name-Cwfh_4oi.js} +2 -2
  101. package/dist/component/{use-element-state-class-name-B9MBWX44.js → use-element-state-class-name-BF7I_Ju7.js} +1 -1
  102. package/dist/component/{use-is-forced-open-dropdown-r5G_sZsO.js → use-is-forced-open-dropdown-BMuhxge2.js} +8 -8
  103. package/dist/component/{use-service-options-base-hcbkvhpw.js → use-service-options-base-DfyQZjmw.js} +1 -1
  104. package/dist/component/{use-text-input-class-name-SnurFqAr.js → use-text-input-class-name-ixt7gTGg.js} +2 -2
  105. package/dist/form.d.ts +18 -0
  106. package/package.json +3 -3
  107. package/dist/component/file-upload-rac-ZdgYt646.js +0 -483
@@ -1,6 +1,6 @@
1
1
  import { useContext as T, useMemo as p } from "react";
2
- import { a$ as u, ac as O, aZ as a, F as n } from "./form-0jt4L5xo.js";
3
- const _ = [
2
+ import { b3 as u, ag as O, b1 as _, F as n } from "./form-DC8xFBa_.js";
3
+ const a = [
4
4
  n.DROPDOWN,
5
5
  n.DEXT_DROPDOWN,
6
6
  n.SERVICES_DROPDOWN,
@@ -10,24 +10,24 @@ const _ = [
10
10
  n.DEXT_DATE_TIME_INPUT,
11
11
  n.DATE_PICKER,
12
12
  n.DEXT_DATE_PICKER
13
- ], c = [
13
+ ], d = [
14
14
  n.PHONE,
15
15
  n.CONTACTS_PHONE,
16
16
  n.BOOKINGS_PHONE,
17
17
  n.DEXT_PHONE
18
- ], d = [
18
+ ], I = [
19
19
  n.MULTILINE_ADDRESS,
20
20
  n.BOOKINGS_ADDRESS,
21
21
  n.ECOM_ADDRESS
22
- ], I = ({ properties: o }) => {
22
+ ], P = ({ properties: o }) => {
23
23
  var t, e, s, r;
24
24
  return ((r = (s = (e = (t = o.validation) == null ? void 0 : t.string) == null ? void 0 : e.phoneOptions) == null ? void 0 : s.allowedCountryCodes) == null ? void 0 : r.length) !== 1;
25
- }, P = ({ properties: o }) => {
25
+ }, S = ({ properties: o }) => {
26
26
  var t, e;
27
27
  return ((e = (t = o.fieldSettings) == null ? void 0 : t.country) == null ? void 0 : e.show) !== !1;
28
- }, S = (o, t) => c.includes(o.fieldType) ? !t && I(o) : d.includes(o.fieldType) ? P(o) : _.includes(o.fieldType), l = (o, t) => S(o, t) && !o.properties.hidden && !o.properties.disabled && !o.properties.readOnly, N = (o, t) => o.layout.row - t.layout.row || o.layout.column - t.layout.column, w = (o) => {
28
+ }, c = (o, t) => d.includes(o.fieldType) ? !t && P(o) : I.includes(o.fieldType) ? S(o) : a.includes(o.fieldType), l = (o, t) => c(o, t) && !o.properties.hidden && !o.properties.disabled && !o.properties.readOnly, N = (o, t) => o.layout.row - t.layout.row || o.layout.column - t.layout.column, w = (o) => {
29
29
  var E;
30
- const t = ((E = u().dropdown) == null ? void 0 : E.open) === !0, e = T(O), { isMobile: s = !1 } = a(), r = p(() => {
30
+ const t = ((E = u().dropdown) == null ? void 0 : E.open) === !0, e = T(O), { isMobile: s = !1 } = _(), r = p(() => {
31
31
  var D;
32
32
  return e && !e.parentId ? (D = e.fields.filter((i) => l(i, s)).sort(N)[0]) == null ? void 0 : D.id : void 0;
33
33
  }, [
@@ -1,5 +1,5 @@
1
1
  import { useState as o, useCallback as y, useEffect as m, useMemo as D } from "react";
2
- import { b4 as v } from "./form-0jt4L5xo.js";
2
+ import { b8 as v } from "./form-DC8xFBa_.js";
3
3
  const k = (I) => {
4
4
  const { fieldType: L, isEditor: t = !1, postProcessOptions: i, customFetchLogic: a, onInitialDataLoaded: n } = I, [O, h] = o(!1), [g, p] = o([]), [E, u] = o(!1), [c, f] = o(!1), s = v(L), r = y((e) => {
5
5
  let d = e.map((l) => ({
@@ -1,6 +1,6 @@
1
- import { b5 as r, Y as i } from "./form-0jt4L5xo.js";
1
+ import { b9 as r, _ as i } from "./form-DC8xFBa_.js";
2
2
  import { s } from "./field-rac.module-B4l_0KRU.js";
3
- import { u as m } from "./use-element-state-class-name-B9MBWX44.js";
3
+ import { u as m } from "./use-element-state-class-name-BF7I_Ju7.js";
4
4
  const d = (...e) => {
5
5
  const { disabled: a, readOnly: t } = r(), o = m({
6
6
  globalClasses: i,
package/dist/form.d.ts CHANGED
@@ -7039,6 +7039,24 @@ declare const defaultProps: {
7039
7039
  };
7040
7040
  };
7041
7041
  };
7042
+ readonly dropZone: {
7043
+ readonly elementProps: {
7044
+ readonly uploadButton: {
7045
+ readonly elementProps: {
7046
+ readonly icon: {
7047
+ readonly svg: {
7048
+ readonly uri: '';
7049
+ readonly viewBox: '0 0 200 200';
7050
+ readonly contentBox: '0 0 200 200';
7051
+ readonly colors: {};
7052
+ readonly contentType: 'shape';
7053
+ readonly svgContent: '<svg data-bbox="20 20 160 160" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg" data-type="shape"><g><path d="M104.5 20h-9v75.5H20v9h75.5V180h9v-75.5H180v-9h-75.5V20z" fill-rule="evenodd" clip-rule="evenodd"/></g></svg>';
7054
+ };
7055
+ };
7056
+ };
7057
+ };
7058
+ };
7059
+ };
7042
7060
  };
7043
7061
  };
7044
7062
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/form-elements",
3
- "version": "1.108.0",
3
+ "version": "1.110.0",
4
4
  "description": "The Wix Forms rendering element for Builder apps, loaded at runtime as @wix/form-elements/Form",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -49,9 +49,9 @@
49
49
  "@wix/bookings": "^1.0.1722",
50
50
  "@wix/essentials": "^1.0.15",
51
51
  "@wix/fed-cli-i18next": "^1.7.1",
52
- "@wix/form-templates": "^1.0.21",
53
52
  "@wix/forms": "^1.0.533",
54
53
  "@wix/image-kit": "^1.126.0",
54
+ "@wix/metro-runtime": "^1.2127.0",
55
55
  "@wix/react-use-promise-polyfill": "^1.2.0",
56
56
  "@wix/ricos": "^11.20.0",
57
57
  "@wix/sdk-runtime": "^1.0.26",
@@ -156,5 +156,5 @@
156
156
  ]
157
157
  }
158
158
  },
159
- "falconPackageHash": "2ff7f14ac81ec0354d8104e138a9f9f5f79cb50513bbbb3d8d4b3f70"
159
+ "falconPackageHash": "d6bd7ca711d56150ee0cab4c01b7dba4d355c227ddbb2bdabe44aca7"
160
160
  }
@@ -1,483 +0,0 @@
1
- import t, { useState as Q, useRef as V, useMemo as oe, useEffect as se, useCallback as P, createContext as pe, useContext as fe } from "react";
2
- import { RicosViewer as Ee } from "@wix/ricos/viewer";
3
- import B from "classnames";
4
- import { b1 as Fe, bf as ie, ba as ge, a9 as he, bd as be, a2 as re, be as xe, b2 as ce, b5 as j, b7 as Ce, H as ne, T as Le, _ as De, p as le, u as ae } from "./form-0jt4L5xo.js";
5
- import { E as Ne } from "./error-icon-hZxQ6DEy.js";
6
- import { s as I } from "./field-rac.module-B4l_0KRU.js";
7
- import { f as h, a as z } from "./find-child-C60k4CxG.js";
8
- import { b as ve, a as ye, D as _e, E as Te } from "./field-error-headless-tsg9FQ-_.js";
9
- import { L as Be } from "./field-label-headless-CB8dEat8.js";
10
- import { DropZone as Re, Text as Se, FileTrigger as Me, Button as de, ProgressBar as Ie } from "react-aria-components";
11
- const we = {
12
- Video: "video/*",
13
- Image: "image/*",
14
- Audio: "audio/*",
15
- Document: ".ai, .cdr, .csv, .doc, .docb, .docx, .dot, .dotx, .dwg, .eps, .epub, .fla, .gpx, .ical, .icalendar, .ics, .ifb, .indd, .ipynb, .key, .kml, .kmz, .mobi, .mtf, .mtx, .numbers, .odg, .odp, .ods, .odt, .otp, .ots, .ott, .oxps, .pages, .pdf, .pdn, .pkg, .pot, .potx, .pps, .ppsx, .ppt, .pptx, .psd, .pub, .rtf, .sldx, .txt, .json, .vcf, .xcf, .xls, .xlsx, .xlt, .xltx, .xlw, .xps,.xml,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel",
16
- Archive: ".zip, .rar, .tar, .tar.gz, .gz, .gzip, .jar, .7z, .fgz, .webarchive",
17
- Model3D: ".gltf, .glb"
18
- }, Ae = (e) => {
19
- const { actions: r, formId: n } = Fe();
20
- return async (o, i, d) => {
21
- if (!(r != null && r.uploadFile) || !o.length)
22
- return r != null && r.uploadFile || console.error("No uploadFile action"), o.length || console.error("No files to upload"), [];
23
- const b = o.map(({ file: l }) => r.uploadFile({
24
- file: l,
25
- formId: n,
26
- uploadTarget: e
27
- }).then((s) => {
28
- const { id: x, displayName: m, url: c, isPrivate: N } = s, v = {
29
- fileId: x,
30
- displayName: m || l.name,
31
- url: N ? void 0 : c,
32
- fileType: l.type || "application/octet-stream"
33
- };
34
- return i({
35
- file: l,
36
- uploadedFile: v
37
- }), v;
38
- }).catch((s) => {
39
- d(s, l);
40
- }));
41
- return (await Promise.all(b)).filter((l) => l !== void 0);
42
- };
43
- };
44
- function Ze({ valueSliderLimit: e, value: r, explanationText: n, target: o, onChange: i, uploadFileFormats: d, onBlur: b, onFilesCleared: D }) {
45
- const [l, s] = Q(Ue(r)), [x, m] = Q(r || []), [c, N] = Q(), v = Ae(o), { t: E } = ie(), U = ge().includes(he.BUTTONS_HOVER), { setFormStatus: y } = be(), S = V(!1), _ = V(i);
46
- _.current = i;
47
- const C = oe(() => l.some((u) => u.state === "uploading"), [
48
- l
49
- ]);
50
- se(() => {
51
- S.current !== C && (S.current = C, y(o, C ? re.BUSY : re.READY));
52
- }, [
53
- C,
54
- y,
55
- o
56
- ]);
57
- const k = P(() => {
58
- if (!l.length)
59
- return n;
60
- const F = l.filter((u) => u.state === "uploading").length;
61
- if (F) {
62
- const u = l.filter((p) => p.state === "uploaded" && p.file.size > 0).length, g = u / (u + F);
63
- return E("form.file-upload.uploading", {
64
- count: Math.round(g * 100)
65
- });
66
- }
67
- return n || E("form.file-upload.explanation-text", {
68
- count: l.length
69
- });
70
- }, [
71
- l,
72
- n,
73
- E
74
- ]), M = P(async (F) => {
75
- await v(F, ({ file: u, uploadedFile: g }) => {
76
- s((p) => p.map((f) => f.file === u ? {
77
- file: u,
78
- state: "uploaded"
79
- } : f)), m((p) => {
80
- var L;
81
- const f = [
82
- ...p
83
- ].concat(g);
84
- return (L = _.current) == null || L.call(_, f), f;
85
- });
86
- }, (u, g) => {
87
- s((p) => p.map((f) => f.file === g ? {
88
- file: g,
89
- state: "error",
90
- errorMessage: E("form.file-upload.error.upload-failed")
91
- } : f));
92
- });
93
- }, [
94
- v,
95
- E
96
- ]), O = async (F) => {
97
- if (c && N(void 0), F) {
98
- if (l.length + F.length > e) {
99
- N(E("form.file-upload.error.upload-limit", {
100
- limit: e
101
- }));
102
- return;
103
- }
104
- const p = Array.from(F).reduce((f, L) => (l.some((W) => W.file.name === L.name) || f.push({
105
- file: L,
106
- state: "uploading"
107
- }), f), []);
108
- s([
109
- ...l,
110
- ...p
111
- ]), await M(p);
112
- }
113
- }, q = (F) => {
114
- const u = l[F];
115
- if (x && i && u.state !== "error") {
116
- const g = x.filter((f) => f.displayName !== u.file.name);
117
- i(g), m(g);
118
- const p = l.filter((f) => f.file.name !== u.file.name);
119
- s(p), p.length === 0 && D();
120
- } else {
121
- const g = l.filter((p) => p !== u);
122
- s(g), g.length === 0 && D();
123
- }
124
- }, $ = () => {
125
- c && N(void 0), b();
126
- }, K = d.map((F) => we[F]).join(), H = P(() => {
127
- s([]), m([]);
128
- }, []);
129
- return xe(H), {
130
- files: l,
131
- limitError: c,
132
- hover: U,
133
- getExplanationText: k,
134
- handleChange: O,
135
- handleDelete: q,
136
- accept: K,
137
- handleBlur: $
138
- };
139
- }
140
- function Ue(e = []) {
141
- const r = e || [];
142
- try {
143
- return r.map((n) => ({
144
- file: new File([
145
- new Int8Array(0)
146
- ], n.displayName, {
147
- type: n.fileType
148
- }),
149
- state: "uploaded"
150
- }));
151
- } catch (n) {
152
- console.error(n);
153
- }
154
- return [];
155
- }
156
- const me = /* @__PURE__ */ pe(void 0);
157
- function Z() {
158
- const e = fe(me);
159
- if (typeof e > "u")
160
- throw new Error("FileUpload components must be used within FileUpload");
161
- return e;
162
- }
163
- const A = ({ children: e, className: r }) => {
164
- const { ariaDescribedBy: n } = ce(), { disabled: o, hasError: i } = j(), { handleFileChange: d } = Z(), b = h(e, A.Title), D = h(e, A.Subtitle), l = h(e, A.Button);
165
- return /* @__PURE__ */ t.createElement(Re, {
166
- "aria-describedby": n,
167
- className: r,
168
- "data-invalid": i,
169
- isDisabled: o,
170
- onDrop: async (s) => {
171
- const x = [];
172
- for (const m of s.items)
173
- if (m.kind === "file") {
174
- const c = await m.getFile();
175
- c && x.push(c);
176
- }
177
- if (x.length > 0) {
178
- const m = new DataTransfer();
179
- x.forEach((c) => m.items.add(c)), d(m.files);
180
- }
181
- }
182
- }, /* @__PURE__ */ t.createElement(Se, {
183
- slot: "label"
184
- }, b, D), l);
185
- }, ke = ({ className: e, children: r }) => {
186
- const { limitReached: n } = Z();
187
- return /* @__PURE__ */ t.createElement("p", {
188
- className: e
189
- }, r({
190
- limitReached: n
191
- }));
192
- }, Oe = ({ className: e, children: r }) => {
193
- const { limitReached: n } = Z();
194
- return /* @__PURE__ */ t.createElement("p", {
195
- className: e
196
- }, r({
197
- limitReached: n
198
- }));
199
- }, J = ({ className: e, children: r, "aria-roledescription": n }) => {
200
- const { ariaDescribedBy: o, inputId: i, labelId: d, errorId: b } = ce(), { disabled: D, required: l, onFocus: s, hasError: x, errorMessage: m } = j(), { handleFileChange: c, accept: N, multiple: v, buttonRef: E, handleBlur: R, limitError: U, files: y } = Z(), S = (y == null ? void 0 : y.some((C) => C.errorMessage)) ?? !1, _ = !!(x || m || U || S);
201
- return /* @__PURE__ */ t.createElement(Me, {
202
- acceptedFileTypes: N ? N.split(",") : void 0,
203
- allowsMultiple: v,
204
- onSelect: (C) => {
205
- if (C) {
206
- const k = Array.from(C), M = new DataTransfer();
207
- k.forEach((O) => M.items.add(O)), c(M.files);
208
- }
209
- }
210
- }, /* @__PURE__ */ t.createElement(de, {
211
- ref: E,
212
- id: i,
213
- "aria-labelledby": d,
214
- "aria-describedby": [
215
- o,
216
- b
217
- ].filter(Boolean).join(" "),
218
- render: (C) => /* @__PURE__ */ t.createElement("button", {
219
- ...C,
220
- "aria-roledescription": n,
221
- "aria-invalid": _ || void 0,
222
- "aria-required": l
223
- }),
224
- isDisabled: D,
225
- className: e,
226
- onFocus: s,
227
- onBlur: R
228
- }, r));
229
- }, Pe = ({ className: e }) => {
230
- const { buttonText: r } = j();
231
- return /* @__PURE__ */ t.createElement("span", {
232
- className: e
233
- }, r);
234
- };
235
- J.Text = Pe;
236
- A.Title = ke;
237
- A.Subtitle = Oe;
238
- A.Button = J;
239
- const T = ({ children: e, className: r, ...n }) => {
240
- const { file: o, index: i } = n, d = o.file.name, b = h(e, T.Name), D = h(e, T.Remove), l = h(e, T.Spinner), s = h(e, T.Error);
241
- return /* @__PURE__ */ t.createElement("div", {
242
- className: r
243
- }, z(b, {
244
- fileName: d
245
- }), o.state === "uploading" ? l : z(D, {
246
- index: i,
247
- fileName: d
248
- }), o.errorMessage && z(s, {
249
- errorMessage: o.errorMessage
250
- }));
251
- }, ze = ({ className: e, ...r }) => {
252
- const { fileName: n } = r;
253
- return /* @__PURE__ */ t.createElement("span", {
254
- className: e
255
- }, n);
256
- }, Ve = ({ className: e, "aria-label": r, children: n, ...o }) => {
257
- const { fileName: i, index: d } = o, { disabled: b } = j(), { handleDelete: D, fileRemoveButtonRefs: l } = Z(), s = V(null);
258
- se(() => {
259
- const m = l.current, c = i;
260
- return m[c] = s, () => {
261
- m[c] === s && (m[c] = void 0);
262
- };
263
- }, [
264
- i,
265
- l
266
- ]);
267
- const x = () => {
268
- D(d);
269
- };
270
- return /* @__PURE__ */ t.createElement(de, {
271
- ref: s,
272
- "aria-disabled": b,
273
- "aria-label": r,
274
- "aria-description": i,
275
- onClick: x,
276
- className: e,
277
- isDisabled: b
278
- }, n);
279
- }, ue = ({ className: e, children: r, ...n }) => {
280
- const { errorMessage: o } = n;
281
- return o ? /* @__PURE__ */ t.createElement(ye, {
282
- value: o
283
- }, /* @__PURE__ */ t.createElement("div", {
284
- className: e,
285
- role: "alert"
286
- }, r)) : null;
287
- }, je = ({ className: e, "aria-label": r, children: n }) => /* @__PURE__ */ t.createElement(Ie, {
288
- "aria-label": r,
289
- className: e,
290
- isIndeterminate: !0
291
- }, n);
292
- T.Name = ze;
293
- T.Remove = Ve;
294
- T.Spinner = je;
295
- T.Error = ue;
296
- ue.Text = ve;
297
- const X = ({ children: e, className: r }) => {
298
- const { files: n } = Z(), o = h(e, X.File);
299
- return !n || n.length === 0 ? null : /* @__PURE__ */ t.createElement("div", {
300
- className: r
301
- }, n.map((i, d) => z(o, {
302
- key: i.file.name || d,
303
- file: i,
304
- index: d
305
- })));
306
- };
307
- X.File = T;
308
- const G = (e) => e.file.name, a = ({ children: e }) => {
309
- const { id: r, value: n, onChange: o, uploadFileFormats: i, valueSliderLimit: d, target: b, explanationText: D, onBlur: l, hasError: s, errorMessage: x, FieldLayout: m } = j(), c = V(null), N = V({}), v = P(() => {
310
- var L;
311
- (L = c.current) == null || L.focus();
312
- }, []), { files: E, limitError: R, hover: U, getExplanationText: y, handleBlur: S, handleChange: _, handleDelete: C, accept: k } = Ze({
313
- valueSliderLimit: d,
314
- value: n,
315
- explanationText: D,
316
- target: b,
317
- onChange: o,
318
- uploadFileFormats: i,
319
- onBlur: l,
320
- onFilesCleared: v
321
- }), M = P((L) => {
322
- var te;
323
- const ee = E[L], W = G(ee);
324
- E.length > 1 && ((te = (E.filter((Y) => G(Y) !== W).map((Y) => N.current[G(Y)]).find(Boolean) ?? c).current) == null || te.focus()), C(L);
325
- }, [
326
- C,
327
- E
328
- ]), O = d > 1, q = E.length >= d, $ = oe(() => ({
329
- handleFileChange: _,
330
- handleBlur: S,
331
- handleDelete: M,
332
- files: E,
333
- accept: k,
334
- limitReached: q,
335
- multiple: O,
336
- getExplanationText: y,
337
- hover: U,
338
- limitError: R,
339
- buttonRef: c,
340
- fileRemoveButtonRefs: N
341
- }), [
342
- _,
343
- S,
344
- M,
345
- E,
346
- k,
347
- q,
348
- O,
349
- y,
350
- U,
351
- R
352
- ]), K = h(e, a.Label), H = h(e, a.DropZone), F = h(e, a.Button), u = h(e, a.Explanation), g = h(e, a.Files), p = h(e, a.Description), f = h(e, a.Error);
353
- return Ce(() => {
354
- var L;
355
- (L = c.current) == null || L.focus();
356
- }, r), /* @__PURE__ */ t.createElement(me.Provider, {
357
- value: $
358
- }, /* @__PURE__ */ t.createElement(m, {
359
- fieldId: r,
360
- renderLabel: () => K,
361
- renderInput: () => H ?? F,
362
- renderDescription: () => /* @__PURE__ */ t.createElement(t.Fragment, null, z(f, {
363
- hasError: !!(s || R),
364
- errorMessage: R ?? x
365
- }), p, u, g)
366
- }));
367
- }, qe = ({ className: e }) => {
368
- const { getExplanationText: r } = Z(), n = r();
369
- return n ? /* @__PURE__ */ t.createElement("p", {
370
- className: e
371
- }, n) : null;
372
- };
373
- a.Label = Be;
374
- a.DropZone = A;
375
- a.Button = J;
376
- a.Explanation = qe;
377
- a.Files = X;
378
- a.Description = _e;
379
- a.Error = Te;
380
- const $e = (e) => /* @__PURE__ */ t.createElement("svg", {
381
- viewBox: "0 0 24 24",
382
- width: 24,
383
- height: 24,
384
- fill: "currentColor",
385
- "aria-hidden": "true",
386
- ...e
387
- }, /* @__PURE__ */ t.createElement("path", {
388
- d: "M12 12 12 6 11 6 11 12 5 12 5 13 11 13 11 19 12 19 12 13 18 13 18 12z"
389
- })), Ke = (e) => /* @__PURE__ */ t.createElement("svg", {
390
- viewBox: "0 0 24 24",
391
- width: 24,
392
- height: 24,
393
- fill: "currentColor",
394
- "aria-hidden": "true",
395
- ...e
396
- }, /* @__PURE__ */ t.createElement("path", {
397
- d: "M12,21 C7.02943725,21 3,16.9705627 3,12 C3,7.02943725 7.02943725,3 12,3 C16.9705627,3 21,7.02943725 21,12 C21,16.9705627 16.9705627,21 12,21 Z M12,20 C16.418278,20 20,16.418278 20,12 C20,7.581722 16.418278,4 12,4 C7.581722,4 4,7.581722 4,12 C4,16.418278 7.581722,20 12,20 Z M12.7287834,7.27532214 C12.9203342,7.46687299 13.0199347,7.73174979 13.0020527,8.00205275 L13.0020527,12.0020527 C13.0199347,12.2723557 12.9203342,12.5372325 12.7287834,12.7287834 C12.5372325,12.9203342 12.2723557,13.0199347 12.0020527,13.0020527 C11.7317498,13.0199347 11.466873,12.9203342 11.2753221,12.7287834 C11.0837713,12.5372325 10.9841708,12.2723557 11.0020527,12.0020527 L11.0020527,8.00205275 C10.9841708,7.73174979 11.0837713,7.46687299 11.2753221,7.27532214 C11.466873,7.08377129 11.7317498,6.98417081 12.0020527,7.00205275 C12.2723557,6.98417081 12.5372325,7.08377129 12.7287834,7.27532214 Z M12.7287834,15.2753221 C12.9203342,15.466873 13.0199347,15.7317498 13.0020527,16.0020527 C13.0199347,16.2723557 12.9203342,16.5372325 12.7287834,16.7287834 C12.5372325,16.9203342 12.2723557,17.0199347 12.0020527,17.0020527 C11.7317498,17.0199347 11.466873,16.9203342 11.2753221,16.7287834 C11.0837713,16.5372325 10.9841708,16.2723557 11.0020527,16.0020527 C10.9841708,15.7317498 11.0837713,15.466873 11.2753221,15.2753221 C11.466873,15.0837713 11.7317498,14.9841708 12.0020527,15.0020527 C12.2723557,14.9841708 12.5372325,15.0837713 12.7287834,15.2753221 Z"
398
- })), He = (e) => /* @__PURE__ */ t.createElement("svg", {
399
- viewBox: "0 0 24 24",
400
- width: 24,
401
- height: 24,
402
- fill: "currentColor",
403
- "aria-hidden": "true",
404
- ...e
405
- }, /* @__PURE__ */ t.createElement("path", {
406
- d: "M17,17 C17,18.6568542 15.6568542,20 14,20 L9,20 C7.34314575,20 6,18.6568542 6,17 L6,7 L5,7 L5,6 L18,6 L18,7 L17,7 L17,17 Z M9,9 L10,9 L10,16 L9,16 L9,9 Z M11,9 L12,9 L12,16 L11,16 L11,9 Z M13,9 L14,9 L14,16 L13,16 L13,9 Z M7,17 C7,18.1045695 7.8954305,19 9,19 L14,19 C15.1045695,19 16,18.1045695 16,17 L16,7 L7,7 L7,17 Z M13,6 L13,5 L10,5 L10,6 L9,6 L9,5 C9,4.44771525 9.44771525,4 10,4 L13,4 C13.5522847,4 14,4.44771525 14,5 L14,6 L13,6 Z"
407
- })), We = () => {
408
- const r = "calc(50% - 2px)";
409
- return /* @__PURE__ */ t.createElement("svg", {
410
- fill: "none",
411
- width: "100%",
412
- height: "100%",
413
- viewBox: "0 0 32 32"
414
- }, /* @__PURE__ */ t.createElement("circle", {
415
- cx: "50%",
416
- cy: "50%",
417
- r
418
- }), /* @__PURE__ */ t.createElement("circle", {
419
- cx: "50%",
420
- cy: "50%",
421
- r,
422
- // Normalize the path length to 100 so we can easily set stroke-dashoffset to a fixed arc.
423
- pathLength: "100",
424
- // Add extra gap between dashes so the arc reads correctly in Chrome.
425
- strokeDasharray: "100 200",
426
- strokeDashoffset: 75,
427
- strokeLinecap: "round",
428
- style: {
429
- rotate: "-90deg",
430
- transformOrigin: "center center"
431
- }
432
- }, /* @__PURE__ */ t.createElement("animateTransform", {
433
- attributeName: "transform",
434
- type: "rotate",
435
- dur: "0.75s",
436
- values: "0;360",
437
- repeatCount: "indefinite"
438
- })));
439
- }, Ye = "_explanation_16me0_1", Qe = "_files_16me0_5", Ge = "_file_16me0_5", Je = "_fileName_16me0_24", Xe = "_removeButton_16me0_32", et = "_spinner_16me0_72", tt = "_fileError_16me0_88", w = {
440
- explanation: Ye,
441
- files: Qe,
442
- file: Ge,
443
- fileName: Je,
444
- removeButton: Xe,
445
- spinner: et,
446
- fileError: tt
447
- }, rt = ({ content: e, locale: r }) => /* @__PURE__ */ t.createElement(Ee, {
448
- content: e,
449
- locale: r
450
- }), nt = () => {
451
- const { t: e } = ie();
452
- return /* @__PURE__ */ t.createElement(a, null, /* @__PURE__ */ t.createElement(a.Label, {
453
- className: B(ne, I.label)
454
- }, /* @__PURE__ */ t.createElement(a.Label.Required, {
455
- className: B(Le, I.requiredMark)
456
- })), /* @__PURE__ */ t.createElement(a.Button, {
457
- className: B(De, I.uploadButton),
458
- "aria-roledescription": e("file-upload.aria-roledescription")
459
- }, /* @__PURE__ */ t.createElement($e, null), /* @__PURE__ */ t.createElement(a.Button.Text, null)), /* @__PURE__ */ t.createElement(a.Explanation, {
460
- className: B(le, I.description, w.explanation)
461
- }), /* @__PURE__ */ t.createElement(a.Files, {
462
- className: B(ne, w.files)
463
- }, /* @__PURE__ */ t.createElement(a.Files.File, {
464
- className: w.file
465
- }, /* @__PURE__ */ t.createElement(a.Files.File.Name, {
466
- className: w.fileName
467
- }), /* @__PURE__ */ t.createElement(a.Files.File.Spinner, {
468
- className: w.spinner,
469
- "aria-label": e("file-upload.file.uploading-spinner.aria-label")
470
- }, /* @__PURE__ */ t.createElement(We, null)), /* @__PURE__ */ t.createElement(a.Files.File.Remove, {
471
- className: w.removeButton,
472
- "aria-label": e("file-upload.delete-file.aria-label")
473
- }, /* @__PURE__ */ t.createElement(He, null)), /* @__PURE__ */ t.createElement(a.Files.File.Error, {
474
- className: B(ae, I.error, w.fileError)
475
- }, /* @__PURE__ */ t.createElement(Ke, null), /* @__PURE__ */ t.createElement(a.Files.File.Error.Text, null)))), /* @__PURE__ */ t.createElement(a.Description, {
476
- className: B(le, I.description)
477
- }, rt), /* @__PURE__ */ t.createElement(a.Error, {
478
- className: B(ae, I.error)
479
- }, /* @__PURE__ */ t.createElement(Ne, null), /* @__PURE__ */ t.createElement(a.Error.Text, null)));
480
- }, Et = () => /* @__PURE__ */ t.createElement(nt, null);
481
- export {
482
- Et as FileUploadRAC
483
- };