@solvimon/solvimon-web 0.1.0-alpha.7 → 0.1.0-alpha.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.
Files changed (202) hide show
  1. package/dist/ApiStatus-CyNDp_op.mjs +9 -0
  2. package/dist/ApiStatus-oqvUEWJx.js +1 -0
  3. package/dist/BillingInformation.vue_vue_type_script_setup_true_lang-C-C0i6i6.js +1 -0
  4. package/dist/{BillingInformation.vue_vue_type_script_setup_true_lang-CupcH8TZ.mjs → BillingInformation.vue_vue_type_script_setup_true_lang-CT0Tjsnw.mjs} +2 -4
  5. package/dist/{ContentWithAsideLayout-Ct24RV-2.mjs → ContentWithAsideLayout-BTdixy3L.mjs} +2 -11
  6. package/dist/ContentWithAsideLayout-oAYVrLvL.js +1 -0
  7. package/dist/{CustomerPaymentMethods.vue_vue_type_script_setup_true_lang-DZJ0xukI.mjs → CustomerPaymentMethods.vue_vue_type_script_setup_true_lang-CK73bYUe.mjs} +2 -5
  8. package/dist/CustomerPaymentMethods.vue_vue_type_script_setup_true_lang-CLU7Yiyx.js +1 -0
  9. package/dist/InvoiceDetailsBlock.vue_vue_type_script_setup_true_lang-B_WLgBur.js +1 -0
  10. package/dist/{InvoiceDetailsBlock.vue_vue_type_script_setup_true_lang-DsrBsrtk.mjs → InvoiceDetailsBlock.vue_vue_type_script_setup_true_lang-Dt_Vb7Wz.mjs} +1 -2
  11. package/dist/PaymentHistoryBlock-DHM-3fh-.js +1 -0
  12. package/dist/PaymentHistoryBlock-YzJ6bxKr.mjs +4 -0
  13. package/dist/{PaymentHistoryBlock.vue_vue_type_script_setup_true_lang-BnKwmJ2s.mjs → PaymentHistoryBlock.vue_vue_type_script_setup_true_lang-D6Cr2Uga.mjs} +1 -5
  14. package/dist/PaymentHistoryBlock.vue_vue_type_script_setup_true_lang-DFw8lrDv.js +1 -0
  15. package/dist/PaymentIntegrationForm-Cl5ua8v8.js +1 -0
  16. package/dist/PaymentIntegrationForm-ID4QnvA3.mjs +4 -0
  17. package/dist/{PaymentIntegrationForm.vue_vue_type_script_setup_true_lang-BE1lWOk9.mjs → PaymentIntegrationForm.vue_vue_type_script_setup_true_lang-CVWPT3Ni.mjs} +32 -189
  18. package/dist/PaymentIntegrationForm.vue_vue_type_script_setup_true_lang-DifRn1ok.js +1 -0
  19. package/dist/PricingGroupContent.vue_vue_type_script_setup_true_lang-CKNMt-JH.js +1 -0
  20. package/dist/{PricingGroupContent.vue_vue_type_script_setup_true_lang-BbvDXvIS.mjs → PricingGroupContent.vue_vue_type_script_setup_true_lang-CzS32ZUt.mjs} +5 -31
  21. package/dist/{SubscriptionsList.vue_vue_type_script_setup_true_lang-DVhJy0t8.mjs → SubscriptionsList.vue_vue_type_script_setup_true_lang-BIxGqr9U.mjs} +4 -7
  22. package/dist/SubscriptionsList.vue_vue_type_script_setup_true_lang-CpEqDnO3.js +1 -0
  23. package/dist/adyenLoader-CEH4A2b2.js +1 -0
  24. package/dist/adyenLoader-gsbzSjYV.mjs +177 -0
  25. package/dist/component-C2Gc-wsE.js +1 -0
  26. package/dist/component-CM9g6tbD.mjs +804 -0
  27. package/dist/components/BillingInformation/BillingInformation.cjs.js +1 -1
  28. package/dist/components/BillingInformation/BillingInformation.es.js +3 -7
  29. package/dist/components/BillingInformationForm/BillingInformationForm.cjs.js +1 -1
  30. package/dist/components/BillingInformationForm/BillingInformationForm.es.js +9 -17
  31. package/dist/components/CustomerPaymentMethods/CustomerPaymentMethods.cjs.js +1 -1
  32. package/dist/components/CustomerPaymentMethods/CustomerPaymentMethods.es.js +3 -7
  33. package/dist/components/Invoice/Invoice.cjs.js +1 -1
  34. package/dist/components/Invoice/Invoice.es.js +42 -2659
  35. package/dist/components/InvoiceDetails/InvoiceDetails.cjs.js +1 -1
  36. package/dist/components/InvoiceDetails/InvoiceDetails.es.js +3 -7
  37. package/dist/components/InvoicesList/InvoicesList.cjs.js +1 -1
  38. package/dist/components/InvoicesList/InvoicesList.es.js +2 -6
  39. package/dist/components/PaymentHistory/PaymentHistory.cjs.js +1 -1
  40. package/dist/components/PaymentHistory/PaymentHistory.es.js +3 -7
  41. package/dist/components/PaymentMethodForm/PaymentMethodForm.cjs.js +1 -1
  42. package/dist/components/PaymentMethodForm/PaymentMethodForm.es.js +7 -33
  43. package/dist/components/SubscriptionSchedules/SubscriptionSchedules.cjs.js +1 -1
  44. package/dist/components/SubscriptionSchedules/SubscriptionSchedules.es.js +8 -4824
  45. package/dist/components/SubscriptionsList/SubscriptionsList.cjs.js +1 -1
  46. package/dist/components/SubscriptionsList/SubscriptionsList.es.js +4 -8
  47. package/dist/components/WalletBalances/WalletBalances.cjs.js +1 -1
  48. package/dist/components/WalletBalances/WalletBalances.es.js +3 -7
  49. package/dist/core/index.cjs.js +1 -1
  50. package/dist/core/index.es.js +1 -1
  51. package/dist/core/types.d.ts +2 -0
  52. package/dist/{customer-CcQR-JIm.js → customer-C_Hz_npf.js} +1 -1
  53. package/dist/{customer-CJrpbGX4.mjs → customer-TIi7iZFw.mjs} +1 -1
  54. package/dist/en-US-CBoPxQwX.mjs +199 -0
  55. package/dist/en-US-DJq-9dD8.js +1 -0
  56. package/dist/index-CzL1ZcGi.mjs +85 -0
  57. package/dist/index-DRdBmZ2-.js +1 -0
  58. package/dist/index.cjs.js +1 -1
  59. package/dist/index.d.ts +1 -0
  60. package/dist/index.es.js +4 -1
  61. package/dist/{invoices-CNK1Ushv.mjs → invoices-BuVOuTOm.mjs} +2 -15
  62. package/dist/invoices-DbvwXAsm.js +1 -0
  63. package/dist/nl-NL-BB7KbK-h.mjs +181 -0
  64. package/dist/nl-NL-CtU1Lg2F.js +1 -0
  65. package/dist/paymentMethods-B4AYGf0K.js +1 -0
  66. package/dist/{paymentMethods-C-ApE-G4.mjs → paymentMethods-Di32oJ39.mjs} +2 -2
  67. package/dist/{payments-CE9U7aKK.mjs → payments-C5fD1PXB.mjs} +1 -1
  68. package/dist/{payments-CLt0SExf.js → payments-DeutKq9x.js} +1 -1
  69. package/dist/{registry-B99ZnfEn.mjs → registry-BLwMl1bK.mjs} +6 -4
  70. package/dist/registry-CMSmkLcy.js +1 -0
  71. package/dist/screens/Checkout/Checkout.cjs.js +1 -1
  72. package/dist/screens/Checkout/Checkout.es.js +420 -2388
  73. package/dist/screens/CustomerOverview/CustomerOverview.cjs.js +1 -1
  74. package/dist/screens/CustomerOverview/CustomerOverview.es.js +13 -14
  75. package/dist/screens/PayInvoice/PayInvoice.ce.d.ts +3 -0
  76. package/dist/screens/PayInvoice/PayInvoice.cjs.js +1 -0
  77. package/dist/screens/PayInvoice/PayInvoice.es.js +456 -0
  78. package/dist/screens/UpgradeSubscription/UpgradeSubscription.cjs.js +1 -1
  79. package/dist/screens/UpgradeSubscription/UpgradeSubscription.es.js +79 -61
  80. package/dist/solvimon-web.css +1 -1
  81. package/dist/source-DKDKBlUm.mjs +179 -0
  82. package/dist/source-dkMNFWDc.js +1 -0
  83. package/dist/{subscriptions-CoeCrY1I.mjs → subscriptions-mOgjjzUi.mjs} +2 -2
  84. package/dist/subscriptions-wdMADcQZ.js +1 -0
  85. package/dist/{useActionDispatchProvider-eO2qFPGv.mjs → useActionDispatchProvider-B4gszz0Q.mjs} +1 -1
  86. package/dist/{useActionDispatchProvider-CWVV_xsi.js → useActionDispatchProvider-DfS2P0bd.js} +1 -1
  87. package/dist/{useCustomer-PthyTFLl.js → useCustomer-DanZzn-l.js} +1 -1
  88. package/dist/{useCustomer--jycAz--.mjs → useCustomer-cbhDyWJL.mjs} +2 -2
  89. package/dist/useIncrementalLoading-DFe5Yh8M.js +1 -0
  90. package/dist/{useIncrementalLoading-CcnL3flF.mjs → useIncrementalLoading-RRicokf1.mjs} +3 -8
  91. package/dist/useInvoiceData-CxxHa5R2.js +1 -0
  92. package/dist/{useInvoiceData-BiMMoVoW.mjs → useInvoiceData-fS6G_244.mjs} +6 -12
  93. package/dist/{useInvoicesList-DFhF_gp7.mjs → useInvoicesList-BQQxcPdz.mjs} +23 -260
  94. package/dist/useInvoicesList-CtJqmblZ.js +1 -0
  95. package/dist/usePaymentMethodOptions-2MloZ9bY.mjs +26 -0
  96. package/dist/usePaymentMethodOptions-D01YWW3G.js +1 -0
  97. package/dist/{usePaymentMethods-BRQ7-dUr.js → usePaymentMethods-Cm9WdSW0.js} +1 -1
  98. package/dist/{usePaymentMethods-BX2RnHZN.mjs → usePaymentMethods-DZvfWSlx.mjs} +2 -2
  99. package/dist/usePayments-B13S_yai.js +1 -0
  100. package/dist/usePayments-D4uGKBsV.mjs +36 -0
  101. package/dist/usePortal-DJDJNLbo.mjs +12 -0
  102. package/dist/usePortal-DWJEVkTj.js +1 -0
  103. package/dist/useService-9fCKPTmu.js +1 -0
  104. package/dist/useService-BuWWE5ND.mjs +68 -0
  105. package/dist/useViewport-Bu0cyeSi.mjs +38 -0
  106. package/dist/useViewport-CKRY1CKR.js +1 -0
  107. package/dist/useWalletBalanceItems-B53Gkjro.mjs +106 -0
  108. package/dist/useWalletBalanceItems-BMaVT4TW.js +1 -0
  109. package/dist/useWatchDebounced-2ZLnfgvG.js +1 -0
  110. package/dist/useWatchDebounced-D1xuIX6_.mjs +12 -0
  111. package/dist/vendor-ui-BwxuPDg8.mjs +28598 -0
  112. package/dist/vendor-ui-Ce_Yp7xA.js +1 -0
  113. package/package.json +17 -10
  114. package/dist/Alert.vue.es-DMPvSykx.js +0 -1
  115. package/dist/Alert.vue.es-DsJ1ckRU.mjs +0 -172
  116. package/dist/Amount.vue.es-C6JE5rL8.mjs +0 -23
  117. package/dist/Amount.vue.es-h8wulbBG.js +0 -1
  118. package/dist/Avatar.vue.es-Ba8ZGfm4.mjs +0 -93
  119. package/dist/Avatar.vue.es-BbyE0AjW.js +0 -1
  120. package/dist/BillingInformation.vue_vue_type_script_setup_true_lang-C4Ndo83E.js +0 -1
  121. package/dist/Button.vue.es-6sBk5tBL.mjs +0 -408
  122. package/dist/Button.vue.es-BC4_TItq.js +0 -1
  123. package/dist/CardContent.vue.es-ChEMrFCc.mjs +0 -115
  124. package/dist/CardContent.vue.es-i9ivuGKG.js +0 -1
  125. package/dist/Chip.vue.es-D0fkSe8a.js +0 -1
  126. package/dist/Chip.vue.es-DcW2CjUA.mjs +0 -1576
  127. package/dist/Comparators.vue.es-BdxDqU8o.js +0 -1
  128. package/dist/Comparators.vue.es-DdTKGB80.mjs +0 -406
  129. package/dist/ContentWithAsideLayout-UHovpjZu.js +0 -1
  130. package/dist/CustomerBillingInformation.vue.es-9rP7-RzN.js +0 -1
  131. package/dist/CustomerBillingInformation.vue.es-DBMl01Es.mjs +0 -175
  132. package/dist/CustomerPaymentMethods.vue_vue_type_script_setup_true_lang-CYTCcMgP.js +0 -1
  133. package/dist/Divider.vue.es-ClFG8QtG.js +0 -1
  134. package/dist/Divider.vue.es-wKkIVBgb.mjs +0 -24
  135. package/dist/DividerText.vue.es-B7oa5Xpn.mjs +0 -72
  136. package/dist/DividerText.vue.es-yiFdPQvo.js +0 -1
  137. package/dist/ErrorNotification.vue.es-Bgw0MIl8.mjs +0 -30
  138. package/dist/ErrorNotification.vue.es-FpRyg0De.js +0 -1
  139. package/dist/FormMessage.vue.es-DFQXxiSC.mjs +0 -46
  140. package/dist/FormMessage.vue.es-LeWoj774.js +0 -1
  141. package/dist/IconButton.vue.es-DNCwwH_j.mjs +0 -825
  142. package/dist/IconButton.vue.es-DiSiGPWO.js +0 -1
  143. package/dist/InvoiceDetailsBlock.vue_vue_type_script_setup_true_lang-BDitcx8B.js +0 -1
  144. package/dist/PaymentHistoryBlock.vue_vue_type_script_setup_true_lang-6yi47YWd.js +0 -1
  145. package/dist/PaymentIntegrationForm.vue_vue_type_script_setup_true_lang-CC3hm3nx.js +0 -1
  146. package/dist/PaymentMethod.vue.es-DYlnmZh7.js +0 -1
  147. package/dist/PaymentMethod.vue.es-nXZoQjG3.mjs +0 -1255
  148. package/dist/PricingGroupContent.vue_vue_type_script_setup_true_lang-CmQILA3q.js +0 -1
  149. package/dist/Section.vue.es-3-H1pUTB.mjs +0 -79
  150. package/dist/Section.vue.es-BuzTXRLP.js +0 -1
  151. package/dist/SubscriptionsList.vue_vue_type_script_setup_true_lang-Pq3d7DTb.js +0 -1
  152. package/dist/TooltipParagraph.vue.es-DVJLF9Kv.mjs +0 -136
  153. package/dist/TooltipParagraph.vue.es-kTbRGoPF.js +0 -1
  154. package/dist/TrialChip.vue.es-BHYbW8b6.mjs +0 -759
  155. package/dist/TrialChip.vue.es-C6Xg_5rR.js +0 -1
  156. package/dist/_Uint8Array-DHE03FZr.mjs +0 -507
  157. package/dist/_Uint8Array-DxISR7XF.js +0 -1
  158. package/dist/_flatRest.es-BHFPCqZh.mjs +0 -642
  159. package/dist/_flatRest.es-dFffnTpX.js +0 -1
  160. package/dist/api.es-B4qAAJKr.js +0 -1
  161. package/dist/api.es-UkfpLiLL.mjs +0 -83
  162. package/dist/cloneDeep-Hs8Pp07F.js +0 -1
  163. package/dist/cloneDeep-sm9cY-u2.mjs +0 -212
  164. package/dist/cn.es-C7xoIs3C.js +0 -1
  165. package/dist/cn.es-tfxVlz02.mjs +0 -3191
  166. package/dist/component-ZRZIt3ZW.js +0 -1
  167. package/dist/component-dpA83LIN.mjs +0 -6569
  168. package/dist/countryData.es--zJAd6LA.mjs +0 -252
  169. package/dist/countryData.es-D3MFzU92.js +0 -1
  170. package/dist/customer.es-D42Md24r.js +0 -1
  171. package/dist/customer.es-LIW2YmLL.mjs +0 -30
  172. package/dist/formatting.es-9hM8aHSg.js +0 -1
  173. package/dist/formatting.es-D5H_ySFv.mjs +0 -68
  174. package/dist/getCountryNameByCode.es-fP52nO_7.js +0 -1
  175. package/dist/getCountryNameByCode.es-ymC9R46j.mjs +0 -8
  176. package/dist/index-2jo9BSPM.js +0 -1
  177. package/dist/index-BFZ0dPh9.mjs +0 -179
  178. package/dist/index-CI71bVGE.mjs +0 -2521
  179. package/dist/index-CWSXne1Q.js +0 -1
  180. package/dist/index-D3v7hAtc.mjs +0 -253
  181. package/dist/index-WLSPwi90.js +0 -1
  182. package/dist/index.es-BBJF2O2l.js +0 -1
  183. package/dist/index.es-LCAKs4tH.mjs +0 -438
  184. package/dist/invoices-3kVHsAXr.js +0 -1
  185. package/dist/isEmpty.es-Bp1SbWFu.mjs +0 -131
  186. package/dist/isEmpty.es-Dycf-CD_.js +0 -1
  187. package/dist/paymentMethods-DZRf0WRl.js +0 -1
  188. package/dist/pick.es-BgDAfhAl.js +0 -1
  189. package/dist/pick.es-DdVOyp0Q.mjs +0 -45
  190. package/dist/registry-ClZ43bQn.js +0 -1
  191. package/dist/sprite.svg.es-CCc3Mz1x.js +0 -1
  192. package/dist/sprite.svg.es-DZD704h3.mjs +0 -4
  193. package/dist/subscriptions-CS8HTxzC.js +0 -1
  194. package/dist/typeGuards.es-C4nR5FkL.js +0 -1
  195. package/dist/typeGuards.es-fwUoeMCe.mjs +0 -12
  196. package/dist/useIncrementalLoading-CAdNW-Bf.js +0 -1
  197. package/dist/useInvoiceData-DvQO_nKz.js +0 -1
  198. package/dist/useInvoicesList-CHkwSNO9.js +0 -1
  199. package/dist/useService-B67YWAcN.js +0 -1
  200. package/dist/useService-DG_zedHV.mjs +0 -282
  201. package/dist/useWalletBalanceItems-B5FMmoU2.mjs +0 -308
  202. package/dist/useWalletBalanceItems-BY3gq0fc.js +0 -1
