@gsc-basic/components 1.0.1 → 1.0.3

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 (164) hide show
  1. package/README.md +59 -0
  2. package/dist/es/index.js +48 -30
  3. package/dist/es/node_modules/@codemirror/autocomplete/dist/index.js +15 -15
  4. package/dist/es/node_modules/@codemirror/commands/dist/index.js +31 -25
  5. package/dist/es/node_modules/@codemirror/lang-java/dist/index.js +3 -3
  6. package/dist/es/node_modules/@codemirror/lang-javascript/dist/index.js +8 -8
  7. package/dist/es/node_modules/@codemirror/lang-json/dist/index.js +1 -1
  8. package/dist/es/node_modules/@codemirror/lang-python/dist/index.js +1 -1
  9. package/dist/es/node_modules/@codemirror/lang-sql/dist/index.js +6 -6
  10. package/dist/es/node_modules/@codemirror/lang-xml/dist/index.js +3 -3
  11. package/dist/es/node_modules/@codemirror/lang-yaml/dist/index.js +1 -1
  12. package/dist/es/node_modules/@codemirror/language/dist/index.js +77 -77
  13. package/dist/es/node_modules/@codemirror/lint/dist/index.js +7 -7
  14. package/dist/es/node_modules/@codemirror/search/dist/index.js +432 -465
  15. package/dist/es/node_modules/@codemirror/state/dist/index.js +272 -268
  16. package/dist/es/node_modules/@codemirror/view/dist/index.js +1732 -1647
  17. package/dist/es/node_modules/@lezer/common/dist/index.js +191 -190
  18. package/dist/es/node_modules/@lezer/lr/dist/index.js +5 -3
  19. package/dist/es/node_modules/@tanstack/devtools-event-client/dist/esm/plugin.js +178 -0
  20. package/dist/es/node_modules/@tanstack/form-core/dist/esm/EventClient.js +13 -0
  21. package/dist/es/node_modules/@tanstack/form-core/dist/esm/FieldApi.js +406 -0
  22. package/dist/es/node_modules/@tanstack/form-core/dist/esm/FormApi.js +772 -0
  23. package/dist/es/node_modules/@tanstack/form-core/dist/esm/ValidationLogic.js +55 -0
  24. package/dist/es/node_modules/@tanstack/form-core/dist/esm/metaHelper.js +109 -0
  25. package/dist/es/node_modules/@tanstack/form-core/dist/esm/standardSchemaValidator.js +45 -0
  26. package/dist/es/node_modules/@tanstack/form-core/dist/esm/utils.js +213 -0
  27. package/dist/es/node_modules/@tanstack/pacer-lite/dist/lite-throttler.js +29 -0
  28. package/dist/es/node_modules/@tanstack/store/dist/esm/derived.js +74 -0
  29. package/dist/es/node_modules/@tanstack/store/dist/esm/scheduler.js +79 -0
  30. package/dist/es/node_modules/@tanstack/store/dist/esm/store.js +21 -0
  31. package/dist/es/node_modules/@tanstack/store/dist/esm/types.js +6 -0
  32. package/dist/es/node_modules/@tanstack/table-core/build/lib/index.js +1885 -0
  33. package/dist/es/node_modules/@tanstack/vue-form/dist/esm/useField.js +38 -0
  34. package/dist/es/node_modules/@tanstack/vue-form/dist/esm/useForm.js +33 -0
  35. package/dist/es/node_modules/@tanstack/vue-store/dist/esm/index.js +48 -0
  36. package/dist/es/node_modules/@tanstack/vue-table/build/lib/index.js +159 -0
  37. package/dist/es/node_modules/@vueuse/core/dist/index.js +1 -1
  38. package/dist/es/node_modules/codemirror/dist/index.js +3 -3
  39. package/dist/es/src/Button/index.js +6 -0
  40. package/dist/es/src/Button/src/Button.css +1 -0
  41. package/dist/es/src/Button/src/Button.vue.js +41 -0
  42. package/dist/es/src/Button/src/Button2.css +1 -0
  43. package/dist/es/src/CodeEditor/src/index.css +1 -1
  44. package/dist/es/src/CodeEditor/src/index.vue.js +54 -51
  45. package/dist/es/src/CodeEditor/src/index2.css +1 -1
  46. package/dist/es/src/ConfigProvider/index.js +1 -2
  47. package/dist/es/src/ConfigProvider/src/useGlobalConfig.js +9 -9
  48. package/dist/es/src/Form/index.js +6 -0
  49. package/dist/es/src/Form/src/Form.css +1 -0
  50. package/dist/es/src/Form/src/Form.vue.js +208 -0
  51. package/dist/es/src/Form/src/styles/form.css +1 -0
  52. package/dist/es/src/Grid/index.js +6 -0
  53. package/dist/es/src/Grid/src/Grid.css +1 -0
  54. package/dist/es/src/Grid/src/Grid.vue.js +180 -0
  55. package/dist/es/src/Grid/src/components/ActionBar.css +1 -0
  56. package/dist/es/src/Grid/src/components/ActionBar.vue.js +65 -0
  57. package/dist/es/src/Grid/src/components/CellEditor.css +1 -0
  58. package/dist/es/src/Grid/src/components/CellEditor.vue.js +132 -0
  59. package/dist/es/src/Grid/src/components/CellEditor2.css +1 -0
  60. package/dist/es/src/Grid/src/components/ColumnFilter.css +1 -0
  61. package/dist/es/src/Grid/src/components/ColumnFilter.vue.js +72 -0
  62. package/dist/es/src/Grid/src/components/ColumnSettings.css +1 -0
  63. package/dist/es/src/Grid/src/components/ColumnSettings.vue.js +109 -0
  64. package/dist/es/src/Grid/src/components/DataTable.css +1 -0
  65. package/dist/es/src/Grid/src/components/DataTable.vue.js +556 -0
  66. package/dist/es/src/Grid/src/components/Pager.css +1 -0
  67. package/dist/es/src/Grid/src/components/Pager.vue.js +64 -0
  68. package/dist/es/src/Grid/src/components/QueryBar.css +1 -0
  69. package/dist/es/src/Grid/src/components/QueryBar.vue.js +156 -0
  70. package/dist/es/src/Grid/src/composables/useCellEditor.js +20 -0
  71. package/dist/es/src/Grid/src/composables/useGridTable.js +213 -0
  72. package/dist/es/src/Grid/src/styles/table.css +1 -0
  73. package/dist/es/src/Overlay/index.js +61 -0
  74. package/dist/es/src/Overlay/src/Message.css +1 -0
  75. package/dist/es/src/Overlay/src/Message.vue.js +36 -0
  76. package/dist/es/src/Overlay/src/Message2.css +1 -0
  77. package/dist/es/src/Overlay/src/Modal.css +1 -0
  78. package/dist/es/src/Overlay/src/Modal.vue.js +67 -0
  79. package/dist/es/src/Overlay/src/Modal2.css +1 -0
  80. package/dist/es/src/Overlay/src/Notice.css +1 -0
  81. package/dist/es/src/Overlay/src/Notice.vue.js +37 -0
  82. package/dist/es/src/Overlay/src/Notice2.css +1 -0
  83. package/dist/es/src/ScaleScreen/src/index.vue.js +2 -2
  84. package/dist/es/src/VideoBackground/src/index.vue.js +8 -8
  85. package/dist/es/src/index.js +35 -19
  86. package/dist/es/src/locale/lang/en-US.js +40 -0
  87. package/dist/es/src/locale/lang/ja-JP.js +42 -2
  88. package/dist/es/src/locale/lang/zh-CN.js +42 -2
  89. package/dist/es/src/styles/tokens.css +1 -1
  90. package/dist/lib/index.js +1 -1
  91. package/dist/lib/node_modules/@codemirror/commands/dist/index.js +1 -1
  92. package/dist/lib/node_modules/@codemirror/language/dist/index.js +1 -1
  93. package/dist/lib/node_modules/@codemirror/search/dist/index.js +2 -2
  94. package/dist/lib/node_modules/@codemirror/state/dist/index.js +4 -4
  95. package/dist/lib/node_modules/@codemirror/view/dist/index.js +5 -5
  96. package/dist/lib/node_modules/@lezer/common/dist/index.js +1 -1
  97. package/dist/lib/node_modules/@lezer/lr/dist/index.js +1 -1
  98. package/dist/lib/node_modules/@tanstack/devtools-event-client/dist/esm/plugin.js +1 -0
  99. package/dist/lib/node_modules/@tanstack/form-core/dist/esm/EventClient.js +1 -0
  100. package/dist/lib/node_modules/@tanstack/form-core/dist/esm/FieldApi.js +1 -0
  101. package/dist/lib/node_modules/@tanstack/form-core/dist/esm/FormApi.js +1 -0
  102. package/dist/lib/node_modules/@tanstack/form-core/dist/esm/ValidationLogic.js +1 -0
  103. package/dist/lib/node_modules/@tanstack/form-core/dist/esm/metaHelper.js +1 -0
  104. package/dist/lib/node_modules/@tanstack/form-core/dist/esm/standardSchemaValidator.js +1 -0
  105. package/dist/lib/node_modules/@tanstack/form-core/dist/esm/utils.js +1 -0
  106. package/dist/lib/node_modules/@tanstack/pacer-lite/dist/lite-throttler.js +1 -0
  107. package/dist/lib/node_modules/@tanstack/store/dist/esm/derived.js +1 -0
  108. package/dist/lib/node_modules/@tanstack/store/dist/esm/scheduler.js +1 -0
  109. package/dist/lib/node_modules/@tanstack/store/dist/esm/store.js +1 -0
  110. package/dist/lib/node_modules/@tanstack/store/dist/esm/types.js +1 -0
  111. package/dist/lib/node_modules/@tanstack/table-core/build/lib/index.js +4 -0
  112. package/dist/lib/node_modules/@tanstack/vue-form/dist/esm/useField.js +1 -0
  113. package/dist/lib/node_modules/@tanstack/vue-form/dist/esm/useForm.js +1 -0
  114. package/dist/lib/node_modules/@tanstack/vue-store/dist/esm/index.js +1 -0
  115. package/dist/lib/node_modules/@tanstack/vue-table/build/lib/index.js +1 -0
  116. package/dist/lib/src/Button/index.js +1 -0
  117. package/dist/lib/src/Button/src/Button.css +1 -0
  118. package/dist/lib/src/Button/src/Button.vue.js +1 -0
  119. package/dist/lib/src/Button/src/Button2.css +1 -0
  120. package/dist/lib/src/CodeEditor/src/index.css +1 -1
  121. package/dist/lib/src/CodeEditor/src/index.vue.js +1 -1
  122. package/dist/lib/src/CodeEditor/src/index2.css +1 -1
  123. package/dist/lib/src/ConfigProvider/index.js +1 -1
  124. package/dist/lib/src/Form/index.js +1 -0
  125. package/dist/lib/src/Form/src/Form.css +1 -0
  126. package/dist/lib/src/Form/src/Form.vue.js +1 -0
  127. package/dist/lib/src/Form/src/styles/form.css +1 -0
  128. package/dist/lib/src/Grid/index.js +1 -0
  129. package/dist/lib/src/Grid/src/Grid.css +1 -0
  130. package/dist/lib/src/Grid/src/Grid.vue.js +1 -0
  131. package/dist/lib/src/Grid/src/components/ActionBar.css +1 -0
  132. package/dist/lib/src/Grid/src/components/ActionBar.vue.js +1 -0
  133. package/dist/lib/src/Grid/src/components/CellEditor.css +1 -0
  134. package/dist/lib/src/Grid/src/components/CellEditor.vue.js +1 -0
  135. package/dist/lib/src/Grid/src/components/CellEditor2.css +1 -0
  136. package/dist/lib/src/Grid/src/components/ColumnFilter.css +1 -0
  137. package/dist/lib/src/Grid/src/components/ColumnFilter.vue.js +1 -0
  138. package/dist/lib/src/Grid/src/components/ColumnSettings.css +1 -0
  139. package/dist/lib/src/Grid/src/components/ColumnSettings.vue.js +1 -0
  140. package/dist/lib/src/Grid/src/components/DataTable.css +1 -0
  141. package/dist/lib/src/Grid/src/components/DataTable.vue.js +1 -0
  142. package/dist/lib/src/Grid/src/components/Pager.css +1 -0
  143. package/dist/lib/src/Grid/src/components/Pager.vue.js +1 -0
  144. package/dist/lib/src/Grid/src/components/QueryBar.css +1 -0
  145. package/dist/lib/src/Grid/src/components/QueryBar.vue.js +1 -0
  146. package/dist/lib/src/Grid/src/composables/useCellEditor.js +1 -0
  147. package/dist/lib/src/Grid/src/composables/useGridTable.js +1 -0
  148. package/dist/lib/src/Grid/src/styles/table.css +1 -0
  149. package/dist/lib/src/Overlay/index.js +1 -0
  150. package/dist/lib/src/Overlay/src/Message.css +1 -0
  151. package/dist/lib/src/Overlay/src/Message.vue.js +1 -0
  152. package/dist/lib/src/Overlay/src/Message2.css +1 -0
  153. package/dist/lib/src/Overlay/src/Modal.css +1 -0
  154. package/dist/lib/src/Overlay/src/Modal.vue.js +1 -0
  155. package/dist/lib/src/Overlay/src/Modal2.css +1 -0
  156. package/dist/lib/src/Overlay/src/Notice.css +1 -0
  157. package/dist/lib/src/Overlay/src/Notice.vue.js +1 -0
  158. package/dist/lib/src/Overlay/src/Notice2.css +1 -0
  159. package/dist/lib/src/index.js +1 -1
  160. package/dist/lib/src/locale/lang/en-US.js +1 -1
  161. package/dist/lib/src/locale/lang/ja-JP.js +1 -1
  162. package/dist/lib/src/locale/lang/zh-CN.js +1 -1
  163. package/dist/lib/src/styles/tokens.css +1 -1
  164. package/package.json +11 -8
