@konstructio/ui 0.1.2-alpha.5 → 0.1.2-alpha.50

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 (203) hide show
  1. package/dist/{Combination-VYaRRJBZ.js → Combination-BtmnusWq.js} +141 -138
  2. package/dist/DatePicker.css +1 -1
  3. package/dist/Modal-CjC-CIJ8.js +99 -0
  4. package/dist/assets/icons/index.js +7 -0
  5. package/dist/chevron-down-DgT-uSF9.js +5 -0
  6. package/dist/chevron-right-DYvXLeql.js +7 -0
  7. package/dist/chevron-up-DEfvgPCw.js +54 -0
  8. package/dist/chevron-up-DrQr2Fwd.js +5 -0
  9. package/dist/components/Alert/Alert.js +2 -2
  10. package/dist/components/AlertDialog/AlertDialog.js +81 -53
  11. package/dist/components/AlertDialog/components/AlertDialogTrigger.js +3 -2
  12. package/dist/components/AlertDialog/components/index.js +1 -1
  13. package/dist/components/Badge/Badge.js +41 -44
  14. package/dist/components/Badge/Badge.variants.js +52 -13
  15. package/dist/components/Breadcrumb/Breadcrumb.js +1 -1
  16. package/dist/components/Breadcrumb/Breadcrumb.variants.js +3 -3
  17. package/dist/components/Breadcrumb/components/Item/Item.js +22 -22
  18. package/dist/components/Breadcrumb/components/Item/Item.variants.js +25 -14
  19. package/dist/components/Breadcrumb/hooks/useBreadcrumb.js +1 -1
  20. package/dist/components/Button/Button.js +1 -1
  21. package/dist/components/Button/Button.variants.js +108 -98
  22. package/dist/components/Card/Card.variants.js +7 -12
  23. package/dist/components/Checkbox/Checkbox.js +108 -105
  24. package/dist/components/Checkbox/Checkbox.variants.js +34 -7
  25. package/dist/components/Command/Command.js +2 -2
  26. package/dist/components/Command/components/Command.js +1 -1
  27. package/dist/components/Command/components/CommandEmpty.js +1 -1
  28. package/dist/components/Command/components/CommandGroup.js +1 -1
  29. package/dist/components/Command/components/CommandInput.js +2 -2
  30. package/dist/components/Command/components/CommandItem.js +1 -1
  31. package/dist/components/Command/components/CommandList.js +1 -1
  32. package/dist/components/Command/components/CommandSeparator.js +1 -1
  33. package/dist/components/Command/components/DialogContent.js +2 -2
  34. package/dist/components/Command/components/DialogOverlay.js +1 -1
  35. package/dist/components/Counter/Counter.js +210 -0
  36. package/dist/components/Counter/Counter.variants.js +70 -0
  37. package/dist/components/Datepicker/DatePicker.js +1587 -1353
  38. package/dist/components/Divider/Divider.variants.js +1 -1
  39. package/dist/components/DropdownButton/DropdownButton.js +1 -1
  40. package/dist/components/Filter/Filter.js +1 -1
  41. package/dist/components/Filter/Filter.variants.js +8 -7
  42. package/dist/components/Filter/components/BadgeDropdown/BadgeMultiSelect.js +71 -45
  43. package/dist/components/Filter/components/DateFilterDropdown/DateFilterDropdown.hook.js +2 -2
  44. package/dist/components/Filter/components/DateFilterDropdown/DateFilterDropdown.js +76 -43
  45. package/dist/components/Filter/components/ResetButton/ResetButton.js +15 -12
  46. package/dist/components/Filter/events/index.js +3 -3
  47. package/dist/components/ImageUpload/ImageUpload.js +221 -0
  48. package/dist/components/ImageUpload/ImageUpload.variants.js +109 -0
  49. package/dist/components/Input/Input.js +185 -118
  50. package/dist/components/Input/Input.variants.js +24 -19
  51. package/dist/components/Loading/Loading.js +1 -7
  52. package/dist/components/Modal/Modal.js +2 -2
  53. package/dist/components/Modal/components/Body/Body.js +1 -1
  54. package/dist/components/Modal/components/Footer/Footer.js +1 -1
  55. package/dist/components/Modal/components/Header/Header.js +1 -1
  56. package/dist/components/Modal/components/Wrapper/Wrapper.js +4 -4
  57. package/dist/components/Modal/components/index.js +1 -1
  58. package/dist/components/MultiSelectDropdown/MultiSelectDropdown.js +34 -0
  59. package/dist/components/MultiSelectDropdown/MultiSelectDropdown.variants.js +30 -0
  60. package/dist/components/MultiSelectDropdown/components/Item/Item.js +30 -0
  61. package/dist/components/MultiSelectDropdown/components/Item/Item.variants.js +38 -0
  62. package/dist/components/MultiSelectDropdown/components/List/List.js +30 -0
  63. package/dist/components/MultiSelectDropdown/components/List/List.variants.js +25 -0
  64. package/dist/components/MultiSelectDropdown/components/Wrapper/Wrapper.js +119 -0
  65. package/dist/components/MultiSelectDropdown/components/index.js +8 -0
  66. package/dist/components/MultiSelectDropdown/contexts/MultiSelectDropdown.context.js +21 -0
  67. package/dist/components/MultiSelectDropdown/contexts/MultiSelectDropdown.hook.js +13 -0
  68. package/dist/components/MultiSelectDropdown/contexts/MultiSelectDropdown.provider.js +138 -0
  69. package/dist/components/MultiSelectDropdown/contexts/index.js +6 -0
  70. package/dist/components/MultiSelectDropdown/hooks/useMultiSelectDropdown.js +32 -0
  71. package/dist/components/PhoneNumberInput/PhoneNumberInput.js +8 -0
  72. package/dist/components/PhoneNumberInput/PhoneNumberInput.variants.js +46 -0
  73. package/dist/components/PhoneNumberInput/components/FlagContent/FlagContent.js +36 -0
  74. package/dist/components/PhoneNumberInput/components/FlagSelectorList/FlagSelectorList.js +690 -0
  75. package/dist/components/PhoneNumberInput/components/FlagSelectorWrapper/FlagSelectorWrapper.js +60 -0
  76. package/dist/components/PhoneNumberInput/components/TruncateText/TruncateText.js +45 -0
  77. package/dist/components/PhoneNumberInput/components/Wrapper.js +651 -0
  78. package/dist/components/PhoneNumberInput/components/index.js +6 -0
  79. package/dist/components/PhoneNumberInput/contexts/index.js +8 -0
  80. package/dist/components/PhoneNumberInput/contexts/phone-number.context.js +28 -0
  81. package/dist/components/PhoneNumberInput/contexts/phone-number.hook.js +13 -0
  82. package/dist/components/PhoneNumberInput/contexts/phone-number.provider.js +6144 -0
  83. package/dist/components/PhoneNumberInput/utils/index.js +11 -0
  84. package/dist/components/PieChart/PieChart.js +463 -482
  85. package/dist/components/Radio/Radio.js +47 -44
  86. package/dist/components/Radio/Radio.variants.js +12 -8
  87. package/dist/components/RadioCard/RadioCard.variants.js +1 -6
  88. package/dist/components/RadioGroup/RadioGroup.js +10 -10
  89. package/dist/components/Range/Range.js +1 -1
  90. package/dist/components/Select/Select.js +48 -0
  91. package/dist/components/{Dropdown/Dropdown.variants.js → Select/Select.variants.js} +17 -11
  92. package/dist/components/Select/components/List/List.js +172 -0
  93. package/dist/components/{Dropdown → Select}/components/List/List.variants.js +11 -8
  94. package/dist/components/Select/components/ListItem/ListItem.js +117 -0
  95. package/dist/components/{Dropdown → Select}/components/ListItem/ListItem.variants.js +5 -4
  96. package/dist/components/Select/components/Wrapper.js +226 -0
  97. package/dist/components/Select/constants/index.js +4 -0
  98. package/dist/components/Select/constants/pagination.js +4 -0
  99. package/dist/components/Select/contexts/index.js +6 -0
  100. package/dist/components/Select/contexts/select.context.js +36 -0
  101. package/dist/components/Select/contexts/select.hook.js +11 -0
  102. package/dist/components/Select/contexts/select.provider.js +58 -0
  103. package/dist/components/Select/hooks/useNavigationList.js +50 -0
  104. package/dist/components/Select/hooks/useSelect.js +103 -0
  105. package/dist/components/Sidebar/Sidebar.variants.js +2 -2
  106. package/dist/components/Slider/Slider.js +1 -1
  107. package/dist/components/Switch/Switch.js +156 -129
  108. package/dist/components/Switch/Switch.variants.js +19 -10
  109. package/dist/components/Tabs/Tabs.js +1 -1
  110. package/dist/components/Tabs/Tabs.variants.js +4 -3
  111. package/dist/components/Tabs/components/Content.js +1 -1
  112. package/dist/components/Tabs/components/List.js +1 -1
  113. package/dist/components/Tabs/components/Trigger.js +1 -1
  114. package/dist/components/Tag/Tag.js +1 -1
  115. package/dist/components/Tag/Tag.variants.js +1 -0
  116. package/dist/components/TagSelect/components/Wrapper/Wrapper.js +49 -98
  117. package/dist/components/TimePicker/TimePicker.js +1 -1
  118. package/dist/components/TimePicker/TimePicker.variants.js +26 -14
  119. package/dist/components/TimePicker/components/MeridianList/MeridianList.js +30 -20
  120. package/dist/components/TimePicker/components/Wrapper/Wrapper.js +57 -35
  121. package/dist/components/TimePicker/components/WrapperList/WrapperList.js +53 -45
  122. package/dist/components/Toast/Toast.js +283 -256
  123. package/dist/components/Toast/Toast.variants.js +37 -24
  124. package/dist/components/Tooltip/Tooltip.js +15 -14
  125. package/dist/components/Tooltip/Tooltip.variants.js +5 -4
  126. package/dist/components/Typography/Typography.js +23 -25
  127. package/dist/components/Typography/Typography.variants.js +55 -52
  128. package/dist/components/VirtualizedTable/VirtualizedTable.js +97 -71
  129. package/dist/components/VirtualizedTable/components/Actions/Actions.js +95 -33
  130. package/dist/components/VirtualizedTable/components/Body/Body.js +73 -21
  131. package/dist/components/VirtualizedTable/components/DotPaginate/DotPaginate.js +94 -91
  132. package/dist/components/VirtualizedTable/components/DropdownPaginate/DropdownPaginate.js +20 -20
  133. package/dist/components/VirtualizedTable/components/Filter/Filter.js +61 -44
  134. package/dist/components/VirtualizedTable/components/FormPaginate/FormPaginate.js +33 -21
  135. package/dist/components/VirtualizedTable/components/Header/Header.js +61 -41
  136. package/dist/components/VirtualizedTable/components/Pagination/Pagination.js +43 -22
  137. package/dist/components/VirtualizedTable/components/Skeleton/Skeleton.js +106 -0
  138. package/dist/components/VirtualizedTable/components/TruncateText/TruncateText.js +22 -1858
  139. package/dist/components/VirtualizedTable/components/WrapperBody/WrapperBody.js +27 -0
  140. package/dist/components/VirtualizedTable/components/index.js +8 -6
  141. package/dist/components/VirtualizedTable/contexts/table.context.js +1 -0
  142. package/dist/components/VirtualizedTable/contexts/table.provider.js +68 -761
  143. package/dist/components/index.js +94 -86
  144. package/dist/contexts/theme.provider.js +0 -1
  145. package/dist/{createLucideIcon-D2CN7Ma9.js → createLucideIcon-D4r5Phnh.js} +0 -24
  146. package/dist/ellipsis-vertical-BVPtjl5f.js +9 -0
  147. package/dist/{index-C1g_chDT.js → index-AV6ZtGhy.js} +2 -2
  148. package/dist/index-BG8O18ZY.js +93 -0
  149. package/dist/index-BKjcReYh.js +55 -0
  150. package/dist/{index-N2OStZoU.js → index-BOE_3f_Z.js} +4 -25
  151. package/dist/{index-Cd2vhaop.js → index-BlSRBdPy.js} +5 -6
  152. package/dist/index-BmVmDQGH.js +662 -0
  153. package/dist/index-BvoZGpli.js +60 -0
  154. package/dist/index-Byr10W8m.js +1873 -0
  155. package/dist/{index-Dx2grAuN.js → index-CSWGJT-v.js} +0 -20
  156. package/dist/index-CeZcoQDw.js +479 -0
  157. package/dist/index-D6KzX_ef.js +135 -0
  158. package/dist/{index-B7t8D14s.js → index-D9SSJ6om.js} +4 -4
  159. package/dist/index-DKfEnhKr.js +200 -0
  160. package/dist/index-DLcqcWxM.js +29 -0
  161. package/dist/{index-ti1b9kqV.js → index-DMb4KD0b.js} +4 -4
  162. package/dist/{index-BAEWsOG1.js → index-DtEcCIrM.js} +1 -1
  163. package/dist/{index-bwWKd82e.js → index-Dy59FQl5.js} +1 -1
  164. package/dist/{index-C84F4YyO.js → index-gSPwC-1I.js} +10 -11
  165. package/dist/{index-Bnb0ezr3.js → index-vcSp8YRZ.js} +11 -12
  166. package/dist/index.d.ts +2142 -99
  167. package/dist/index.js +116 -106
  168. package/dist/libphonenumber-FTwQ9nyV.js +11549 -0
  169. package/dist/loader-juvMSJ9L.js +5 -0
  170. package/dist/package.json +43 -33
  171. package/dist/styles.css +1 -1
  172. package/dist/ui/civo-theme.css +194 -168
  173. package/dist/ui/theme.css +27 -0
  174. package/dist/{useBreadcrumb-B8DnuqkR.js → useBreadcrumb-BAHbGQ_O.js} +0 -10
  175. package/dist/utils/index.js +534 -501
  176. package/dist/x-BXShoIAM.js +8 -0
  177. package/dist/{x-4F_5p77m.js → x-Eoa9FJjA.js} +1 -1
  178. package/package.json +43 -33
  179. package/dist/Modal-D-NOEWMX.js +0 -98
  180. package/dist/chevron-down-MZvQoT2F.js +0 -11
  181. package/dist/chevron-right-VYBOBhRt.js +0 -19
  182. package/dist/components/Dropdown/Dropdown.js +0 -42
  183. package/dist/components/Dropdown/components/List/List.js +0 -79
  184. package/dist/components/Dropdown/components/ListItem/ListItem.js +0 -67
  185. package/dist/components/Dropdown/components/Wrapper.js +0 -205
  186. package/dist/components/Dropdown/contexts/dropdown.context.js +0 -19
  187. package/dist/components/Dropdown/contexts/dropdown.hook.js +0 -13
  188. package/dist/components/Dropdown/contexts/dropdown.provider.js +0 -30
  189. package/dist/components/Dropdown/contexts/index.js +0 -6
  190. package/dist/components/Dropdown/hooks/useDropdown.js +0 -58
  191. package/dist/components/Dropdown/hooks/useNavigationList.js +0 -62
  192. package/dist/components/NumberInput/NumberInput.js +0 -179
  193. package/dist/components/NumberInput/NumberInput.variants.js +0 -50
  194. package/dist/components/TimePicker/components/WrapperList/WrapperList.variants.js +0 -16
  195. package/dist/index-BITvcJAz.js +0 -423
  196. package/dist/index-BfXxHr_2.js +0 -125
  197. package/dist/index-Cvx4lqTq.js +0 -47
  198. package/dist/index-DBbEcSUG.js +0 -31
  199. package/dist/index-DQH6odE9.js +0 -82
  200. package/dist/index-DzIBBMjs.js +0 -436
  201. package/dist/index-os7vysFS.js +0 -131
  202. /package/dist/components/{Dropdown → Select}/components/EmptyList.js +0 -0
  203. /package/dist/components/{Dropdown → Select}/components/index.js +0 -0
