kanto-ds 1.4.0 → 1.5.2

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 (130) hide show
  1. package/README.md +10 -10
  2. package/dist/chunks/{defaults-BwgjMcww.js → defaults-CFrjqae2.js} +22 -21
  3. package/dist/chunks/{defaults-BwgjMcww.js.map → defaults-CFrjqae2.js.map} +1 -1
  4. package/dist/chunks/events-r51msXNf.js +22 -0
  5. package/dist/chunks/{events-Bjl5Zmmq.js.map → events-r51msXNf.js.map} +1 -1
  6. package/dist/chunks/floating-B7_Dahpn.js +54 -0
  7. package/dist/chunks/floating-B7_Dahpn.js.map +1 -0
  8. package/dist/chunks/{form-control-CxjBTt1c.js → form-control-B74_EHtG.js} +7 -7
  9. package/dist/chunks/form-control-B74_EHtG.js.map +1 -0
  10. package/dist/chunks/{index-DSSLJirw.js → index-STEEvEP7.js} +24 -12
  11. package/dist/chunks/index-STEEvEP7.js.map +1 -0
  12. package/dist/chunks/kt-calendar-B_hFdD9V.js +640 -0
  13. package/dist/chunks/kt-calendar-B_hFdD9V.js.map +1 -0
  14. package/dist/chunks/{kt-element-E-tfJpGQ.js → kt-element-Djx2JcGl.js} +2 -2
  15. package/dist/chunks/{kt-element-E-tfJpGQ.js.map → kt-element-Djx2JcGl.js.map} +1 -1
  16. package/dist/chunks/{listbox-Sm3nvsC6.js → listbox-llcUu_V-.js} +18 -14
  17. package/dist/chunks/{listbox-Sm3nvsC6.js.map → listbox-llcUu_V-.js.map} +1 -1
  18. package/dist/chunks/locale-C5xLkGx5.js +14 -0
  19. package/dist/chunks/locale-C5xLkGx5.js.map +1 -0
  20. package/dist/chunks/position-Cx_ZH5zh.js +39 -0
  21. package/dist/chunks/position-Cx_ZH5zh.js.map +1 -0
  22. package/dist/components/core/kt-avatar/kt-avatar.js +2 -2
  23. package/dist/components/core/kt-badge/kt-badge.js +3 -3
  24. package/dist/components/core/kt-button/kt-button.js +1 -1
  25. package/dist/components/core/kt-card/kt-card.js +2 -2
  26. package/dist/components/core/kt-code/kt-code.js +3 -3
  27. package/dist/components/core/kt-icon/kt-icon.js +2 -2
  28. package/dist/components/core/kt-kbd/kt-kbd.js +1 -1
  29. package/dist/components/core/kt-split-button/kt-split-button.js +4 -4
  30. package/dist/components/data/kt-chart/kt-chart.js +3 -3
  31. package/dist/components/data/kt-meter/kt-meter.js +1 -1
  32. package/dist/components/data/kt-pagination/kt-pagination.js +3 -3
  33. package/dist/components/data/kt-stat/kt-stat.js +1 -1
  34. package/dist/components/data/kt-table/kt-table.d.ts +53 -3
  35. package/dist/components/data/kt-table/kt-table.js +286 -131
  36. package/dist/components/data/kt-table/kt-table.js.map +1 -1
  37. package/dist/components/data/kt-table/window.d.ts +19 -0
  38. package/dist/components/data/kt-timeline/kt-timeline.js +1 -1
  39. package/dist/components/feedback/kt-alert/kt-alert.js +3 -3
  40. package/dist/components/feedback/kt-empty-state/kt-empty-state.js +1 -1
  41. package/dist/components/feedback/kt-progress-bar/kt-progress-bar.js +10 -10
  42. package/dist/components/feedback/kt-progress-bar/kt-progress-bar.js.map +1 -1
  43. package/dist/components/feedback/kt-skeleton/kt-skeleton.js +1 -1
  44. package/dist/components/feedback/kt-toast/kt-toast.js +58 -42
  45. package/dist/components/feedback/kt-toast/kt-toast.js.map +1 -1
  46. package/dist/components/feedback/kt-toast-container/kt-toast-container.js +1 -1
  47. package/dist/components/feedback/kt-tooltip/kt-tooltip.d.ts +20 -0
  48. package/dist/components/feedback/kt-tooltip/kt-tooltip.js +95 -51
  49. package/dist/components/feedback/kt-tooltip/kt-tooltip.js.map +1 -1
  50. package/dist/components/forms/kt-calendar/kt-calendar.d.ts +96 -0
  51. package/dist/components/forms/kt-calendar/kt-calendar.js +13 -0
  52. package/dist/components/forms/kt-calendar/kt-calendar.js.map +1 -0
  53. package/dist/components/forms/kt-checkbox/kt-checkbox.d.ts +9 -0
  54. package/dist/components/forms/kt-checkbox/kt-checkbox.js +34 -20
  55. package/dist/components/forms/kt-checkbox/kt-checkbox.js.map +1 -1
  56. package/dist/components/forms/kt-date-picker/kt-date-picker.d.ts +105 -0
  57. package/dist/components/forms/kt-date-picker/kt-date-picker.js +382 -0
  58. package/dist/components/forms/kt-date-picker/kt-date-picker.js.map +1 -0
  59. package/dist/components/forms/kt-drag-drop/kt-drag-drop.d.ts +9 -0
  60. package/dist/components/forms/kt-drag-drop/kt-drag-drop.js +36 -22
  61. package/dist/components/forms/kt-drag-drop/kt-drag-drop.js.map +1 -1
  62. package/dist/components/forms/kt-form/kt-form.js +2 -2
  63. package/dist/components/forms/kt-input/kt-input.d.ts +37 -1
  64. package/dist/components/forms/kt-input/kt-input.js +380 -194
  65. package/dist/components/forms/kt-input/kt-input.js.map +1 -1
  66. package/dist/components/forms/kt-input-menu/kt-input-menu.d.ts +13 -0
  67. package/dist/components/forms/kt-input-menu/kt-input-menu.js +73 -42
  68. package/dist/components/forms/kt-input-menu/kt-input-menu.js.map +1 -1
  69. package/dist/components/forms/kt-label-input/kt-label-input.js +1 -1
  70. package/dist/components/forms/kt-radio-group/kt-radio-group.d.ts +9 -0
  71. package/dist/components/forms/kt-radio-group/kt-radio-group.js +67 -53
  72. package/dist/components/forms/kt-radio-group/kt-radio-group.js.map +1 -1
  73. package/dist/components/forms/kt-select/kt-select.d.ts +13 -0
  74. package/dist/components/forms/kt-select/kt-select.js +87 -56
  75. package/dist/components/forms/kt-select/kt-select.js.map +1 -1
  76. package/dist/components/forms/kt-textarea/kt-textarea.d.ts +9 -0
  77. package/dist/components/forms/kt-textarea/kt-textarea.js +28 -14
  78. package/dist/components/forms/kt-textarea/kt-textarea.js.map +1 -1
  79. package/dist/components/forms/kt-toggle/kt-toggle.d.ts +9 -0
  80. package/dist/components/forms/kt-toggle/kt-toggle.js +43 -29
  81. package/dist/components/forms/kt-toggle/kt-toggle.js.map +1 -1
  82. package/dist/components/navigation/kt-breadcrumb/kt-breadcrumb.js +3 -3
  83. package/dist/components/navigation/kt-header/kt-header.js +3 -3
  84. package/dist/components/navigation/kt-page-header/kt-page-header.js +1 -1
  85. package/dist/components/navigation/kt-segmented-control/kt-segmented-control.d.ts +9 -0
  86. package/dist/components/navigation/kt-segmented-control/kt-segmented-control.js +40 -22
  87. package/dist/components/navigation/kt-segmented-control/kt-segmented-control.js.map +1 -1
  88. package/dist/components/navigation/kt-sub-menu-navigation/kt-sub-menu-navigation.js +3 -3
  89. package/dist/components/navigation/kt-tabs/kt-tabs.js +2 -2
  90. package/dist/components/navigation/kt-toggle-button/kt-toggle-button.js +2 -2
  91. package/dist/components/navigation/kt-toggle-button-group/kt-toggle-button-group.js +3 -3
  92. package/dist/components/overlays/kt-collapsible/kt-collapsible.js +2 -2
  93. package/dist/components/overlays/kt-confirm-dialog/kt-confirm-dialog.js +3 -3
  94. package/dist/components/overlays/kt-dropdown/kt-dropdown.d.ts +7 -5
  95. package/dist/components/overlays/kt-dropdown/kt-dropdown.js +67 -57
  96. package/dist/components/overlays/kt-dropdown/kt-dropdown.js.map +1 -1
  97. package/dist/components/overlays/kt-modal/kt-modal.js +3 -3
  98. package/dist/components/overlays/kt-side-panel/kt-side-panel.js +3 -3
  99. package/dist/custom-elements.json +2110 -124
  100. package/dist/icons/defaults.d.ts +1 -0
  101. package/dist/icons/index.js +1 -1
  102. package/dist/index.d.ts +4 -0
  103. package/dist/index.js +91 -87
  104. package/dist/index.js.map +1 -1
  105. package/dist/internal/countries.d.ts +24 -9
  106. package/dist/internal/date.d.ts +53 -0
  107. package/dist/internal/events.d.ts +5 -0
  108. package/dist/internal/floating.d.ts +48 -0
  109. package/dist/internal/form-control.d.ts +5 -1
  110. package/dist/internal/locale.d.ts +15 -0
  111. package/dist/internal/position.d.ts +27 -0
  112. package/dist/internal/strings.d.ts +15 -0
  113. package/dist/react/index.d.ts +12 -0
  114. package/dist/react/index.js +180 -166
  115. package/dist/react/index.js.map +1 -1
  116. package/dist/react/jsx.d.ts +11 -1
  117. package/dist/strings/index.js +1 -1
  118. package/dist/tokens/base.css +2 -0
  119. package/dist/tokens/responsive.css +1 -0
  120. package/dist/tokens/spacing.css +1 -0
  121. package/dist/vscode.css-custom-data.json +8 -0
  122. package/dist/vscode.html-custom-data.json +138 -11
  123. package/dist/vue/index.d.ts +4 -0
  124. package/dist/vue/index.js +9 -7
  125. package/dist/vue/index.js.map +1 -1
  126. package/dist/web-types.json +292 -14
  127. package/package.json +10 -1
  128. package/dist/chunks/events-Bjl5Zmmq.js +0 -18
  129. package/dist/chunks/form-control-CxjBTt1c.js.map +0 -1
  130. package/dist/chunks/index-DSSLJirw.js.map +0 -1