@@ -112,11 +112,13 @@ class v {
112
112
  this.pushState(t & 65535, this.pos);
113
113
  else if ((t & 262144) == 0) {
114
114
  let h = t, { parser: r } = this.p;
115
- (i > this.pos || e <= r.maxNode) && (this.pos = i, r.stateFlag(
115
+ this.pos = i;
116
+ let n = r.stateFlag(
116
117
  h,
117
118
  1
118
119
  /* StateFlag.Skipped */
119
- ) || (this.reducePos = i)), this.pushState(h, s), this.shiftContext(e, s), e <= r.maxNode && this.buffer.push(e, s, i, 4);
120
+ );
121
+ !n && (i > s || e <= r.maxNode) && (this.reducePos = i), this.pushState(h, n ? s : Math.min(s, this.reducePos)), this.shiftContext(e, s), e <= r.maxNode && this.buffer.push(e, s, i, 4);
120
122
  } else
121
123
  this.pos = i, this.shiftContext(e, s), e <= this.p.parser.maxNode && this.buffer.push(e, s, i, 4);
122
124
  }
@@ -978,7 +980,7 @@ class K {
978
980
  g && (p = this.stackID(f) + " -> ");
979
981
  for (let c of n.recoverByInsert(o))
980
982
  g && console.log(u + this.stackID(c) + " (via recover-insert)"), this.advanceFully(c, s);
981
- this.stream.end > n.pos ? (a == n.pos && (a++, o = 0), n.recoverByDelete(o, a), g && console.log(u + this.stackID(n) + ` (via recover-delete ${this.parser.getName(o)})`), D(n, s)) : (!i || i.score < n.score) && (i = n);
983
+ this.stream.end > n.pos ? (a == n.pos && (a++, o = 0), n.recoverByDelete(o, a), g && console.log(u + this.stackID(n) + ` (via recover-delete ${this.parser.getName(o)})`), D(n, s)) : (!i || i.score < f.score) && (i = f);
982
984
  }