@@ -1,778 +1,85 @@
1
- import { jsx as ee } from "react/jsx-runtime";
2
- import * as b from "react";
3
- import { useState as w, useMemo as te, useCallback as _ } from "react";
4
- import { u as se, g as re, a as ie } from "../../../index-Dx2grAuN.js";
5
- import { TableContext as ne } from "./table.context.js";
6
- import { DEFAULT_PAGE_SIZE as oe } from "../constants/pagination.js";
7
- var k = class {
8
- constructor() {
9
- this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
10
- }
11
- subscribe(e) {
12
- return this.listeners.add(e), this.onSubscribe(), () => {
13
- this.listeners.delete(e), this.onUnsubscribe();
14
- };
15
- }
16
- hasListeners() {
17
- return this.listeners.size > 0;
18
- }
19
- onSubscribe() {
20
- }
21
- onUnsubscribe() {
22
- }
23
- }, ae = {
24
- // We need the wrapper function syntax below instead of direct references to
25
- // global setTimeout etc.
26
- //
27
- // BAD: `setTimeout: setTimeout`
28
- // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
29
- //
30
- // If we use direct references here, then anything that wants to spy on or
31
- // replace the global setTimeout (like tests) won't work since we'll already
32
- // have a hard reference to the original implementation at the time when this
33
- // file was imported.
34
- setTimeout: (e, t) => setTimeout(e, t),
35
- clearTimeout: (e) => clearTimeout(e),
36
- setInterval: (e, t) => setInterval(e, t),
37
- clearInterval: (e) => clearInterval(e)
38
- }, ce = class {
39
- // We cannot have TimeoutManager<T> as we must instantiate it with a concrete
40
- // type at app boot; and if we leave that type, then any new timer provider
41
- // would need to support ReturnType<typeof setTimeout>, which is infeasible.
42
- //
43
- // We settle for type safety for the TimeoutProvider type, and accept that
44
- // this class is unsafe internally to allow for extension.
45
- #t = ae;
46
- #e = !1;
47
- setTimeoutProvider(e) {
48
- process.env.NODE_ENV !== "production" && this.#e && e !== this.#t && console.error(
49
- "[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",
50
- { previous: this.#t, provider: e }
51
- ), this.#t = e, process.env.NODE_ENV !== "production" && (this.#e = !1);
52
- }
53
- setTimeout(e, t) {
54
- return process.env.NODE_ENV !== "production" && (this.#e = !0), this.#t.setTimeout(e, t);
55
- }
56
- clearTimeout(e) {
57
- this.#t.clearTimeout(e);
58
- }
59
- setInterval(e, t) {
60
- return process.env.NODE_ENV !== "production" && (this.#e = !0), this.#t.setInterval(e, t);
61
- }
62
- clearInterval(e) {
63
- this.#t.clearInterval(e);
64
- }
65
- }, N = new ce();
66
- function ue(e) {
67
- setTimeout(e, 0);
68
- }
69
- var F = typeof window > "u" || "Deno" in globalThis;
70
- function Q() {
71
- }
72
- function z(e) {
73
- return typeof e == "number" && e >= 0 && e !== 1 / 0;
74
- }
75
- function he(e, t) {
76
- return Math.max(e + (t || 0) - Date.now(), 0);
77
- }
78
- function T(e, t) {
79
- return typeof e == "function" ? e(t) : e;
80
- }
81
- function g(e, t) {
82
- return typeof e == "function" ? e(t) : e;
83
- }
84
- var le = Object.prototype.hasOwnProperty;
85
- function j(e, t) {
86
- if (e === t)
87
- return e;
88
- const s = V(e) && V(t);
89
- if (!s && !(B(e) && B(t))) return t;
90
- const r = (s ? e : Object.keys(e)).length, h = s ? t : Object.keys(t), n = h.length, o = s ? new Array(n) : {};
91
- let a = 0;
92
- for (let l = 0; l < n; l++) {
93
- const c = s ? l : h[l], f = e[c], u = t[c];
94
- if (f === u) {
95
- o[c] = f, (s ? l < r : le.call(e, c)) && a++;
96
- continue;
97
- }
98
- if (f === null || u === null || typeof f != "object" || typeof u != "object") {
99
- o[c] = u;
100
- continue;
101
- }
102
- const O = j(f, u);
103
- o[c] = O, O === f && a++;
104
- }
105
- return r === n && a === r ? e : o;
106
- }
107
- function D(e, t) {
108
- if (!t || Object.keys(e).length !== Object.keys(t).length)
109
- return !1;
110
- for (const s in e)
111
- if (e[s] !== t[s])
112
- return !1;
113
- return !0;
114
- }
115
- function V(e) {
116
- return Array.isArray(e) && e.length === Object.keys(e).length;
117
- }
118
- function B(e) {
119
- if (!H(e))
120
- return !1;
121
- const t = e.constructor;
122
- if (t === void 0)
123
- return !0;
124
- const s = t.prototype;
125
- return !(!H(s) || !s.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(e) !== Object.prototype);
126
- }
127
- function H(e) {
128
- return Object.prototype.toString.call(e) === "[object Object]";
129
- }
130
- function W(e, t, s) {
131
- if (typeof s.structuralSharing == "function")
132
- return s.structuralSharing(e, t);
133
- if (s.structuralSharing !== !1) {
134
- if (process.env.NODE_ENV !== "production")
135
- try {
136
- return j(e, t);
137
- } catch (i) {
138
- throw console.error(
139
- `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${s.queryHash}]: ${i}`
140
- ), i;
141
- }
142
- return j(e, t);
143
- }
144
- return t;
145
- }
146
- function fe(e, t) {
147
- return typeof e == "function" ? e(...t) : !!e;
148
- }
149
- var de = class extends k {
150
- #t;
151
- #e;
152
- #r;
153
- constructor() {
154
- super(), this.#r = (e) => {
155
- if (!F && window.addEventListener) {
156
- const t = () => e();
157
- return window.addEventListener("visibilitychange", t, !1), () => {
158
- window.removeEventListener("visibilitychange", t);
159
- };
160
- }
161
- };
162
- }
163
- onSubscribe() {
164
- this.#e || this.setEventListener(this.#r);
165
- }
166
- onUnsubscribe() {
167
- this.hasListeners() || (this.#e?.(), this.#e = void 0);
168
- }
169
- setEventListener(e) {
170
- this.#r = e, this.#e?.(), this.#e = e((t) => {
171
- typeof t == "boolean" ? this.setFocused(t) : this.onFocus();
172
- });
173
- }
174
- setFocused(e) {
175
- this.#t !== e && (this.#t = e, this.onFocus());
176
- }
177
- onFocus() {
178
- const e = this.isFocused();
179
- this.listeners.forEach((t) => {
180
- t(e);
181
- });
182
- }
183
- isFocused() {
184
- return typeof this.#t == "boolean" ? this.#t : globalThis.document?.visibilityState !== "hidden";
185
- }
186
- }, pe = new de();
187
- function J() {
188
- let e, t;
189
- const s = new Promise((r, h) => {
190
- e = r, t = h;
191
- });
192
- s.status = "pending", s.catch(() => {
193
- });
194
- function i(r) {
195
- Object.assign(s, r), delete s.resolve, delete s.reject;
196
- }
197
- return s.resolve = (r) => {
198
- i({
199
- status: "fulfilled",
200
- value: r
201
- }), e(r);
202
- }, s.reject = (r) => {
203
- i({
204
- status: "rejected",
205
- reason: r
206
- }), t(r);
207
- }, s;
208
- }
209
- var ye = ue;
210
- function ge() {
211
- let e = [], t = 0, s = (o) => {
212
- o();
213
- }, i = (o) => {
214
- o();
215
- }, r = ye;
216
- const h = (o) => {
217
- t ? e.push(o) : r(() => {
218
- s(o);
219
- });
220
- }, n = () => {
221
- const o = e;
222
- e = [], o.length && r(() => {
223
- i(() => {
224
- o.forEach((a) => {
225
- s(a);
226
- });
227
- });
228
- });
229
- };
230
- return {
231
- batch: (o) => {
232
- let a;
233
- t++;
234
- try {
235
- a = o();
236
- } finally {
237
- t--, t || n();
238
- }
239
- return a;
240
- },
241
- /**
242
- * All calls to the wrapped function will be batched.
243
- */
244
- batchCalls: (o) => (...a) => {
245
- h(() => {
246
- o(...a);
247
- });
248
- },
249
- schedule: h,
250
- /**
251
- * Use this method to set a custom notify function.
252
- * This can be used to for example wrap notifications with `React.act` while running tests.
253
- */
254
- setNotifyFunction: (o) => {
255
- s = o;
256
- },
257
- /**
258
- * Use this method to set a custom function to batch notifications together into a single tick.
259
- * By default React Query will use the batch function provided by ReactDOM or React Native.
260
- */
261
- setBatchNotifyFunction: (o) => {
262
- i = o;
263
- },
264
- setScheduler: (o) => {
265
- r = o;
266
- }
267
- };
268
- }
269
- var G = ge(), be = class extends k {
270
- #t = !0;
271
- #e;
272
- #r;
273
- constructor() {
274
- super(), this.#r = (e) => {
275
- if (!F && window.addEventListener) {
276
- const t = () => e(!0), s = () => e(!1);
277
- return window.addEventListener("online", t, !1), window.addEventListener("offline", s, !1), () => {
278
- window.removeEventListener("online", t), window.removeEventListener("offline", s);
279
- };
280
- }
281
- };
282
- }
283
- onSubscribe() {
284
- this.#e || this.setEventListener(this.#r);
285
- }
286
- onUnsubscribe() {
287
- this.hasListeners() || (this.#e?.(), this.#e = void 0);
288
- }
289
- setEventListener(e) {
290
- this.#r = e, this.#e?.(), this.#e = e(this.setOnline.bind(this));
291
- }
292
- setOnline(e) {
293
- this.#t !== e && (this.#t = e, this.listeners.forEach((s) => {
294
- s(e);
295
- }));
296
- }
297
- isOnline() {
298
- return this.#t;
299
- }
300
- }, ve = new be();
301
- function me(e) {
302
- return (e ?? "online") === "online" ? ve.isOnline() : !0;
303
- }
304
- function Se(e, t) {
305
- return {
306
- fetchFailureCount: 0,
307
- fetchFailureReason: null,
308
- fetchStatus: me(t.networkMode) ? "fetching" : "paused",
309
- ...e === void 0 && {
310
- error: null,
311
- status: "pending"
312
- }
313
- };
314
- }
315
- var Oe = class extends k {
316
- constructor(e, t) {
317
- super(), this.options = t, this.#t = e, this.#n = null, this.#i = J(), this.bindMethods(), this.setOptions(t);
318
- }
319
- #t;
320
- #e = void 0;
321
- #r = void 0;
322
- #s = void 0;
323
- #a;
324
- #l;
325
- #i;
326
- #n;
327
- #y;
328
- #f;
329
- // This property keeps track of the last query with defined data.
330
- // It will be used to pass the previous data and query to the placeholder function between renders.
331
- #d;
332
- #c;
333
- #u;
334
- #o;
335
- #p = /* @__PURE__ */ new Set();
336
- bindMethods() {
337
- this.refetch = this.refetch.bind(this);
338
- }
339
- onSubscribe() {
340
- this.listeners.size === 1 && (this.#e.addObserver(this), K(this.#e, this.options) ? this.#h() : this.updateResult(), this.#m());
341
- }
342
- onUnsubscribe() {
343
- this.hasListeners() || this.destroy();
344
- }
345
- shouldFetchOnReconnect() {
346
- return U(
347
- this.#e,
348
- this.options,
349
- this.options.refetchOnReconnect
350
- );
351
- }
352
- shouldFetchOnWindowFocus() {
353
- return U(
354
- this.#e,
355
- this.options,
356
- this.options.refetchOnWindowFocus
357
- );
358
- }
359
- destroy() {
360
- this.listeners = /* @__PURE__ */ new Set(), this.#S(), this.#O(), this.#e.removeObserver(this);
361
- }
362
- setOptions(e) {
363
- const t = this.options, s = this.#e;
364
- if (this.options = this.#t.defaultQueryOptions(e), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof g(this.options.enabled, this.#e) != "boolean")
365
- throw new Error(
366
- "Expected enabled to be a boolean or a callback that returns a boolean"
367
- );
368
- this.#R(), this.#e.setOptions(this.options), t._defaulted && !D(this.options, t) && this.#t.getQueryCache().notify({
369
- type: "observerOptionsUpdated",
370
- query: this.#e,
371
- observer: this
372
- });
373
- const i = this.hasListeners();
374
- i && $(
375
- this.#e,
376
- s,
377
- this.options,
378
- t
379
- ) && this.#h(), this.updateResult(), i && (this.#e !== s || g(this.options.enabled, this.#e) !== g(t.enabled, this.#e) || T(this.options.staleTime, this.#e) !== T(t.staleTime, this.#e)) && this.#g();
380
- const r = this.#b();
381
- i && (this.#e !== s || g(this.options.enabled, this.#e) !== g(t.enabled, this.#e) || r !== this.#o) && this.#v(r);
382
- }
383
- getOptimisticResult(e) {
384
- const t = this.#t.getQueryCache().build(this.#t, e), s = this.createResult(t, e);
385
- return Ee(this, s) && (this.#s = s, this.#l = this.options, this.#a = this.#e.state), s;
386
- }
387
- getCurrentResult() {
388
- return this.#s;
389
- }
390
- trackResult(e, t) {
391
- return new Proxy(e, {
392
- get: (s, i) => (this.trackProp(i), t?.(i), i === "promise" && !this.options.experimental_prefetchInRender && this.#i.status === "pending" && this.#i.reject(
393
- new Error(
394
- "experimental_prefetchInRender feature flag is not enabled"
395
- )
396
- ), Reflect.get(s, i))
397
- });
398
- }
399
- trackProp(e) {
400
- this.#p.add(e);
401
- }
402
- getCurrentQuery() {
403
- return this.#e;
404
- }
405
- refetch({ ...e } = {}) {
406
- return this.fetch({
407
- ...e
408
- });
409
- }
410
- fetchOptimistic(e) {
411
- const t = this.#t.defaultQueryOptions(e), s = this.#t.getQueryCache().build(this.#t, t);
412
- return s.fetch().then(() => this.createResult(s, t));
413
- }
414
- fetch(e) {
415
- return this.#h({
416
- ...e,
417
- cancelRefetch: e.cancelRefetch ?? !0
418
- }).then(() => (this.updateResult(), this.#s));
419
- }
420
- #h(e) {
421
- this.#R();
422
- let t = this.#e.fetch(
423
- this.options,
424
- e
425
- );
426
- return e?.throwOnError || (t = t.catch(Q)), t;
427
- }
428
- #g() {
429
- this.#S();
430
- const e = T(
431
- this.options.staleTime,
432
- this.#e
433
- );
434
- if (F || this.#s.isStale || !z(e))
435
- return;
436
- const s = he(this.#s.dataUpdatedAt, e) + 1;
437
- this.#c = N.setTimeout(() => {
438
- this.#s.isStale || this.updateResult();
439
- }, s);
440
- }
441
- #b() {
442
- return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(this.#e) : this.options.refetchInterval) ?? !1;
443
- }
444
- #v(e) {
445
- this.#O(), this.#o = e, !(F || g(this.options.enabled, this.#e) === !1 || !z(this.#o) || this.#o === 0) && (this.#u = N.setInterval(() => {
446
- (this.options.refetchIntervalInBackground || pe.isFocused()) && this.#h();
447
- }, this.#o));
448
- }
449
- #m() {
450
- this.#g(), this.#v(this.#b());
451
- }
452
- #S() {
453
- this.#c && (N.clearTimeout(this.#c), this.#c = void 0);
454
- }
455
- #O() {
456
- this.#u && (N.clearInterval(this.#u), this.#u = void 0);
457
- }
458
- createResult(e, t) {
459
- const s = this.#e, i = this.options, r = this.#s, h = this.#a, n = this.#l, a = e !== s ? e.state : this.#r, { state: l } = e;
460
- let c = { ...l }, f = !1, u;
461
- if (t._optimisticResults) {
462
- const d = this.hasListeners(), E = !d && K(e, t), S = d && $(e, s, t, i);
463
- (E || S) && (c = {
464
- ...c,
465
- ...Se(l.data, e.options)
466
- }), t._optimisticResults === "isRestoring" && (c.fetchStatus = "idle");
467
- }
468
- let { error: O, errorUpdatedAt: R, status: v } = c;
469
- u = c.data;
470
- let M = !1;
471
- if (t.placeholderData !== void 0 && u === void 0 && v === "pending") {
472
- let d;
473
- r?.isPlaceholderData && t.placeholderData === n?.placeholderData ? (d = r.data, M = !0) : d = typeof t.placeholderData == "function" ? t.placeholderData(
474
- this.#d?.state.data,
475
- this.#d
476
- ) : t.placeholderData, d !== void 0 && (v = "success", u = W(
477
- r?.data,
478
- d,
479
- t
480
- ), f = !0);
481
- }
482
- if (t.select && u !== void 0 && !M)
483
- if (r && u === h?.data && t.select === this.#y)
484
- u = this.#f;
485
- else
486
- try {
487
- this.#y = t.select, u = t.select(u), u = W(r?.data, u, t), this.#f = u, this.#n = null;
488
- } catch (d) {
489
- this.#n = d;
490
- }
491
- this.#n && (O = this.#n, u = this.#f, R = Date.now(), v = "error");
492
- const m = c.fetchStatus === "fetching", C = v === "pending", I = v === "error", P = C && m, x = u !== void 0, y = {
493
- status: v,
494
- fetchStatus: c.fetchStatus,
495
- isPending: C,
496
- isSuccess: v === "success",
497
- isError: I,
498
- isInitialLoading: P,
499
- isLoading: P,
500
- data: u,
501
- dataUpdatedAt: c.dataUpdatedAt,
502
- error: O,
503
- errorUpdatedAt: R,
504
- failureCount: c.fetchFailureCount,
505
- failureReason: c.fetchFailureReason,
506
- errorUpdateCount: c.errorUpdateCount,
507
- isFetched: c.dataUpdateCount > 0 || c.errorUpdateCount > 0,
508
- isFetchedAfterMount: c.dataUpdateCount > a.dataUpdateCount || c.errorUpdateCount > a.errorUpdateCount,
509
- isFetching: m,
510
- isRefetching: m && !C,
511
- isLoadingError: I && !x,
512
- isPaused: c.fetchStatus === "paused",
513
- isPlaceholderData: f,
514
- isRefetchError: I && x,
515
- isStale: q(e, t),
516
- refetch: this.refetch,
517
- promise: this.#i,
518
- isEnabled: g(t.enabled, e) !== !1
519
- };
520
- if (this.options.experimental_prefetchInRender) {
521
- const d = (p) => {
522
- y.status === "error" ? p.reject(y.error) : y.data !== void 0 && p.resolve(y.data);
523
- }, E = () => {
524
- const p = this.#i = y.promise = J();
525
- d(p);
526
- }, S = this.#i;
527
- switch (S.status) {
528
- case "pending":
529
- e.queryHash === s.queryHash && d(S);
530
- break;
531
- case "fulfilled":
532
- (y.status === "error" || y.data !== S.value) && E();
533
- break;
534
- case "rejected":
535
- (y.status !== "error" || y.error !== S.reason) && E();
536
- break;
537
- }
538
- }
539
- return y;
540
- }
541
- updateResult() {
542
- const e = this.#s, t = this.createResult(this.#e, this.options);
543
- if (this.#a = this.#e.state, this.#l = this.options, this.#a.data !== void 0 && (this.#d = this.#e), D(t, e))
544
- return;
545
- this.#s = t;
546
- const s = () => {
547
- if (!e)
548
- return !0;
549
- const { notifyOnChangeProps: i } = this.options, r = typeof i == "function" ? i() : i;
550
- if (r === "all" || !r && !this.#p.size)
551
- return !0;
552
- const h = new Set(
553
- r ?? this.#p
554
- );
555
- return this.options.throwOnError && h.add("error"), Object.keys(this.#s).some((n) => {
556
- const o = n;
557
- return this.#s[o] !== e[o] && h.has(o);
558
- });
559
- };
560
- this.#E({ listeners: s() });
561
- }
562
- #R() {
563
- const e = this.#t.getQueryCache().build(this.#t, this.options);
564
- if (e === this.#e)
565
- return;
566
- const t = this.#e;
567
- this.#e = e, this.#r = e.state, this.hasListeners() && (t?.removeObserver(this), e.addObserver(this));
568
- }
569
- onQueryUpdate() {
570
- this.updateResult(), this.hasListeners() && this.#m();
571
- }
572
- #E(e) {
573
- G.batch(() => {
574
- e.listeners && this.listeners.forEach((t) => {
575
- t(this.#s);
576
- }), this.#t.getQueryCache().notify({
577
- query: this.#e,
578
- type: "observerResultsUpdated"
579
- });
580
- });
581
- }
582
- };
583
- function Re(e, t) {
584
- return g(t.enabled, e) !== !1 && e.state.data === void 0 && !(e.state.status === "error" && t.retryOnMount === !1);
585
- }
586
- function K(e, t) {
587
- return Re(e, t) || e.state.data !== void 0 && U(e, t, t.refetchOnMount);
588
- }
589
- function U(e, t, s) {
590
- if (g(t.enabled, e) !== !1 && T(t.staleTime, e) !== "static") {
591
- const i = typeof s == "function" ? s(e) : s;
592
- return i === "always" || i !== !1 && q(e, t);
593
- }
594
- return !1;
595
- }
596
- function $(e, t, s, i) {
597
- return (e !== t || g(i.enabled, e) === !1) && (!s.suspense || e.state.status !== "error") && q(e, s);
598
- }
599
- function q(e, t) {
600
- return g(t.enabled, e) !== !1 && e.isStaleByTime(T(t.staleTime, e));
601
- }
602
- function Ee(e, t) {
603
- return !D(e.getCurrentResult(), t);
604
- }
605
- var we = b.createContext(
606
- void 0
607
- ), Ce = (e) => {
608
- const t = b.useContext(we);
609
- if (!t)
610
- throw new Error("No QueryClient set, use QueryClientProvider to set one");
611
- return t;
612
- }, Ie = b.createContext(!1), Te = () => b.useContext(Ie);
613
- function Fe() {
614
- let e = !1;
615
- return {
616
- clearReset: () => {
617
- e = !1;
618
- },
619
- reset: () => {
620
- e = !0;
621
- },
622
- isReset: () => e
623
- };
624
- }
625
- var Me = b.createContext(Fe()), Pe = () => b.useContext(Me), xe = (e, t) => {
626
- (e.suspense || e.throwOnError || e.experimental_prefetchInRender) && (t.isReset() || (e.retryOnMount = !1));
627
- }, _e = (e) => {
628
- b.useEffect(() => {
629
- e.clearReset();
630
- }, [e]);
631
- }, Ne = ({
632
- result: e,
633
- errorResetBoundary: t,
634
- throwOnError: s,
635
- query: i,
636
- suspense: r
637
- }) => e.isError && !t.isReset() && !e.isFetching && i && (r && e.data === void 0 || fe(s, [e.error, i])), Le = (e) => {
638
- if (e.suspense) {
639
- const s = (r) => r === "static" ? r : Math.max(r ?? 1e3, 1e3), i = e.staleTime;
640
- e.staleTime = typeof i == "function" ? (...r) => s(i(...r)) : s(i), typeof e.gcTime == "number" && (e.gcTime = Math.max(
641
- e.gcTime,
642
- 1e3
643
- ));
644
- }
645
- }, Qe = (e, t) => e.isLoading && e.isFetching && !t, je = (e, t) => e?.suspense && t.isPending, Z = (e, t, s) => t.fetchOptimistic(e).catch(() => {
646
- s.clearReset();
647
- });
648
- function De(e, t, s) {
649
- if (process.env.NODE_ENV !== "production" && (typeof e != "object" || Array.isArray(e)))
650
- throw new Error(
651
- 'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'
652
- );
653
- const i = Te(), r = Pe(), h = Ce(), n = h.defaultQueryOptions(e);
654
- h.getDefaultOptions().queries?._experimental_beforeQuery?.(
655
- n
656
- ), process.env.NODE_ENV !== "production" && (n.queryFn || console.error(
657
- `[${n.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`
658
- )), n._optimisticResults = i ? "isRestoring" : "optimistic", Le(n), xe(n, r), _e(r);
659
- const o = !h.getQueryCache().get(n.queryHash), [a] = b.useState(
660
- () => new t(
661
- h,
662
- n
663
- )
664
- ), l = a.getOptimisticResult(n), c = !i && e.subscribed !== !1;
665
- if (b.useSyncExternalStore(
666
- b.useCallback(
667
- (f) => {
668
- const u = c ? a.subscribe(G.batchCalls(f)) : Q;
669
- return a.updateResult(), u;
670
- },
671
- [a, c]
672
- ),
673
- () => a.getCurrentResult(),
674
- () => a.getCurrentResult()
675
- ), b.useEffect(() => {
676
- a.setOptions(n);
677
- }, [n, a]), je(n, l))
678
- throw Z(n, a, r);
679
- if (Ne({
680
- result: l,
681
- errorResetBoundary: r,
682
- throwOnError: n.throwOnError,
683
- query: h.getQueryCache().get(n.queryHash),
684
- suspense: n.suspense
685
- }))
686
- throw l.error;
687
- return h.getDefaultOptions().queries?._experimental_afterQuery?.(
688
- n,
689
- l
690
- ), n.experimental_prefetchInRender && !F && Qe(l, i) && (o ? (
691
- // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
692
- Z(n, a, r)
693
- ) : (
694
- // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
695
- h.getQueryCache().get(n.queryHash)?.promise
696
- ))?.catch(Q).finally(() => {
697
- a.updateResult();
698
- }), n.notifyOnChangeProps ? l : a.trackResult(l);
699
- }
700
- function Ue(e, t) {
701
- return De(e, Oe);
702
- }
703
- const Be = ({
704
- children: e,
705
- id: t,
706
- data: s = [],
707
- columns: i = [],
708
- totalItems: r,
709
- fetchData: h
1
+ import { jsx as k } from "react/jsx-runtime";
2
+ import { useQuery as A } from "@tanstack/react-query";
3
+ import { u as D, g as Q, a as $ } from "../../../index-CSWGJT-v.js";
4
+ import { useState as t, useMemo as G, useCallback as c } from "react";
5
+ import { TableContext as U } from "./table.context.js";
6
+ import { DEFAULT_PAGE_SIZE as W } from "../constants/pagination.js";
7
+ const X = ({
8
+ children: p,
9
+ id: r,
10
+ data: g = [],
11
+ columns: S = [],
12
+ totalItems: y,
13
+ isPaginationEnabled: b,
14
+ queryOptions: M = {},
15
+ fetchData: m
710
16
  }) => {
711
- const [n, o] = w([]), [a, l] = w(0), [c, f] = w(), [u, O] = w(oe), [R, v] = w(r), M = te(
712
- () => Math.ceil(R / u),
713
- [R, u]
714
- ), [m, C] = w({}), { data: I, isLoading: P, isFetching: x } = Ue({
715
- queryKey: [
716
- t,
717
- a,
718
- u,
719
- c,
720
- JSON.stringify(m)
721
- ],
17
+ const [f, d] = t([]), [C, P] = t(!0), [i, h] = t(0), [a, w] = t(), [s, F] = t(W), [l, O] = t(y), T = G(
18
+ () => Math.ceil(l / s),
19
+ [l, s]
20
+ ), [n, L] = t({}), I = () => {
21
+ const e = typeof r == "string" || typeof r == "number" ? [r] : r;
22
+ return b && e.push(i, s), a && e.push(a), Object.entries(n).forEach(([o, u]) => {
23
+ e.push(`${o}:${u.join(",")}`);
24
+ }), e;
25
+ }, { data: R, isLoading: j, isFetching: x } = A({
26
+ queryKey: I(),
722
27
  refetchOnMount: !1,
723
28
  refetchOnWindowFocus: !1,
724
- initialData: s,
725
- queryFn: () => h({
726
- page: Math.max(a + 1, 1),
727
- pageSize: u,
728
- termOfSearch: c,
729
- ...Object.keys(m).length > 0 ? m : {}
730
- }).then(({ data: p, totalItemsCount: L }) => (v(L), p))
731
- }), A = _((p) => {
732
- f(p), l(0);
733
- }, []), y = _((p, L) => {
734
- const X = p.toLowerCase().replace(/\s+/g, "_");
735
- C((Y) => ({
736
- ...Y,
737
- [X]: L
29
+ initialData: g,
30
+ queryFn: async () => m ? m({
31
+ page: Math.max(i + 1, 1),
32
+ pageSize: s,
33
+ termOfSearch: a,
34
+ ...Object.keys(n).length > 0 ? n : {}
35
+ }).then(({ data: e, totalItemsCount: o }) => (P(!1), o && O(o), e)) : g ?? [],
36
+ ...M
37
+ }), E = c((e) => {
38
+ w(e), h(0);
39
+ }, []), K = c((e, o) => {
40
+ const u = e.toLowerCase().replace(/\s+/g, "_");
41
+ L((_) => ({
42
+ ..._,
43
+ [u]: o
738
44
  }));
739
- }, []), d = _((p) => l(p), []), E = _(
740
- (p) => O(p),
45
+ }, []), q = c((e) => h(e), []), v = c(
46
+ (e) => F(e),
741
47
  []
742
- ), S = se({
743
- data: I,
744
- columns: i,
48
+ ), z = D({
49
+ data: R,
50
+ columns: S,
745
51
  state: {
746
- sorting: n
52
+ sorting: f
747
53
  },
748
- onSortingChange: o,
749
- getCoreRowModel: ie(),
750
- getSortedRowModel: re()
54
+ onSortingChange: d,
55
+ getCoreRowModel: $(),
56
+ getSortedRowModel: Q()
751
57
  });
752
- return /* @__PURE__ */ ee(
753
- ne.Provider,
58
+ return /* @__PURE__ */ k(
59
+ U.Provider,
754
60
  {
755
61
  value: {
756
- sortedData: n,
757
- table: S,
62
+ sortedData: f,
63
+ table: z,
758
64
  tableFetching: x,
759
- tableLoading: P,
760
- totalItems: R,
761
- termOfSearch: c,
762
- page: a,
763
- multiselectSelected: m,
764
- pageSize: u,
765
- totalPages: M,
766
- handlePage: d,
767
- onPageSize: E,
768
- onChangeTermOfSearch: A,
769
- onSorting: o,
770
- onSelectMultiselect: y
65
+ tableLoading: j,
66
+ totalItems: l,
67
+ termOfSearch: a,
68
+ page: i,
69
+ multiselectSelected: n,
70
+ pageSize: s,
71
+ totalPages: T,
72
+ isFirstLoad: C,
73
+ handlePage: q,
74
+ onPageSize: v,
75
+ onChangeTermOfSearch: E,
76
+ onSorting: d,
77
+ onSelectMultiselect: K
771
78
  },
772
- children: e
79
+ children: p
773
80
  }
774
81
  );
775
82
  };
776
83
  export {
777
- Be as TableProvider
84
+ X as TableProvider
778
85
  };