@@ -1,63 +1,169 @@
1
- import { css as w, nothing as n, html as l } from "lit";
2
- import { query as x, state as y, property as a } from "lit/decorators.js";
3
- import { classMap as m } from "lit/directives/class-map.js";
4
- import { live as $ } from "lit/directives/live.js";
5
- import { K as b, d as C } from "../../../chunks/kt-element-E-tfJpGQ.js";
6
- import { e as c } from "../../../chunks/events-Bjl5Zmmq.js";
7
- import { a as k, s as g, b as P } from "../../../chunks/form-control-CxjBTt1c.js";
8
- import { s as d } from "../../../chunks/index-DSSLJirw.js";
1
+ import { css as v, nothing as s, html as d } from "lit";
2
+ import { query as P, state as m, property as l } from "lit/decorators.js";
3
+ import { classMap as y } from "lit/directives/class-map.js";
4
+ import { live as w } from "lit/directives/live.js";
5
+ import { K as g, d as $ } from "../../../chunks/kt-element-Djx2JcGl.js";
6
+ import { t as C, e as c } from "../../../chunks/events-r51msXNf.js";
7
+ import { a as S, s as b, b as E } from "../../../chunks/form-control-B74_EHtG.js";
8
+ import { F as O, f as z } from "../../../chunks/floating-B7_Dahpn.js";
9
+ import { s as u } from "../../../chunks/index-STEEvEP7.js";
9
10
  import "../../core/kt-icon/kt-icon.js";
