xmlui 0.10.19 → 0.10.20
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.
- package/dist/lib/{apiInterceptorWorker-DPgtUtdA.mjs → apiInterceptorWorker-QiltRtq1.mjs} +1 -1
- package/dist/lib/{index-cuh97e2e.mjs → index-Ckhnrf1F.mjs} +848 -615
- package/dist/lib/index.css +1 -1
- package/dist/{metadata/initMock-C-cnv--V.mjs → lib/initMock-qnCFw6Zc.mjs} +25 -15
- package/dist/lib/language-server-web-worker.mjs +1 -1
- package/dist/lib/language-server.mjs +1 -1
- package/dist/lib/{metadata-utils-CtY0QcvH.mjs → metadata-utils-BTIt1_wE.mjs} +1 -1
- package/dist/lib/{server-common-Cine5nRR.mjs → server-common-DYZtsdM7.mjs} +51 -14
- package/dist/lib/{transform-bHBjkKSL.mjs → transform-Tooy42EB.mjs} +16 -18
- package/dist/lib/xmlui-parser.mjs +2 -2
- package/dist/lib/{xmlui-serializer-DB6BLiXK.mjs → xmlui-serializer-uCYa8_tZ.mjs} +1 -1
- package/dist/lib/xmlui.d.ts +11 -3
- package/dist/lib/xmlui.mjs +2 -2
- package/dist/metadata/{apiInterceptorWorker-BmKP8bnq.mjs → apiInterceptorWorker-Dql7QGw2.mjs} +1 -1
- package/dist/metadata/{collectedComponentMetadata-Cp-9lpnG.mjs → collectedComponentMetadata-Dg7P-zOz.mjs} +824 -600
- package/dist/{lib/initMock-BMxsanHc.mjs → metadata/initMock-ZyyFNOpL.mjs} +25 -15
- package/dist/metadata/style.css +1 -1
- package/dist/metadata/xmlui-metadata.mjs +1 -1
- package/dist/metadata/xmlui-metadata.umd.js +3 -3
- package/dist/scripts/package.json +1 -1
- package/dist/scripts/src/components/Animation/AnimationNative.js +28 -28
- package/dist/scripts/src/components/App/App.spec.js +17 -17
- package/dist/scripts/src/components/AppState/AppState.js +3 -2
- package/dist/scripts/src/components/AppState/AppState.spec.js +26 -2
- package/dist/scripts/src/components/AppState/AppStateNative.js +3 -4
- package/dist/scripts/src/components/AutoComplete/AutoComplete.js +15 -10
- package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +4 -4
- package/dist/scripts/src/components/Carousel/Carousel.spec.js +214 -0
- package/dist/scripts/src/components/CodeBlock/CodeBlockNative.js +1 -1
- package/dist/scripts/src/components/ContentSeparator/ContentSeparator.js +2 -0
- package/dist/scripts/src/components/ContentSeparator/ContentSeparator.spec.js +193 -0
- package/dist/scripts/src/components/DateInput/DateInput.spec.js +6 -6
- package/dist/scripts/src/components/DropdownMenu/DropdownMenu.spec.js +3 -3
- package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZoneNative.js +4 -13
- package/dist/scripts/src/components/Form/Form.spec.js +25 -9
- package/dist/scripts/src/components/Form/FormNative.js +7 -4
- package/dist/scripts/src/components/FormItem/FormItem.js +3 -1
- package/dist/scripts/src/components/FormItem/FormItem.spec.js +5 -14
- package/dist/scripts/src/components/FormItem/FormItemNative.js +12 -8
- package/dist/scripts/src/components/FormItem/Validations.js +2 -2
- package/dist/scripts/src/components/IconRegistryContext.js +1 -1
- package/dist/scripts/src/components/List/ListNative.js +2 -2
- package/dist/scripts/src/components/ModalDialog/ConfirmationModalContextProvider.js +3 -12
- package/dist/scripts/src/components/ModalDialog/ModalDialog.js +2 -2
- package/dist/scripts/src/components/ModalDialog/ModalDialogNative.js +6 -3
- package/dist/scripts/src/components/NestedApp/AppWithCodeViewNative.js +1 -1
- package/dist/scripts/src/components/NestedApp/NestedAppNative.js +3 -3
- package/dist/scripts/src/components/NumberBox/NumberBox.spec.js +2 -2
- package/dist/scripts/src/components/Pagination/Pagination.spec.js +5 -0
- package/dist/scripts/src/components/Pagination/PaginationNative.js +1 -3
- package/dist/scripts/src/components/Queue/Queue.spec.js +45 -47
- package/dist/scripts/src/components/Queue/QueueNative.js +1 -1
- package/dist/scripts/src/components/RadioGroup/RadioGroup.spec.js +5 -5
- package/dist/scripts/src/components/RealTimeAdapter/RealTimeAdapterNative.js +1 -1
- package/dist/scripts/src/components/Select/MultiSelectOption.js +42 -0
- package/dist/scripts/src/components/Select/Select.js +3 -3
- package/dist/scripts/src/components/Select/SelectContext.js +8 -1
- package/dist/scripts/src/components/Select/SelectNative.js +134 -142
- package/dist/scripts/src/components/Select/SelectOption.js +34 -0
- package/dist/scripts/src/components/Select/SimpleSelect.js +57 -0
- package/dist/scripts/src/components/Spinner/Spinner.spec.js +1 -1
- package/dist/scripts/src/components/Table/useRowSelection.js +14 -23
- package/dist/scripts/src/components/TextArea/TextArea.spec.js +8 -8
- package/dist/scripts/src/components/Theme/Theme.js +2 -1
- package/dist/scripts/src/components/Theme/Theme.spec.js +266 -0
- package/dist/scripts/src/components/Theme/ThemeNative.js +8 -1
- package/dist/scripts/src/components/TimeInput/TimeInput.spec.js +3 -3
- package/dist/scripts/src/components/Tree/TreeNative.js +9 -11
- package/dist/scripts/src/components-core/InspectorContext.js +1 -1
- package/dist/scripts/src/components-core/StandaloneApp.js +6 -8
- package/dist/scripts/src/components-core/action/FileUploadAction.js +1 -1
- package/dist/scripts/src/components-core/behaviors/BehaviorContext.js +50 -0
- package/dist/scripts/src/components-core/behaviors/CoreBehaviors.js +6 -1
- package/dist/scripts/src/components-core/interception/ApiInterceptor.js +9 -11
- package/dist/scripts/src/components-core/interception/ApiInterceptorProvider.js +3 -3
- package/dist/scripts/src/components-core/interception/Backend.js +1 -1
- package/dist/scripts/src/components-core/interception/IndexedDb.js +64 -66
- package/dist/scripts/src/components-core/interception/apiInterceptorWorker.js +2 -2
- package/dist/scripts/src/components-core/loader/DataLoader.js +6 -14
- package/dist/scripts/src/components-core/loader/Loader.js +11 -11
- package/dist/scripts/src/components-core/loader/MockLoaderRenderer.js +4 -2
- package/dist/scripts/src/components-core/loader/PageableLoader.js +10 -9
- package/dist/scripts/src/components-core/rendering/AppContent.js +1 -7
- package/dist/scripts/src/components-core/rendering/ErrorBoundary.js +1 -1
- package/dist/scripts/src/components-core/script-runner/bannedFunctions.js +1 -1
- package/dist/scripts/src/components-core/script-runner/eval-tree-async.js +180 -186
- package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +6 -6
- package/dist/scripts/src/components-core/script-runner/process-statement-sync.js +2 -2
- package/dist/scripts/src/components-core/utils/actionUtils.js +1 -1
- package/dist/scripts/src/components-core/utils/hooks.js +1 -1
- package/dist/scripts/src/components-core/utils/misc.js +4 -4
- package/dist/scripts/src/components-core/xmlui-parser.js +47 -31
- package/dist/scripts/src/language-server/server-common.js +25 -24
- package/dist/scripts/src/language-server/services/common/lsp-utils.js +2 -2
- package/dist/scripts/src/language-server/services/completion.js +20 -2
- package/dist/scripts/src/language-server/services/diagnostic.js +1 -1
- package/dist/scripts/src/language-server/services/hover.js +2 -2
- package/dist/scripts/src/parsers/common/utils.js +2 -2
- package/dist/scripts/src/parsers/scripting/Lexer.js +21 -15
- package/dist/scripts/src/parsers/scripting/Parser.js +8 -9
- package/dist/scripts/src/parsers/style-parser/StyleLexer.js +22 -22
- package/dist/scripts/src/parsers/style-parser/StyleParser.js +70 -68
- package/dist/scripts/src/testing/ComponentDrivers.js +20 -39
- package/dist/scripts/src/testing/component-test-helpers.js +34 -50
- package/dist/scripts/src/testing/fixtures.js +114 -113
- package/dist/scripts/src/testing/themed-app-test-helpers.js +7 -13
- package/dist/standalone/xmlui-standalone.es.d.ts +11 -3
- package/dist/standalone/xmlui-standalone.umd.js +12 -12
- package/package.json +1 -1
|
@@ -154,6 +154,199 @@ fixtures_1.test.describe("Visual States & Themes", () => {
|
|
|
154
154
|
}));
|
|
155
155
|
});
|
|
156
156
|
// =============================================================================
|
|
157
|
+
// THEME VARIABLE TESTS
|
|
158
|
+
// =============================================================================
|
|
159
|
+
fixtures_1.test.describe("Theme Variables", () => {
|
|
160
|
+
(0, fixtures_1.test)("applies basic theme variables", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createContentSeparatorDriver }) {
|
|
161
|
+
yield initTestBed(`<ContentSeparator />`, {
|
|
162
|
+
testThemeVars: {
|
|
163
|
+
"backgroundColor-ContentSeparator": "rgb(255, 0, 0)",
|
|
164
|
+
"size-ContentSeparator": "5px",
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
const driver = yield createContentSeparatorDriver();
|
|
168
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("background-color", "rgb(255, 0, 0)");
|
|
169
|
+
const height = yield driver.getComputedHeight();
|
|
170
|
+
(0, fixtures_1.expect)(height).toBe('5px');
|
|
171
|
+
}));
|
|
172
|
+
(0, fixtures_1.test)("applies vertical margin theme variables", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createContentSeparatorDriver }) {
|
|
173
|
+
yield initTestBed(`<ContentSeparator />`, {
|
|
174
|
+
testThemeVars: {
|
|
175
|
+
"marginVertical-ContentSeparator": "10px",
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
const driver = yield createContentSeparatorDriver();
|
|
179
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-top", "10px");
|
|
180
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-bottom", "10px");
|
|
181
|
+
}));
|
|
182
|
+
(0, fixtures_1.test)("applies horizontal margin theme variables", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createContentSeparatorDriver }) {
|
|
183
|
+
yield initTestBed(`<ContentSeparator />`, {
|
|
184
|
+
testThemeVars: {
|
|
185
|
+
"marginHorizontal-ContentSeparator": "15px",
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
const driver = yield createContentSeparatorDriver();
|
|
189
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-left", "15px");
|
|
190
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-right", "15px");
|
|
191
|
+
}));
|
|
192
|
+
(0, fixtures_1.test)("specific margin-top overrides vertical margin", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createContentSeparatorDriver }) {
|
|
193
|
+
yield initTestBed(`<ContentSeparator />`, {
|
|
194
|
+
testThemeVars: {
|
|
195
|
+
"marginVertical-ContentSeparator": "10px",
|
|
196
|
+
"marginTop-ContentSeparator": "20px",
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
const driver = yield createContentSeparatorDriver();
|
|
200
|
+
// Specific margin-top should override vertical margin
|
|
201
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-top", "20px");
|
|
202
|
+
// Bottom should still use vertical margin
|
|
203
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-bottom", "10px");
|
|
204
|
+
}));
|
|
205
|
+
(0, fixtures_1.test)("specific margin-bottom overrides vertical margin", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createContentSeparatorDriver }) {
|
|
206
|
+
yield initTestBed(`<ContentSeparator />`, {
|
|
207
|
+
testThemeVars: {
|
|
208
|
+
"marginVertical-ContentSeparator": "10px",
|
|
209
|
+
"marginBottom-ContentSeparator": "25px",
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
const driver = yield createContentSeparatorDriver();
|
|
213
|
+
// Top should use vertical margin
|
|
214
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-top", "10px");
|
|
215
|
+
// Specific margin-bottom should override vertical margin
|
|
216
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-bottom", "25px");
|
|
217
|
+
}));
|
|
218
|
+
(0, fixtures_1.test)("specific margin-left overrides horizontal margin", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createContentSeparatorDriver }) {
|
|
219
|
+
yield initTestBed(`<ContentSeparator />`, {
|
|
220
|
+
testThemeVars: {
|
|
221
|
+
"marginHorizontal-ContentSeparator": "15px",
|
|
222
|
+
"marginLeft-ContentSeparator": "30px",
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
const driver = yield createContentSeparatorDriver();
|
|
226
|
+
// Specific margin-left should override horizontal margin
|
|
227
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-left", "30px");
|
|
228
|
+
// Right should still use horizontal margin
|
|
229
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-right", "15px");
|
|
230
|
+
}));
|
|
231
|
+
(0, fixtures_1.test)("specific margin-right overrides horizontal margin", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createContentSeparatorDriver }) {
|
|
232
|
+
yield initTestBed(`<ContentSeparator />`, {
|
|
233
|
+
testThemeVars: {
|
|
234
|
+
"marginHorizontal-ContentSeparator": "15px",
|
|
235
|
+
"marginRight-ContentSeparator": "35px",
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
const driver = yield createContentSeparatorDriver();
|
|
239
|
+
// Left should use horizontal margin
|
|
240
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-left", "15px");
|
|
241
|
+
// Specific margin-right should override horizontal margin
|
|
242
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-right", "35px");
|
|
243
|
+
}));
|
|
244
|
+
(0, fixtures_1.test)("all specific margins override general margins", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createContentSeparatorDriver }) {
|
|
245
|
+
yield initTestBed(`<ContentSeparator />`, {
|
|
246
|
+
testThemeVars: {
|
|
247
|
+
"marginVertical-ContentSeparator": "10px",
|
|
248
|
+
"marginHorizontal-ContentSeparator": "15px",
|
|
249
|
+
"marginTop-ContentSeparator": "5px",
|
|
250
|
+
"marginBottom-ContentSeparator": "8px",
|
|
251
|
+
"marginLeft-ContentSeparator": "12px",
|
|
252
|
+
"marginRight-ContentSeparator": "18px",
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
const driver = yield createContentSeparatorDriver();
|
|
256
|
+
// All specific margins should be used instead of general ones
|
|
257
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-top", "5px");
|
|
258
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-bottom", "8px");
|
|
259
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-left", "12px");
|
|
260
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-right", "18px");
|
|
261
|
+
}));
|
|
262
|
+
(0, fixtures_1.test)("fallback to vertical margin when specific margins not defined", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createContentSeparatorDriver }) {
|
|
263
|
+
yield initTestBed(`<ContentSeparator />`, {
|
|
264
|
+
testThemeVars: {
|
|
265
|
+
"marginVertical-ContentSeparator": "20px",
|
|
266
|
+
// No specific marginTop or marginBottom defined
|
|
267
|
+
},
|
|
268
|
+
});
|
|
269
|
+
const driver = yield createContentSeparatorDriver();
|
|
270
|
+
// Should fall back to vertical margin values
|
|
271
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-top", "20px");
|
|
272
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-bottom", "20px");
|
|
273
|
+
}));
|
|
274
|
+
(0, fixtures_1.test)("fallback to horizontal margin when specific margins not defined", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createContentSeparatorDriver }) {
|
|
275
|
+
yield initTestBed(`<ContentSeparator />`, {
|
|
276
|
+
testThemeVars: {
|
|
277
|
+
"marginHorizontal-ContentSeparator": "25px",
|
|
278
|
+
// No specific marginLeft or marginRight defined
|
|
279
|
+
},
|
|
280
|
+
});
|
|
281
|
+
const driver = yield createContentSeparatorDriver();
|
|
282
|
+
// Should fall back to horizontal margin values
|
|
283
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-left", "25px");
|
|
284
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-right", "25px");
|
|
285
|
+
}));
|
|
286
|
+
(0, fixtures_1.test)("handles zero margin values", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createContentSeparatorDriver }) {
|
|
287
|
+
yield initTestBed(`<ContentSeparator />`, {
|
|
288
|
+
testThemeVars: {
|
|
289
|
+
"marginTop-ContentSeparator": "0px",
|
|
290
|
+
"marginBottom-ContentSeparator": "0px",
|
|
291
|
+
"marginLeft-ContentSeparator": "0px",
|
|
292
|
+
"marginRight-ContentSeparator": "0px",
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
const driver = yield createContentSeparatorDriver();
|
|
296
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-top", "0px");
|
|
297
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-bottom", "0px");
|
|
298
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-left", "0px");
|
|
299
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-right", "0px");
|
|
300
|
+
}));
|
|
301
|
+
(0, fixtures_1.test)("handles negative margin values", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createContentSeparatorDriver }) {
|
|
302
|
+
yield initTestBed(`<ContentSeparator />`, {
|
|
303
|
+
testThemeVars: {
|
|
304
|
+
"marginTop-ContentSeparator": "-5px",
|
|
305
|
+
"marginLeft-ContentSeparator": "-10px",
|
|
306
|
+
},
|
|
307
|
+
});
|
|
308
|
+
const driver = yield createContentSeparatorDriver();
|
|
309
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-top", "-5px");
|
|
310
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-left", "-10px");
|
|
311
|
+
}));
|
|
312
|
+
(0, fixtures_1.test)("handles different unit types for margins", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createContentSeparatorDriver }) {
|
|
313
|
+
yield initTestBed(`<ContentSeparator />`, {
|
|
314
|
+
testThemeVars: {
|
|
315
|
+
"marginTop-ContentSeparator": "1rem",
|
|
316
|
+
"marginBottom-ContentSeparator": "2em",
|
|
317
|
+
"marginLeft-ContentSeparator": "10px",
|
|
318
|
+
"marginRight-ContentSeparator": "10px",
|
|
319
|
+
},
|
|
320
|
+
});
|
|
321
|
+
const driver = yield createContentSeparatorDriver();
|
|
322
|
+
// Browser computes rem/em to px values, so we check that margins are applied (not zero)
|
|
323
|
+
const marginTop = yield driver.separator.evaluate((el) => window.getComputedStyle(el).marginTop);
|
|
324
|
+
const marginBottom = yield driver.separator.evaluate((el) => window.getComputedStyle(el).marginBottom);
|
|
325
|
+
// rem and em should resolve to non-zero pixel values
|
|
326
|
+
(0, fixtures_1.expect)(parseFloat(marginTop)).toBeGreaterThan(0);
|
|
327
|
+
(0, fixtures_1.expect)(parseFloat(marginBottom)).toBeGreaterThan(0);
|
|
328
|
+
// px values should be exact
|
|
329
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-left", "10px");
|
|
330
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-right", "10px");
|
|
331
|
+
}));
|
|
332
|
+
(0, fixtures_1.test)("mixed general and specific margins work correctly", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createContentSeparatorDriver }) {
|
|
333
|
+
yield initTestBed(`<ContentSeparator />`, {
|
|
334
|
+
testThemeVars: {
|
|
335
|
+
"marginVertical-ContentSeparator": "8px",
|
|
336
|
+
"marginHorizontal-ContentSeparator": "12px",
|
|
337
|
+
"marginTop-ContentSeparator": "16px", // Override top
|
|
338
|
+
"marginRight-ContentSeparator": "20px", // Override right
|
|
339
|
+
// marginBottom and marginLeft should use general values
|
|
340
|
+
},
|
|
341
|
+
});
|
|
342
|
+
const driver = yield createContentSeparatorDriver();
|
|
343
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-top", "16px"); // Specific
|
|
344
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-bottom", "8px"); // Fallback to vertical
|
|
345
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-left", "12px"); // Fallback to horizontal
|
|
346
|
+
yield (0, fixtures_1.expect)(driver.separator).toHaveCSS("margin-right", "20px"); // Specific
|
|
347
|
+
}));
|
|
348
|
+
});
|
|
349
|
+
// =============================================================================
|
|
157
350
|
// EDGE CASE TESTS
|
|
158
351
|
// =============================================================================
|
|
159
352
|
fixtures_1.test.describe("Edge Cases", () => {
|
|
@@ -492,7 +492,7 @@ fixtures_1.test.describe("User Interactions", () => {
|
|
|
492
492
|
yield (0, fixtures_1.expect)(driver.monthInput).toHaveValue("05");
|
|
493
493
|
yield (0, fixtures_1.expect)(driver.dayInput).toHaveValue("25");
|
|
494
494
|
yield (0, fixtures_1.expect)(driver.yearInput).toHaveValue("2024");
|
|
495
|
-
driver.dayInput.fill("18");
|
|
495
|
+
yield driver.dayInput.fill("18");
|
|
496
496
|
yield driver.clearButton.click();
|
|
497
497
|
yield (0, fixtures_1.expect)(driver.monthInput).toHaveValue("05");
|
|
498
498
|
yield (0, fixtures_1.expect)(driver.dayInput).toHaveValue("25");
|
|
@@ -504,7 +504,7 @@ fixtures_1.test.describe("User Interactions", () => {
|
|
|
504
504
|
yield (0, fixtures_1.expect)(driver.monthInput).toHaveValue("05");
|
|
505
505
|
yield (0, fixtures_1.expect)(driver.dayInput).toHaveValue("25");
|
|
506
506
|
yield (0, fixtures_1.expect)(driver.yearInput).toHaveValue("2024");
|
|
507
|
-
driver.dayInput.fill("18");
|
|
507
|
+
yield driver.dayInput.fill("18");
|
|
508
508
|
yield driver.clearButton.click();
|
|
509
509
|
yield (0, fixtures_1.expect)(driver.monthInput).toHaveValue("");
|
|
510
510
|
yield (0, fixtures_1.expect)(driver.dayInput).toHaveValue("");
|
|
@@ -805,8 +805,8 @@ fixtures_1.test.describe("Accessibility", () => {
|
|
|
805
805
|
fixtures_1.test.describe("Theme Variables", () => {
|
|
806
806
|
(0, fixtures_1.test)("component renders with theme variables", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver }) {
|
|
807
807
|
yield initTestBed(`
|
|
808
|
-
<DateInput
|
|
809
|
-
testId="dateInput"
|
|
808
|
+
<DateInput
|
|
809
|
+
testId="dateInput"
|
|
810
810
|
style="--color-divider: red; --width-input: 100px; --backgroundColor-input-invalid: rgb(255, 200, 200);"
|
|
811
811
|
/>
|
|
812
812
|
`);
|
|
@@ -818,8 +818,8 @@ fixtures_1.test.describe("Theme Variables", () => {
|
|
|
818
818
|
}));
|
|
819
819
|
(0, fixtures_1.test)("component renders with clearable and theme variables", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver, }) {
|
|
820
820
|
yield initTestBed(`
|
|
821
|
-
<DateInput
|
|
822
|
-
testId="dateInput"
|
|
821
|
+
<DateInput
|
|
822
|
+
testId="dateInput"
|
|
823
823
|
clearable="{true}"
|
|
824
824
|
style="--padding-button: 15px; --outlineColor-button--focused: green;"
|
|
825
825
|
/>
|
|
@@ -141,7 +141,7 @@ const fixtures_1 = require("../../testing/fixtures");
|
|
|
141
141
|
yield (0, fixtures_1.expect)(btn).toHaveAttribute("aria-haspopup", "menu");
|
|
142
142
|
yield (0, fixtures_1.expect)(btn).toHaveAttribute("aria-expanded", "false");
|
|
143
143
|
yield driver.open();
|
|
144
|
-
page.getByRole("button", { includeHidden: true, expanded: true }).waitFor();
|
|
144
|
+
yield page.getByRole("button", { includeHidden: true, expanded: true }).waitFor();
|
|
145
145
|
yield page.getByRole("menu").waitFor();
|
|
146
146
|
}));
|
|
147
147
|
(0, fixtures_1.test)("is keyboard accessible", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDropdownMenuDriver, page }) {
|
|
@@ -151,10 +151,10 @@ const fixtures_1 = require("../../testing/fixtures");
|
|
|
151
151
|
</DropdownMenu>
|
|
152
152
|
`);
|
|
153
153
|
const btn = page.getByRole("button");
|
|
154
|
-
page.keyboard.press("Tab");
|
|
154
|
+
yield page.keyboard.press("Tab");
|
|
155
155
|
yield (0, fixtures_1.expect)(btn).toBeFocused();
|
|
156
156
|
// Open with Enter
|
|
157
|
-
page.keyboard.press("Enter");
|
|
157
|
+
yield page.keyboard.press("Enter");
|
|
158
158
|
yield (0, fixtures_1.expect)(page.getByRole("menuitem", { name: "Item 1" })).toBeVisible();
|
|
159
159
|
// Navigate and select with keyboard
|
|
160
160
|
yield page.keyboard.press("ArrowDown");
|
|
@@ -32,15 +32,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
35
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
45
36
|
var t = {};
|
|
46
37
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -81,7 +72,7 @@ exports.FileUploadDropZone = (0, react_1.forwardRef)(function FileUploadDropZone
|
|
|
81
72
|
const accept = acceptedFileTypes
|
|
82
73
|
? acceptedFileTypes.split(",").reduce((acc, type) => (Object.assign(Object.assign({}, acc), { [type.trim()]: [] })), {})
|
|
83
74
|
: undefined;
|
|
84
|
-
const onDrop = (0, react_1.useCallback)((acceptedFiles) =>
|
|
75
|
+
const onDrop = (0, react_1.useCallback)((acceptedFiles) => {
|
|
85
76
|
if (!acceptedFiles.length) {
|
|
86
77
|
return;
|
|
87
78
|
}
|
|
@@ -89,7 +80,7 @@ exports.FileUploadDropZone = (0, react_1.forwardRef)(function FileUploadDropZone
|
|
|
89
80
|
value: acceptedFiles,
|
|
90
81
|
});
|
|
91
82
|
onUpload === null || onUpload === void 0 ? void 0 : onUpload(acceptedFiles);
|
|
92
|
-
}
|
|
83
|
+
}, [onUpload, updateState]);
|
|
93
84
|
const { getRootProps, getInputProps, isDragActive, open, inputRef, isDragAccept } = useDropzone({
|
|
94
85
|
onDrop,
|
|
95
86
|
noClick: true,
|
|
@@ -97,7 +88,7 @@ exports.FileUploadDropZone = (0, react_1.forwardRef)(function FileUploadDropZone
|
|
|
97
88
|
noDragEventsBubbling: true,
|
|
98
89
|
disabled,
|
|
99
90
|
accept,
|
|
100
|
-
maxFiles
|
|
91
|
+
maxFiles,
|
|
101
92
|
});
|
|
102
93
|
const doOpen = (0, misc_1.useEvent)(() => {
|
|
103
94
|
open();
|
|
@@ -139,5 +130,5 @@ exports.FileUploadDropZone = (0, react_1.forwardRef)(function FileUploadDropZone
|
|
|
139
130
|
}, [doOpen, registerComponentApi, uid]);
|
|
140
131
|
const _b = getRootProps(Object.assign(Object.assign({}, rest), { style, className: (0, classnames_1.default)(FileUploadDropZone_module_scss_1.default.wrapper, className), onPaste: handleOnPaste })), { ref } = _b, rootProps = __rest(_b, ["ref"]);
|
|
141
132
|
const rootRef = (0, component_utils_1.getComposedRef)(ref, forwardedRef);
|
|
142
|
-
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, rootProps, { "data-drop-enabled": !disabled, ref: rootRef, children: [(0, jsx_runtime_1.jsx)("input", Object.assign({}, getInputProps())), children,
|
|
133
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, rootProps, { "data-drop-enabled": !disabled, ref: rootRef, children: [(0, jsx_runtime_1.jsx)("input", Object.assign({}, getInputProps())), children, isDragActive && isDragAccept && ((0, jsx_runtime_1.jsxs)("div", { className: FileUploadDropZone_module_scss_1.default.dropPlaceholder, children: [(0, jsx_runtime_1.jsx)(IconNative_1.Icon, { name: "upload" }), text] }))] })));
|
|
143
134
|
});
|
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const abstractions_1 = require("../abstractions");
|
|
13
13
|
const fixtures_1 = require("../../testing/fixtures");
|
|
14
|
+
const component_test_helpers_1 = require("../../testing/component-test-helpers");
|
|
14
15
|
// Test data constants
|
|
15
16
|
const errorDisplayInterceptor = {
|
|
16
17
|
initialize: `
|
|
@@ -177,6 +178,21 @@ fixtures_1.test.describe("Basic Functionality", () => {
|
|
|
177
178
|
const driver = yield createFormDriver("form");
|
|
178
179
|
yield (0, fixtures_1.expect)(driver.component).toBeVisible();
|
|
179
180
|
}));
|
|
181
|
+
(0, fixtures_1.test)("handles theme variable", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createFormItemDriver }) {
|
|
182
|
+
const spaceBase = 0.25; //rem
|
|
183
|
+
const labelSize = 10;
|
|
184
|
+
const widthInPx = labelSize * spaceBase * 16; //px
|
|
185
|
+
yield initTestBed(`
|
|
186
|
+
<Theme space-base="${spaceBase}rem">
|
|
187
|
+
<Form itemLabelWidth="$space-${labelSize}">
|
|
188
|
+
<FormItem label="Test Label" bindTo="test" testId="testField" />
|
|
189
|
+
</Form>
|
|
190
|
+
</Theme>
|
|
191
|
+
`);
|
|
192
|
+
const driver = yield createFormItemDriver("testField");
|
|
193
|
+
const labelWidth = yield (0, component_test_helpers_1.getElementStyle)(driver.label, "width");
|
|
194
|
+
(0, fixtures_1.expect)(labelWidth).toBe(`${widthInPx}px`);
|
|
195
|
+
}));
|
|
180
196
|
});
|
|
181
197
|
// =============================================================================
|
|
182
198
|
// ITEM LABEL BREAK TESTS
|
|
@@ -272,7 +288,7 @@ fixtures_1.test.describe("Basic Functionality", () => {
|
|
|
272
288
|
}));
|
|
273
289
|
(0, fixtures_1.test)("onSuccess event fires on successful submission", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, createFormDriver, }) {
|
|
274
290
|
const { testStateDriver } = yield initTestBed(`
|
|
275
|
-
<Form
|
|
291
|
+
<Form
|
|
276
292
|
testId="form"
|
|
277
293
|
submitUrl="/test-success"
|
|
278
294
|
onSuccess="testState = 'success'; console.log('Submitted successfully')"
|
|
@@ -296,7 +312,7 @@ fixtures_1.test.describe("Basic Functionality", () => {
|
|
|
296
312
|
}));
|
|
297
313
|
(0, fixtures_1.test)("onReset event fires when form is reset", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
298
314
|
const { testStateDriver } = yield initTestBed(`
|
|
299
|
-
<Form
|
|
315
|
+
<Form
|
|
300
316
|
id="testForm"
|
|
301
317
|
onReset="testState = 'reset'"
|
|
302
318
|
data="{{ name: 'Test' }}">
|
|
@@ -314,7 +330,7 @@ fixtures_1.test.describe("Basic Functionality", () => {
|
|
|
314
330
|
fixtures_1.test.describe("APIs", () => {
|
|
315
331
|
(0, fixtures_1.test)("update method updates form data", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, createFormItemDriver, createTextBoxDriver, }) {
|
|
316
332
|
yield initTestBed(`
|
|
317
|
-
<Form
|
|
333
|
+
<Form
|
|
318
334
|
id="testForm"
|
|
319
335
|
data="{{ name: 'Original', age: 25 }}">
|
|
320
336
|
<FormItem label="Name" bindTo="name" testId="nameField" />
|
|
@@ -334,7 +350,7 @@ fixtures_1.test.describe("Basic Functionality", () => {
|
|
|
334
350
|
}));
|
|
335
351
|
(0, fixtures_1.test)("reset method resets form to initial state", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, createFormItemDriver, createTextBoxDriver, }) {
|
|
336
352
|
yield initTestBed(`
|
|
337
|
-
<Form
|
|
353
|
+
<Form
|
|
338
354
|
id="testForm"
|
|
339
355
|
data="{{ name: 'Initial' }}">
|
|
340
356
|
<FormItem label="Name" bindTo="name" testId="nameField" />
|
|
@@ -603,7 +619,7 @@ fixtures_1.test.describe("Edge Cases", () => {
|
|
|
603
619
|
}));
|
|
604
620
|
(0, fixtures_1.test)("handles form with empty string properties", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
605
621
|
yield initTestBed(`
|
|
606
|
-
<Form
|
|
622
|
+
<Form
|
|
607
623
|
cancelLabel=""
|
|
608
624
|
saveLabel=""
|
|
609
625
|
data="{{ name: '' }}">
|
|
@@ -829,8 +845,8 @@ fixtures_1.test.describe("Edge Cases", () => {
|
|
|
829
845
|
</property>
|
|
830
846
|
</Form>`);
|
|
831
847
|
const driver = yield createFormDriver("form");
|
|
832
|
-
(0, fixtures_1.expect)(driver.submitButton).not.toBeVisible();
|
|
833
|
-
(0, fixtures_1.expect)(driver.cancelButton).not.toBeVisible();
|
|
848
|
+
yield (0, fixtures_1.expect)(driver.submitButton).not.toBeVisible();
|
|
849
|
+
yield (0, fixtures_1.expect)(driver.cancelButton).not.toBeVisible();
|
|
834
850
|
}));
|
|
835
851
|
(0, fixtures_1.test)("setting buttonRowTemplate without buttons still runs submit on Enter", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createFormDriver, }) {
|
|
836
852
|
const { testStateDriver } = yield initTestBed(`
|
|
@@ -1105,7 +1121,7 @@ fixtures_1.test.describe("Edge Cases", () => {
|
|
|
1105
1121
|
yield formDriver.submitForm();
|
|
1106
1122
|
yield (0, fixtures_1.expect)(fieldDriver.validationStatusIndicator).toHaveAttribute(fieldDriver.validationStatusTag, "warning");
|
|
1107
1123
|
}));
|
|
1108
|
-
fixtures_1.test.skip("field-related errors disappear if user updates FormItems", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, createFormItemDriver }) {
|
|
1124
|
+
fixtures_1.test.skip("field-related errors disappear if user updates FormItems", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, createFormItemDriver, }) {
|
|
1109
1125
|
yield initTestBed(`
|
|
1110
1126
|
<Form testId="form">
|
|
1111
1127
|
<FormItem testId="testField" bindTo="test" label="test" required />
|
|
@@ -1196,7 +1212,7 @@ const smartCrudInterceptor = {
|
|
|
1196
1212
|
const formDriver = yield createFormDriver("modalForm");
|
|
1197
1213
|
const inputElement = (yield createFormItemDriver("nameInput")).input;
|
|
1198
1214
|
const inputDriver = yield createTextBoxDriver(inputElement);
|
|
1199
|
-
(yield createButtonDriver("openModalButton")).click();
|
|
1215
|
+
yield (yield createButtonDriver("openModalButton")).click();
|
|
1200
1216
|
yield (0, fixtures_1.expect)(inputDriver.field).toHaveValue("Smith");
|
|
1201
1217
|
yield inputDriver.field.fill("EDITED-Smith");
|
|
1202
1218
|
yield formDriver.submitForm("click");
|
|
@@ -45,6 +45,7 @@ const FormContext_1 = require("./FormContext");
|
|
|
45
45
|
const lodash_es_1 = require("lodash-es");
|
|
46
46
|
const classnames_1 = __importDefault(require("classnames"));
|
|
47
47
|
const react_slot_1 = require("@radix-ui/react-slot");
|
|
48
|
+
const layout_resolver_1 = require("../../components-core/theming/layout-resolver");
|
|
48
49
|
const PART_CANCEL_BUTTON = "cancelButton";
|
|
49
50
|
const PART_SUBMIT_BUTTON = "submitButton";
|
|
50
51
|
const getByPath = (obj, path) => {
|
|
@@ -241,7 +242,7 @@ const Form = (0, react_2.forwardRef)(function (_a, ref) {
|
|
|
241
242
|
]);
|
|
242
243
|
const doCancel = (0, misc_1.useEvent)(() => {
|
|
243
244
|
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
244
|
-
requestModalFormClose();
|
|
245
|
+
void requestModalFormClose();
|
|
245
246
|
});
|
|
246
247
|
const doSubmit = (0, misc_1.useEvent)((event) => __awaiter(this, void 0, void 0, function* () {
|
|
247
248
|
var _a;
|
|
@@ -277,7 +278,7 @@ const Form = (0, react_2.forwardRef)(function (_a, ref) {
|
|
|
277
278
|
dispatch((0, formActions_1.formSubmitted)());
|
|
278
279
|
yield (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(result));
|
|
279
280
|
if (!keepModalOpenOnSubmit) {
|
|
280
|
-
requestModalFormClose();
|
|
281
|
+
void requestModalFormClose();
|
|
281
282
|
}
|
|
282
283
|
// we only reset the form automatically if the initial value is empty ()
|
|
283
284
|
if (initialValue === constants_1.EMPTY_OBJECT) {
|
|
@@ -353,7 +354,7 @@ const Form = (0, react_2.forwardRef)(function (_a, ref) {
|
|
|
353
354
|
update: updateData,
|
|
354
355
|
});
|
|
355
356
|
}, [doReset, updateData, registerComponentApi]);
|
|
356
|
-
let safeButtonRow = (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: buttonRow || ((0, jsx_runtime_1.jsxs)("div", { className: Form_module_scss_1.default.buttonRow, children: [swapCancelAndSave && [submitButton, cancelButton], !swapCancelAndSave && [cancelButton, submitButton]] })) });
|
|
357
|
+
let safeButtonRow = ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: buttonRow || ((0, jsx_runtime_1.jsxs)("div", { className: Form_module_scss_1.default.buttonRow, children: [swapCancelAndSave && [submitButton, cancelButton], !swapCancelAndSave && [cancelButton, submitButton]] })) }));
|
|
357
358
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, react_1.createElement)("form", Object.assign({}, rest, { style: style, className: (0, classnames_1.default)(Form_module_scss_1.default.wrapper, className), onSubmit: doSubmit, onReset: doReset, id: id, key: formState.resetVersion, ref: formRef }),
|
|
358
359
|
(0, jsx_runtime_1.jsx)(ValidationSummary_1.ValidationSummary, { generalValidationResults: formState.generalValidationResults }),
|
|
359
360
|
(0, jsx_runtime_1.jsx)(FormContext_1.FormContext.Provider, { value: formContextValue, children: children }),
|
|
@@ -395,7 +396,9 @@ exports.FormWithContextVar = (0, react_2.forwardRef)(function ({ node, renderChi
|
|
|
395
396
|
const errorNotificationMessage = extractValue.asOptionalString(node.props.errorNotificationMessage) || "";
|
|
396
397
|
const submitUrl = extractValue.asOptionalString(node.props.submitUrl) ||
|
|
397
398
|
extractValue.asOptionalString(node.props._data_url);
|
|
398
|
-
|
|
399
|
+
const itemLabelWidth = extractValue.asOptionalString(node.props.itemLabelWidth);
|
|
400
|
+
const { cssProps: itemLabelWidthCssProps } = (0, layout_resolver_1.resolveLayoutProps)({ width: itemLabelWidth });
|
|
401
|
+
return ((0, jsx_runtime_1.jsx)(react_slot_1.Slot, { ref: ref, style: style, children: (0, jsx_runtime_1.jsx)(Form, { keepModalOpenOnSubmit: extractValue.asOptionalBoolean(node.props.keepModalOpenOnSubmit), itemLabelPosition: extractValue.asOptionalString(node.props.itemLabelPosition), itemLabelBreak: extractValue.asOptionalBoolean(node.props.itemLabelBreak), itemLabelWidth: itemLabelWidthCssProps.width, hideButtonRowUntilDirty: extractValue.asOptionalBoolean(node.props.hideButtonRowUntilDirty), formState: formState, dispatch: dispatch, id: node.uid, className: className, cancelLabel: extractValue(node.props.cancelLabel), saveLabel: extractValue(node.props.saveLabel), saveInProgressLabel: extractValue(node.props.saveInProgressLabel), swapCancelAndSave: extractValue.asOptionalBoolean(node.props.swapCancelAndSave, false), onSubmit: lookupEventHandler("submit", {
|
|
399
402
|
defaultHandler: submitUrl
|
|
400
403
|
? `(eventArgs)=> Actions.callApi({ url: "${submitUrl}", method: "${submitMethod}", body: eventArgs, inProgressNotificationMessage: "${inProgressNotificationMessage}", completedNotificationMessage: "${completedNotificationMessage}", errorNotificationMessage: "${errorNotificationMessage}" })`
|
|
401
404
|
: undefined,
|
|
@@ -33,7 +33,9 @@ exports.FormItemMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
33
33
|
description: "`FormItem` wraps individual input controls within a `Form`, providing data " +
|
|
34
34
|
"binding, validation, labeling, and layout functionality. It connects form " +
|
|
35
35
|
"controls to the parent form's data model and handles validation feedback " +
|
|
36
|
-
"automatically."
|
|
36
|
+
"automatically." +
|
|
37
|
+
"\n\n" +
|
|
38
|
+
"> **Note:** `FormItem` must be used inside a `Form` component.",
|
|
37
39
|
props: {
|
|
38
40
|
bindTo: {
|
|
39
41
|
description: "This property binds a particular input field to one of the attributes of the \`Form\` data. " +
|
|
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const component_test_helpers_1 = require("../../testing/component-test-helpers");
|
|
13
12
|
const fixtures_1 = require("../../testing/fixtures");
|
|
14
13
|
// =============================================================================
|
|
15
14
|
// BASIC FUNCTIONALITY TESTS
|
|
@@ -855,18 +854,10 @@ fixtures_1.test.describe("Other Edge Cases", () => {
|
|
|
855
854
|
yield input.field.blur();
|
|
856
855
|
yield (0, fixtures_1.expect)(driver.validationStatusIndicator).toBeVisible();
|
|
857
856
|
}));
|
|
858
|
-
fixtures_1.test
|
|
859
|
-
yield initTestBed(
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
// Component should either render with fallback behavior or be gracefully hidden
|
|
864
|
-
const isVisible = yield driver.component.isVisible();
|
|
865
|
-
if (isVisible) {
|
|
866
|
-
yield (0, fixtures_1.expect)(driver.component).toBeVisible();
|
|
867
|
-
}
|
|
868
|
-
else {
|
|
869
|
-
(0, fixtures_1.expect)(isVisible).toBe(false);
|
|
870
|
-
}
|
|
857
|
+
(0, fixtures_1.test)("handles FormItem with no Form parent gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
858
|
+
yield initTestBed(`<FormItem label="Standalone FormItem" type="text" />`);
|
|
859
|
+
const field = page.getByRole("textbox");
|
|
860
|
+
yield (0, fixtures_1.expect)(field).not.toBeVisible();
|
|
861
|
+
yield (0, fixtures_1.expect)(page.locator("[data-error-boundary]")).toBeVisible();
|
|
871
862
|
}));
|
|
872
863
|
});
|
|
@@ -112,15 +112,15 @@ exports.FormItem = (0, react_1.memo)(function FormItem(_a) {
|
|
|
112
112
|
return safeBindTo;
|
|
113
113
|
}
|
|
114
114
|
}, [bindTo, defaultId, itemIndex, parentFormItemId]);
|
|
115
|
-
const labelWidthValue = (0, FormContext_1.useFormContextPart)((value) => labelWidth || value.itemLabelWidth);
|
|
116
|
-
const labelBreakValue = (0, FormContext_1.useFormContextPart)((value) => labelBreak !== undefined ? labelBreak : value.itemLabelBreak);
|
|
117
|
-
const labelPositionValue = (0, FormContext_1.useFormContextPart)((value) => labelPosition || value.itemLabelPosition || DEFAULT_LABEL_POSITIONS[type]);
|
|
118
|
-
const initialValueFromSubject = (0, FormContext_1.useFormContextPart)((value) => (0, FormNative_1.getByPath)(value.originalSubject, formItemId));
|
|
115
|
+
const labelWidthValue = (0, FormContext_1.useFormContextPart)((value) => labelWidth || (value === null || value === void 0 ? void 0 : value.itemLabelWidth));
|
|
116
|
+
const labelBreakValue = (0, FormContext_1.useFormContextPart)((value) => labelBreak !== undefined ? labelBreak : value === null || value === void 0 ? void 0 : value.itemLabelBreak);
|
|
117
|
+
const labelPositionValue = (0, FormContext_1.useFormContextPart)((value) => labelPosition || (value === null || value === void 0 ? void 0 : value.itemLabelPosition) || DEFAULT_LABEL_POSITIONS[type]);
|
|
118
|
+
const initialValueFromSubject = (0, FormContext_1.useFormContextPart)((value) => (0, FormNative_1.getByPath)(value === null || value === void 0 ? void 0 : value.originalSubject, formItemId));
|
|
119
119
|
const initialValue = initialValueFromSubject === undefined ? initialValueFromProps : initialValueFromSubject;
|
|
120
|
-
const value = (0, FormContext_1.useFormContextPart)((value) => (0, FormNative_1.getByPath)(value.subject, formItemId));
|
|
121
|
-
const validationResult = (0, FormContext_1.useFormContextPart)((value) => value.validationResults[formItemId]);
|
|
122
|
-
const dispatch = (0, FormContext_1.useFormContextPart)((value) => value.dispatch);
|
|
123
|
-
const formEnabled = (0, FormContext_1.useFormContextPart)((value) => value.enabled);
|
|
120
|
+
const value = (0, FormContext_1.useFormContextPart)((value) => (0, FormNative_1.getByPath)(value === null || value === void 0 ? void 0 : value.subject, formItemId));
|
|
121
|
+
const validationResult = (0, FormContext_1.useFormContextPart)((value) => value === null || value === void 0 ? void 0 : value.validationResults[formItemId]);
|
|
122
|
+
const dispatch = (0, FormContext_1.useFormContextPart)((value) => value === null || value === void 0 ? void 0 : value.dispatch);
|
|
123
|
+
const formEnabled = (0, FormContext_1.useFormContextPart)((value) => value === null || value === void 0 ? void 0 : value.enabled);
|
|
124
124
|
const isEnabled = enabled && formEnabled;
|
|
125
125
|
(0, react_1.useEffect)(() => {
|
|
126
126
|
if (initialValue !== undefined) {
|
|
@@ -217,6 +217,10 @@ exports.FormItem = (0, react_1.memo)(function FormItem(_a) {
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
const [animateContainerRef] = (0, react_2.useAutoAnimate)({ duration: 100 });
|
|
220
|
+
const isInsideForm = (0, FormContext_1.useIsInsideForm)();
|
|
221
|
+
if (!isInsideForm) {
|
|
222
|
+
throw new Error("FormItem must be used inside a Form");
|
|
223
|
+
}
|
|
220
224
|
return ((0, jsx_runtime_1.jsx)(ItemWithLabel_1.ItemWithLabel, { labelPosition: labelPositionValue, label: label, labelWidth: labelWidthValue, labelBreak: labelBreakValue, enabled: isEnabled, required: validations.required, validationInProgress: validationResult === null || validationResult === void 0 ? void 0 : validationResult.partial, onFocus: onFocus, onBlur: onBlur, style: style, className: className, validationResult: (0, jsx_runtime_1.jsx)("div", { ref: animateContainerRef, children: isHelperTextShown &&
|
|
221
225
|
(validationResult === null || validationResult === void 0 ? void 0 : validationResult.validations.map((singleValidation, i) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [singleValidation.isValid && !!singleValidation.validMessage && ((0, jsx_runtime_1.jsx)(HelperText_1.HelperText, { text: singleValidation.validMessage, status: "valid", style: { opacity: singleValidation.stale ? 0.5 : undefined } })), !singleValidation.isValid && !!singleValidation.invalidMessage && ((0, jsx_runtime_1.jsx)(HelperText_1.HelperText, { text: singleValidation.invalidMessage, status: singleValidation.severity, style: { opacity: singleValidation.stale ? 0.5 : undefined } }))] }, i)))) }), children: formControl }));
|
|
222
226
|
});
|
|
@@ -273,7 +273,7 @@ function useValidation(validations, onValidate, value, dispatch, bindTo, throttl
|
|
|
273
273
|
if (!ignore) {
|
|
274
274
|
dispatch((0, formActions_1.fieldValidated)(bindTo, partialResult));
|
|
275
275
|
if (partialResult.partial) {
|
|
276
|
-
(() => __awaiter(this, void 0, void 0, function* () {
|
|
276
|
+
void (() => __awaiter(this, void 0, void 0, function* () {
|
|
277
277
|
const result = yield throttledAsyncValidate(validations, onValidate, deferredValue);
|
|
278
278
|
if (!ignore) {
|
|
279
279
|
// console.log(`async validation result for ${bindTo}`, result);
|
|
@@ -288,7 +288,7 @@ function useValidation(validations, onValidate, value, dispatch, bindTo, throttl
|
|
|
288
288
|
}, [bindTo, deferredValue, dispatch, onValidate, throttledAsyncValidate, validations]);
|
|
289
289
|
}
|
|
290
290
|
function useValidationDisplay(bindTo, value, validationResult, validationMode = FormContext_1.defaultValidationMode) {
|
|
291
|
-
const interactionFlags = (0, FormContext_1.useFormContextPart)((value) => value.interactionFlags[bindTo]) || constants_1.EMPTY_OBJECT;
|
|
291
|
+
const interactionFlags = (0, FormContext_1.useFormContextPart)((value) => value === null || value === void 0 ? void 0 : value.interactionFlags[bindTo]) || constants_1.EMPTY_OBJECT;
|
|
292
292
|
const forceShowValidationResult = interactionFlags.forceShowValidationResult;
|
|
293
293
|
const focused = interactionFlags.focused;
|
|
294
294
|
const afterFirstDirtyBlur = interactionFlags.afterFirstDirtyBlur;
|
|
@@ -293,7 +293,7 @@ function useCustomSvgIconRenderer(resourceUrl) {
|
|
|
293
293
|
if (!resourceUrl) {
|
|
294
294
|
return;
|
|
295
295
|
}
|
|
296
|
-
ensureCustomSvgIcon(resourceUrl);
|
|
296
|
+
void ensureCustomSvgIcon(resourceUrl);
|
|
297
297
|
}, [ensureCustomSvgIcon, resourceUrl]);
|
|
298
298
|
const customSvg = resourceUrl ? customSvgs[resourceUrl] : null;
|
|
299
299
|
const iconRenderer = (0, react_1.useCallback)(({ style, className }) => {
|
|
@@ -293,7 +293,7 @@ exports.ListNative = (0, react_1.forwardRef)(function DynamicHeightList(_a, ref)
|
|
|
293
293
|
!pageInfo.isFetchingPrevPage &&
|
|
294
294
|
!isFetchingPrevPage.current) {
|
|
295
295
|
isFetchingPrevPage.current = true;
|
|
296
|
-
(function doFetch() {
|
|
296
|
+
void (function doFetch() {
|
|
297
297
|
return __awaiter(this, void 0, void 0, function* () {
|
|
298
298
|
try {
|
|
299
299
|
yield requestFetchPrevPage();
|
|
@@ -314,7 +314,7 @@ exports.ListNative = (0, react_1.forwardRef)(function DynamicHeightList(_a, ref)
|
|
|
314
314
|
!pageInfo.isFetchingNextPage &&
|
|
315
315
|
!isFetchingNextPage.current) {
|
|
316
316
|
isFetchingNextPage.current = true;
|
|
317
|
-
(function doFetch() {
|
|
317
|
+
void (function doFetch() {
|
|
318
318
|
return __awaiter(this, void 0, void 0, function* () {
|
|
319
319
|
try {
|
|
320
320
|
yield requestFetchNextPage();
|