983
985
  return i;
984
986
  }
@@ -0,0 +1,178 @@
1
+ class a {
2
+ #o = !0;
3
+ #e;
4
+ #t;
5
+ #u;
6
+ #n;
7
+ #r;
8
+ #i;
9
+ #a;
10
+ #l = 0;
11
+ #v = 5;
12
+ #h = !1;
13
+ #d = !1;
14
+ #s = null;
15
+ #c = () => {
16
+ this.debugLog("Connected to event bus"), this.#r = !0, this.#h = !1, this.debugLog("Emitting queued events", this.#n), this.#n.forEach((t) => this.emitEventToBus(t)), this.#n = [], this.stopConnectLoop(), this.#t().removeEventListener(
17
+ "tanstack-connect-success",
18
+ this.#c
19
+ );
20
+ };
21
+ // fired off right away and then at intervals
22
+ #g = () => {
23
+ if (this.#l < this.#v) {
24
+ this.#l++, this.dispatchCustomEvent("tanstack-connect", {});
25
+ return;
26
+ }
27
+ this.#t().removeEventListener(
28
+ "tanstack-connect",
29
+ this.#g
30
+ ), this.#d = !0, this.debugLog("Max retries reached, giving up on connection"), this.stopConnectLoop();
31
+ };
32
+ // This is run to register connection handlers on first emit attempt
33
+ #E = () => {
34
+ this.#h || (this.#h = !0, this.#t().addEventListener(
35
+ "tanstack-connect-success",
36
+ this.#c
37
+ ), this.#g());
38
+ };
39
+ constructor({
40
+ pluginId: t,
41
+ debug: e = !1,
42
+ enabled: n = !0,
43
+ reconnectEveryMs: i = 300
44
+ }) {
45
+ this.#e = t, this.#o = n, this.#t = this.getGlobalTarget, this.#u = e, this.debugLog(" Initializing event subscription for plugin", this.#e), this.#n = [], this.#r = !1, this.#d = !1, this.#i = null, this.#a = i;
46
+ }
47
+ startConnectLoop() {
48
+ this.#i !== null || this.#r || (this.debugLog(`Starting connect loop (every ${this.#a}ms)`), this.#i = setInterval(
49
+ this.#g,
50
+ this.#a
51
+ ));
52
+ }
53
+ stopConnectLoop() {
54
+ this.#h = !1, this.#i !== null && (clearInterval(this.#i), this.#i = null, this.#n = [], this.debugLog("Stopped connect loop"));
55
+ }
56
+ debugLog(...t) {
57
+ this.#u && console.log(`🌴 [tanstack-devtools:${this.#e}-plugin]`, ...t);
58
+ }
59
+ getGlobalTarget() {
60
+ if (typeof globalThis < "u" && globalThis.__TANSTACK_EVENT_TARGET__)
61
+ return this.debugLog("Using global event target"), globalThis.__TANSTACK_EVENT_TARGET__;
62
+ if (typeof window < "u" && typeof window.addEventListener < "u")
63
+ return this.debugLog("Using window as event target"), window;
64
+ const t = typeof EventTarget < "u" ? new EventTarget() : void 0;
65
+ return typeof t > "u" || typeof t.addEventListener > "u" ? (this.debugLog(
66
+ "No event mechanism available, running in non-web environment"
67
+ ), {
68
+ addEventListener: () => {
69
+ },
70
+ removeEventListener: () => {
71
+ },
72
+ dispatchEvent: () => !1
73
+ }) : (this.debugLog("Using new EventTarget as fallback"), t);
74
+ }
75
+ getPluginId() {
76
+ return this.#e;
77
+ }
78
+ dispatchCustomEventShim(t, e) {
79
+ try {
80
+ const n = new Event(t, {
81
+ detail: e
82
+ });
83
+ this.#t().dispatchEvent(n);
84
+ } catch {
85
+ this.debugLog("Failed to dispatch shim event");
86
+ }
87
+ }
88
+ dispatchCustomEvent(t, e) {
89
+ try {
90
+ this.#t().dispatchEvent(new CustomEvent(t, { detail: e }));
91
+ } catch {
92
+ this.dispatchCustomEventShim(t, e);
93
+ }
94
+ }
95
+ emitEventToBus(t) {
96
+ this.debugLog("Emitting event to client bus", t), this.dispatchCustomEvent("tanstack-dispatch-event", t);
97
+ }
98
+ createEventPayload(t, e) {
99
+ return {
100
+ type: `${this.#e}:${t}`,
101
+ payload: e,
102
+ pluginId: this.#e
103
+ };
104
+ }
105
+ emit(t, e) {
106
+ if (!this.#o) {
107
+ this.debugLog(
108
+ "Event bus client is disabled, not emitting event",
109
+ t,
110
+ e
111
+ );
112
+ return;
113
+ }
114
+ if (this.#s && (this.debugLog(
115
+ "Emitting event to internal event target",
116
+ t,
117
+ e
118
+ ), this.#s.dispatchEvent(
119
+ new CustomEvent(`${this.#e}:${t}`, {
120
+ detail: this.createEventPayload(t, e)
121
+ })
122
+ )), this.#d) {
123
+ this.debugLog("Previously failed to connect, not emitting to bus");
124
+ return;
125
+ }
126
+ if (!this.#r) {
127
+ this.debugLog("Bus not available, will be pushed as soon as connected"), this.#n.push(this.createEventPayload(t, e)), typeof CustomEvent < "u" && !this.#h && (this.#E(), this.startConnectLoop());
128
+ return;
129
+ }
130
+ return this.emitEventToBus(this.createEventPayload(t, e));
131
+ }
132
+ on(t, e, n) {
133
+ const i = n?.withEventTarget ?? !1, s = `${this.#e}:${t}`;
134
+ if (i && (this.#s || (this.#s = new EventTarget()), this.#s.addEventListener(s, (o) => {
135
+ e(o.detail);
136
+ })), !this.#o)
137
+ return this.debugLog(
138
+ "Event bus client is disabled, not registering event",
139
+ s
140
+ ), () => {
141
+ };
142
+ const h = (o) => {
143
+ this.debugLog("Received event from bus", o.detail), e(o.detail);
144
+ };
145
+ return this.#t().addEventListener(s, h), this.debugLog("Registered event to bus", s), () => {
146
+ i && this.#s?.removeEventListener(s, h), this.#t().removeEventListener(s, h);
147
+ };
148
+ }
149
+ onAll(t) {
150
+ if (!this.#o)
151
+ return this.debugLog("Event bus client is disabled, not registering event"), () => {
152
+ };
153
+ const e = (n) => {
154
+ const i = n.detail;
155
+ t(i);
156
+ };
157
+ return this.#t().addEventListener("tanstack-devtools-global", e), () => this.#t().removeEventListener(
158
+ "tanstack-devtools-global",
159
+ e
160
+ );
161
+ }
162
+ onAllPluginEvents(t) {
163
+ if (!this.#o)
164
+ return this.debugLog("Event bus client is disabled, not registering event"), () => {
165
+ };
166
+ const e = (n) => {
167
+ const i = n.detail;
168
+ this.#e && i.pluginId !== this.#e || t(i);
169
+ };
170
+ return this.#t().addEventListener("tanstack-devtools-global", e), () => this.#t().removeEventListener(
171
+ "tanstack-devtools-global",
172
+ e
173
+ );
174
+ }
175
+ }
176
+ export {
177
+ a as EventClient
178
+ };
@@ -0,0 +1,13 @@
1
+ import { EventClient as e } from "../../../devtools-event-client/dist/esm/plugin.js";
2
+ class t extends e {
3
+ constructor() {
4
+ super({
5
+ pluginId: "form-devtools",
6
+ reconnectEveryMs: 1e3
7
+ });
8
+ }
9
+ }
10
+ const r = new t();
11
+ export {
12
+ r as formEventClient
13
+ };
@@ -0,0 +1,406 @@
1
+ import { Derived as K } from "../../../store/dist/esm/derived.js";
2
+ import { batch as U } from "../../../store/dist/esm/scheduler.js";
3
+ import { standardSchemaValidators as b, isStandardSchemaValidator as W } from "./standardSchemaValidator.js";
4
+ import { defaultFieldMeta as x } from "./metaHelper.js";
5
+ import { evaluate as C, mergeOpts as g, getSyncValidatorArray as T, determineFieldLevelErrorSourceAndValue as R, getAsyncValidatorArray as E } from "./utils.js";
6
+ import { defaultValidationLogic as F } from "./ValidationLogic.js";
7
+ class Q {
8
+ /**
9
+ * Initializes a new `FieldApi` instance.
10
+ */
11
+ constructor(n) {
12
+ this.options = {}, this.mount = () => {
13
+ const t = this.store.mount();
14
+ this.options.defaultValue !== void 0 && !this.getMeta().isTouched && this.form.setFieldValue(this.name, this.options.defaultValue, {
15
+ dontUpdateMeta: !0
16
+ });
17
+ const e = this.getInfo();
18
+ e.instance = this, this.update(this.options);
19
+ const { onMount: i } = this.options.validators || {};
20
+ if (i) {
21
+ const a = this.runValidator({
22
+ validate: i,
23
+ value: {
24
+ value: this.state.value,
25
+ fieldApi: this,
26
+ validationSource: "field"
27
+ },
28
+ type: "validate"
29
+ });
30
+ a && this.setMeta(
31
+ (l) => ({
32
+ ...l,
33
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
34
+ errorMap: { ...l?.errorMap, onMount: a },
35
+ errorSourceMap: {
36
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
37
+ ...l?.errorSourceMap,
38
+ onMount: "field"
39
+ }
40
+ })
41
+ );
42
+ }
43
+ return this.options.listeners?.onMount?.({
44
+ value: this.state.value,
45
+ fieldApi: this
46
+ }), t;
47
+ }, this.update = (t) => {
48
+ if (this.options = t, this.name = t.name, !this.state.meta.isTouched && this.options.defaultValue !== void 0) {
49
+ const e = this.form.getFieldValue(this.name);
50
+ C(e, t.defaultValue) || this.form.setFieldValue(this.name, t.defaultValue, {
51
+ dontUpdateMeta: !0,
52
+ dontValidate: !0,
53
+ dontRunListeners: !0
54
+ });
55
+ }
56
+ this.form.getFieldMeta(this.name) || this.form.setFieldMeta(this.name, this.state.meta);
57
+ }, this.getValue = () => this.form.getFieldValue(this.name), this.setValue = (t, e) => {
58
+ this.form.setFieldValue(
59
+ this.name,
60
+ t,
61
+ g(e, { dontRunListeners: !0, dontValidate: !0 })
62
+ ), e?.dontRunListeners || this.triggerOnChangeListener(), e?.dontValidate || this.validate("change");
63
+ }, this.getMeta = () => this.store.state.meta, this.setMeta = (t) => this.form.setFieldMeta(this.name, t), this.getInfo = () => this.form.getFieldInfo(this.name), this.pushValue = (t, e) => {
64
+ this.form.pushFieldValue(
65
+ this.name,
66
+ t,
67
+ g(e, { dontRunListeners: !0 })
68
+ ), e?.dontRunListeners || this.triggerOnChangeListener();
69
+ }, this.insertValue = (t, e, i) => {
70
+ this.form.insertFieldValue(
71
+ this.name,
72
+ t,
73
+ e,
74
+ g(i, { dontRunListeners: !0 })
75
+ ), i?.dontRunListeners || this.triggerOnChangeListener();
76
+ }, this.replaceValue = (t, e, i) => {
77
+ this.form.replaceFieldValue(
78
+ this.name,
79
+ t,
80
+ e,
81
+ g(i, { dontRunListeners: !0 })
82
+ ), i?.dontRunListeners || this.triggerOnChangeListener();
83
+ }, this.removeValue = (t, e) => {
84
+ this.form.removeFieldValue(
85
+ this.name,
86
+ t,
87
+ g(e, { dontRunListeners: !0 })
88
+ ), e?.dontRunListeners || this.triggerOnChangeListener();
89
+ }, this.swapValues = (t, e, i) => {
90
+ this.form.swapFieldValues(
91
+ this.name,
92
+ t,
93
+ e,
94
+ g(i, { dontRunListeners: !0 })
95
+ ), i?.dontRunListeners || this.triggerOnChangeListener();
96
+ }, this.moveValue = (t, e, i) => {
97
+ this.form.moveFieldValues(
98
+ this.name,
99
+ t,
100
+ e,
101
+ g(i, { dontRunListeners: !0 })
102
+ ), i?.dontRunListeners || this.triggerOnChangeListener();
103
+ }, this.clearValues = (t) => {
104
+ this.form.clearFieldValues(
105
+ this.name,
106
+ g(t, { dontRunListeners: !0 })
107
+ ), t?.dontRunListeners || this.triggerOnChangeListener();
108
+ }, this.getLinkedFields = (t) => {
109
+ const e = Object.values(this.form.fieldInfo), i = [];
110
+ for (const a of e) {
111
+ if (!a.instance) continue;
112
+ const { onChangeListenTo: l, onBlurListenTo: m } = a.instance.options.validators || {};
113
+ t === "change" && l?.includes(this.name) && i.push(a.instance), t === "blur" && m?.includes(this.name) && i.push(a.instance);
114
+ }
115
+ return i;
116
+ }, this.validateSync = (t, e) => {
117
+ const i = T(t, {
118
+ ...this.options,
119
+ form: this.form,
120
+ validationLogic: this.form.options.validationLogic || F
121
+ }), l = this.getLinkedFields(t).reduce(
122
+ (u, r) => {
123
+ const h = T(t, {
124
+ ...r.options,
125
+ form: r.form,
126
+ validationLogic: r.form.options.validationLogic || F
127
+ });
128
+ return h.forEach((d) => {
129
+ d.field = r;
130
+ }), u.concat(h);
131
+ },
132
+ []
133
+ );
134
+ let m = !1;
135
+ U(() => {
136
+ const u = (r, h) => {
137
+ const d = A(h.cause), s = h.validate ? w(
138
+ r.runValidator({
139
+ validate: h.validate,
140
+ value: {
141
+ value: r.store.state.value,
142
+ validationSource: "field",
143
+ fieldApi: r
144
+ },
145
+ type: "validate"
146
+ })
147
+ ) : void 0, o = e[d], { newErrorValue: c, newSource: f } = R({
148
+ formLevelError: o,
149
+ fieldLevelError: s
150
+ });
151
+ r.state.meta.errorMap?.[d] !== c && r.setMeta((V) => ({
152
+ ...V,
153
+ errorMap: {
154
+ ...V.errorMap,
155
+ [d]: c
156
+ },
157
+ errorSourceMap: {
158
+ ...V.errorSourceMap,
159
+ [d]: f
160
+ }
161
+ })), c && (m = !0);
162
+ };
163
+ for (const r of i)
164
+ u(this, r);
165
+ for (const r of l)
166
+ r.validate && u(r.field, r);
167
+ });
168
+ const p = A("submit");
169
+ return (
170
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
171
+ this.state.meta.errorMap?.[p] && t !== "submit" && !m && this.setMeta((u) => ({
172
+ ...u,
173
+ errorMap: {
174
+ ...u.errorMap,
175
+ [p]: void 0
176
+ },
177
+ errorSourceMap: {
178
+ ...u.errorSourceMap,
179
+ [p]: void 0
180
+ }
181
+ })), { hasErrored: m }
182
+ );
183
+ }, this.validateAsync = async (t, e) => {
184
+ const i = E(t, {
185
+ ...this.options,
186
+ form: this.form,
187
+ validationLogic: this.form.options.validationLogic || F
188
+ }), a = await e, l = this.getLinkedFields(t), m = l.reduce(
189
+ (s, o) => {
190
+ const c = E(t, {
191
+ ...o.options,
192
+ form: o.form,
193
+ validationLogic: o.form.options.validationLogic || F
194
+ });
195
+ return c.forEach((f) => {
196
+ f.field = o;
197
+ }), s.concat(c);
198
+ },
199
+ []
200
+ ), p = [], u = [], r = i.some((s) => s.validate) || m.some((s) => s.validate);
201
+ if (r) {
202
+ this.state.meta.isValidating || this.setMeta((s) => ({ ...s, isValidating: !0 }));
203
+ for (const s of l)
204
+ s.setMeta((o) => ({ ...o, isValidating: !0 }));
205
+ }
206
+ const h = (s, o, c) => {
207
+ const f = A(o.cause);
208
+ s.getInfo().validationMetaMap[f]?.lastAbortController.abort();
209
+ const L = new AbortController();
210
+ this.getInfo().validationMetaMap[f] = {
211
+ lastAbortController: L
212
+ }, c.push(
213
+ new Promise(async (S) => {
214
+ let y;
215
+ try {
216
+ y = await new Promise((v, O) => {
217
+ this.timeoutIds.validations[o.cause] && clearTimeout(this.timeoutIds.validations[o.cause]), this.timeoutIds.validations[o.cause] = setTimeout(
218
+ async () => {
219
+ if (L.signal.aborted) return v(void 0);
220
+ try {
221
+ v(
222
+ await this.runValidator({
223
+ validate: o.validate,
224
+ value: {
225
+ value: s.store.state.value,
226
+ fieldApi: s,
227
+ signal: L.signal,
228
+ validationSource: "field"
229
+ },
230
+ type: "validateAsync"
231
+ })
232
+ );
233
+ } catch (P) {
234
+ O(P);
235
+ }
236
+ },
237
+ o.debounceMs
238
+ );
239
+ });
240
+ } catch (v) {
241
+ y = v;
242
+ }
243
+ if (L.signal.aborted) return S(void 0);
244
+ const k = w(y), B = a[this.name]?.[f], { newErrorValue: I, newSource: D } = R({
245
+ formLevelError: B,
246
+ fieldLevelError: k
247
+ });
248
+ s.setMeta((v) => ({
249
+ ...v,
250
+ errorMap: {
251
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
252
+ ...v?.errorMap,
253
+ [f]: I
254
+ },
255
+ errorSourceMap: {
256
+ ...v.errorSourceMap,
257
+ [f]: D
258
+ }
259
+ })), S(I);
260
+ })
261
+ );
262
+ };
263
+ for (const s of i)
264
+ s.validate && h(this, s, p);
265
+ for (const s of m)
266
+ s.validate && h(
267
+ s.field,
268
+ s,
269
+ u
270
+ );
271
+ let d = [];
272
+ if ((p.length || u.length) && (d = await Promise.all(p), await Promise.all(u)), r) {
273
+ this.setMeta((s) => ({ ...s, isValidating: !1 }));
274
+ for (const s of l)
275
+ s.setMeta((o) => ({ ...o, isValidating: !1 }));
276
+ }
277
+ return d.filter(Boolean);
278
+ }, this.validate = (t, e) => {
279
+ if (!this.state.meta.isTouched) return [];
280
+ const { fieldsErrorMap: i } = e?.skipFormValidation ? { fieldsErrorMap: {} } : this.form.validateSync(t), { hasErrored: a } = this.validateSync(
281
+ t,
282
+ i[this.name] ?? {}
283
+ );
284
+ if (a && !this.options.asyncAlways)
285
+ return this.getInfo().validationMetaMap[A(t)]?.lastAbortController.abort(), this.state.meta.errors;
286
+ const l = e?.skipFormValidation ? Promise.resolve({}) : this.form.validateAsync(t);
287
+ return this.validateAsync(t, l);
288
+ }, this.handleChange = (t) => {
289
+ this.setValue(t);
290
+ }, this.handleBlur = () => {
291
+ this.state.meta.isTouched || this.setMeta((e) => ({ ...e, isTouched: !0 })), this.state.meta.isBlurred || this.setMeta((e) => ({ ...e, isBlurred: !0 })), this.validate("blur"), this.triggerOnBlurListener();
292
+ }, this.setErrorMap = (t) => {
293
+ this.setMeta((e) => ({
294
+ ...e,
295
+ errorMap: {
296
+ ...e.errorMap,
297
+ ...t
298
+ }
299
+ }));
300
+ }, this.parseValueWithSchema = (t) => b.validate(
301
+ { value: this.state.value, validationSource: "field" },
302
+ t
303
+ ), this.parseValueWithSchemaAsync = (t) => b.validateAsync(
304
+ { value: this.state.value, validationSource: "field" },
305
+ t
306
+ ), this.triggerOnChangeListener = () => {
307
+ const t = this.form.options.listeners?.onChangeDebounceMs;
308
+ t && t > 0 ? (this.timeoutIds.formListeners.change && clearTimeout(this.timeoutIds.formListeners.change), this.timeoutIds.formListeners.change = setTimeout(() => {
309
+ this.form.options.listeners?.onChange?.({
310
+ formApi: this.form,
311
+ fieldApi: this
312
+ });
313
+ }, t)) : this.form.options.listeners?.onChange?.({
314
+ formApi: this.form,
315
+ fieldApi: this
316
+ });
317
+ const e = this.options.listeners?.onChangeDebounceMs;
318
+ e && e > 0 ? (this.timeoutIds.listeners.change && clearTimeout(this.timeoutIds.listeners.change), this.timeoutIds.listeners.change = setTimeout(() => {
319
+ this.options.listeners?.onChange?.({
320
+ value: this.state.value,
321
+ fieldApi: this
322
+ });
323
+ }, e)) : this.options.listeners?.onChange?.({
324
+ value: this.state.value,
325
+ fieldApi: this
326
+ });
327
+ }, this.form = n.form, this.name = n.name, this.options = n, this.timeoutIds = {
328
+ validations: {},
329
+ listeners: {},
330
+ formListeners: {}
331
+ }, this.store = new K({
332
+ deps: [this.form.store],
333
+ fn: ({ prevVal: t }) => {
334
+ const e = t, i = this.form.getFieldMeta(this.name) ?? {
335
+ ...x,
336
+ ...n.defaultMeta
337
+ };
338
+ let a = this.form.getFieldValue(this.name);
339
+ return !i.isTouched && a === void 0 && this.options.defaultValue !== void 0 && !C(a, this.options.defaultValue) && (a = this.options.defaultValue), e && e.value === a && e.meta === i ? e : {
340
+ value: a,
341
+ meta: i
342
+ };
343
+ }
344
+ });
345
+ }
346
+ /**
347
+ * The current field state.
348
+ */
349
+ get state() {
350
+ return this.store.state;
351
+ }
352
+ /**
353
+ * @private
354
+ */
355
+ runValidator(n) {
356
+ return W(n.validate) ? b[n.type](
357
+ n.value,
358
+ n.validate
359
+ ) : n.validate(n.value);
360
+ }
361
+ triggerOnBlurListener() {
362
+ const n = this.form.options.listeners?.onBlurDebounceMs;
363
+ n && n > 0 ? (this.timeoutIds.formListeners.blur && clearTimeout(this.timeoutIds.formListeners.blur), this.timeoutIds.formListeners.blur = setTimeout(() => {
364
+ this.form.options.listeners?.onBlur?.({
365
+ formApi: this.form,
366
+ fieldApi: this
367
+ });
368
+ }, n)) : this.form.options.listeners?.onBlur?.({
369
+ formApi: this.form,
370
+ fieldApi: this
371
+ });
372
+ const t = this.options.listeners?.onBlurDebounceMs;
373
+ t && t > 0 ? (this.timeoutIds.listeners.blur && clearTimeout(this.timeoutIds.listeners.blur), this.timeoutIds.listeners.blur = setTimeout(() => {
374
+ this.options.listeners?.onBlur?.({
375
+ value: this.state.value,
376
+ fieldApi: this
377
+ });
378
+ }, t)) : this.options.listeners?.onBlur?.({
379
+ value: this.state.value,
380
+ fieldApi: this
381
+ });
382
+ }
383
+ }
384
+ function w(M) {
385
+ if (M)
386
+ return M;
387
+ }
388
+ function A(M) {
389
+ switch (M) {
390
+ case "submit":
391
+ return "onSubmit";
392
+ case "blur":
393
+ return "onBlur";
394
+ case "mount":
395
+ return "onMount";
396
+ case "server":
397
+ return "onServer";
398
+ case "dynamic":
399
+ return "onDynamic";
400
+ default:
401
+ return "onChange";
402
+ }
403
+ }
404
+ export {
405
+ Q as FieldApi
406
+ };