@@ -1,2521 +0,0 @@
1
- import { defineComponent, computed, openBlock, createElementBlock, Fragment, renderList, createCommentVNode, normalizeClass, toDisplayString, ref, onMounted, getCurrentInstance, onBeforeMount, watch, isRef, reactive, onBeforeUnmount, unref, inject, provide, isReactive, isReadonly, nextTick, createElementVNode, renderSlot, withKeys, mergeProps, createBlock, resolveDynamicComponent, normalizeProps, createVNode, withCtx, createTextVNode, useModel, toRefs, createSlots, withDirectives, vModelDynamic, mergeModels, withModifiers, guardReactiveProps, Teleport, normalizeStyle, vModelCheckbox } from "vue";
2
- import { i as isEmpty, a as isArrayLike, g as getTag, b as baseUnary } from "./isEmpty.es-Bp1SbWFu.mjs";
3
- import { E as toString, F as baseAssignValue, G as setToString, H as overRest, I as identity, A as isObjectLike, J as baseFlatten, K as arrayMap, L as hasPath, p as baseGet, w as baseGetTag, C as isArray, j as isObject, N as isKey, l as toKey, q as hasIn, O as eq, P as isSymbol } from "./_flatRest.es-BHFPCqZh.mjs";
4
- import { S as SetCache, c as cacheHas, l as last, m as mapToArray, k as keys, i as isEqual, b as Stack, d as baseIsEqual, u as uniqueId, g as getRootTestId, _ as _sfc_main$8, a as _sfc_main$a } from "./IconButton.vue.es-DNCwwH_j.mjs";
5
- import { a as useVModel, c as useElementSize, d as useEventListener } from "./index.es-LCAKs4tH.mjs";
6
- import { c as countryData } from "./countryData.es--zJAd6LA.mjs";
7
- import { b as _export_sfc, u as useFloating, a as autoUpdate, o as offset, f as flip, _ as _sfc_main$c } from "./Chip.vue.es-DcW2CjUA.mjs";
8
- import { S as SEARCH_SELECT_TELEPORT_TARGET } from "./component-dpA83LIN.mjs";
9
- import { a as _sfc_main$b, _ as _sfc_main$d } from "./Button.vue.es-6sBk5tBL.mjs";
10
- import { c as cn } from "./cn.es-tfxVlz02.mjs";
11
- import { _ as _sfc_main$9 } from "./FormMessage.vue.es-DFQXxiSC.mjs";
12
- const escapeUserInput = (str) => str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
13
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, reHasRegExpChar = RegExp(reRegExpChar.source);
14
- function escapeRegExp(string) {
15
- string = toString(string);
16
- return string && reHasRegExpChar.test(string) ? string.replace(reRegExpChar, "\\$&") : string;
17
- }
18
- const _hoisted_1$6 = ["innerHTML"];
19
- const _sfc_main$7 = /* @__PURE__ */ defineComponent({
20
- __name: "TextWithHighlights",
21
- props: {
22
- text: {},
23
- search: { default: "" },
24
- highlighClasses: { default: "text-primary-600 font-bold underline" }
25
- },
26
- setup(__props) {
27
- const props = __props;
28
- const parts = computed(() => {
29
- const escapedInput = escapeUserInput(props.text);
30
- const unmatchedParts = [
31
- {
32
- type: "text",
33
- value: escapedInput
34
- }
35
- ];
36
- if (props.search === "") {
37
- return unmatchedParts;
38
- }
39
- const regex2 = new RegExp(escapeRegExp(props.search), "gi");
40
- const matches = [...escapedInput.matchAll(regex2)];
41
- if (isEmpty(matches)) {
42
- return unmatchedParts;
43
- }
44
- const parts2 = [];
45
- matches.forEach((match, index) => {
46
- if (match.index === void 0) return;
47
- if (index === 0) {
48
- parts2.push({ type: "text", value: escapedInput.substring(0, match.index) });
49
- parts2.push({
50
- type: "highlight",
51
- value: escapedInput.substring(match.index, match.index + props.search.length)
52
- });
53
- }
54
- if (index > 0 && index < matches.length - 1 && matches[index - 1].index) {
55
- parts2.push({
56
- type: "text",
57
- value: escapedInput.substring(
58
- matches[index - 1].index ?? 0 + props.search.length,
59
- match.index
60
- )
61
- });
62
- parts2.push({
63
- type: "highlight",
64
- value: escapedInput.substring(match.index, match.index + props.search.length)
65
- });
66
- }
67
- if (index === matches.length - 1 && match.index + props.search.length < escapedInput.length) {
68
- parts2.push({
69
- type: "text",
70
- value: escapedInput.substring(
71
- match.index + props.search.length,
72
- escapedInput.length
73
- )
74
- });
75
- }
76
- });
77
- return parts2;
78
- });
79
- return (_ctx, _cache) => {
80
- return openBlock(), createElementBlock("span", null, [
81
- (openBlock(true), createElementBlock(Fragment, null, renderList(parts.value, ({ type, value }, index) => {
82
- return openBlock(), createElementBlock(Fragment, { key: index }, [
83
- type === "text" ? (openBlock(), createElementBlock("span", {
84
- key: 0,
85
- innerHTML: value
86
- }, null, 8, _hoisted_1$6)) : createCommentVNode("", true),
87
- type === "highlight" ? (openBlock(), createElementBlock("span", {
88
- key: 1,
89
- class: normalizeClass(__props.highlighClasses)
90
- }, toDisplayString(value), 3)) : createCommentVNode("", true)
91
- ], 64);
92
- }), 128))
93
- ]);
94
- };
95
- }
96
- });
97
- const useIsMounted = () => {
98
- const isMounted = ref(false);
99
- onMounted(() => {
100
- isMounted.value = true;
101
- });
102
- return isMounted;
103
- };
104
- function ownKeys(object, enumerableOnly) {
105
- var keys2 = Object.keys(object);
106
- if (Object.getOwnPropertySymbols) {
107
- var symbols = Object.getOwnPropertySymbols(object);
108
- enumerableOnly && (symbols = symbols.filter(function(sym) {
109
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
110
- })), keys2.push.apply(keys2, symbols);
111
- }
112
- return keys2;
113
- }
114
- function _objectSpread2(target) {
115
- for (var i = 1; i < arguments.length; i++) {
116
- var source = null != arguments[i] ? arguments[i] : {};
117
- i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
118
- _defineProperty(target, key, source[key]);
119
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
120
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
121
- });
122
- }
123
- return target;
124
- }
125
- function _defineProperty(obj, key, value) {
126
- if (key in obj) {
127
- Object.defineProperty(obj, key, {
128
- value,
129
- enumerable: true,
130
- configurable: true,
131
- writable: true
132
- });
133
- } else {
134
- obj[key] = value;
135
- }
136
- return obj;
137
- }
138
- function unwrapObj(obj) {
139
- let ignoreKeys = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
140
- return Object.keys(obj).reduce((o, k) => {
141
- if (ignoreKeys.includes(k)) return o;
142
- o[k] = unref(obj[k]);
143
- return o;
144
- }, {});
145
- }
146
- function isFunction(val) {
147
- return typeof val === "function";
148
- }
149
- function isProxy(value) {
150
- return isReactive(value) || isReadonly(value);
151
- }
152
- function get$1(obj, stringPath, def) {
153
- let current = obj;
154
- const path = stringPath.split(".");
155
- for (let i = 0; i < path.length; i++) {
156
- if (!current[path[i]]) return def;
157
- current = current[path[i]];
158
- }
159
- return current;
160
- }
161
- function gatherBooleanGroupProperties(group, nestedResults, property2) {
162
- return computed(() => {
163
- return group.some((path) => {
164
- return get$1(nestedResults, path, {
165
- [property2]: false
166
- })[property2];
167
- });
168
- });
169
- }
170
- function gatherArrayGroupProperties(group, nestedResults, property2) {
171
- return computed(() => {
172
- return group.reduce((all, path) => {
173
- const fetchedProperty = get$1(nestedResults, path, {
174
- [property2]: false
175
- })[property2] || [];
176
- return all.concat(fetchedProperty);
177
- }, []);
178
- });
179
- }
180
- function callRule(rule, value, siblingState, instance) {
181
- return rule.call(instance, unref(value), unref(siblingState), instance);
182
- }
183
- function normalizeValidatorResponse(result) {
184
- return result.$valid !== void 0 ? !result.$valid : !result;
185
- }
186
- function createAsyncResult(rule, model, $pending, $dirty, _ref, $response, instance) {
187
- let {
188
- $lazy,
189
- $rewardEarly
190
- } = _ref;
191
- let watchTargets = arguments.length > 7 && arguments[7] !== void 0 ? arguments[7] : [];
192
- let siblingState = arguments.length > 8 ? arguments[8] : void 0;
193
- let $lastInvalidState = arguments.length > 9 ? arguments[9] : void 0;
194
- let $lastCommittedOn = arguments.length > 10 ? arguments[10] : void 0;
195
- const $invalid = ref(!!$dirty.value);
196
- const $pendingCounter = ref(0);
197
- $pending.value = false;
198
- const $unwatch = watch([model, $dirty].concat(watchTargets, $lastCommittedOn), () => {
199
- if ($lazy && !$dirty.value || $rewardEarly && !$lastInvalidState.value && !$pending.value) {
200
- return;
201
- }
202
- let ruleResult;
203
- try {
204
- ruleResult = callRule(rule, model, siblingState, instance);
205
- } catch (err) {
206
- ruleResult = Promise.reject(err);
207
- }
208
- $pendingCounter.value++;
209
- $pending.value = !!$pendingCounter.value;
210
- $invalid.value = false;
211
- Promise.resolve(ruleResult).then((data) => {
212
- $pendingCounter.value--;
213
- $pending.value = !!$pendingCounter.value;
214
- $response.value = data;
215
- $invalid.value = normalizeValidatorResponse(data);
216
- }).catch((error) => {
217
- $pendingCounter.value--;
218
- $pending.value = !!$pendingCounter.value;
219
- $response.value = error;
220
- $invalid.value = true;
221
- });
222
- }, {
223
- immediate: true,
224
- deep: typeof model === "object"
225
- });
226
- return {
227
- $invalid,
228
- $unwatch
229
- };
230
- }
231
- function createSyncResult(rule, model, $dirty, _ref2, $response, instance, siblingState, $lastInvalidState) {
232
- let {
233
- $lazy,
234
- $rewardEarly
235
- } = _ref2;
236
- const $unwatch = () => ({});
237
- const $invalid = computed(() => {
238
- if ($lazy && !$dirty.value || $rewardEarly && !$lastInvalidState.value) {
239
- return false;
240
- }
241
- let returnValue = true;
242
- try {
243
- const result = callRule(rule, model, siblingState, instance);
244
- $response.value = result;
245
- returnValue = normalizeValidatorResponse(result);
246
- } catch (err) {
247
- $response.value = err;
248
- }
249
- return returnValue;
250
- });
251
- return {
252
- $unwatch,
253
- $invalid
254
- };
255
- }
256
- function createValidatorResult(rule, model, $dirty, config, instance, validatorName, propertyKey, propertyPath, siblingState, $lastInvalidState, $lastCommittedOn) {
257
- const $pending = ref(false);
258
- const $params = rule.$params || {};
259
- const $response = ref(null);
260
- let $invalid;
261
- let $unwatch;
262
- if (rule.$async) {
263
- ({
264
- $invalid,
265
- $unwatch
266
- } = createAsyncResult(rule.$validator, model, $pending, $dirty, config, $response, instance, rule.$watchTargets, siblingState, $lastInvalidState, $lastCommittedOn));
267
- } else {
268
- ({
269
- $invalid,
270
- $unwatch
271
- } = createSyncResult(rule.$validator, model, $dirty, config, $response, instance, siblingState, $lastInvalidState));
272
- }
273
- const message = rule.$message;
274
- const $message = isFunction(message) ? computed(() => message(unwrapObj({
275
- $pending,
276
- $invalid,
277
- $params: unwrapObj($params),
278
- $model: model,
279
- $response,
280
- $validator: validatorName,
281
- $propertyPath: propertyPath,
282
- $property: propertyKey
283
- }))) : message || "";
284
- return {
285
- $message,
286
- $params,
287
- $pending,
288
- $invalid,
289
- $response,
290
- $unwatch
291
- };
292
- }
293
- function sortValidations() {
294
- let validationsRaw = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
295
- const validations = unref(validationsRaw);
296
- const validationKeys = Object.keys(validations);
297
- const rules = {};
298
- const nestedValidators = {};
299
- const config = {};
300
- let validationGroups = null;
301
- validationKeys.forEach((key) => {
302
- const v = validations[key];
303
- switch (true) {
304
- case isFunction(v.$validator):
305
- rules[key] = v;
306
- break;
307
- case isFunction(v):
308
- rules[key] = {
309
- $validator: v
310
- };
311
- break;
312
- case key === "$validationGroups":
313
- validationGroups = v;
314
- break;
315
- case key.startsWith("$"):
316
- config[key] = v;
317
- break;
318
- default:
319
- nestedValidators[key] = v;
320
- }
321
- });
322
- return {
323
- rules,
324
- nestedValidators,
325
- config,
326
- validationGroups
327
- };
328
- }
329
- const ROOT_PATH = "__root";
330
- function createValidationResults(rules, model, key, resultsCache, path, config, instance, externalResults, siblingState) {
331
- const ruleKeys = Object.keys(rules);
332
- const cachedResult = resultsCache.get(path, rules);
333
- const $dirty = ref(false);
334
- const $lastInvalidState = ref(false);
335
- const $lastCommittedOn = ref(0);
336
- if (cachedResult) {
337
- if (!cachedResult.$partial) return cachedResult;
338
- cachedResult.$unwatch();
339
- $dirty.value = cachedResult.$dirty.value;
340
- }
341
- const result = {
342
- $dirty,
343
- $path: path,
344
- $touch: () => {
345
- if (!$dirty.value) $dirty.value = true;
346
- },
347
- $reset: () => {
348
- if ($dirty.value) $dirty.value = false;
349
- },
350
- $commit: () => {
351
- }
352
- };
353
- if (!ruleKeys.length) {
354
- cachedResult && resultsCache.set(path, rules, result);
355
- return result;
356
- }
357
- ruleKeys.forEach((ruleKey) => {
358
- result[ruleKey] = createValidatorResult(rules[ruleKey], model, result.$dirty, config, instance, ruleKey, key, path, siblingState, $lastInvalidState, $lastCommittedOn);
359
- });
360
- result.$externalResults = computed(() => {
361
- if (!externalResults.value) return [];
362
- return [].concat(externalResults.value).map((stringError, index) => ({
363
- $propertyPath: path,
364
- $property: key,
365
- $validator: "$externalResults",
366
- $uid: `${path}-externalResult-${index}`,
367
- $message: stringError,
368
- $params: {},
369
- $response: null,
370
- $pending: false
371
- }));
372
- });
373
- result.$invalid = computed(() => {
374
- const r = ruleKeys.some((ruleKey) => unref(result[ruleKey].$invalid));
375
- $lastInvalidState.value = r;
376
- return !!result.$externalResults.value.length || r;
377
- });
378
- result.$pending = computed(() => ruleKeys.some((ruleKey) => unref(result[ruleKey].$pending)));
379
- result.$error = computed(() => result.$dirty.value ? result.$pending.value || result.$invalid.value : false);
380
- result.$silentErrors = computed(() => ruleKeys.filter((ruleKey) => unref(result[ruleKey].$invalid)).map((ruleKey) => {
381
- const res = result[ruleKey];
382
- return reactive({
383
- $propertyPath: path,
384
- $property: key,
385
- $validator: ruleKey,
386
- $uid: `${path}-${ruleKey}`,
387
- $message: res.$message,
388
- $params: res.$params,
389
- $response: res.$response,
390
- $pending: res.$pending
391
- });
392
- }).concat(result.$externalResults.value));
393
- result.$errors = computed(() => result.$dirty.value ? result.$silentErrors.value : []);
394
- result.$unwatch = () => ruleKeys.forEach((ruleKey) => {
395
- result[ruleKey].$unwatch();
396
- });
397
- result.$commit = () => {
398
- $lastInvalidState.value = true;
399
- $lastCommittedOn.value = Date.now();
400
- };
401
- resultsCache.set(path, rules, result);
402
- return result;
403
- }
404
- function collectNestedValidationResults(validations, nestedState, path, resultsCache, config, instance, nestedExternalResults) {
405
- const nestedValidationKeys = Object.keys(validations);
406
- if (!nestedValidationKeys.length) return {};
407
- return nestedValidationKeys.reduce((results, nestedKey) => {
408
- results[nestedKey] = setValidations({
409
- validations: validations[nestedKey],
410
- state: nestedState,
411
- key: nestedKey,
412
- parentKey: path,
413
- resultsCache,
414
- globalConfig: config,
415
- instance,
416
- externalResults: nestedExternalResults
417
- });
418
- return results;
419
- }, {});
420
- }
421
- function createMetaFields(results, nestedResults, childResults) {
422
- const allResults = computed(() => [nestedResults, childResults].filter((res) => res).reduce((allRes, res) => {
423
- return allRes.concat(Object.values(unref(res)));
424
- }, []));
425
- const $dirty = computed({
426
- get() {
427
- return results.$dirty.value || (allResults.value.length ? allResults.value.every((r) => r.$dirty) : false);
428
- },
429
- set(v) {
430
- results.$dirty.value = v;
431
- }
432
- });
433
- const $silentErrors = computed(() => {
434
- const modelErrors = unref(results.$silentErrors) || [];
435
- const nestedErrors = allResults.value.filter((result) => (unref(result).$silentErrors || []).length).reduce((errors, result) => {
436
- return errors.concat(...result.$silentErrors);
437
- }, []);
438
- return modelErrors.concat(nestedErrors);
439
- });
440
- const $errors = computed(() => {
441
- const modelErrors = unref(results.$errors) || [];
442
- const nestedErrors = allResults.value.filter((result) => (unref(result).$errors || []).length).reduce((errors, result) => {
443
- return errors.concat(...result.$errors);
444
- }, []);
445
- return modelErrors.concat(nestedErrors);
446
- });
447
- const $invalid = computed(() => allResults.value.some((r) => r.$invalid) || unref(results.$invalid) || false);
448
- const $pending = computed(() => allResults.value.some((r) => unref(r.$pending)) || unref(results.$pending) || false);
449
- const $anyDirty = computed(() => allResults.value.some((r) => r.$dirty) || allResults.value.some((r) => r.$anyDirty) || $dirty.value);
450
- const $error = computed(() => $dirty.value ? $pending.value || $invalid.value : false);
451
- const $touch = () => {
452
- results.$touch();
453
- allResults.value.forEach((result) => {
454
- result.$touch();
455
- });
456
- };
457
- const $commit = () => {
458
- results.$commit();
459
- allResults.value.forEach((result) => {
460
- result.$commit();
461
- });
462
- };
463
- const $reset = () => {
464
- results.$reset();
465
- allResults.value.forEach((result) => {
466
- result.$reset();
467
- });
468
- };
469
- if (allResults.value.length && allResults.value.every((nr) => nr.$dirty)) $touch();
470
- return {
471
- $dirty,
472
- $errors,
473
- $invalid,
474
- $anyDirty,
475
- $error,
476
- $pending,
477
- $touch,
478
- $reset,
479
- $silentErrors,
480
- $commit
481
- };
482
- }
483
- function setValidations(_ref) {
484
- let {
485
- validations,
486
- state,
487
- key,
488
- parentKey,
489
- childResults,
490
- resultsCache,
491
- globalConfig = {},
492
- instance,
493
- externalResults
494
- } = _ref;
495
- const path = parentKey ? `${parentKey}.${key}` : key;
496
- const {
497
- rules,
498
- nestedValidators,
499
- config,
500
- validationGroups
501
- } = sortValidations(validations);
502
- const mergedConfig = _objectSpread2(_objectSpread2({}, globalConfig), config);
503
- const nestedState = key ? computed(() => {
504
- const s = unref(state);
505
- return s ? unref(s[key]) : void 0;
506
- }) : state;
507
- const cachedExternalResults = _objectSpread2({}, unref(externalResults) || {});
508
- const nestedExternalResults = computed(() => {
509
- const results2 = unref(externalResults);
510
- if (!key) return results2;
511
- return results2 ? unref(results2[key]) : void 0;
512
- });
513
- const results = createValidationResults(rules, nestedState, key, resultsCache, path, mergedConfig, instance, nestedExternalResults, state);
514
- const nestedResults = collectNestedValidationResults(nestedValidators, nestedState, path, resultsCache, mergedConfig, instance, nestedExternalResults);
515
- const $validationGroups = {};
516
- if (validationGroups) {
517
- Object.entries(validationGroups).forEach((_ref2) => {
518
- let [key2, group] = _ref2;
519
- $validationGroups[key2] = {
520
- $invalid: gatherBooleanGroupProperties(group, nestedResults, "$invalid"),
521
- $error: gatherBooleanGroupProperties(group, nestedResults, "$error"),
522
- $pending: gatherBooleanGroupProperties(group, nestedResults, "$pending"),
523
- $errors: gatherArrayGroupProperties(group, nestedResults, "$errors"),
524
- $silentErrors: gatherArrayGroupProperties(group, nestedResults, "$silentErrors")
525
- };
526
- });
527
- }
528
- const {
529
- $dirty,
530
- $errors,
531
- $invalid,
532
- $anyDirty,
533
- $error,
534
- $pending,
535
- $touch,
536
- $reset,
537
- $silentErrors,
538
- $commit
539
- } = createMetaFields(results, nestedResults, childResults);
540
- const $model = key ? computed({
541
- get: () => unref(nestedState),
542
- set: (val) => {
543
- $dirty.value = true;
544
- const s = unref(state);
545
- const external = unref(externalResults);
546
- if (external) {
547
- external[key] = cachedExternalResults[key];
548
- }
549
- if (isRef(s[key])) {
550
- s[key].value = val;
551
- } else {
552
- s[key] = val;
553
- }
554
- }
555
- }) : null;
556
- if (key && mergedConfig.$autoDirty) {
557
- watch(nestedState, () => {
558
- if (!$dirty.value) $touch();
559
- const external = unref(externalResults);
560
- if (external) {
561
- external[key] = cachedExternalResults[key];
562
- }
563
- }, {
564
- flush: "sync"
565
- });
566
- }
567
- async function $validate() {
568
- $touch();
569
- if (mergedConfig.$rewardEarly) {
570
- $commit();
571
- await nextTick();
572
- }
573
- await nextTick();
574
- return new Promise((resolve) => {
575
- if (!$pending.value) return resolve(!$invalid.value);
576
- const unwatch = watch($pending, () => {
577
- resolve(!$invalid.value);
578
- unwatch();
579
- });
580
- });
581
- }
582
- function $getResultsForChild(key2) {
583
- return (childResults.value || {})[key2];
584
- }
585
- function $clearExternalResults() {
586
- if (isRef(externalResults)) {
587
- externalResults.value = cachedExternalResults;
588
- } else {
589
- if (Object.keys(cachedExternalResults).length === 0) {
590
- Object.keys(externalResults).forEach((k) => {
591
- delete externalResults[k];
592
- });
593
- } else {
594
- Object.assign(externalResults, cachedExternalResults);
595
- }
596
- }
597
- }
598
- return reactive(_objectSpread2(_objectSpread2(_objectSpread2({}, results), {}, {
599
- $model,
600
- $dirty,
601
- $error,
602
- $errors,
603
- $invalid,
604
- $anyDirty,
605
- $pending,
606
- $touch,
607
- $reset,
608
- $path: path || ROOT_PATH,
609
- $silentErrors,
610
- $validate,
611
- $commit
612
- }, childResults && {
613
- $getResultsForChild,
614
- $clearExternalResults,
615
- $validationGroups
616
- }), nestedResults));
617
- }
618
- class ResultsStorage {
619
- constructor() {
620
- this.storage = /* @__PURE__ */ new Map();
621
- }
622
- set(path, rules, result) {
623
- this.storage.set(path, {
624
- rules,
625
- result
626
- });
627
- }
628
- checkRulesValidity(path, rules, storedRules) {
629
- const storedRulesKeys = Object.keys(storedRules);
630
- const newRulesKeys = Object.keys(rules);
631
- if (newRulesKeys.length !== storedRulesKeys.length) return false;
632
- const hasAllValidators = newRulesKeys.every((ruleKey) => storedRulesKeys.includes(ruleKey));
633
- if (!hasAllValidators) return false;
634
- return newRulesKeys.every((ruleKey) => {
635
- if (!rules[ruleKey].$params) return true;
636
- return Object.keys(rules[ruleKey].$params).every((paramKey) => {
637
- return unref(storedRules[ruleKey].$params[paramKey]) === unref(rules[ruleKey].$params[paramKey]);
638
- });
639
- });
640
- }
641
- get(path, rules) {
642
- const storedRuleResultPair = this.storage.get(path);
643
- if (!storedRuleResultPair) return void 0;
644
- const {
645
- rules: storedRules,
646
- result
647
- } = storedRuleResultPair;
648
- const isValidCache = this.checkRulesValidity(path, rules, storedRules);
649
- const $unwatch = result.$unwatch ? result.$unwatch : () => ({});
650
- if (!isValidCache) return {
651
- $dirty: result.$dirty,
652
- $partial: true,
653
- $unwatch
654
- };
655
- return result;
656
- }
657
- }
658
- const CollectFlag = {
659
- COLLECT_ALL: true,
660
- COLLECT_NONE: false
661
- };
662
- const VuelidateInjectChildResults = Symbol("vuelidate#injectChildResults");
663
- const VuelidateRemoveChildResults = Symbol("vuelidate#removeChildResults");
664
- function nestedValidations(_ref) {
665
- let {
666
- $scope,
667
- instance
668
- } = _ref;
669
- const childResultsRaw = {};
670
- const childResultsKeys = ref([]);
671
- const childResults = computed(() => childResultsKeys.value.reduce((results, key) => {
672
- results[key] = unref(childResultsRaw[key]);
673
- return results;
674
- }, {}));
675
- function injectChildResultsIntoParent(results, _ref2) {
676
- let {
677
- $registerAs: key,
678
- $scope: childScope,
679
- $stopPropagation
680
- } = _ref2;
681
- if ($stopPropagation || $scope === CollectFlag.COLLECT_NONE || childScope === CollectFlag.COLLECT_NONE || $scope !== CollectFlag.COLLECT_ALL && $scope !== childScope) return;
682
- childResultsRaw[key] = results;
683
- childResultsKeys.value.push(key);
684
- }
685
- instance.__vuelidateInjectInstances = [].concat(instance.__vuelidateInjectInstances || [], injectChildResultsIntoParent);
686
- function removeChildResultsFromParent(key) {
687
- childResultsKeys.value = childResultsKeys.value.filter((childKey) => childKey !== key);
688
- delete childResultsRaw[key];
689
- }
690
- instance.__vuelidateRemoveInstances = [].concat(instance.__vuelidateRemoveInstances || [], removeChildResultsFromParent);
691
- const sendValidationResultsToParent = inject(VuelidateInjectChildResults, []);
692
- provide(VuelidateInjectChildResults, instance.__vuelidateInjectInstances);
693
- const removeValidationResultsFromParent = inject(VuelidateRemoveChildResults, []);
694
- provide(VuelidateRemoveChildResults, instance.__vuelidateRemoveInstances);
695
- return {
696
- childResults,
697
- sendValidationResultsToParent,
698
- removeValidationResultsFromParent
699
- };
700
- }
701
- function ComputedProxyFactory(target) {
702
- return new Proxy(target, {
703
- get(target2, prop) {
704
- return typeof target2[prop] === "object" ? ComputedProxyFactory(target2[prop]) : computed(() => target2[prop]);
705
- }
706
- });
707
- }
708
- let uid = 0;
709
- function useVuelidate(validations, state) {
710
- var _getCurrentInstance;
711
- let globalConfig = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
712
- if (arguments.length === 1) {
713
- globalConfig = validations;
714
- validations = void 0;
715
- state = void 0;
716
- }
717
- let {
718
- $registerAs,
719
- $scope = CollectFlag.COLLECT_ALL,
720
- $stopPropagation,
721
- $externalResults,
722
- currentVueInstance
723
- } = globalConfig;
724
- const instance = currentVueInstance || ((_getCurrentInstance = getCurrentInstance()) === null || _getCurrentInstance === void 0 ? void 0 : _getCurrentInstance.proxy);
725
- const componentOptions = instance ? instance.$options : {};
726
- if (!$registerAs) {
727
- uid += 1;
728
- $registerAs = `_vuelidate_${uid}`;
729
- }
730
- const validationResults = ref({});
731
- const resultsCache = new ResultsStorage();
732
- const {
733
- childResults,
734
- sendValidationResultsToParent,
735
- removeValidationResultsFromParent
736
- } = instance ? nestedValidations({
737
- $scope,
738
- instance
739
- }) : {
740
- childResults: ref({})
741
- };
742
- if (!validations && componentOptions.validations) {
743
- const rules = componentOptions.validations;
744
- state = ref({});
745
- onBeforeMount(() => {
746
- state.value = instance;
747
- watch(() => isFunction(rules) ? rules.call(state.value, new ComputedProxyFactory(state.value)) : rules, (validations2) => {
748
- validationResults.value = setValidations({
749
- validations: validations2,
750
- state,
751
- childResults,
752
- resultsCache,
753
- globalConfig,
754
- instance,
755
- externalResults: $externalResults || instance.vuelidateExternalResults
756
- });
757
- }, {
758
- immediate: true
759
- });
760
- });
761
- globalConfig = componentOptions.validationsConfig || globalConfig;
762
- } else {
763
- const validationsWatchTarget = isRef(validations) || isProxy(validations) ? validations : reactive(validations || {});
764
- watch(validationsWatchTarget, (newValidationRules) => {
765
- validationResults.value = setValidations({
766
- validations: newValidationRules,
767
- state,
768
- childResults,
769
- resultsCache,
770
- globalConfig,
771
- instance: instance !== null && instance !== void 0 ? instance : {},
772
- externalResults: $externalResults
773
- });
774
- }, {
775
- immediate: true
776
- });
777
- }
778
- if (instance) {
779
- sendValidationResultsToParent.forEach((f) => f(validationResults, {
780
- $registerAs,
781
- $scope,
782
- $stopPropagation
783
- }));
784
- onBeforeUnmount(() => removeValidationResultsFromParent.forEach((f) => f($registerAs)));
785
- }
786
- return computed(() => {
787
- return _objectSpread2(_objectSpread2({}, unref(validationResults.value)), childResults.value);
788
- });
789
- }
790
- function useValidation(rulesOrGlobalConfig, model, globalConfig) {
791
- if (rulesOrGlobalConfig && model) {
792
- return useVuelidate(rulesOrGlobalConfig, model, { $autoDirty: true, ...globalConfig });
793
- }
794
- return useVuelidate({ $autoDirty: true, ...rulesOrGlobalConfig });
795
- }
796
- const nullWhenEmpty = (value) => isEmpty(value) && typeof value !== "boolean" ? null : value;
797
- function fromPairs(pairs) {
798
- var index = -1, length = pairs == null ? 0 : pairs.length, result = {};
799
- while (++index < length) {
800
- var pair = pairs[index];
801
- baseAssignValue(result, pair[0], pair[1]);
802
- }
803
- return result;
804
- }
805
- function baseFindIndex(array, predicate, fromIndex, fromRight) {
806
- var length = array.length, index = fromIndex + -1;
807
- while (++index < length) {
808
- if (predicate(array[index], index, array)) {
809
- return index;
810
- }
811
- }
812
- return -1;
813
- }
814
- function baseIsNaN(value) {
815
- return value !== value;
816
- }
817
- function strictIndexOf(array, value, fromIndex) {
818
- var index = fromIndex - 1, length = array.length;
819
- while (++index < length) {
820
- if (array[index] === value) {
821
- return index;
822
- }
823
- }
824
- return -1;
825
- }
826
- function baseIndexOf(array, value, fromIndex) {
827
- return value === value ? strictIndexOf(array, value, fromIndex) : baseFindIndex(array, baseIsNaN, fromIndex);
828
- }
829
- function arrayIncludes(array, value) {
830
- var length = array == null ? 0 : array.length;
831
- return !!length && baseIndexOf(array, value, 0) > -1;
832
- }
833
- function arrayIncludesWith(array, value, comparator) {
834
- var index = -1, length = array == null ? 0 : array.length;
835
- while (++index < length) {
836
- if (comparator(value, array[index])) {
837
- return true;
838
- }
839
- }
840
- return false;
841
- }
842
- var LARGE_ARRAY_SIZE = 200;
843
- function baseDifference(array, values, iteratee, comparator) {
844
- var index = -1, includes = arrayIncludes, isCommon = true, length = array.length, result = [], valuesLength = values.length;
845
- if (!length) {
846
- return result;
847
- }
848
- if (comparator) {
849
- includes = arrayIncludesWith;
850
- isCommon = false;
851
- } else if (values.length >= LARGE_ARRAY_SIZE) {
852
- includes = cacheHas;
853
- isCommon = false;
854
- values = new SetCache(values);
855
- }
856
- outer:
857
- while (++index < length) {
858
- var value = array[index], computed2 = value;
859
- value = comparator || value !== 0 ? value : 0;
860
- if (isCommon && computed2 === computed2) {
861
- var valuesIndex = valuesLength;
862
- while (valuesIndex--) {
863
- if (values[valuesIndex] === computed2) {
864
- continue outer;
865
- }
866
- }
867
- result.push(value);
868
- } else if (!includes(values, computed2, comparator)) {
869
- result.push(value);
870
- }
871
- }
872
- return result;
873
- }
874
- function baseRest(func, start) {
875
- return setToString(overRest(func, start, identity), func + "");
876
- }
877
- function isArrayLikeObject(value) {
878
- return isObjectLike(value) && isArrayLike(value);
879
- }
880
- var differenceWith = baseRest(function(array, values) {
881
- var comparator = last(values);
882
- if (isArrayLikeObject(comparator)) {
883
- comparator = void 0;
884
- }
885
- return isArrayLikeObject(array) ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), void 0, comparator) : [];
886
- });
887
- function baseToPairs(object, props) {
888
- return arrayMap(props, function(key) {
889
- return [key, object[key]];
890
- });
891
- }
892
- function setToPairs(set) {
893
- var index = -1, result = Array(set.size);
894
- set.forEach(function(value) {
895
- result[++index] = [value, value];
896
- });
897
- return result;
898
- }
899
- var mapTag = "[object Map]", setTag = "[object Set]";
900
- function createToPairs(keysFunc) {
901
- return function(object) {
902
- var tag = getTag(object);
903
- if (tag == mapTag) {
904
- return mapToArray(object);
905
- }
906
- if (tag == setTag) {
907
- return setToPairs(object);
908
- }
909
- return baseToPairs(object, keysFunc(object));
910
- };
911
- }
912
- var toPairs = createToPairs(keys);
913
- var objectProto = Object.prototype;
914
- var hasOwnProperty = objectProto.hasOwnProperty;
915
- function baseHas(object, key) {
916
- return object != null && hasOwnProperty.call(object, key);
917
- }
918
- function has(object, path) {
919
- return object != null && hasPath(object, path, baseHas);
920
- }
921
- function get(object, path, defaultValue) {
922
- var result = object == null ? void 0 : baseGet(object, path);
923
- return result === void 0 ? defaultValue : result;
924
- }
925
- var boolTag = "[object Boolean]";
926
- function isBoolean(value) {
927
- return value === true || value === false || isObjectLike(value) && baseGetTag(value) == boolTag;
928
- }
929
- function isUndefined(value) {
930
- return value === void 0;
931
- }
932
- const shallowObjectDiff = ({
933
- from,
934
- to,
935
- nullifyEmptyValues = false
936
- }) => {
937
- const changes = fromPairs(differenceWith(toPairs(to), toPairs(from), isEqual));
938
- if (nullifyEmptyValues) {
939
- return Object.entries(changes).reduce(
940
- (acc, [key, value]) => ({ ...acc, [key]: nullWhenEmpty(value) }),
941
- {}
942
- );
943
- }
944
- return changes;
945
- };
946
- const deepObjectDiff = ({
947
- from,
948
- to,
949
- nullifyEmptyValues = false
950
- }) => {
951
- const changes = {};
952
- const buildPath = (path, obj, key) => {
953
- const origVal = get(obj, key);
954
- if (isUndefined(path)) {
955
- if (isArray(origVal)) {
956
- changes[key] = [];
957
- } else if (isObject(origVal)) {
958
- changes[key] = {};
959
- }
960
- } else {
961
- if (isArray(origVal)) {
962
- path[key] = [];
963
- } else if (isObject(origVal)) {
964
- path[key] = {};
965
- }
966
- }
967
- return [isUndefined(path) ? changes : path, key];
968
- };
969
- const walk = (fromObject, toObject, path) => {
970
- for (const key of keys(fromObject)) {
971
- const objKeyPair = buildPath(path, fromObject, key);
972
- if (!has(toObject, key)) {
973
- objKeyPair[0][objKeyPair[1]] = { from: get(fromObject, key) };
974
- }
975
- }
976
- for (const [key, to2] of toPairs(toObject)) {
977
- const isLast = has(fromObject, key);
978
- const objKeyPair = buildPath(path, fromObject, key);
979
- if (isLast) {
980
- const from2 = get(fromObject, key);
981
- if (!isEqual(from2, to2)) {
982
- if (isObjectLike(to2) && isObjectLike(from2)) {
983
- walk(from2, to2, objKeyPair[0][objKeyPair[1]]);
984
- } else {
985
- objKeyPair[0][objKeyPair[1]] = nullifyEmptyValues && !isBoolean(to2) ? nullWhenEmpty(to2) : to2;
986
- }
987
- } else {
988
- delete objKeyPair[0][objKeyPair[1]];
989
- }
990
- } else {
991
- objKeyPair[0][objKeyPair[1]] = nullifyEmptyValues ? nullWhenEmpty(to2) : to2;
992
- }
993
- }
994
- };
995
- walk(from, to);
996
- return changes;
997
- };
998
- const objectDiff = ({
999
- from,
1000
- to,
1001
- mode = "shallow",
1002
- nullifyEmptyValues = false
1003
- }) => mode === "deep" ? deepObjectDiff({ from, to, nullifyEmptyValues }) : shallowObjectDiff({ from, to, nullifyEmptyValues });
1004
- const _sfc_main$6 = {};
1005
- const _hoisted_1$5 = { class: "flex items-center pt-1" };
1006
- const _hoisted_2$4 = { class: "px-1.5 text-gray-500 text-xs font-semibold" };
1007
- function _sfc_render(_ctx, _cache) {
1008
- return openBlock(), createElementBlock("div", _hoisted_1$5, [
1009
- _cache[0] || (_cache[0] = createElementVNode("div", { class: "border-t w-2" }, null, -1)),
1010
- createElementVNode("span", _hoisted_2$4, [
1011
- renderSlot(_ctx.$slots, "default")
1012
- ]),
1013
- _cache[1] || (_cache[1] = createElementVNode("div", { class: "border-t grow" }, null, -1))
1014
- ]);
1015
- }
1016
- const SearchSelectInputOptionsDivider = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render]]);
1017
- const getOptionName = (value) => {
1018
- return `checkbox-item-${value}`;
1019
- };
1020
- const DONE_BUTTON_TEST_ID = "select-search-done-button";
1021
- const _hoisted_1$4 = ["aria-selected", "aria-disabled", "data-testid"];
1022
- const _hoisted_2$3 = ["id", "value", "checked", "disabled"];
1023
- const _hoisted_3$3 = ["for"];
1024
- const _hoisted_4$3 = { class: "flex items-center gap-1" };
1025
- const _hoisted_5$3 = { class: "flex flex-grow flex-col" };
1026
- const _hoisted_6$3 = { class: "flex flex-grow gap-2" };
1027
- const _hoisted_7$2 = { class: "flex flex-grow flex-col" };
1028
- const _hoisted_8 = { class: "flex flex-grow gap-2 items-center" };
1029
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1030
- __name: "SearchSelectInputOption",
1031
- props: {
1032
- multiple: { type: Boolean },
1033
- search: {},
1034
- condensed: { type: Boolean },
1035
- label: {},
1036
- checked: { type: Boolean },
1037
- disabled: { type: Boolean },
1038
- subLabel: {},
1039
- labelPrefixComponent: {},
1040
- labelSuffixComponent: {},
1041
- labelInlineComponent: {},
1042
- value: {},
1043
- labelSrOnly: { type: Boolean }
1044
- },
1045
- emits: ["value-changed"],
1046
- setup(__props, { emit: __emit }) {
1047
- const emit = __emit;
1048
- const props = __props;
1049
- const handleChange = (event) => {
1050
- const target = event.target;
1051
- const payload = {
1052
- value: target.value,
1053
- checked: target.checked
1054
- };
1055
- emit("value-changed", payload);
1056
- };
1057
- const handleClick = () => {
1058
- if (props.multiple || props.disabled) {
1059
- return;
1060
- }
1061
- emit("value-changed", {
1062
- value: props.value
1063
- });
1064
- };
1065
- const name = computed(() => getOptionName(props.value));
1066
- const escapedSearch = computed(() => escapeUserInput(props.search ?? ""));
1067
- return (_ctx, _cache) => {
1068
- return openBlock(), createElementBlock("li", {
1069
- role: "option",
1070
- "aria-selected": __props.checked,
1071
- "aria-disabled": __props.disabled,
1072
- class: normalizeClass([{ "hover:bg-gray-100": !__props.disabled }, "flex relative"]),
1073
- "data-testid": name.value,
1074
- tabindex: "0",
1075
- onClick: handleClick,
1076
- onKeydown: withKeys(handleClick, ["enter"])
1077
- }, [
1078
- __props.multiple ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
1079
- createElementVNode("input", mergeProps(_ctx.$attrs, {
1080
- id: name.value,
1081
- ref: "inputRef",
1082
- value: __props.value,
1083
- checked: __props.checked,
1084
- disabled: __props.disabled,
1085
- type: "checkbox",
1086
- class: ["absolute top-[50%] -translate-y-2 left-3.5 w-4 h-4 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 focus:ring-2", __props.disabled ? "text-gray-400 placeholder-gray-500" : "text-blue-600"],
1087
- tabindex: "-1",
1088
- onChange: handleChange
1089
- }), null, 16, _hoisted_2$3),
1090
- createElementVNode("label", {
1091
- for: name.value,
1092
- class: normalizeClass([__props.disabled ? `text-gray-400` : "text-gray-900 rounded", "w-full px-4 py-3 pl-10 text-sm font-medium"])
1093
- }, [
1094
- createElementVNode("div", _hoisted_4$3, [
1095
- __props.labelPrefixComponent ? (openBlock(), createBlock(resolveDynamicComponent(__props.labelPrefixComponent.component), normalizeProps(mergeProps({ key: 0 }, __props.labelPrefixComponent.props)), null, 16)) : createCommentVNode("", true),
1096
- createElementVNode("div", _hoisted_5$3, [
1097
- createElementVNode("div", _hoisted_6$3, [
1098
- createVNode(_sfc_main$7, {
1099
- text: __props.label,
1100
- search: escapedSearch.value,
1101
- class: normalizeClass(["font-semibold", { "sr-only": __props.labelSrOnly }])
1102
- }, null, 8, ["text", "search", "class"]),
1103
- __props.labelInlineComponent ? (openBlock(), createBlock(resolveDynamicComponent(__props.labelInlineComponent.component), normalizeProps(mergeProps({ key: 0 }, __props.labelInlineComponent.props)), null, 16)) : createCommentVNode("", true),
1104
- __props.subLabel && __props.condensed ? (openBlock(), createBlock(_sfc_main$7, {
1105
- key: 1,
1106
- class: "text-xs text-slate-500",
1107
- text: __props.subLabel,
1108
- search: escapedSearch.value
1109
- }, null, 8, ["text", "search"])) : createCommentVNode("", true)
1110
- ]),
1111
- __props.subLabel && !__props.condensed ? (openBlock(), createBlock(_sfc_main$7, {
1112
- key: 0,
1113
- class: "text-xs text-slate-500",
1114
- text: __props.subLabel,
1115
- search: escapedSearch.value
1116
- }, null, 8, ["text", "search"])) : createCommentVNode("", true)
1117
- ]),
1118
- __props.labelSuffixComponent ? (openBlock(), createBlock(resolveDynamicComponent(__props.labelSuffixComponent.component), normalizeProps(mergeProps({ key: 1 }, __props.labelSuffixComponent.props)), null, 16)) : createCommentVNode("", true)
1119
- ])
1120
- ], 10, _hoisted_3$3)
1121
- ], 64)) : (openBlock(), createElementBlock("div", {
1122
- key: 1,
1123
- class: normalizeClass(["w-full px-4 text-sm font-medium flex items-center gap-3", [
1124
- __props.condensed ? "p-2" : "py-3",
1125
- __props.disabled ?? "cursor-not-allowed",
1126
- !__props.disabled && "cursor-pointer"
1127
- ]])
1128
- }, [
1129
- __props.labelPrefixComponent ? (openBlock(), createBlock(resolveDynamicComponent(__props.labelPrefixComponent.component), normalizeProps(mergeProps({ key: 0 }, __props.labelPrefixComponent.props)), null, 16)) : createCommentVNode("", true),
1130
- createElementVNode("div", _hoisted_7$2, [
1131
- createElementVNode("div", _hoisted_8, [
1132
- createVNode(_sfc_main$7, {
1133
- text: __props.label,
1134
- search: unref(escapeUserInput)(__props.search ?? ""),
1135
- class: normalizeClass(["font-semibold", { "text-gray-400": __props.disabled }])
1136
- }, null, 8, ["text", "search", "class"]),
1137
- __props.labelInlineComponent ? (openBlock(), createBlock(resolveDynamicComponent(__props.labelInlineComponent.component), normalizeProps(mergeProps({ key: 0 }, __props.labelInlineComponent.props)), null, 16)) : createCommentVNode("", true),
1138
- __props.subLabel && __props.condensed ? (openBlock(), createBlock(_sfc_main$7, {
1139
- key: 1,
1140
- class: "text-xs text-slate-500",
1141
- text: __props.subLabel,
1142
- search: escapedSearch.value
1143
- }, null, 8, ["text", "search"])) : createCommentVNode("", true)
1144
- ]),
1145
- __props.subLabel && !__props.condensed ? (openBlock(), createBlock(_sfc_main$7, {
1146
- key: 0,
1147
- class: "text-xs text-slate-500",
1148
- text: __props.subLabel,
1149
- search: escapedSearch.value
1150
- }, null, 8, ["text", "search"])) : createCommentVNode("", true)
1151
- ]),
1152
- __props.labelSuffixComponent ? (openBlock(), createBlock(resolveDynamicComponent(__props.labelSuffixComponent.component), normalizeProps(mergeProps({ key: 1 }, __props.labelSuffixComponent.props)), null, 16)) : createCommentVNode("", true)
1153
- ], 2))
1154
- ], 42, _hoisted_1$4);
1155
- };
1156
- }
1157
- });
1158
- var COMPARE_PARTIAL_FLAG$1 = 1, COMPARE_UNORDERED_FLAG$1 = 2;
1159
- function baseIsMatch(object, source, matchData, customizer) {
1160
- var index = matchData.length, length = index;
1161
- if (object == null) {
1162
- return !length;
1163
- }
1164
- object = Object(object);
1165
- while (index--) {
1166
- var data = matchData[index];
1167
- if (data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
1168
- return false;
1169
- }
1170
- }
1171
- while (++index < length) {
1172
- data = matchData[index];
1173
- var key = data[0], objValue = object[key], srcValue = data[1];
1174
- if (data[2]) {
1175
- if (objValue === void 0 && !(key in object)) {
1176
- return false;
1177
- }
1178
- } else {
1179
- var stack = new Stack();
1180
- var result;
1181
- if (!(result === void 0 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack) : result)) {
1182
- return false;
1183
- }
1184
- }
1185
- }
1186
- return true;
1187
- }
1188
- function isStrictComparable(value) {
1189
- return value === value && !isObject(value);
1190
- }
1191
- function getMatchData(object) {
1192
- var result = keys(object), length = result.length;
1193
- while (length--) {
1194
- var key = result[length], value = object[key];
1195
- result[length] = [key, value, isStrictComparable(value)];
1196
- }
1197
- return result;
1198
- }
1199
- function matchesStrictComparable(key, srcValue) {
1200
- return function(object) {
1201
- if (object == null) {
1202
- return false;
1203
- }
1204
- return object[key] === srcValue && (srcValue !== void 0 || key in Object(object));
1205
- };
1206
- }
1207
- function baseMatches(source) {
1208
- var matchData = getMatchData(source);
1209
- if (matchData.length == 1 && matchData[0][2]) {
1210
- return matchesStrictComparable(matchData[0][0], matchData[0][1]);
1211
- }
1212
- return function(object) {
1213
- return object === source || baseIsMatch(object, source, matchData);
1214
- };
1215
- }
1216
- var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2;
1217
- function baseMatchesProperty(path, srcValue) {
1218
- if (isKey(path) && isStrictComparable(srcValue)) {
1219
- return matchesStrictComparable(toKey(path), srcValue);
1220
- }
1221
- return function(object) {
1222
- var objValue = get(object, path);
1223
- return objValue === void 0 && objValue === srcValue ? hasIn(object, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
1224
- };
1225
- }
1226
- function baseProperty(key) {
1227
- return function(object) {
1228
- return object == null ? void 0 : object[key];
1229
- };
1230
- }
1231
- function basePropertyDeep(path) {
1232
- return function(object) {
1233
- return baseGet(object, path);
1234
- };
1235
- }
1236
- function property(path) {
1237
- return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
1238
- }
1239
- function baseIteratee(value) {
1240
- if (typeof value == "function") {
1241
- return value;
1242
- }
1243
- if (value == null) {
1244
- return identity;
1245
- }
1246
- if (typeof value == "object") {
1247
- return isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
1248
- }
1249
- return property(value);
1250
- }
1251
- function baseSortedUniq(array, iteratee) {
1252
- var index = -1, length = array.length, resIndex = 0, result = [];
1253
- while (++index < length) {
1254
- var value = array[index], computed2 = iteratee ? iteratee(value) : value;
1255
- if (!index || !eq(computed2, seen)) {
1256
- var seen = computed2;
1257
- result[resIndex++] = value === 0 ? 0 : value;
1258
- }
1259
- }
1260
- return result;
1261
- }
1262
- function sortedUniqBy(array, iteratee) {
1263
- return array && array.length ? baseSortedUniq(array, baseIteratee(iteratee)) : [];
1264
- }
1265
- const _hoisted_1$3 = { class: "flex flex-col rounded-bl rounded-br" };
1266
- const _hoisted_2$2 = {
1267
- key: 0,
1268
- class: "px-5 py-5 text-sm text-slate-400"
1269
- };
1270
- const _hoisted_3$2 = { key: 0 };
1271
- const _hoisted_4$2 = ["innerHTML"];
1272
- const _hoisted_5$2 = { key: 0 };
1273
- const _hoisted_6$2 = { class: "mt-1 px-3 py-2 text-sm text-slate-600" };
1274
- const _hoisted_7$1 = {
1275
- key: 2,
1276
- class: "border-t border-gray-200"
1277
- };
1278
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1279
- __name: "SearchSelectInputOptions",
1280
- props: {
1281
- i18n: {},
1282
- model: {},
1283
- search: {},
1284
- multiple: { type: Boolean },
1285
- condensed: { type: Boolean },
1286
- hasLargeDropdown: { type: Boolean },
1287
- addOnly: { type: Boolean },
1288
- options: {}
1289
- },
1290
- emits: ["value-changed"],
1291
- setup(__props, { emit: __emit }) {
1292
- const emit = __emit;
1293
- const props = __props;
1294
- const handleChange = (payload) => emit("value-changed", payload);
1295
- const noResultsText = computed(() => {
1296
- var _a, _b;
1297
- const searchTerm = props.search ? `<span class="font-bold">"${escapeUserInput(props.search)}"</span>` : "";
1298
- return ((_b = (_a = props.i18n) == null ? void 0 : _a.noResults) == null ? void 0 : _b.call(_a, searchTerm)) ?? `No matches found for ${searchTerm}.`;
1299
- });
1300
- const isSearchEmpty = computed(() => props.search === "");
1301
- const groups = computed(
1302
- () => sortedUniqBy(props.options, "group").reduce(
1303
- (acc, option) => option.value === "" ? acc : {
1304
- ...acc,
1305
- [option.value]: option.group
1306
- },
1307
- {}
1308
- )
1309
- );
1310
- return (_ctx, _cache) => {
1311
- var _a, _b;
1312
- return openBlock(), createElementBlock("div", _hoisted_1$3, [
1313
- __props.options.length === 0 ? (openBlock(), createElementBlock("div", _hoisted_2$2, [
1314
- isSearchEmpty.value ? (openBlock(), createElementBlock("span", _hoisted_3$2, toDisplayString(((_a = props.i18n) == null ? void 0 : _a.noOptionsAvailable) ?? "No available options."), 1)) : (openBlock(), createElementBlock("span", {
1315
- key: 1,
1316
- innerHTML: noResultsText.value
1317
- }, null, 8, _hoisted_4$2))
1318
- ])) : (openBlock(), createElementBlock("ul", {
1319
- key: 1,
1320
- class: normalizeClass(["list-none overflow-y-auto text-gray-700", [__props.hasLargeDropdown ? "max-h-76" : "max-h-48"]])
1321
- }, [
1322
- __props.addOnly ? (openBlock(), createElementBlock("div", _hoisted_5$2, [
1323
- createElementVNode("p", _hoisted_6$2, toDisplayString(((_b = __props.i18n) == null ? void 0 : _b.addOnly) ?? "You can only select currently unselected options."), 1)
1324
- ])) : createCommentVNode("", true),
1325
- (openBlock(true), createElementBlock(Fragment, null, renderList(__props.options, ({
1326
- label,
1327
- subLabel,
1328
- value,
1329
- checked,
1330
- disabled,
1331
- labelInlineComponent,
1332
- labelSuffixComponent,
1333
- labelSrOnly,
1334
- labelPrefixComponent,
1335
- hidden,
1336
- searchValues
1337
- }) => {
1338
- return openBlock(), createElementBlock(Fragment, { key: value }, [
1339
- groups.value[value] ? (openBlock(), createBlock(SearchSelectInputOptionsDivider, { key: 0 }, {
1340
- default: withCtx(() => [
1341
- createTextVNode(toDisplayString(groups.value[value]), 1)
1342
- ]),
1343
- _: 2
1344
- }, 1024)) : createCommentVNode("", true),
1345
- !hidden ? (openBlock(), createBlock(_sfc_main$5, {
1346
- key: 1,
1347
- label,
1348
- "sub-label": subLabel,
1349
- value,
1350
- checked,
1351
- disabled,
1352
- search: searchValues ? "" : __props.search,
1353
- multiple: __props.multiple,
1354
- condensed: __props.condensed,
1355
- "label-suffix-component": labelSuffixComponent,
1356
- "label-prefix-component": labelPrefixComponent,
1357
- "label-inline-component": labelInlineComponent,
1358
- "label-sr-only": labelSrOnly,
1359
- onValueChanged: handleChange
1360
- }, null, 8, ["label", "sub-label", "value", "checked", "disabled", "search", "multiple", "condensed", "label-suffix-component", "label-prefix-component", "label-inline-component", "label-sr-only"])) : createCommentVNode("", true)
1361
- ], 64);
1362
- }), 128))
1363
- ], 2)),
1364
- _ctx.$slots["list-footer-content"] ? (openBlock(), createElementBlock("div", _hoisted_7$1, [
1365
- renderSlot(_ctx.$slots, "list-footer-content")
1366
- ])) : createCommentVNode("", true)
1367
- ]);
1368
- };
1369
- }
1370
- });
1371
- function createBaseFor(fromRight) {
1372
- return function(object, iteratee, keysFunc) {
1373
- var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length;
1374
- while (length--) {
1375
- var key = props[++index];
1376
- if (iteratee(iterable[key], key, iterable) === false) {
1377
- break;
1378
- }
1379
- }
1380
- return object;
1381
- };
1382
- }
1383
- var baseFor = createBaseFor();
1384
- function baseForOwn(object, iteratee) {
1385
- return object && baseFor(object, iteratee, keys);
1386
- }
1387
- function createBaseEach(eachFunc, fromRight) {
1388
- return function(collection, iteratee) {
1389
- if (collection == null) {
1390
- return collection;
1391
- }
1392
- if (!isArrayLike(collection)) {
1393
- return eachFunc(collection, iteratee);
1394
- }
1395
- var length = collection.length, index = -1, iterable = Object(collection);
1396
- while (++index < length) {
1397
- if (iteratee(iterable[index], index, iterable) === false) {
1398
- break;
1399
- }
1400
- }
1401
- return collection;
1402
- };
1403
- }
1404
- var baseEach = createBaseEach(baseForOwn);
1405
- function baseMap(collection, iteratee) {
1406
- var index = -1, result = isArrayLike(collection) ? Array(collection.length) : [];
1407
- baseEach(collection, function(value, key, collection2) {
1408
- result[++index] = iteratee(value, key, collection2);
1409
- });
1410
- return result;
1411
- }
1412
- function baseSortBy(array, comparer) {
1413
- var length = array.length;
1414
- array.sort(comparer);
1415
- while (length--) {
1416
- array[length] = array[length].value;
1417
- }
1418
- return array;
1419
- }
1420
- function compareAscending(value, other) {
1421
- if (value !== other) {
1422
- var valIsDefined = value !== void 0, valIsNull = value === null, valIsReflexive = value === value, valIsSymbol = isSymbol(value);
1423
- var othIsDefined = other !== void 0, othIsNull = other === null, othIsReflexive = other === other, othIsSymbol = isSymbol(other);
1424
- if (!othIsNull && !othIsSymbol && !valIsSymbol && value > other || valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol || valIsNull && othIsDefined && othIsReflexive || !valIsDefined && othIsReflexive || !valIsReflexive) {
1425
- return 1;
1426
- }
1427
- if (!valIsNull && !valIsSymbol && !othIsSymbol && value < other || othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol || othIsNull && valIsDefined && valIsReflexive || !othIsDefined && valIsReflexive || !othIsReflexive) {
1428
- return -1;
1429
- }
1430
- }
1431
- return 0;
1432
- }
1433
- function compareMultiple(object, other, orders) {
1434
- var index = -1, objCriteria = object.criteria, othCriteria = other.criteria, length = objCriteria.length, ordersLength = orders.length;
1435
- while (++index < length) {
1436
- var result = compareAscending(objCriteria[index], othCriteria[index]);
1437
- if (result) {
1438
- if (index >= ordersLength) {
1439
- return result;
1440
- }
1441
- var order = orders[index];
1442
- return result * (order == "desc" ? -1 : 1);
1443
- }
1444
- }
1445
- return object.index - other.index;
1446
- }
1447
- function baseOrderBy(collection, iteratees, orders) {
1448
- if (iteratees.length) {
1449
- iteratees = arrayMap(iteratees, function(iteratee) {
1450
- if (isArray(iteratee)) {
1451
- return function(value) {
1452
- return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);
1453
- };
1454
- }
1455
- return iteratee;
1456
- });
1457
- } else {
1458
- iteratees = [identity];
1459
- }
1460
- var index = -1;
1461
- iteratees = arrayMap(iteratees, baseUnary(baseIteratee));
1462
- var result = baseMap(collection, function(value, key, collection2) {
1463
- var criteria = arrayMap(iteratees, function(iteratee) {
1464
- return iteratee(value);
1465
- });
1466
- return { "criteria": criteria, "index": ++index, "value": value };
1467
- });
1468
- return baseSortBy(result, function(object, other) {
1469
- return compareMultiple(object, other, orders);
1470
- });
1471
- }
1472
- function orderBy(collection, iteratees, orders, guard) {
1473
- if (collection == null) {
1474
- return [];
1475
- }
1476
- if (!isArray(iteratees)) {
1477
- iteratees = iteratees == null ? [] : [iteratees];
1478
- }
1479
- orders = orders;
1480
- if (!isArray(orders)) {
1481
- orders = orders == null ? [] : [orders];
1482
- }
1483
- return baseOrderBy(collection, iteratees, orders);
1484
- }
1485
- const sizeClasses = {
1486
- sm: "h-8",
1487
- md: "h-10",
1488
- lg: "h-12",
1489
- xl: "h-16"
1490
- };
1491
- function useInputClasses({
1492
- size,
1493
- disabled,
1494
- labelScreenReaderOnly,
1495
- ring,
1496
- hasShadow,
1497
- hasFocusStyles,
1498
- type,
1499
- prefixHasBorder,
1500
- wrapperClass,
1501
- inputClass,
1502
- prefixClass,
1503
- suffixClass
1504
- }) {
1505
- const isDisabled = computed(() => (disabled == null ? void 0 : disabled.value) ?? false);
1506
- const isCheckbox = computed(() => (type == null ? void 0 : type.value) === "checkbox");
1507
- const isFocusStyles = computed(() => (hasFocusStyles == null ? void 0 : hasFocusStyles.value) !== false);
1508
- const labelClasses = computed(() => ({
1509
- "block text-sm font-medium text-gray-900": true,
1510
- "sr-only": labelScreenReaderOnly == null ? void 0 : labelScreenReaderOnly.value
1511
- }));
1512
- const wrapperClasses = computed(() => ({
1513
- "rounded border border-gray-300 overflow-hidden": true,
1514
- "cursor-not-allowed bg-gray-50 border-transparent": isDisabled.value,
1515
- "bg-white": !isDisabled.value,
1516
- "focus-within:border-primary-500 focus-within:outline-1 focus-within:outline focus-within:outline-primary-500": isFocusStyles.value,
1517
- "focus-within:ring-primary-500": ring == null ? void 0 : ring.value,
1518
- "shadow-sm focus-within:shadow-sm": hasShadow == null ? void 0 : hasShadow.value
1519
- }));
1520
- const inputClasses = computed(() => ({
1521
- "text-gray-900 text-sm block w-full border-0 focus:border-transparent focus:outline-0 focus:ring-0 bg-transparent": true,
1522
- "p-2": isCheckbox.value,
1523
- "px-4": !isCheckbox.value,
1524
- [sizeClasses[size.value]]: !isCheckbox.value,
1525
- "cursor-default": isDisabled.value
1526
- }));
1527
- const prefixClasses = computed(() => ({
1528
- "z-10 flex shrink-0 items-center": true,
1529
- "px-3": prefixHasBorder == null ? void 0 : prefixHasBorder.value,
1530
- "pl-3": !(prefixHasBorder == null ? void 0 : prefixHasBorder.value),
1531
- "border-r border-gray-300": prefixHasBorder == null ? void 0 : prefixHasBorder.value,
1532
- "border-none": !(prefixHasBorder == null ? void 0 : prefixHasBorder.value)
1533
- }));
1534
- const wrapperCombinedClasses = computed(() => cn(wrapperClasses.value, wrapperClass == null ? void 0 : wrapperClass.value));
1535
- const inputCombinedClasses = computed(() => cn(inputClasses.value, inputClass == null ? void 0 : inputClass.value));
1536
- const prefixCombinedClasses = computed(() => cn(prefixClasses.value, prefixClass == null ? void 0 : prefixClass.value));
1537
- const suffixCombinedClasses = computed(
1538
- () => cn(
1539
- "align-end z-10 flex shrink-0 items-center gap-2 border-l border-gray-300 px-4",
1540
- suffixClass == null ? void 0 : suffixClass.value
1541
- )
1542
- );
1543
- return {
1544
- wrapperClasses: wrapperCombinedClasses,
1545
- inputClasses: inputCombinedClasses,
1546
- prefixClasses: prefixCombinedClasses,
1547
- suffixClasses: suffixCombinedClasses,
1548
- labelClasses
1549
- };
1550
- }
1551
- const _hoisted_1$2 = ["data-testid"];
1552
- const _hoisted_2$1 = { class: "relative" };
1553
- const _hoisted_3$1 = { class: "relative grow" };
1554
- const _hoisted_4$1 = ["id", "disabled", "type", "value", "name", "form", "placeholder"];
1555
- const _hoisted_5$1 = ["id", "value", "disabled", "type", "name", "form", "placeholder"];
1556
- const _hoisted_6$1 = {
1557
- key: 1,
1558
- class: "mt-2 text-sm text-gray-500"
1559
- };
1560
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1561
- __name: "Input",
1562
- props: /* @__PURE__ */ mergeModels({
1563
- label: { default: "" },
1564
- labelScreenReaderOnly: { type: Boolean },
1565
- disabled: { type: Boolean, default: false },
1566
- type: { default: "text" },
1567
- asTextType: { type: Boolean, default: false },
1568
- size: { default: "md" },
1569
- prefixClass: {},
1570
- suffixClass: {},
1571
- wrapperClass: { default: "" },
1572
- inputClass: {},
1573
- rootClass: { default: "" },
1574
- required: { type: Boolean, default: false },
1575
- id: {},
1576
- checked: { type: Boolean },
1577
- value: {},
1578
- hasShadow: { type: Boolean, default: false },
1579
- hasFocusStyles: { type: Boolean, default: true },
1580
- form: {},
1581
- ring: { type: Boolean, default: true },
1582
- error: {},
1583
- name: {},
1584
- prefixHasBorder: { type: Boolean, default: true },
1585
- placeholder: {}
1586
- }, {
1587
- "modelValue": {},
1588
- "modelModifiers": {}
1589
- }),
1590
- emits: /* @__PURE__ */ mergeModels(["blur"], ["update:modelValue"]),
1591
- setup(__props) {
1592
- const props = __props;
1593
- const model = useModel(__props, "modelValue");
1594
- const bypassModel = props.type === "number" && props.asTextType;
1595
- const name = props.name ?? uniqueId("name");
1596
- const handleUpdateModel = (event) => {
1597
- if (!bypassModel) return;
1598
- model.value = event.target.value;
1599
- };
1600
- const inputId = props.id ?? uniqueId(`${name}-`);
1601
- const handleScroll = (event) => {
1602
- if (props.type === "number") {
1603
- const el = event.target;
1604
- el.blur();
1605
- }
1606
- };
1607
- const { wrapperClasses, inputClasses, labelClasses, prefixClasses, suffixClasses } = useInputClasses(toRefs(props));
1608
- return (_ctx, _cache) => {
1609
- return openBlock(), createElementBlock("div", {
1610
- class: normalizeClass(__props.rootClass),
1611
- "data-testid": unref(getRootTestId)(unref(name))
1612
- }, [
1613
- __props.label ? (openBlock(), createBlock(_sfc_main$8, {
1614
- key: 0,
1615
- class: normalizeClass(unref(labelClasses)),
1616
- for: unref(inputId),
1617
- required: __props.required
1618
- }, createSlots({
1619
- suffix: withCtx(() => [
1620
- renderSlot(_ctx.$slots, "label-suffix")
1621
- ]),
1622
- default: withCtx(() => [
1623
- createTextVNode(toDisplayString(__props.label) + " ", 1)
1624
- ]),
1625
- _: 2
1626
- }, [
1627
- _ctx.$slots.tooltip ? {
1628
- name: "tooltip",
1629
- fn: withCtx(() => [
1630
- renderSlot(_ctx.$slots, "tooltip")
1631
- ]),
1632
- key: "0"
1633
- } : void 0
1634
- ]), 1032, ["class", "for", "required"])) : createCommentVNode("", true),
1635
- createElementVNode("div", _hoisted_2$1, [
1636
- createElementVNode("div", {
1637
- class: normalizeClass(["flex", unref(wrapperClasses)])
1638
- }, [
1639
- _ctx.$slots.prefix ? (openBlock(), createElementBlock("div", {
1640
- key: 0,
1641
- class: normalizeClass(unref(prefixClasses))
1642
- }, [
1643
- renderSlot(_ctx.$slots, "prefix")
1644
- ], 2)) : createCommentVNode("", true),
1645
- createElementVNode("div", _hoisted_3$1, [
1646
- unref(bypassModel) ? (openBlock(), createElementBlock("input", mergeProps({ key: 0 }, _ctx.$attrs, {
1647
- id: unref(inputId),
1648
- disabled: __props.disabled,
1649
- type: __props.type,
1650
- class: unref(inputClasses),
1651
- value: model.value,
1652
- name: unref(name),
1653
- form: __props.form,
1654
- placeholder: __props.placeholder,
1655
- autocomplete: "off",
1656
- onKeyup: handleUpdateModel,
1657
- onChange: handleUpdateModel,
1658
- onBlur: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("blur")),
1659
- onWheel: handleScroll
1660
- }), null, 16, _hoisted_4$1)) : withDirectives((openBlock(), createElementBlock("input", mergeProps({ key: 1 }, _ctx.$attrs, {
1661
- id: unref(inputId),
1662
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => model.value = $event),
1663
- value: __props.type === "checkbox" ? __props.value : model.value,
1664
- disabled: __props.disabled,
1665
- type: __props.type,
1666
- name: unref(name),
1667
- form: __props.form,
1668
- class: unref(inputClasses),
1669
- placeholder: __props.placeholder,
1670
- autocomplete: "off",
1671
- onBlur: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("blur")),
1672
- onWheel: handleScroll
1673
- }), null, 16, _hoisted_5$1)), [
1674
- [vModelDynamic, model.value]
1675
- ]),
1676
- renderSlot(_ctx.$slots, "input")
1677
- ]),
1678
- _ctx.$slots.suffix ? (openBlock(), createElementBlock("div", {
1679
- key: 1,
1680
- class: normalizeClass(unref(suffixClasses))
1681
- }, [
1682
- renderSlot(_ctx.$slots, "suffix")
1683
- ], 2)) : createCommentVNode("", true)
1684
- ], 2),
1685
- renderSlot(_ctx.$slots, "adornment-end")
1686
- ]),
1687
- !unref(isEmpty)(__props.error) || _ctx.$slots.helper ? (openBlock(), createElementBlock("div", _hoisted_6$1, [
1688
- !unref(isEmpty)(__props.error) ? (openBlock(), createBlock(_sfc_main$9, {
1689
- key: 0,
1690
- message: __props.error
1691
- }, null, 8, ["message"])) : _ctx.$slots.helper ? renderSlot(_ctx.$slots, "helper", { key: 1 }) : createCommentVNode("", true)
1692
- ])) : createCommentVNode("", true)
1693
- ], 10, _hoisted_1$2);
1694
- };
1695
- }
1696
- });
1697
- const _hoisted_1$1 = { class: "flex flex-col gap-2" };
1698
- const _hoisted_2 = ["aria-expanded"];
1699
- const _hoisted_3 = { class: "flex items-center gap-2" };
1700
- const _hoisted_4 = { key: 0 };
1701
- const _hoisted_5 = { class: "flex items-center gap-2" };
1702
- const _hoisted_6 = {
1703
- key: 0,
1704
- class: "flex flex-wrap gap-2"
1705
- };
1706
- const _hoisted_7 = ["innerHTML"];
1707
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1708
- __name: "SearchSelectInput",
1709
- props: /* @__PURE__ */ mergeModels({
1710
- addOnly: { type: Boolean, default: false },
1711
- disabled: { type: Boolean },
1712
- i18n: {},
1713
- label: {},
1714
- labelScreenReaderOnly: { type: Boolean },
1715
- singleModelValue: {},
1716
- multiModelValue: {},
1717
- options: { default: () => [] },
1718
- optionsOrder: { default: () => ["asc", "asc"] },
1719
- optionsOrderProperties: { default: () => ["group", "label"] },
1720
- required: { type: Boolean, default: false },
1721
- rootClass: {},
1722
- size: { default: "md" },
1723
- withChips: { type: Boolean, default: false },
1724
- chipColor: {},
1725
- error: {},
1726
- hasReset: { type: Boolean },
1727
- name: {},
1728
- hasLargeDropdown: { type: Boolean, default: false },
1729
- showSuffixInClosedInput: { type: Boolean },
1730
- showSuffixLabelInInput: { type: Boolean },
1731
- condensed: { type: Boolean },
1732
- form: {}
1733
- }, {
1734
- "search": { default: "" },
1735
- "searchModifiers": {}
1736
- }),
1737
- emits: /* @__PURE__ */ mergeModels(["update:singleModelValue", "update:multiModelValue", "blur", "change", "focus", "add-option"], ["update:search"]),
1738
- setup(__props, { expose: __expose, emit: __emit }) {
1739
- var _a;
1740
- const props = __props;
1741
- const teleportTarget = inject(SEARCH_SELECT_TELEPORT_TARGET);
1742
- const instanceProps = (_a = getCurrentInstance()) == null ? void 0 : _a.vnode.props;
1743
- const isHandlingSearchInternally = !(instanceProps == null ? void 0 : instanceProps["onUpdate:search"]);
1744
- const allowsMultipleValues = computed(() => Array.isArray(props.multiModelValue));
1745
- const initialValues = ref(props.singleModelValue);
1746
- const emit = __emit;
1747
- const singleModel = useVModel(props, "singleModelValue", emit);
1748
- const multiModel = useVModel(props, "multiModelValue", emit);
1749
- const unappliedMultiModel = ref(multiModel.value ?? []);
1750
- watch(
1751
- () => props.multiModelValue,
1752
- (value) => {
1753
- if (value) unappliedMultiModel.value = value;
1754
- }
1755
- );
1756
- const searchValue = useModel(__props, "search");
1757
- const derivedModel = computed({
1758
- get: () => {
1759
- if (allowsMultipleValues.value) {
1760
- return unappliedMultiModel.value ?? [];
1761
- }
1762
- if (typeof singleModel.value === "string") {
1763
- return [singleModel.value];
1764
- }
1765
- return [];
1766
- },
1767
- set(value) {
1768
- if (allowsMultipleValues.value) {
1769
- unappliedMultiModel.value = value;
1770
- } else {
1771
- singleModel.value = (value == null ? void 0 : value[0]) ?? "";
1772
- }
1773
- }
1774
- });
1775
- const selectedOptions = computed(
1776
- () => parsedOptions.value.filter((option) => {
1777
- var _a2;
1778
- return (_a2 = derivedModel.value) == null ? void 0 : _a2.includes(option.value);
1779
- })
1780
- );
1781
- const firstSelectedOption = computed(() => selectedOptions.value[0]);
1782
- const isMounted = useIsMounted();
1783
- const isOpen = ref(false);
1784
- const optionsRef = ref();
1785
- const wrapperRef = ref();
1786
- const inputRef = ref();
1787
- const getFocusableElements = () => {
1788
- if (!optionsRef.value) return [];
1789
- return Array.from(
1790
- optionsRef.value.querySelectorAll('li[tabindex="0"], button:not([disabled])')
1791
- );
1792
- };
1793
- const getDeepActiveElement = () => {
1794
- var _a2;
1795
- let active = document.activeElement;
1796
- while ((_a2 = active == null ? void 0 : active.shadowRoot) == null ? void 0 : _a2.activeElement) {
1797
- active = active.shadowRoot.activeElement;
1798
- }
1799
- return active;
1800
- };
1801
- const getInputElement = () => {
1802
- if (!wrapperRef.value) return null;
1803
- let input = wrapperRef.value.querySelector("input");
1804
- if (input) return input;
1805
- const shadowRoots = wrapperRef.value.querySelectorAll("*");
1806
- for (const el of shadowRoots) {
1807
- if (el.shadowRoot) {
1808
- input = el.shadowRoot.querySelector("input");
1809
- if (input) return input;
1810
- }
1811
- }
1812
- return null;
1813
- };
1814
- const handleWrapperKeyDown = (event) => {
1815
- var _a2, _b;
1816
- if (!isOpen.value) return;
1817
- const focusableElements = getFocusableElements();
1818
- const input = getInputElement();
1819
- const activeElement = getDeepActiveElement();
1820
- const isInputFocused = activeElement === input;
1821
- if (!isInputFocused) return;
1822
- switch (event.key) {
1823
- case "ArrowDown":
1824
- if (focusableElements.length > 0) {
1825
- event.preventDefault();
1826
- (_a2 = focusableElements[0]) == null ? void 0 : _a2.focus();
1827
- }
1828
- break;
1829
- case "Tab":
1830
- if (!event.shiftKey && focusableElements.length > 0) {
1831
- event.preventDefault();
1832
- (_b = focusableElements[0]) == null ? void 0 : _b.focus();
1833
- }
1834
- break;
1835
- case "Escape":
1836
- event.preventDefault();
1837
- close();
1838
- searchValue.value = "";
1839
- break;
1840
- }
1841
- };
1842
- const handleOptionsKeyDown = (event) => {
1843
- var _a2, _b, _c, _d;
1844
- const focusableElements = getFocusableElements();
1845
- const activeElement = getDeepActiveElement();
1846
- const currentIndex = focusableElements.indexOf(activeElement);
1847
- const input = getInputElement();
1848
- switch (event.key) {
1849
- case "ArrowDown":
1850
- if (currentIndex < focusableElements.length - 1) {
1851
- event.preventDefault();
1852
- (_a2 = focusableElements[currentIndex + 1]) == null ? void 0 : _a2.focus();
1853
- }
1854
- break;
1855
- case "ArrowUp":
1856
- event.preventDefault();
1857
- if (currentIndex <= 0) {
1858
- input == null ? void 0 : input.focus();
1859
- } else {
1860
- (_b = focusableElements[currentIndex - 1]) == null ? void 0 : _b.focus();
1861
- }
1862
- break;
1863
- case "Tab":
1864
- if (event.shiftKey) {
1865
- if (currentIndex <= 0) {
1866
- event.preventDefault();
1867
- input == null ? void 0 : input.focus();
1868
- } else {
1869
- event.preventDefault();
1870
- (_c = focusableElements[currentIndex - 1]) == null ? void 0 : _c.focus();
1871
- }
1872
- } else {
1873
- if (currentIndex >= focusableElements.length - 1) {
1874
- event.preventDefault();
1875
- close();
1876
- searchValue.value = "";
1877
- input == null ? void 0 : input.focus();
1878
- } else {
1879
- event.preventDefault();
1880
- (_d = focusableElements[currentIndex + 1]) == null ? void 0 : _d.focus();
1881
- }
1882
- }
1883
- break;
1884
- case "Escape":
1885
- event.preventDefault();
1886
- close();
1887
- searchValue.value = "";
1888
- nextTick(() => {
1889
- input == null ? void 0 : input.focus();
1890
- });
1891
- break;
1892
- }
1893
- };
1894
- const { floatingStyles } = useFloating(wrapperRef, optionsRef, {
1895
- whileElementsMounted: autoUpdate,
1896
- placement: "bottom",
1897
- middleware: [
1898
- offset(4),
1899
- flip({
1900
- mainAxis: true
1901
- })
1902
- ]
1903
- });
1904
- const { width } = useElementSize(wrapperRef);
1905
- const isDisabled = (value) => {
1906
- var _a2;
1907
- return props.disabled || !props.disabled && props.addOnly && !!((_a2 = initialValues.value) == null ? void 0 : _a2.includes(value));
1908
- };
1909
- const parsedOptions = computed(() => {
1910
- const options = props.options.map((option) => ({
1911
- ...option,
1912
- checked: derivedModel.value.includes(option.value),
1913
- disabled: option.disabled ?? isDisabled(option.value)
1914
- }));
1915
- const optionsWithSelectedItem = [
1916
- ...options,
1917
- ...searchValue.value.length === 0 && memoryCachedSelectedOptions.value ? memoryCachedSelectedOptions.value.filter(
1918
- (selectedOption) => !options.some((option) => option.value === selectedOption.value)
1919
- ) : []
1920
- ];
1921
- return props.optionsOrderProperties && !isEmpty(props.optionsOrderProperties) ? orderBy(optionsWithSelectedItem, props.optionsOrderProperties, props.optionsOrder) : optionsWithSelectedItem;
1922
- });
1923
- const getSelectedItems = (selectedValue) => parsedOptions.value.filter((option) => selectedValue.some((value) => option.value === value));
1924
- const selectedItems = computed(() => getSelectedItems(derivedModel.value));
1925
- const firstSelectedItem = computed(() => selectedItems.value[0]);
1926
- const memoryCachedSelectedOptions = ref([]);
1927
- const handleChange = ({
1928
- value,
1929
- checked
1930
- }) => {
1931
- let updatedValue;
1932
- if (allowsMultipleValues.value) {
1933
- updatedValue = checked ? [...derivedModel.value, value] : derivedModel.value.filter((selectedValue) => selectedValue !== value);
1934
- } else {
1935
- updatedValue = [value];
1936
- isOpen.value = false;
1937
- searchValue.value = "";
1938
- }
1939
- memoryCachedSelectedOptions.value = getSelectedItems(updatedValue);
1940
- derivedModel.value = updatedValue;
1941
- emit("change");
1942
- };
1943
- const canReset = computed(
1944
- () => derivedModel.value.length > 0 && !props.disabled && !(derivedModel.value.length === 1 && derivedModel.value[0] === "")
1945
- );
1946
- const reset = () => {
1947
- derivedModel.value = [];
1948
- unappliedMultiModel.value = [];
1949
- };
1950
- const handleClear = () => {
1951
- searchValue.value = "";
1952
- };
1953
- const filteredOptions = computed(() => {
1954
- if (!isHandlingSearchInternally) {
1955
- return parsedOptions.value;
1956
- }
1957
- return parsedOptions.value.filter((option) => {
1958
- const escapedUserInput = escapeUserInput(searchValue.value.toLowerCase());
1959
- if (option.searchValues) {
1960
- return option.searchValues.some(
1961
- (value) => value.toLowerCase().match(escapedUserInput)
1962
- );
1963
- }
1964
- return (option.label ?? "").toLowerCase().match(escapedUserInput);
1965
- });
1966
- });
1967
- const close = () => {
1968
- if (allowsMultipleValues.value) {
1969
- multiModel.value = unappliedMultiModel.value;
1970
- }
1971
- isOpen.value = false;
1972
- };
1973
- watch(unappliedMultiModel, () => {
1974
- if (!isOpen.value && !isEqual(multiModel.value, unappliedMultiModel.value) && allowsMultipleValues.value) {
1975
- multiModel.value = unappliedMultiModel.value;
1976
- }
1977
- });
1978
- const handleClickOutside = (event) => {
1979
- const path = event.composedPath();
1980
- if (optionsRef.value && path.includes(optionsRef.value) || wrapperRef.value && path.includes(wrapperRef.value)) {
1981
- return;
1982
- }
1983
- if (isOpen.value) {
1984
- close();
1985
- searchValue.value = "";
1986
- }
1987
- };
1988
- useEventListener("mousedown", handleClickOutside);
1989
- const placeholder = computed(() => {
1990
- var _a2, _b, _c, _d, _e, _f;
1991
- if (allowsMultipleValues.value && isOpen.value) {
1992
- return ((_a2 = props.i18n) == null ? void 0 : _a2.placeholderSearch) ?? "Search";
1993
- }
1994
- if (allowsMultipleValues.value && selectedItems.value.length === 1) {
1995
- return (_b = firstSelectedItem.value) == null ? void 0 : _b.label;
1996
- }
1997
- if (allowsMultipleValues.value && selectedItems.value.length >= 2) {
1998
- return `${(_c = firstSelectedItem.value) == null ? void 0 : _c.label} +${selectedItems.value.length - 1}`;
1999
- }
2000
- if (!singleModel.value && !firstSelectedItem.value) {
2001
- return ((_d = props.i18n) == null ? void 0 : _d.placeholderDefault) ?? "Select an option";
2002
- } else if (isOpen.value) {
2003
- return ((_e = props.i18n) == null ? void 0 : _e.placeholderSearch) ?? "Search";
2004
- }
2005
- if (!props.singleModelValue && !firstSelectedItem.value) {
2006
- return "";
2007
- }
2008
- return (_f = parsedOptions.value.find((option) => {
2009
- var _a3;
2010
- return option.value === ((_a3 = firstSelectedOption.value) == null ? void 0 : _a3.value);
2011
- })) == null ? void 0 : _f.label;
2012
- });
2013
- const isSearchEmpty = computed(() => searchValue.value === "");
2014
- const hasAddOptionListener = !!(instanceProps == null ? void 0 : instanceProps["onAddOption"]);
2015
- const onAddOption = () => {
2016
- emit("add-option");
2017
- close();
2018
- };
2019
- const hasPrefixComponent = computed(
2020
- () => {
2021
- var _a2;
2022
- return !isOpen.value && !allowsMultipleValues.value && ((_a2 = firstSelectedItem.value) == null ? void 0 : _a2.labelPrefixComponent);
2023
- }
2024
- );
2025
- const optionsId = `search-select-options-${Math.random().toString(36).substring(2, 9)}`;
2026
- __expose({
2027
- flushMemoryCachedSelectedOptions: () => memoryCachedSelectedOptions.value = []
2028
- });
2029
- return (_ctx, _cache) => {
2030
- var _a2, _b, _c;
2031
- return openBlock(), createElementBlock(Fragment, null, [
2032
- createElementVNode("div", _hoisted_1$1, [
2033
- createElementVNode("div", {
2034
- ref_key: "wrapperRef",
2035
- ref: wrapperRef,
2036
- class: normalizeClass(["relative flex items-end", {
2037
- [`${__props.rootClass}`]: __props.rootClass,
2038
- "z-30": isOpen.value
2039
- }]),
2040
- role: "combobox",
2041
- "aria-expanded": isOpen.value,
2042
- "aria-haspopup": true,
2043
- "aria-controls": optionsId,
2044
- onKeydown: handleWrapperKeyDown
2045
- }, [
2046
- createVNode(unref(_sfc_main$3), {
2047
- ref_key: "inputRef",
2048
- ref: inputRef,
2049
- modelValue: searchValue.value,
2050
- "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => searchValue.value = $event),
2051
- required: __props.required,
2052
- label: __props.label,
2053
- name: __props.name,
2054
- form: __props.form,
2055
- "label-screen-reader-only": __props.labelScreenReaderOnly,
2056
- placeholder: placeholder.value,
2057
- class: normalizeClass(["grow", {
2058
- "placeholder:text-gray-900": !isOpen.value && (!allowsMultipleValues.value && unref(singleModel) || allowsMultipleValues.value && !unref(isEmpty)(__props.multiModelValue))
2059
- }]),
2060
- "wrapper-class": {
2061
- "border-transparent border border-b-gray-200 focus-within:border-b relative z-10 rounded-b-none": isOpen.value
2062
- },
2063
- "suffix-class": "border-l-0 pl-0",
2064
- disabled: __props.disabled,
2065
- size: __props.size,
2066
- error: __props.error,
2067
- "prefix-has-border": !hasPrefixComponent.value,
2068
- "aria-autocomplete": "list",
2069
- onFocus: _cache[3] || (_cache[3] = () => isOpen.value = true),
2070
- onBlur: _cache[4] || (_cache[4] = ($event) => _ctx.$emit("blur"))
2071
- }, createSlots({
2072
- "label-suffix": withCtx(() => [
2073
- renderSlot(_ctx.$slots, "label-suffix")
2074
- ]),
2075
- suffix: withCtx(() => {
2076
- var _a3, _b2;
2077
- return [
2078
- createElementVNode("div", _hoisted_5, [
2079
- !isOpen.value && !allowsMultipleValues.value && ((_a3 = firstSelectedItem.value) == null ? void 0 : _a3.labelInlineComponent) && (!__props.showSuffixInClosedInput || __props.showSuffixLabelInInput) ? (openBlock(), createBlock(resolveDynamicComponent(firstSelectedItem.value.labelInlineComponent.component), normalizeProps(mergeProps({ key: 0 }, firstSelectedItem.value.labelInlineComponent.props)), null, 16)) : createCommentVNode("", true),
2080
- !isOpen.value && !allowsMultipleValues.value && ((_b2 = firstSelectedItem.value) == null ? void 0 : _b2.labelSuffixComponent) && __props.showSuffixInClosedInput ? (openBlock(), createBlock(resolveDynamicComponent(firstSelectedItem.value.labelSuffixComponent.component), normalizeProps(mergeProps({ key: 1 }, firstSelectedItem.value.labelSuffixComponent.props)), null, 16)) : createCommentVNode("", true),
2081
- canReset.value && __props.hasReset ? (openBlock(), createBlock(_sfc_main$a, {
2082
- key: 2,
2083
- icon: "close",
2084
- size: "sm",
2085
- variant: "ghost",
2086
- color: "gray",
2087
- type: "button",
2088
- onMousedown: _cache[0] || (_cache[0] = withModifiers(() => {
2089
- }, ["prevent"])),
2090
- onClick: reset
2091
- })) : createCommentVNode("", true),
2092
- !isSearchEmpty.value ? (openBlock(), createBlock(_sfc_main$a, {
2093
- key: 3,
2094
- icon: "close",
2095
- size: "sm",
2096
- variant: "ghost",
2097
- color: "gray",
2098
- type: "button",
2099
- onClick: handleClear
2100
- })) : createCommentVNode("", true),
2101
- createVNode(_sfc_main$a, {
2102
- class: "-mr-3",
2103
- icon: isOpen.value ? "keyboard_arrow_up" : "keyboard_arrow_down",
2104
- size: "sm",
2105
- variant: "ghost",
2106
- color: "gray",
2107
- type: "button",
2108
- disabled: __props.disabled,
2109
- onClick: _cache[1] || (_cache[1] = ($event) => isOpen.value = !isOpen.value)
2110
- }, null, 8, ["icon", "disabled"])
2111
- ])
2112
- ];
2113
- }),
2114
- _: 2
2115
- }, [
2116
- _ctx.$slots.tooltip ? {
2117
- name: "tooltip",
2118
- fn: withCtx(() => [
2119
- renderSlot(_ctx.$slots, "tooltip")
2120
- ]),
2121
- key: "0"
2122
- } : void 0,
2123
- hasPrefixComponent.value || !isHandlingSearchInternally ? {
2124
- name: "prefix",
2125
- fn: withCtx(() => {
2126
- var _a3;
2127
- return [
2128
- createElementVNode("div", _hoisted_3, [
2129
- hasPrefixComponent.value && ((_a3 = firstSelectedItem.value) == null ? void 0 : _a3.labelPrefixComponent) ? (openBlock(), createElementBlock("div", _hoisted_4, [
2130
- (openBlock(), createBlock(resolveDynamicComponent(firstSelectedItem.value.labelPrefixComponent.component), normalizeProps(guardReactiveProps(firstSelectedItem.value.labelPrefixComponent.props)), null, 16))
2131
- ])) : !isHandlingSearchInternally ? (openBlock(), createBlock(_sfc_main$b, {
2132
- key: 1,
2133
- icon: "search",
2134
- size: "sm"
2135
- })) : createCommentVNode("", true)
2136
- ])
2137
- ];
2138
- }),
2139
- key: "1"
2140
- } : void 0,
2141
- _ctx.$slots.helper ? {
2142
- name: "helper",
2143
- fn: withCtx(() => [
2144
- renderSlot(_ctx.$slots, "helper")
2145
- ]),
2146
- key: "2"
2147
- } : void 0
2148
- ]), 1032, ["modelValue", "required", "label", "name", "form", "label-screen-reader-only", "placeholder", "wrapper-class", "class", "disabled", "size", "error", "prefix-has-border"])
2149
- ], 42, _hoisted_2),
2150
- __props.withChips ? (openBlock(), createElementBlock("div", _hoisted_6, [
2151
- (openBlock(true), createElementBlock(Fragment, null, renderList(selectedItems.value, ({ value, label }) => {
2152
- return openBlock(), createBlock(_sfc_main$c, {
2153
- key: value,
2154
- removable: !isDisabled(value),
2155
- color: __props.chipColor,
2156
- onRemoved: ($event) => handleChange({ value, checked: false })
2157
- }, {
2158
- default: withCtx(() => [
2159
- createElementVNode("span", { innerHTML: label }, null, 8, _hoisted_7)
2160
- ]),
2161
- _: 2
2162
- }, 1032, ["removable", "color", "onRemoved"]);
2163
- }), 128))
2164
- ])) : createCommentVNode("", true)
2165
- ]),
2166
- unref(isMounted) && unref(teleportTarget) ? (openBlock(), createBlock(Teleport, {
2167
- key: 0,
2168
- to: unref(teleportTarget)
2169
- }, [
2170
- isOpen.value && !__props.disabled ? (openBlock(), createElementBlock("div", {
2171
- key: 0,
2172
- id: optionsId,
2173
- ref_key: "optionsRef",
2174
- ref: optionsRef,
2175
- role: "listbox",
2176
- style: normalizeStyle(unref(floatingStyles)),
2177
- class: "z-70 rounded border border-gray-200 bg-white drop-shadow-md",
2178
- onMouseenter: _cache[5] || (_cache[5] = ($event) => isOpen.value = true),
2179
- onKeydown: handleOptionsKeyDown
2180
- }, [
2181
- createElementVNode("div", {
2182
- class: "rounded pt-0",
2183
- style: normalizeStyle({ width: `${unref(width)}px` })
2184
- }, [
2185
- createVNode(_sfc_main$4, {
2186
- i18n: {
2187
- addOnly: (_a2 = __props.i18n) == null ? void 0 : _a2.addOnly,
2188
- noResults: (_b = __props.i18n) == null ? void 0 : _b.noResults,
2189
- noOptionsAvailable: (_c = __props.i18n) == null ? void 0 : _c.noOptionsAvailable
2190
- },
2191
- options: filteredOptions.value,
2192
- multiple: allowsMultipleValues.value,
2193
- search: searchValue.value,
2194
- model: derivedModel.value,
2195
- "add-only": __props.addOnly,
2196
- "allows-multiple-values": !!allowsMultipleValues.value,
2197
- condensed: __props.condensed,
2198
- "has-large-dropdown": __props.hasLargeDropdown,
2199
- onValueChanged: handleChange
2200
- }, {
2201
- "list-footer-content": withCtx(() => [
2202
- hasAddOptionListener ? (openBlock(), createBlock(_sfc_main$d, {
2203
- key: 0,
2204
- variant: "ghost",
2205
- class: "w-full rounded-t-none",
2206
- type: "button",
2207
- "icon-prefix": "add",
2208
- onClick: onAddOption
2209
- }, {
2210
- default: withCtx(() => {
2211
- var _a3;
2212
- return [
2213
- createTextVNode(toDisplayString((_a3 = __props.i18n) == null ? void 0 : _a3.addOption), 1)
2214
- ];
2215
- }),
2216
- _: 1
2217
- })) : createCommentVNode("", true),
2218
- allowsMultipleValues.value ? (openBlock(), createElementBlock("div", {
2219
- key: 1,
2220
- class: normalizeClass(["flex items-center justify-between", { "py-2": !_ctx.$slots["list-footer-content"] }])
2221
- }, [
2222
- canReset.value ? (openBlock(), createBlock(_sfc_main$d, {
2223
- key: 0,
2224
- type: "button",
2225
- variant: "ghost",
2226
- size: "sm",
2227
- class: "ml-2",
2228
- onClick: reset
2229
- }, {
2230
- default: withCtx(() => {
2231
- var _a3;
2232
- return [
2233
- createTextVNode(toDisplayString(((_a3 = __props.i18n) == null ? void 0 : _a3.multipleValuesClearButtonText) ?? "Clear"), 1)
2234
- ];
2235
- }),
2236
- _: 1
2237
- })) : createCommentVNode("", true),
2238
- createElementVNode("div", null, [
2239
- renderSlot(_ctx.$slots, "list-footer-content", { close })
2240
- ]),
2241
- createVNode(_sfc_main$d, {
2242
- type: "button",
2243
- size: "sm",
2244
- class: "mr-2",
2245
- "data-testid": unref(DONE_BUTTON_TEST_ID),
2246
- onClick: close
2247
- }, {
2248
- default: withCtx(() => {
2249
- var _a3;
2250
- return [
2251
- createTextVNode(toDisplayString(((_a3 = __props.i18n) == null ? void 0 : _a3.multipleValuesDoneButtonText) ?? "Done"), 1)
2252
- ];
2253
- }),
2254
- _: 1
2255
- }, 8, ["data-testid"])
2256
- ], 2)) : renderSlot(_ctx.$slots, "list-footer-content", {
2257
- key: 2,
2258
- close
2259
- })
2260
- ]),
2261
- _: 3
2262
- }, 8, ["i18n", "options", "multiple", "search", "model", "add-only", "allows-multiple-values", "condensed", "has-large-dropdown"])
2263
- ], 4)
2264
- ], 36)) : createCommentVNode("", true)
2265
- ], 8, ["to"])) : createCommentVNode("", true)
2266
- ], 64);
2267
- };
2268
- }
2269
- });
2270
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
2271
- __name: "CountrySelect",
2272
- props: {
2273
- label: {},
2274
- singleModelValue: {},
2275
- multiModelValue: {},
2276
- error: {},
2277
- required: { type: Boolean, default: true },
2278
- hasReset: { type: Boolean },
2279
- disabled: { type: Boolean },
2280
- name: {},
2281
- form: {}
2282
- },
2283
- emits: ["update:modelValue", "update:singleModelValue"],
2284
- setup(__props, { emit: __emit }) {
2285
- const props = __props;
2286
- const singleModel = useVModel(props, "singleModelValue");
2287
- const multiModel = useVModel(props, "multiModelValue");
2288
- const emit = __emit;
2289
- return (_ctx, _cache) => {
2290
- return openBlock(), createBlock(_sfc_main$2, {
2291
- "multi-model-value": unref(multiModel),
2292
- "onUpdate:multiModelValue": _cache[0] || (_cache[0] = ($event) => isRef(multiModel) ? multiModel.value = $event : null),
2293
- "single-model-value": unref(singleModel),
2294
- "onUpdate:singleModelValue": [
2295
- _cache[1] || (_cache[1] = ($event) => isRef(singleModel) ? singleModel.value = $event : null),
2296
- _cache[2] || (_cache[2] = (value) => {
2297
- emit("update:modelValue", value);
2298
- })
2299
- ],
2300
- "root-class": _ctx.$attrs.class,
2301
- label: __props.label,
2302
- options: unref(countryData).map(({ key, value }) => ({ label: value, value: key })),
2303
- error: __props.error,
2304
- "has-reset": __props.hasReset,
2305
- disabled: __props.disabled,
2306
- required: __props.required,
2307
- "with-chips": !!__props.multiModelValue,
2308
- name: __props.name,
2309
- form: __props.form
2310
- }, {
2311
- "label-suffix": withCtx(() => [
2312
- renderSlot(_ctx.$slots, "label-suffix")
2313
- ]),
2314
- _: 3
2315
- }, 8, ["multi-model-value", "single-model-value", "root-class", "label", "options", "error", "has-reset", "disabled", "required", "with-chips", "name", "form"]);
2316
- };
2317
- }
2318
- });
2319
- const defaultLabelClassesObj = {
2320
- "w-fit": true,
2321
- "relative": true,
2322
- "inline-flex": true,
2323
- "items-center": true
2324
- };
2325
- const defaultToggleBallClasses = "grow text-sm font-medium text-gray-900";
2326
- const toggleSizeClasses = {
2327
- xl: "w-16 h-8 after:top-0.5 after:left-0.5 after:h-7 after:w-7",
2328
- lg: "w-14 h-7 after:top-0.5 after:left-0.5 after:h-6 after:w-6",
2329
- md: "w-11 h-6 after:top-0.5 after:left-0.5 after:h-5 after:w-5",
2330
- sm: "w-9 h-5 after:top-0.5 after:left-0.5 after:h-4 after:w-4",
2331
- xs: "w-7 h-4 after:top-0.5 after:left-0.5 after:h-3 after:w-3"
2332
- };
2333
- const toggleColorClasses = {
2334
- red: "peer-focus:ring-red-300 peer-checked:bg-red-600",
2335
- green: "peer-focus:ring-green-300 peer-checked:bg-green-600",
2336
- purple: "peer-focus:ring-purple-300 peer-checked:bg-purple-600",
2337
- yellow: "peer-focus:ring-yellow-300 peer-checked:bg-yellow-400",
2338
- teal: "peer-focus:ring-teal-300 peer-checked:bg-teal-600",
2339
- orange: "peer-focus:ring-orange-300 peer-checked:bg-orange-500"
2340
- };
2341
- const useToggleClasses = (props) => {
2342
- const labelClasses = computed(() => {
2343
- var _a, _b;
2344
- return {
2345
- ...defaultLabelClassesObj,
2346
- "cursor-pointer": !((_a = props.disabled) == null ? void 0 : _a.value),
2347
- "cursor-default": !!((_b = props.disabled) == null ? void 0 : _b.value)
2348
- };
2349
- });
2350
- const toggleClasses = computed(() => {
2351
- var _a, _b;
2352
- return {
2353
- 'peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[""] after:absolute after:top-0.5 after:left-0.5 after:border-gray-300 after:border after:rounded-full after:transition-all': true,
2354
- "bg-gray-200 peer-checked:bg-primary-600 after:bg-white": !((_a = props.disabled) == null ? void 0 : _a.value),
2355
- "bg-gray-100 peer-checked:bg-primary-200 after:bg-gray-200": (_b = props.disabled) == null ? void 0 : _b.value
2356
- };
2357
- });
2358
- const toggleSize = computed(() => toggleSizeClasses[props.size.value]);
2359
- const toggleColor = computed(() => toggleColorClasses[props.color.value]);
2360
- const toggleBallClasses = computed(() => defaultToggleBallClasses);
2361
- return {
2362
- labelClasses,
2363
- toggleSize,
2364
- toggleClasses,
2365
- toggleColor,
2366
- toggleBallClasses
2367
- };
2368
- };
2369
- const _hoisted_1 = ["disabled"];
2370
- const _sfc_main = /* @__PURE__ */ defineComponent({
2371
- __name: "Toggle",
2372
- props: {
2373
- modelValue: { type: Boolean, default: false },
2374
- labelPosition: { default: "after" },
2375
- size: { default: "md" },
2376
- disabled: { type: Boolean, default: false },
2377
- color: { default: "" },
2378
- hasBackground: { type: Boolean, default: false },
2379
- noSpacing: { type: Boolean, default: false }
2380
- },
2381
- emits: ["update:modelValue"],
2382
- setup(__props, { emit: __emit }) {
2383
- const props = __props;
2384
- const emit = __emit;
2385
- const model = computed({
2386
- get() {
2387
- return props.modelValue;
2388
- },
2389
- set(val) {
2390
- emit("update:modelValue", val);
2391
- }
2392
- });
2393
- const { labelClasses, toggleSize, toggleClasses, toggleColor, toggleBallClasses } = useToggleClasses(toRefs(props));
2394
- return (_ctx, _cache) => {
2395
- return openBlock(), createElementBlock("label", {
2396
- class: normalizeClass(["inline-flex items-center gap-1.5", {
2397
- "flex-row-reverse": __props.labelPosition === "before",
2398
- "rounded bg-gray-50 border-l-4 border-gray-200": __props.hasBackground,
2399
- "p-2": !__props.noSpacing
2400
- }]),
2401
- onClick: _cache[1] || (_cache[1] = withModifiers(() => {
2402
- }, ["stop"]))
2403
- }, [
2404
- createElementVNode("div", {
2405
- class: normalizeClass(unref(labelClasses))
2406
- }, [
2407
- withDirectives(createElementVNode("input", {
2408
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event),
2409
- disabled: __props.disabled,
2410
- class: "sr-only peer",
2411
- type: "checkbox"
2412
- }, null, 8, _hoisted_1), [
2413
- [vModelCheckbox, model.value]
2414
- ]),
2415
- createElementVNode("span", {
2416
- class: normalizeClass([unref(toggleClasses), unref(toggleSize), unref(toggleColor)])
2417
- }, null, 2)
2418
- ], 2),
2419
- _ctx.$slots["inline-label"] ? (openBlock(), createElementBlock("span", {
2420
- key: 0,
2421
- class: normalizeClass(unref(toggleBallClasses))
2422
- }, [
2423
- renderSlot(_ctx.$slots, "inline-label")
2424
- ], 2)) : createCommentVNode("", true)
2425
- ], 2);
2426
- };
2427
- }
2428
- });
2429
- const req = (value) => {
2430
- value = unref(value);
2431
- if (Array.isArray(value)) return !!value.length;
2432
- if (value === void 0 || value === null) {
2433
- return false;
2434
- }
2435
- if (value === false) {
2436
- return true;
2437
- }
2438
- if (value instanceof Date) {
2439
- return !isNaN(value.getTime());
2440
- }
2441
- if (typeof value === "object") {
2442
- for (let _ in value) return true;
2443
- return false;
2444
- }
2445
- return !!String(value).length;
2446
- };
2447
- function regex() {
2448
- for (var _len = arguments.length, expr = new Array(_len), _key = 0; _key < _len; _key++) {
2449
- expr[_key] = arguments[_key];
2450
- }
2451
- return (value) => {
2452
- value = unref(value);
2453
- return !req(value) || expr.every((reg) => {
2454
- reg.lastIndex = 0;
2455
- return reg.test(value);
2456
- });
2457
- };
2458
- }
2459
- regex(/^[a-zA-Z]*$/);
2460
- regex(/^[a-zA-Z0-9]*$/);
2461
- regex(/^\d*(\.\d+)?$/);
2462
- const emailRegex = /^(?:[A-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[A-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9]{2,}(?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i;
2463
- var email$1 = regex(emailRegex);
2464
- var email = {
2465
- $validator: email$1,
2466
- $message: "Value is not a valid email address",
2467
- $params: {
2468
- type: "email"
2469
- }
2470
- };
2471
- function required$1(value) {
2472
- if (typeof value === "string") {
2473
- value = value.trim();
2474
- }
2475
- return req(value);
2476
- }
2477
- var required = {
2478
- $validator: required$1,
2479
- $message: "Value is required",
2480
- $params: {
2481
- type: "required"
2482
- }
2483
- };
2484
- const validate$1 = (prop, val) => prop ? req(typeof val === "string" ? val.trim() : val) : true;
2485
- function requiredIf$1(propOrFunction) {
2486
- return function(value, parentVM) {
2487
- if (typeof propOrFunction !== "function") {
2488
- return validate$1(unref(propOrFunction), value);
2489
- }
2490
- const result = propOrFunction.call(this, value, parentVM);
2491
- return validate$1(result, value);
2492
- };
2493
- }
2494
- function requiredIf(prop) {
2495
- return {
2496
- $validator: requiredIf$1(prop),
2497
- $message: "The value is required",
2498
- $params: {
2499
- type: "requiredIf",
2500
- prop
2501
- }
2502
- };
2503
- }
2504
- const urlRegex = /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i;
2505
- regex(urlRegex);
2506
- regex(/(^[0-9]*$)|(^-[0-9]+$)/);
2507
- regex(/^[-]?\d*(\.\d+)?$/);
2508
- export {
2509
- _sfc_main$3 as _,
2510
- _sfc_main$1 as a,
2511
- _sfc_main as b,
2512
- escapeUserInput as c,
2513
- _sfc_main$7 as d,
2514
- email as e,
2515
- useIsMounted as f,
2516
- requiredIf as g,
2517
- objectDiff as o,
2518
- required as r,
2519
- sortedUniqBy as s,
2520
- useValidation as u
2521
- };