10
- const O = [
11
- { id: "us", name: "United States", dialCode: "1", format: "123-456-7890" },
12
- { id: "gb", name: "United Kingdom", dialCode: "44", format: "7123 456789" },
13
- { id: "de", name: "Germany", dialCode: "49", format: "1234 567890" },
14
- { id: "fr", name: "France", dialCode: "33", format: "1 23 45 67 89" },
15
- { id: "be", name: "Belgium", dialCode: "32", format: "1 23 45 67 89" },
16
- { id: "ch", name: "Switzerland", dialCode: "41", format: "12 345 67 89" }
17
- ], V = 127462, S = 65;
18
- function v(s) {
19
- return /^[a-z]{2}$/i.test(s) ? String.fromCodePoint(
20
- ...[...s.toUpperCase()].map(
21
- (e) => V + e.charCodeAt(0) - S
11
+ import "../../feedback/kt-tooltip/kt-tooltip.js";
12
+ const D = [
13
+ { id: "al", name: "Albania", dialCode: "355", format: "67 212 3456", trunkPrefix: "0" },
14
+ { id: "dz", name: "Algeria", dialCode: "213", format: "551 23 45 67", trunkPrefix: "0" },
15
+ { id: "ao", name: "Angola", dialCode: "244", format: "923 123 456" },
16
+ { id: "ar", name: "Argentina", dialCode: "54", format: "11 2345 6789", trunkPrefix: "0" },
17
+ { id: "au", name: "Australia", dialCode: "61", format: "412 345 678", trunkPrefix: "0" },
18
+ { id: "at", name: "Austria", dialCode: "43", format: "664 1234567", trunkPrefix: "0" },
19
+ { id: "bd", name: "Bangladesh", dialCode: "880", format: "1812 345678", trunkPrefix: "0" },
20
+ { id: "be", name: "Belgium", dialCode: "32", format: "1 23 45 67 89", trunkPrefix: "0" },
21
+ { id: "bo", name: "Bolivia", dialCode: "591", format: "7123 4567", trunkPrefix: "0" },
22
+ { id: "br", name: "Brazil", dialCode: "55", format: "11 91234 5678", trunkPrefix: "0" },
23
+ { id: "bg", name: "Bulgaria", dialCode: "359", format: "87 123 4567", trunkPrefix: "0" },
24
+ { id: "cm", name: "Cameroon", dialCode: "237", format: "6 71 23 45 67" },
25
+ { id: "ca", name: "Canada", dialCode: "1", format: "506-234-5678", trunkPrefix: "1" },
26
+ { id: "cl", name: "Chile", dialCode: "56", format: "9 1234 5678" },
27
+ { id: "cn", name: "China", dialCode: "86", format: "131 2345 6789", trunkPrefix: "0" },
28
+ { id: "co", name: "Colombia", dialCode: "57", format: "321 123 4567", trunkPrefix: "0" },
29
+ { id: "cr", name: "Costa Rica", dialCode: "506", format: "8312 3456" },
30
+ { id: "ci", name: "Côte d'Ivoire", dialCode: "225", format: "01 23 45 67 89" },
31
+ { id: "hr", name: "Croatia", dialCode: "385", format: "91 234 5678", trunkPrefix: "0" },
32
+ { id: "cy", name: "Cyprus", dialCode: "357", format: "96 123456" },
33
+ { id: "cz", name: "Czechia", dialCode: "420", format: "601 123 456" },
34
+ { id: "dk", name: "Denmark", dialCode: "45", format: "32 12 34 56" },
35
+ { id: "cd", name: "DR Congo", dialCode: "243", format: "991 234 567", trunkPrefix: "0" },
36
+ { id: "ec", name: "Ecuador", dialCode: "593", format: "99 123 4567", trunkPrefix: "0" },
37
+ { id: "eg", name: "Egypt", dialCode: "20", format: "100 123 4567", trunkPrefix: "0" },
38
+ { id: "ee", name: "Estonia", dialCode: "372", format: "5123 4567" },
39
+ { id: "et", name: "Ethiopia", dialCode: "251", format: "91 123 4567", trunkPrefix: "0" },
40
+ { id: "fi", name: "Finland", dialCode: "358", format: "41 234 5678", trunkPrefix: "0" },
41
+ { id: "fr", name: "France", dialCode: "33", format: "1 23 45 67 89", trunkPrefix: "0" },
42
+ { id: "ge", name: "Georgia", dialCode: "995", format: "555 123 456", trunkPrefix: "0" },
43
+ { id: "de", name: "Germany", dialCode: "49", format: "1234 567890", trunkPrefix: "0" },
44
+ { id: "gh", name: "Ghana", dialCode: "233", format: "23 123 4567", trunkPrefix: "0" },
45
+ { id: "gr", name: "Greece", dialCode: "30", format: "691 234 5678" },
46
+ { id: "gt", name: "Guatemala", dialCode: "502", format: "5123 4567" },
47
+ { id: "hk", name: "Hong Kong", dialCode: "852", format: "5123 4567" },
48
+ { id: "hu", name: "Hungary", dialCode: "36", format: "20 123 4567", trunkPrefix: "06" },
49
+ { id: "is", name: "Iceland", dialCode: "354", format: "611 1234" },
50
+ { id: "in", name: "India", dialCode: "91", format: "81234 56789", trunkPrefix: "0" },
51
+ { id: "id", name: "Indonesia", dialCode: "62", format: "812 3456 7890", trunkPrefix: "0" },
52
+ { id: "ir", name: "Iran", dialCode: "98", format: "912 345 6789", trunkPrefix: "0" },
53
+ { id: "iq", name: "Iraq", dialCode: "964", format: "791 234 5678", trunkPrefix: "0" },
54
+ { id: "ie", name: "Ireland", dialCode: "353", format: "85 123 4567", trunkPrefix: "0" },
55
+ { id: "il", name: "Israel", dialCode: "972", format: "50 234 5678", trunkPrefix: "0" },
56
+ { id: "it", name: "Italy", dialCode: "39", format: "312 345 6789" },
57
+ { id: "jp", name: "Japan", dialCode: "81", format: "90 1234 5678", trunkPrefix: "0" },
58
+ { id: "jo", name: "Jordan", dialCode: "962", format: "7 9012 3456", trunkPrefix: "0" },
59
+ { id: "kz", name: "Kazakhstan", dialCode: "7", format: "771 000 9998" },
60
+ { id: "ke", name: "Kenya", dialCode: "254", format: "712 123456", trunkPrefix: "0" },
61
+ { id: "lv", name: "Latvia", dialCode: "371", format: "2123 4567" },
62
+ { id: "lb", name: "Lebanon", dialCode: "961", format: "71 123 456", trunkPrefix: "0" },
63
+ { id: "lt", name: "Lithuania", dialCode: "370", format: "612 34567", trunkPrefix: "0" },
64
+ { id: "lu", name: "Luxembourg", dialCode: "352", format: "628 123 456" },
65
+ { id: "my", name: "Malaysia", dialCode: "60", format: "12 345 6789", trunkPrefix: "0" },
66
+ { id: "mx", name: "Mexico", dialCode: "52", format: "55 1234 5678" },
67
+ { id: "ma", name: "Morocco", dialCode: "212", format: "650 123456", trunkPrefix: "0" },
68
+ { id: "np", name: "Nepal", dialCode: "977", format: "984 1234567", trunkPrefix: "0" },
69
+ { id: "nl", name: "Netherlands", dialCode: "31", format: "6 12345678", trunkPrefix: "0" },
70
+ { id: "nz", name: "New Zealand", dialCode: "64", format: "21 123 4567", trunkPrefix: "0" },
71
+ { id: "ng", name: "Nigeria", dialCode: "234", format: "802 123 4567", trunkPrefix: "0" },
72
+ { id: "mk", name: "North Macedonia", dialCode: "389", format: "72 345 678", trunkPrefix: "0" },
73
+ { id: "no", name: "Norway", dialCode: "47", format: "406 12 345" },
74
+ { id: "pk", name: "Pakistan", dialCode: "92", format: "301 2345678", trunkPrefix: "0" },
75
+ { id: "pa", name: "Panama", dialCode: "507", format: "6123 4567" },
76
+ { id: "pe", name: "Peru", dialCode: "51", format: "912 345 678", trunkPrefix: "0" },
77
+ { id: "ph", name: "Philippines", dialCode: "63", format: "905 123 4567", trunkPrefix: "0" },
78
+ { id: "pl", name: "Poland", dialCode: "48", format: "512 345 678" },
79
+ { id: "pt", name: "Portugal", dialCode: "351", format: "912 345 678" },
80
+ { id: "qa", name: "Qatar", dialCode: "974", format: "3312 3456" },
81
+ { id: "ro", name: "Romania", dialCode: "40", format: "712 034 567", trunkPrefix: "0" },
82
+ { id: "ru", name: "Russia", dialCode: "7", format: "912 345 67 89" },
83
+ { id: "sa", name: "Saudi Arabia", dialCode: "966", format: "51 234 5678", trunkPrefix: "0" },
84
+ { id: "sn", name: "Senegal", dialCode: "221", format: "70 123 45 67" },
85
+ { id: "rs", name: "Serbia", dialCode: "381", format: "60 123 4567", trunkPrefix: "0" },
86
+ { id: "sg", name: "Singapore", dialCode: "65", format: "8123 4567" },
87
+ { id: "sk", name: "Slovakia", dialCode: "421", format: "912 123 456", trunkPrefix: "0" },
88
+ { id: "si", name: "Slovenia", dialCode: "386", format: "31 234 567", trunkPrefix: "0" },
89
+ { id: "za", name: "South Africa", dialCode: "27", format: "71 123 4567", trunkPrefix: "0" },
90
+ { id: "kr", name: "South Korea", dialCode: "82", format: "10 1234 5678", trunkPrefix: "0" },
91
+ { id: "es", name: "Spain", dialCode: "34", format: "612 34 56 78" },
92
+ { id: "lk", name: "Sri Lanka", dialCode: "94", format: "71 234 5678", trunkPrefix: "0" },
93
+ { id: "se", name: "Sweden", dialCode: "46", format: "70 123 45 67", trunkPrefix: "0" },
94
+ { id: "ch", name: "Switzerland", dialCode: "41", format: "12 345 67 89", trunkPrefix: "0" },
95
+ { id: "tw", name: "Taiwan", dialCode: "886", format: "912 345 678", trunkPrefix: "0" },
96
+ { id: "tz", name: "Tanzania", dialCode: "255", format: "621 234 567", trunkPrefix: "0" },
97
+ { id: "th", name: "Thailand", dialCode: "66", format: "81 234 5678", trunkPrefix: "0" },
98
+ { id: "tn", name: "Tunisia", dialCode: "216", format: "20 123 456" },
99
+ { id: "tr", name: "Türkiye", dialCode: "90", format: "501 234 56 78", trunkPrefix: "0" },
100
+ { id: "ug", name: "Uganda", dialCode: "256", format: "712 345678", trunkPrefix: "0" },
101
+ { id: "ua", name: "Ukraine", dialCode: "380", format: "50 123 4567", trunkPrefix: "0" },
102
+ {
103
+ id: "ae",
104
+ name: "United Arab Emirates",
105
+ dialCode: "971",
106
+ format: "50 123 4567",
107
+ trunkPrefix: "0"
108
+ },
109
+ { id: "gb", name: "United Kingdom", dialCode: "44", format: "7123 456789", trunkPrefix: "0" },
110
+ { id: "us", name: "United States", dialCode: "1", format: "201-555-0123", trunkPrefix: "1" },
111
+ { id: "uy", name: "Uruguay", dialCode: "598", format: "94 231 234", trunkPrefix: "0" },
112
+ { id: "ve", name: "Venezuela", dialCode: "58", format: "412 123 4567", trunkPrefix: "0" },
113
+ { id: "vn", name: "Vietnam", dialCode: "84", format: "91 234 5678", trunkPrefix: "0" }
114
+ ], A = 127462, T = 65;
115
+ function k(n) {
116
+ return /^[a-z]{2}$/i.test(n) ? String.fromCodePoint(
117
+ ...[...n.toUpperCase()].map(
118
+ (e) => A + e.charCodeAt(0) - T
22
119
  )
23
120
  ) : "";
24
121
  }
25
- function z(s) {
26
- return s.replace(/\D/g, "");
122
+ function V(n) {
123
+ return n.replace(/\D/g, "");
27
124
  }
28
- function E(s, e) {
29
- if (!s) return "";
30
- const r = [];
31
- let t = s;
32
- if (e?.id === "fr")
33
- for (r.push(t.slice(0, 1)), t = t.slice(1); t; )
34
- r.push(t.slice(0, 2)), t = t.slice(2);
35
- else if (e?.id === "us" || e?.id === "ca") {
36
- for (const u of [3, 3, 4]) {
37
- if (!t) break;
38
- r.push(t.slice(0, u)), t = t.slice(u);
39
- }
40
- t && r.push(t);
41
- } else
42
- for (; t; )
43
- r.push(t.slice(0, 3)), t = t.slice(3);
44
- return r.filter(Boolean).join(" ");
125
+ function I(n, e) {
126
+ if (!n) return "";
127
+ const t = e ? (e.format.match(/\d+/g) ?? []).map((h) => h.length) : [], o = [];
128
+ let a = n;
129
+ for (const h of t) {
130
+ if (!a) break;
131
+ o.push(a.slice(0, h)), a = a.slice(h);
132
+ }
133
+ if (t.length > 0)
134
+ a && o.push(a);
135
+ else
136
+ for (; a; )
137
+ o.push(a.slice(0, 3)), a = a.slice(3);
138
+ return o.join(" ");
139
+ }
140
+ function B(n, e) {
141
+ const t = e?.trunkPrefix;
142
+ return t && n.startsWith(t) ? t : void 0;
143
+ }
144
+ function x(n) {
145
+ return n.normalize("NFD").replace(/\p{Diacritic}/gu, "").toLowerCase();
45
146
  }
46
- function A(s, e) {
47
- const r = e.trim().toLowerCase();
48
- return r ? s.filter(
49
- (t) => t.name.toLowerCase().includes(r) || t.dialCode.includes(r.replace(/^\+/, "")) || t.id === r
50
- ) : s;
147
+ function N(n, e) {
148
+ const t = x(e.trim());
149
+ if (!t) return n;
150
+ const o = t.replace(/^\+/, "");
151
+ return n.filter(
152
+ (a) => x(a.name).includes(t) || o !== "" && a.dialCode.startsWith(o) || a.id === t
153
+ );
51
154
  }
52
- var B = Object.defineProperty, o = (s, e, r, t) => {
53
- for (var u = void 0, p = s.length - 1, f; p >= 0; p--)
54
- (f = s[p]) && (u = f(e, r, u) || u);
55
- return u && B(e, r, u), u;
155
+ var q = Object.defineProperty, i = (n, e, t, o) => {
156
+ for (var a = void 0, h = n.length - 1, p; h >= 0; h--)
157
+ (p = n[h]) && (a = p(e, t, a) || a);
158
+ return a && q(e, t, a), a;
56
159
  };
57
- const h = 18;
58
- class i extends b {
160
+ const f = 18, F = /^([a-z]{2}):(\d*)$/;
161
+ class r extends g {
59
162
  constructor() {
60
- super(...arguments), this.internals = null, this.passwordVisible = !1, this.countryOpen = !1, this.countryQuery = "", this.value = "", this.name = "", this.type = "text", this.placeholder = "", this.size = "medium", this.disabled = !1, this.readonly = !1, this.required = !1, this.icon = "", this.error = "", this.clearable = !0, this.label = "", this.autocomplete = "", this.countries = O, this.country = "us", this.defaultValue = "", this.closeCountryPanel = (e) => {
163
+ super(...arguments), this.internals = null, this.passwordVisible = !1, this.countryOpen = !1, this.countryQuery = "", this.focused = !1, this.errorDismissed = !1, this.floating = new O(this, {
164
+ panel: () => this.shadowRoot?.querySelector(".country-panel"),
165
+ anchor: () => this.shadowRoot?.querySelector(".field")
166
+ }), this.value = "", this.name = "", this.type = "text", this.placeholder = "", this.size = "medium", this.disabled = !1, this.formDisabled = !1, this.readonly = !1, this.required = !1, this.icon = "", this.error = "", this.clearable = !0, this.label = "", this.autocomplete = "", this.countries = D, this.country = "us", this.defaultValue = "", this.closeCountryPanel = (e) => {
61
167
  e.composedPath().includes(this) || (this.countryOpen = !1);
62
168
  };
63
169
  }
@@ -66,8 +172,9 @@ class i extends b {
66
172
  }
67
173
  static {
68
174
  this.styles = [
69
- b.styles,
70
- w`
175
+ g.styles,
176
+ z,
177
+ v`
71
178
  :host {
72
179
  display: block;
73
180
  }
@@ -231,11 +338,8 @@ class i extends b {
231
338
  color: var(--text-muted);
232
339
  }
233
340
 
341
+ /* Placed from the field by FloatingController. */
234
342
  .country-panel {
235
- position: absolute;
236
- top: calc(100% + 6px);
237
- left: 0;
238
- z-index: var(--z-dropdown);
239
343
  display: flex;
240
344
  flex-direction: column;
241
345
  gap: var(--gap-element);
@@ -247,6 +351,9 @@ class i extends b {
247
351
  }
248
352
 
249
353
  .country-search {
354
+ /* Never shrunk by the list below it, which would otherwise take the
355
+ search box's height whenever there are more results than room. */
356
+ flex: none;
250
357
  width: 100%;
251
358
  height: var(--button-height-small);
252
359
  padding: 0 12px;
@@ -296,18 +403,30 @@ class i extends b {
296
403
  `
297
404
  ];
298
405
  }
406
+ /** Whether the control is off, by its own `disabled` or by its form. */
407
+ get inactive() {
408
+ return this.disabled || this.formDisabled;
409
+ }
299
410
  connectedCallback() {
300
- super.connectedCallback(), document.addEventListener("pointerdown", this.closeCountryPanel), this.internals ??= k(this), this.defaultValue = this.value, g(this.internals, this.formValue);
411
+ super.connectedCallback(), C(this.countryOpen, document, "pointerdown", this.closeCountryPanel), this.internals ??= S(this), this.defaultValue = this.value, b(this.internals, this.formValue, this.formState);
412
+ }
413
+ // Untyped: `countryOpen` is private, so not among the keys PropertyValues<this> knows.
414
+ updated(e) {
415
+ e.has("countryOpen") && C(this.countryOpen, document, "pointerdown", this.closeCountryPanel), this.floating.sync(this.countryOpen);
301
416
  }
302
417
  willUpdate(e) {
303
- (e.has("value") || e.has("required") || e.has("error") || e.has("country") || this.stringsChanged(e)) && (g(this.internals, this.value), this.refreshValidity());
418
+ (e.has("value") || e.has("required") || e.has("error") || e.has("country") || e.has("countries") || e.has("type") || this.stringsChanged(e)) && (b(this.internals, this.formValue, this.formState), this.refreshValidity());
304
419
  }
305
420
  refreshValidity() {
306
- const e = this.required && this.value.length === 0, r = this.error || (e ? d().required : "");
307
- P(
421
+ const e = this.required && this.value.length === 0, t = this.phoneError, o = this.error || t || (e ? u().required : "");
422
+ E(
308
423
  this.internals,
309
- { valueMissing: e, customError: !!this.error },
310
- r
424
+ {
425
+ valueMissing: e,
426
+ patternMismatch: !!t,
427
+ customError: !!this.error
428
+ },
429
+ o
311
430
  );
312
431
  }
313
432
  disconnectedCallback() {
@@ -317,9 +436,17 @@ class i extends b {
317
436
  formResetCallback() {
318
437
  this.value = this.defaultValue, this.passwordVisible = !1;
319
438
  }
439
+ /**
440
+ * Called by the platform when the control's disabled state changes — its
441
+ * own `disabled`, or an ancestor `<fieldset disabled>` it cannot see.
442
+ */
443
+ formDisabledCallback(e) {
444
+ this.formDisabled = e;
445
+ }
320
446
  /** Called by the platform when the browser restores a session. */
321
447
  formStateRestoreCallback(e) {
322
- this.value = e;
448
+ const t = F.exec(e);
449
+ this.isPhone && t ? (this.country = t[1], this.value = t[2]) : this.value = e;
323
450
  }
324
451
  focus(e) {
325
452
  this.input?.focus(e);
@@ -346,18 +473,36 @@ class i extends b {
346
473
  get formValue() {
347
474
  return !this.isPhone || !this.value ? this.value : `+${this.selectedCountry?.dialCode ?? ""}${this.value}`;
348
475
  }
476
+ /**
477
+ * What the browser saves for a restore. The international number cannot be
478
+ * split back into country and digits — `+1` is both the US and Canada — so
479
+ * phone mode saves the two apart.
480
+ */
481
+ get formState() {
482
+ return this.isPhone ? `${this.country}:${this.value}` : void 0;
483
+ }
484
+ /** Phone mode: a number typed with the prefix only dialled at home. */
485
+ get phoneError() {
486
+ if (!this.isPhone) return "";
487
+ const e = B(this.value, this.selectedCountry);
488
+ return e ? u().phoneTrunkPrefix(e) : "";
489
+ }
490
+ /** The message on show: the application's first, then the field's own. */
491
+ get shownError() {
492
+ return this.error || this.phoneError;
493
+ }
349
494
  get displayValue() {
350
- return this.isPhone ? E(this.value, this.selectedCountry) : this.value;
495
+ return this.isPhone ? I(this.value, this.selectedCountry) : this.value;
351
496
  }
352
497
  get showClear() {
353
- return this.clearable && this.value.length > 0 && !this.readonly && !this.disabled;
498
+ return this.clearable && this.value.length > 0 && !this.readonly && !this.inactive;
354
499
  }
355
500
  get resolvedType() {
356
501
  return this.isPhone ? "text" : this.type !== "password" ? this.type : this.passwordVisible ? "text" : "password";
357
502
  }
358
503
  onInput(e) {
359
- const r = e.target.value;
360
- this.value = this.isPhone ? z(r) : r, c(this, "kt-input", { value: this.value });
504
+ const t = e.target.value;
505
+ this.value = this.isPhone ? V(t) : t, c(this, "kt-input", { value: this.value });
361
506
  }
362
507
  toggleCountryPanel() {
363
508
  this.countryOpen = !this.countryOpen, this.countryQuery = "";
@@ -369,47 +514,64 @@ class i extends b {
369
514
  e.key === "Escape" && this.countryOpen && (e.stopPropagation(), this.countryOpen = !1, this.shadowRoot?.querySelector(".country")?.focus());
370
515
  }
371
516
  renderCountryPicker() {
372
- const e = this.selectedCountry, r = A(this.countries, this.countryQuery);
373
- return l`<button
517
+ const e = this.selectedCountry, t = N(this.countries, this.countryQuery);
518
+ return d`<button
374
519
  type="button"
375
520
  class="country"
376
521
  aria-haspopup="listbox"
377
522
  aria-expanded=${this.countryOpen ? "true" : "false"}
378
- aria-label=${d().countryCode(e?.name)}
379
- ?disabled=${this.disabled || this.readonly}
523
+ aria-label=${u().countryCode(e?.name)}
524
+ ?disabled=${this.inactive || this.readonly}
380
525
  @click=${this.toggleCountryPanel}
381
526
  >
382
- <span aria-hidden="true">${v(this.country)}</span>
527
+ <span aria-hidden="true">${k(this.country)}</span>
383
528
  <span class="dial">+${e?.dialCode ?? ""}</span>
384
- <span class=${m({ chevron: !0, open: this.countryOpen })}>
529
+ <span class=${y({ chevron: !0, open: this.countryOpen })}>
385
530
  <kt-icon name="chevron-down" size="14"></kt-icon>
386
531
  </span>
387
532
  </button>
388
- ${this.countryOpen ? l`<div class="country-panel" @pointerdown=${(t) => t.stopPropagation()}>
533
+ ${this.countryOpen ? d`<div
534
+ class="country-panel floating"
535
+ popover="manual"
536
+ @pointerdown=${(o) => o.stopPropagation()}
537
+ >
389
538
  <input
390
539
  class="country-search"
391
- placeholder=${d().searchCountry}
540
+ placeholder=${u().searchCountry}
392
541
  .value=${this.countryQuery}
393
- aria-label=${d().searchCountry}
394
- @input=${(t) => {
395
- this.countryQuery = t.target.value;
542
+ aria-label=${u().searchCountry}
543
+ @input=${(o) => {
544
+ this.countryQuery = o.target.value;
396
545
  }}
397
546
  />
398
547
  <ul class="country-list" role="listbox">
399
- ${r.length === 0 ? l`<li class="country-empty">${d().noCountry}</li>` : r.map(
400
- (t) => l`<li
548
+ ${t.length === 0 ? d`<li class="country-empty">${u().noCountry}</li>` : t.map(
549
+ (o) => d`<li
401
550
  class="country-item"
402
551
  role="option"
403
- aria-selected=${t.id === this.country ? "true" : "false"}
404
- @click=${() => this.selectCountry(t)}
552
+ aria-selected=${o.id === this.country ? "true" : "false"}
553
+ @click=${() => this.selectCountry(o)}
405
554
  >
406
- <span aria-hidden="true">${v(t.id)}</span>
407
- <span class="country-name">${t.name}</span>
408
- <span class="dial">+${t.dialCode}</span>
555
+ <span aria-hidden="true">${k(o.id)}</span>
556
+ <span class="country-name">${o.name}</span>
557
+ <span class="dial">+${o.dialCode}</span>
409
558
  </li>`
410
559
  )}
411
560
  </ul>
412
- </div>` : n}`;
561
+ </div>` : s}`;
562
+ }
563
+ onFocus() {
564
+ this.focused = !0, this.errorDismissed = !1;
565
+ }
566
+ onBlur() {
567
+ this.focused = !1;
568
+ }
569
+ /** WCAG 1.4.13: content shown on focus can be dismissed without moving it. */
570
+ onControlKeyDown(e) {
571
+ e.key !== "Escape" || !this.errorTooltipOpen || (e.stopPropagation(), this.errorDismissed = !0);
572
+ }
573
+ get errorTooltipOpen() {
574
+ return this.focused && !this.errorDismissed && !!this.shownError;
413
575
  }
414
576
  onChange(e) {
415
577
  e.stopPropagation(), c(this, "kt-change", { value: this.value });
@@ -424,15 +586,30 @@ class i extends b {
424
586
  onFieldPointerDown(e) {
425
587
  e.target !== this.input && (e.target.closest("button") || (e.preventDefault(), this.focus()));
426
588
  }
589
+ /** Both buttons are out of the tab order, so their tooltips are for the pointer. */
590
+ renderPasswordToggle() {
591
+ const e = this.passwordVisible ? u().hidePassword : u().showPassword;
592
+ return d`<kt-tooltip text=${e}>
593
+ <button
594
+ type="button"
595
+ class="icon-button"
596
+ tabindex="-1"
597
+ aria-label=${e}
598
+ @click=${this.togglePassword}
599
+ >
600
+ <kt-icon name=${this.passwordVisible ? "eye-off" : "eye"} size=${f}></kt-icon>
601
+ </button>
602
+ </kt-tooltip>`;
603
+ }
427
604
  render() {
428
- const e = this.type === "password" || !!this.icon || !!this.error || this.showClear;
429
- return l`<div
605
+ const e = this.shownError, t = this.type === "password" || !!this.icon || !!e || this.showClear;
606
+ return d`<div
430
607
  part="base"
431
- class=${m({
608
+ class=${y({
432
609
  field: !0,
433
610
  [this.size]: !0,
434
- error: !!this.error,
435
- disabled: this.disabled
611
+ error: !!e,
612
+ disabled: this.inactive
436
613
  })}
437
614
  @pointerdown=${this.onFieldPointerDown}
438
615
  @keydown=${this.onCountryKeyDown}
@@ -440,122 +617,131 @@ class i extends b {
440
617
  ${// The icon only shows that something is wrong; this is what gets read
441
618
  // out. aria-describedby rather than aria-errormessage, which most
442
619
  // screen readers still ignore.
443
- this.error ? l`<span id="error-message" class="visually-hidden">${this.error}</span>` : n}
444
- ${this.isPhone ? this.renderCountryPicker() : n}
620
+ e ? d`<span id="error-message" class="visually-hidden">${e}</span>` : s}
621
+ ${this.isPhone ? this.renderCountryPicker() : s}
445
622
 
446
623
  <input
447
624
  part="control"
448
625
  type=${this.resolvedType}
449
- name=${this.name || n}
450
- .value=${$(this.displayValue)}
451
- placeholder=${this.placeholder || this.selectedCountry?.format || n}
452
- autocomplete=${this.autocomplete || n}
453
- inputmode=${this.isPhone ? "tel" : n}
454
- maxlength=${this.maxlength ?? n}
455
- aria-label=${this.label || n}
456
- aria-invalid=${this.error ? "true" : n}
457
- aria-describedby=${this.error ? "error-message" : n}
458
- ?disabled=${this.disabled}
626
+ name=${this.name || s}
627
+ .value=${w(this.displayValue)}
628
+ placeholder=${this.placeholder || this.isPhone && this.selectedCountry?.format || s}
629
+ autocomplete=${this.autocomplete || s}
630
+ inputmode=${this.isPhone ? "tel" : s}
631
+ maxlength=${this.maxlength ?? s}
632
+ aria-label=${this.label || s}
633
+ aria-invalid=${e ? "true" : s}
634
+ aria-describedby=${e ? "error-message" : s}
635
+ ?disabled=${this.inactive}
459
636
  ?readonly=${this.readonly}
460
637
  ?required=${this.required}
461
638
  @input=${this.onInput}
462
639
  @change=${this.onChange}
640
+ @focus=${this.onFocus}
641
+ @blur=${this.onBlur}
642
+ @keydown=${this.onControlKeyDown}
463
643
  />
464
644
 
465
- ${e ? l`<div part="actions" class="actions">
466
- ${this.type === "password" ? l`<button
467
- type="button"
468
- class="icon-button"
469
- tabindex="-1"
470
- aria-label=${this.passwordVisible ? d().hidePassword : d().showPassword}
471
- @click=${this.togglePassword}
472
- >
473
- <kt-icon
474
- name=${this.passwordVisible ? "eye-off" : "eye"}
475
- size=${h}
476
- ></kt-icon>
477
- </button>` : n}
478
- ${this.icon ? l`<span class="adornment">
479
- <kt-icon name=${this.icon} size=${h}></kt-icon>
480
- </span>` : n}
481
- ${this.error ? l`<span class="adornment error-icon" title=${this.error}>
482
- <kt-icon name="circle-alert" size=${h} label=${this.error}></kt-icon>
483
- </span>` : n}
484
- ${this.showClear ? l`<button
485
- type="button"
486
- class="icon-button clear"
487
- tabindex="-1"
488
- aria-label=${d().clear}
489
- @click=${this.clear}
645
+ ${t ? d`<div part="actions" class="actions">
646
+ ${this.type === "password" ? this.renderPasswordToggle() : s}
647
+ ${this.icon ? d`<span class="adornment">
648
+ <kt-icon name=${this.icon} size=${f}></kt-icon>
649
+ </span>` : s}
650
+ ${// The message on hover, and while the field has focus for whoever
651
+ // uses a keyboard; aria-describedby is what a screen reader reads.
652
+ e ? d`<kt-tooltip
653
+ class="adornment error-icon"
654
+ text=${e}
655
+ ?open=${this.errorTooltipOpen}
490
656
  >
491
- <kt-icon name="x" size=${h}></kt-icon>
492
- </button>` : n}
493
- </div>` : n}
657
+ <kt-icon name="circle-alert" size=${f}></kt-icon>
658
+ </kt-tooltip>` : s}
659
+ ${this.showClear ? d`<kt-tooltip text=${u().clear}>
660
+ <button
661
+ type="button"
662
+ class="icon-button clear"
663
+ tabindex="-1"
664
+ aria-label=${u().clear}
665
+ @click=${this.clear}
666
+ >
667
+ <kt-icon name="x" size=${f}></kt-icon>
668
+ </button>
669
+ </kt-tooltip>` : s}
670
+ </div>` : s}
494
671
  </div>`;
495
672
  }
496
673
  }
497
- o([
498
- x("input")
499
- ], i.prototype, "input");
500
- o([
501
- y()
502
- ], i.prototype, "passwordVisible");
503
- o([
504
- y()
505
- ], i.prototype, "countryOpen");
506
- o([
507
- y()
508
- ], i.prototype, "countryQuery");
509
- o([
510
- a({ type: String })
511
- ], i.prototype, "value");
512
- o([
513
- a({ type: String })
514
- ], i.prototype, "name");
515
- o([
516
- a({ type: String })
517
- ], i.prototype, "type");
518
- o([
519
- a({ type: String })
520
- ], i.prototype, "placeholder");
521
- o([
522
- a({ type: String, reflect: !0 })
523
- ], i.prototype, "size");
524
- o([
525
- a({ type: Boolean, reflect: !0 })
526
- ], i.prototype, "disabled");
527
- o([
528
- a({ type: Boolean, reflect: !0 })
529
- ], i.prototype, "readonly");
530
- o([
531
- a({ type: Boolean, reflect: !0 })
532
- ], i.prototype, "required");
533
- o([
534
- a({ type: String })
535
- ], i.prototype, "icon");
536
- o([
537
- a({ type: String, reflect: !0 })
538
- ], i.prototype, "error");
539
- o([
540
- a({ type: Boolean })
541
- ], i.prototype, "clearable");
542
- o([
543
- a({ type: String })
544
- ], i.prototype, "label");
545
- o([
546
- a({ type: String })
547
- ], i.prototype, "autocomplete");
548
- o([
549
- a({ type: Number })
550
- ], i.prototype, "maxlength");
551
- o([
552
- a({ attribute: !1 })
553
- ], i.prototype, "countries");
554
- o([
555
- a({ type: String })
556
- ], i.prototype, "country");
557
- C("kt-input", i);
674
+ i([
675
+ P("input")
676
+ ], r.prototype, "input");
677
+ i([
678
+ m()
679
+ ], r.prototype, "passwordVisible");
680
+ i([
681
+ m()
682
+ ], r.prototype, "countryOpen");
683
+ i([
684
+ m()
685
+ ], r.prototype, "countryQuery");
686
+ i([
687
+ m()
688
+ ], r.prototype, "focused");
689
+ i([
690
+ m()
691
+ ], r.prototype, "errorDismissed");
692
+ i([
693
+ l({ type: String })
694
+ ], r.prototype, "value");
695
+ i([
696
+ l({ type: String })
697
+ ], r.prototype, "name");
698
+ i([
699
+ l({ type: String })
700
+ ], r.prototype, "type");
701
+ i([
702
+ l({ type: String })
703
+ ], r.prototype, "placeholder");
704
+ i([
705
+ l({ type: String, reflect: !0 })
706
+ ], r.prototype, "size");
707
+ i([
708
+ l({ type: Boolean, reflect: !0 })
709
+ ], r.prototype, "disabled");
710
+ i([
711
+ m()
712
+ ], r.prototype, "formDisabled");
713
+ i([
714
+ l({ type: Boolean, reflect: !0 })
715
+ ], r.prototype, "readonly");
716
+ i([
717
+ l({ type: Boolean, reflect: !0 })
718
+ ], r.prototype, "required");
719
+ i([
720
+ l({ type: String })
721
+ ], r.prototype, "icon");
722
+ i([
723
+ l({ type: String, reflect: !0 })
724
+ ], r.prototype, "error");
725
+ i([
726
+ l({ type: Boolean })
727
+ ], r.prototype, "clearable");
728
+ i([
729
+ l({ type: String })
730
+ ], r.prototype, "label");
731
+ i([
732
+ l({ type: String })
733
+ ], r.prototype, "autocomplete");
734
+ i([
735
+ l({ type: Number })
736
+ ], r.prototype, "maxlength");
737
+ i([
738
+ l({ attribute: !1 })
739
+ ], r.prototype, "countries");
740
+ i([
741
+ l({ type: String })
742
+ ], r.prototype, "country");
743
+ $("kt-input", r);
558
744
  export {
559
- i as KtInput
745
+ r as KtInput
560
746
  };
561
747
  //# sourceMappingURL=kt-input.js.map