xmlui 0.10.16 → 0.10.19
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/{index-D4RYJasT.mjs → index-cuh97e2e.mjs} +1603 -1635
- package/dist/lib/index.css +1 -1
- package/dist/lib/{initMock-qzTZlH-6.mjs → initMock-BMxsanHc.mjs} +1 -1
- package/dist/lib/xmlui.mjs +1 -1
- package/dist/metadata/{collectedComponentMetadata-BQaefK3f.mjs → collectedComponentMetadata-Cp-9lpnG.mjs} +1716 -1757
- package/dist/metadata/{initMock-Cz6QssI3.mjs → initMock-C-cnv--V.mjs} +1 -1
- 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/Accordion/Accordion.spec.js +1 -1
- package/dist/scripts/src/components/Accordion/AccordionItemNative.js +1 -1
- package/dist/scripts/src/components/AutoComplete/AutoComplete.spec.js +54 -4
- package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +81 -62
- package/dist/scripts/src/components/Checkbox/Checkbox.js +1 -5
- package/dist/scripts/src/components/Checkbox/Checkbox.spec.js +5 -0
- package/dist/scripts/src/components/ColorPicker/ColorPicker.js +2 -6
- package/dist/scripts/src/components/ColorPicker/ColorPicker.spec.js +29 -0
- package/dist/scripts/src/components/ColorPicker/ColorPickerNative.js +12 -9
- package/dist/scripts/src/components/ComponentProvider.js +2 -0
- package/dist/scripts/src/components/DateInput/DateInput.js +1 -5
- package/dist/scripts/src/components/DateInput/DateInput.spec.js +51 -17
- package/dist/scripts/src/components/DateInput/DateInputNative.js +12 -16
- package/dist/scripts/src/components/DatePicker/DatePicker.js +14 -13
- package/dist/scripts/src/components/DatePicker/DatePicker.spec.js +50 -18
- package/dist/scripts/src/components/DatePicker/DatePickerNative.js +34 -32
- package/dist/scripts/src/components/FileInput/FileInput.js +1 -5
- package/dist/scripts/src/components/FileInput/FileInput.spec.js +36 -0
- package/dist/scripts/src/components/FileInput/FileInputNative.js +14 -15
- package/dist/scripts/src/components/Form/Form.spec.js +11 -9
- package/dist/scripts/src/components/Form/FormNative.js +15 -9
- package/dist/scripts/src/components/FormItem/FormItem.spec.js +179 -30
- package/dist/scripts/src/components/FormItem/FormItemNative.js +20 -22
- package/dist/scripts/src/components/FormItem/ItemWithLabel.js +8 -17
- package/dist/scripts/src/components/FormItem/Validations.js +25 -6
- package/dist/scripts/src/components/Icon/Icon.js +1 -1
- package/dist/scripts/src/components/Input/PartialInput.js +2 -2
- package/dist/scripts/src/components/NumberBox/NumberBox.js +1 -5
- package/dist/scripts/src/components/NumberBox/NumberBox.spec.js +38 -4
- package/dist/scripts/src/components/NumberBox/NumberBoxNative.js +15 -17
- package/dist/scripts/src/components/RadioGroup/RadioGroup.js +1 -5
- package/dist/scripts/src/components/RadioGroup/RadioGroup.spec.js +9 -0
- package/dist/scripts/src/components/RadioGroup/RadioGroupNative.js +4 -5
- package/dist/scripts/src/components/RadioGroup/RadioItem.js +28 -0
- package/dist/scripts/src/components/Select/Select.js +1 -5
- package/dist/scripts/src/components/Select/Select.spec.js +290 -193
- package/dist/scripts/src/components/Select/SelectNative.js +26 -32
- package/dist/scripts/src/components/Slider/Slider.js +1 -5
- package/dist/scripts/src/components/Slider/Slider.spec.js +36 -0
- package/dist/scripts/src/components/Slider/SliderNative.js +18 -19
- package/dist/scripts/src/components/Switch/Switch.js +1 -5
- package/dist/scripts/src/components/Switch/Switch.spec.js +24 -17
- package/dist/scripts/src/components/Table/Table.js +11 -1
- package/dist/scripts/src/components/Table/Table.spec.js +272 -0
- package/dist/scripts/src/components/Table/TableNative.js +162 -5
- package/dist/scripts/src/components/TextArea/TextArea.js +1 -5
- package/dist/scripts/src/components/TextArea/TextArea.spec.js +80 -0
- package/dist/scripts/src/components/TextArea/TextAreaNative.js +8 -29
- package/dist/scripts/src/components/TextBox/TextBox.spec.js +45 -7
- package/dist/scripts/src/components/TextBox/TextBoxNative.js +2 -2
- package/dist/scripts/src/components/TimeInput/TimeInput.spec.js +75 -37
- package/dist/scripts/src/components/TimeInput/TimeInputNative.js +6 -20
- package/dist/scripts/src/components/Timer/Timer.spec.js +66 -96
- package/dist/scripts/src/components/Toggle/Toggle.js +30 -25
- package/dist/scripts/src/components/Tree/Tree-icons.spec.js +206 -0
- package/dist/scripts/src/components/Tree/Tree.spec.js +1 -94
- package/dist/scripts/src/components/Tree/TreeComponent.js +44 -7
- package/dist/scripts/src/components/Tree/TreeNative.js +127 -85
- package/dist/scripts/src/components/Tree/testData.js +25 -1
- package/dist/scripts/src/components-core/behaviors/Behavior.js +2 -0
- package/dist/scripts/src/components-core/behaviors/CoreBehaviors.js +8 -5
- package/dist/scripts/src/components-core/rendering/AppRoot.js +1 -2
- package/dist/scripts/src/components-core/rendering/ComponentAdapter.js +12 -13
- package/dist/scripts/src/components-core/utils/treeUtils.js +8 -5
- package/dist/scripts/src/testing/ComponentDrivers.js +2 -4
- package/dist/standalone/xmlui-standalone.umd.js +15 -15
- package/package.json +1 -1
- package/dist/scripts/src/components-core/behaviors/BehaviorContext.js +0 -54
|
@@ -179,7 +179,7 @@ fixtures_1.test.describe("initialValue property", () => {
|
|
|
179
179
|
yield (0, fixtures_1.expect)(driver.dayInput).toHaveValue("");
|
|
180
180
|
yield (0, fixtures_1.expect)(driver.yearInput).toHaveValue("");
|
|
181
181
|
}));
|
|
182
|
-
(0, fixtures_1.test)("handles numeric initialValue gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver }) {
|
|
182
|
+
(0, fixtures_1.test)("handles numeric initialValue gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver, }) {
|
|
183
183
|
yield initTestBed(`<DateInput testId="dateInput" initialValue="{123456789}" />`);
|
|
184
184
|
const driver = yield createDateInputDriver("dateInput");
|
|
185
185
|
yield (0, fixtures_1.expect)(driver.monthInput).toHaveValue("");
|
|
@@ -193,14 +193,14 @@ fixtures_1.test.describe("initialValue property", () => {
|
|
|
193
193
|
yield (0, fixtures_1.expect)(driver.dayInput).toHaveValue("");
|
|
194
194
|
yield (0, fixtures_1.expect)(driver.yearInput).toHaveValue("");
|
|
195
195
|
}));
|
|
196
|
-
(0, fixtures_1.test)("handles boolean initialValue gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver }) {
|
|
196
|
+
(0, fixtures_1.test)("handles boolean initialValue gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver, }) {
|
|
197
197
|
yield initTestBed(`<DateInput testId="dateInput" initialValue="{true}" />`);
|
|
198
198
|
const driver = yield createDateInputDriver("dateInput");
|
|
199
199
|
yield (0, fixtures_1.expect)(driver.monthInput).toHaveValue("");
|
|
200
200
|
yield (0, fixtures_1.expect)(driver.dayInput).toHaveValue("");
|
|
201
201
|
yield (0, fixtures_1.expect)(driver.yearInput).toHaveValue("");
|
|
202
202
|
}));
|
|
203
|
-
(0, fixtures_1.test)("handles false boolean initialValue gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver }) {
|
|
203
|
+
(0, fixtures_1.test)("handles false boolean initialValue gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver, }) {
|
|
204
204
|
yield initTestBed(`<DateInput testId="dateInput" initialValue="{false}" />`);
|
|
205
205
|
const driver = yield createDateInputDriver("dateInput");
|
|
206
206
|
yield (0, fixtures_1.expect)(driver.monthInput).toHaveValue("");
|
|
@@ -214,28 +214,28 @@ fixtures_1.test.describe("initialValue property", () => {
|
|
|
214
214
|
yield (0, fixtures_1.expect)(driver.dayInput).toHaveValue("");
|
|
215
215
|
yield (0, fixtures_1.expect)(driver.yearInput).toHaveValue("");
|
|
216
216
|
}));
|
|
217
|
-
(0, fixtures_1.test)("handles function initialValue gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver }) {
|
|
217
|
+
(0, fixtures_1.test)("handles function initialValue gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver, }) {
|
|
218
218
|
yield initTestBed(`<DateInput testId="dateInput" initialValue="{() => '2024-01-01'}" />`);
|
|
219
219
|
const driver = yield createDateInputDriver("dateInput");
|
|
220
220
|
yield (0, fixtures_1.expect)(driver.monthInput).toHaveValue("");
|
|
221
221
|
yield (0, fixtures_1.expect)(driver.dayInput).toHaveValue("");
|
|
222
222
|
yield (0, fixtures_1.expect)(driver.yearInput).toHaveValue("");
|
|
223
223
|
}));
|
|
224
|
-
(0, fixtures_1.test)("handles zero numeric initialValue gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver }) {
|
|
224
|
+
(0, fixtures_1.test)("handles zero numeric initialValue gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver, }) {
|
|
225
225
|
yield initTestBed(`<DateInput testId="dateInput" initialValue="{0}" />`);
|
|
226
226
|
const driver = yield createDateInputDriver("dateInput");
|
|
227
227
|
yield (0, fixtures_1.expect)(driver.monthInput).toHaveValue("");
|
|
228
228
|
yield (0, fixtures_1.expect)(driver.dayInput).toHaveValue("");
|
|
229
229
|
yield (0, fixtures_1.expect)(driver.yearInput).toHaveValue("");
|
|
230
230
|
}));
|
|
231
|
-
(0, fixtures_1.test)("handles negative numeric initialValue gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver }) {
|
|
231
|
+
(0, fixtures_1.test)("handles negative numeric initialValue gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver, }) {
|
|
232
232
|
yield initTestBed(`<DateInput testId="dateInput" initialValue="{-123}" />`);
|
|
233
233
|
const driver = yield createDateInputDriver("dateInput");
|
|
234
234
|
yield (0, fixtures_1.expect)(driver.monthInput).toHaveValue("");
|
|
235
235
|
yield (0, fixtures_1.expect)(driver.dayInput).toHaveValue("");
|
|
236
236
|
yield (0, fixtures_1.expect)(driver.yearInput).toHaveValue("");
|
|
237
237
|
}));
|
|
238
|
-
(0, fixtures_1.test)("handles float numeric initialValue gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver }) {
|
|
238
|
+
(0, fixtures_1.test)("handles float numeric initialValue gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver, }) {
|
|
239
239
|
yield initTestBed(`<DateInput testId="dateInput" initialValue="{123.456}" />`);
|
|
240
240
|
const driver = yield createDateInputDriver("dateInput");
|
|
241
241
|
yield (0, fixtures_1.expect)(driver.monthInput).toHaveValue("");
|
|
@@ -249,21 +249,21 @@ fixtures_1.test.describe("initialValue property", () => {
|
|
|
249
249
|
yield (0, fixtures_1.expect)(driver.dayInput).toHaveValue("");
|
|
250
250
|
yield (0, fixtures_1.expect)(driver.yearInput).toHaveValue("");
|
|
251
251
|
}));
|
|
252
|
-
(0, fixtures_1.test)("handles Infinity initialValue gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver }) {
|
|
252
|
+
(0, fixtures_1.test)("handles Infinity initialValue gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver, }) {
|
|
253
253
|
yield initTestBed(`<DateInput testId="dateInput" initialValue="{Infinity}" />`);
|
|
254
254
|
const driver = yield createDateInputDriver("dateInput");
|
|
255
255
|
yield (0, fixtures_1.expect)(driver.monthInput).toHaveValue("");
|
|
256
256
|
yield (0, fixtures_1.expect)(driver.dayInput).toHaveValue("");
|
|
257
257
|
yield (0, fixtures_1.expect)(driver.yearInput).toHaveValue("");
|
|
258
258
|
}));
|
|
259
|
-
(0, fixtures_1.test)("handles Date object initialValue gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver }) {
|
|
259
|
+
(0, fixtures_1.test)("handles Date object initialValue gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver, }) {
|
|
260
260
|
yield initTestBed(`<DateInput testId="dateInput" initialValue="{Date.now()}" />`);
|
|
261
261
|
const driver = yield createDateInputDriver("dateInput");
|
|
262
262
|
yield (0, fixtures_1.expect)(driver.monthInput).toHaveValue("");
|
|
263
263
|
yield (0, fixtures_1.expect)(driver.dayInput).toHaveValue("");
|
|
264
264
|
yield (0, fixtures_1.expect)(driver.yearInput).toHaveValue("");
|
|
265
265
|
}));
|
|
266
|
-
(0, fixtures_1.test)("handles complex object initialValue gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver }) {
|
|
266
|
+
(0, fixtures_1.test)("handles complex object initialValue gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver, }) {
|
|
267
267
|
yield initTestBed(`<DateInput testId="dateInput" initialValue="{{year: 2024, month: 5, day: 25}}" />`);
|
|
268
268
|
const driver = yield createDateInputDriver("dateInput");
|
|
269
269
|
yield (0, fixtures_1.expect)(driver.monthInput).toHaveValue("");
|
|
@@ -548,6 +548,11 @@ fixtures_1.test.describe("Event Handling", () => {
|
|
|
548
548
|
yield driver.dayInput.focus();
|
|
549
549
|
yield fixtures_1.expect.poll(testStateDriver.testState).toEqual("focused");
|
|
550
550
|
}));
|
|
551
|
+
(0, fixtures_1.test)("fires gotFocus event when label receives focus", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
552
|
+
const { testStateDriver } = yield initTestBed(`<DateInput testId="dateInput" onGotFocus="testState = 'focused'" label="test" />`);
|
|
553
|
+
yield page.getByText("test").click();
|
|
554
|
+
yield fixtures_1.expect.poll(testStateDriver.testState).toEqual("focused");
|
|
555
|
+
}));
|
|
551
556
|
(0, fixtures_1.test)("fires lostFocus event when input loses focus", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver, page, }) {
|
|
552
557
|
const { testStateDriver } = yield initTestBed(`<DateInput testId="dateInput" onLostFocus="testState = 'blurred'" />`);
|
|
553
558
|
const driver = yield createDateInputDriver("dateInput");
|
|
@@ -557,7 +562,7 @@ fixtures_1.test.describe("Event Handling", () => {
|
|
|
557
562
|
yield page.keyboard.press("Tab"); // Move focus away from all inputs
|
|
558
563
|
yield fixtures_1.expect.poll(testStateDriver.testState).toEqual("blurred");
|
|
559
564
|
}));
|
|
560
|
-
(0, fixtures_1.test)("preserves field values when date combination becomes invalid", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver, page }) {
|
|
565
|
+
(0, fixtures_1.test)("preserves field values when date combination becomes invalid", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver, page, }) {
|
|
561
566
|
yield initTestBed(`<DateInput testId="dateInput" dateFormat="MM/dd/yyyy" initialValue="01/30/2024" />`);
|
|
562
567
|
const driver = yield createDateInputDriver("dateInput");
|
|
563
568
|
// Verify initial state
|
|
@@ -576,7 +581,7 @@ fixtures_1.test.describe("Event Handling", () => {
|
|
|
576
581
|
// The day field should also be marked as invalid visually
|
|
577
582
|
yield (0, fixtures_1.expect)(driver.dayInput).toHaveClass(/invalid/);
|
|
578
583
|
}));
|
|
579
|
-
(0, fixtures_1.test)("does not clear all fields when invalid date is entered", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver, page }) {
|
|
584
|
+
(0, fixtures_1.test)("does not clear all fields when invalid date is entered", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver, page, }) {
|
|
580
585
|
yield initTestBed(`<DateInput testId="dateInput" dateFormat="MM/dd/yyyy" />`);
|
|
581
586
|
const driver = yield createDateInputDriver("dateInput");
|
|
582
587
|
// Create a scenario where the complete date would be invalid
|
|
@@ -665,7 +670,7 @@ fixtures_1.test.describe("API Methods", () => {
|
|
|
665
670
|
yield page.getByTestId("getIsoBtn").click();
|
|
666
671
|
yield fixtures_1.expect.poll(testStateDriver.testState).toBe("2024-05-25");
|
|
667
672
|
}));
|
|
668
|
-
(0, fixtures_1.test)("isoValue() method handles different date formats correctly", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
673
|
+
(0, fixtures_1.test)("isoValue() method handles different date formats correctly", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, }) {
|
|
669
674
|
const { testStateDriver } = yield initTestBed(`
|
|
670
675
|
<Fragment>
|
|
671
676
|
<DateInput id="dateInput" dateFormat="dd/MM/yyyy" initialValue="25/05/2024" />
|
|
@@ -675,7 +680,7 @@ fixtures_1.test.describe("API Methods", () => {
|
|
|
675
680
|
yield page.getByTestId("getIsoBtn").click();
|
|
676
681
|
yield fixtures_1.expect.poll(testStateDriver.testState).toBe("2024-05-25");
|
|
677
682
|
}));
|
|
678
|
-
(0, fixtures_1.test)("isoValue() method returns null for incomplete date", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, createDateInputDriver }) {
|
|
683
|
+
(0, fixtures_1.test)("isoValue() method returns null for incomplete date", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, createDateInputDriver, }) {
|
|
679
684
|
const { testStateDriver } = yield initTestBed(`
|
|
680
685
|
<Fragment>
|
|
681
686
|
<DateInput id="dateInput" testId="dateInput" />
|
|
@@ -689,7 +694,7 @@ fixtures_1.test.describe("API Methods", () => {
|
|
|
689
694
|
yield page.getByTestId("getIsoBtn").click();
|
|
690
695
|
yield fixtures_1.expect.poll(testStateDriver.testState).toBe(null);
|
|
691
696
|
}));
|
|
692
|
-
(0, fixtures_1.test)("isoValue() method returns null for invalid date", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, createDateInputDriver }) {
|
|
697
|
+
(0, fixtures_1.test)("isoValue() method returns null for invalid date", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, createDateInputDriver, }) {
|
|
693
698
|
const { testStateDriver } = yield initTestBed(`
|
|
694
699
|
<Fragment>
|
|
695
700
|
<DateInput id="dateInput" testId="dateInput" />
|
|
@@ -704,7 +709,7 @@ fixtures_1.test.describe("API Methods", () => {
|
|
|
704
709
|
yield page.getByTestId("getIsoBtn").click();
|
|
705
710
|
yield fixtures_1.expect.poll(testStateDriver.testState).toBe(null);
|
|
706
711
|
}));
|
|
707
|
-
(0, fixtures_1.test)("isoValue() method updates when date is changed programmatically", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
712
|
+
(0, fixtures_1.test)("isoValue() method updates when date is changed programmatically", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, }) {
|
|
708
713
|
const { testStateDriver } = yield initTestBed(`
|
|
709
714
|
<Fragment>
|
|
710
715
|
<DateInput id="dateInput" initialValue="05/25/2024" />
|
|
@@ -811,7 +816,7 @@ fixtures_1.test.describe("Theme Variables", () => {
|
|
|
811
816
|
yield (0, fixtures_1.expect)(driver.monthInput).toBeVisible();
|
|
812
817
|
yield (0, fixtures_1.expect)(driver.yearInput).toBeVisible();
|
|
813
818
|
}));
|
|
814
|
-
(0, fixtures_1.test)("component renders with clearable and theme variables", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver }) {
|
|
819
|
+
(0, fixtures_1.test)("component renders with clearable and theme variables", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createDateInputDriver, }) {
|
|
815
820
|
yield initTestBed(`
|
|
816
821
|
<DateInput
|
|
817
822
|
testId="dateInput"
|
|
@@ -916,3 +921,32 @@ fixtures_1.test.describe("Other Edge Cases", () => {
|
|
|
916
921
|
yield (0, fixtures_1.expect)(driver.monthInput).toBeFocused();
|
|
917
922
|
}));
|
|
918
923
|
});
|
|
924
|
+
// =============================================================================
|
|
925
|
+
// VISUAL STATE TESTS
|
|
926
|
+
// =============================================================================
|
|
927
|
+
(0, fixtures_1.test)("input has correct width in px", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
928
|
+
yield initTestBed(`<DateInput width="200px" testId="test"/>`, {});
|
|
929
|
+
const input = page.getByTestId("test");
|
|
930
|
+
const { width } = yield input.boundingBox();
|
|
931
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
932
|
+
}));
|
|
933
|
+
(0, fixtures_1.test)("input with label has correct width in px", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
934
|
+
yield initTestBed(`<DateInput width="200px" label="test" testId="test"/>`, {});
|
|
935
|
+
const input = page.getByTestId("test");
|
|
936
|
+
const { width } = yield input.boundingBox();
|
|
937
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
938
|
+
}));
|
|
939
|
+
(0, fixtures_1.test)("input has correct width in %", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
940
|
+
yield page.setViewportSize({ width: 400, height: 300 });
|
|
941
|
+
yield initTestBed(`<DateInput width="50%" testId="test"/>`, {});
|
|
942
|
+
const input = page.getByTestId("test");
|
|
943
|
+
const { width } = yield input.boundingBox();
|
|
944
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
945
|
+
}));
|
|
946
|
+
(0, fixtures_1.test)("input with label has correct width in %", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
947
|
+
yield page.setViewportSize({ width: 400, height: 300 });
|
|
948
|
+
yield initTestBed(`<DateInput width="50%" label="test" testId="test"/>`, {});
|
|
949
|
+
const input = page.getByTestId("test");
|
|
950
|
+
const { width } = yield input.boundingBox();
|
|
951
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
952
|
+
}));
|
|
@@ -25,7 +25,6 @@ const PartialInput_1 = require("../Input/PartialInput");
|
|
|
25
25
|
const InputDivider_1 = require("../Input/InputDivider");
|
|
26
26
|
const misc_1 = require("../../components-core/utils/misc");
|
|
27
27
|
const InputAdornment_1 = require("../Input/InputAdornment");
|
|
28
|
-
const ItemWithLabel_1 = require("../FormItem/ItemWithLabel");
|
|
29
28
|
const IconNative_1 = __importDefault(require("../Icon/IconNative"));
|
|
30
29
|
// Component part names
|
|
31
30
|
const PART_DAY = "day";
|
|
@@ -77,7 +76,7 @@ exports.defaultProps = {
|
|
|
77
76
|
emptyCharacter: "-",
|
|
78
77
|
};
|
|
79
78
|
exports.DateInput = (0, react_2.forwardRef)(function DateInputNative(_a, ref) {
|
|
80
|
-
var { id, initialValue, value: controlledValue, enabled = exports.defaultProps.enabled, updateState, style, className, onDidChange, onFocus, onBlur, onInvalidChange, validationStatus = exports.defaultProps.validationStatus, registerComponentApi, mode = exports.defaultProps.mode, dateFormat = exports.defaultProps.dateFormat, showWeekNumber = exports.defaultProps.showWeekNumber, weekStartsOn = exports.defaultProps.weekStartsOn, minValue, maxValue, disabledDates, inline = exports.defaultProps.inline, clearable = exports.defaultProps.clearable, clearIcon, clearToInitialValue = exports.defaultProps.clearToInitialValue, required = exports.defaultProps.required, startText, startIcon, endText, endIcon, gap,
|
|
79
|
+
var { id, initialValue, value: controlledValue, enabled = exports.defaultProps.enabled, updateState, style, className, onDidChange, onFocus, onBlur, onInvalidChange, validationStatus = exports.defaultProps.validationStatus, registerComponentApi, mode = exports.defaultProps.mode, dateFormat = exports.defaultProps.dateFormat, showWeekNumber = exports.defaultProps.showWeekNumber, weekStartsOn = exports.defaultProps.weekStartsOn, minValue, maxValue, disabledDates, inline = exports.defaultProps.inline, clearable = exports.defaultProps.clearable, clearIcon, clearToInitialValue = exports.defaultProps.clearToInitialValue, required = exports.defaultProps.required, startText, startIcon, endText, endIcon, gap, readOnly = exports.defaultProps.readOnly, autoFocus = exports.defaultProps.autoFocus, emptyCharacter = exports.defaultProps.emptyCharacter } = _a, rest = __rest(_a, ["id", "initialValue", "value", "enabled", "updateState", "style", "className", "onDidChange", "onFocus", "onBlur", "onInvalidChange", "validationStatus", "registerComponentApi", "mode", "dateFormat", "showWeekNumber", "weekStartsOn", "minValue", "maxValue", "disabledDates", "inline", "clearable", "clearIcon", "clearToInitialValue", "required", "startText", "startIcon", "endText", "endIcon", "gap", "readOnly", "autoFocus", "emptyCharacter"]);
|
|
81
80
|
const dateInputRef = (0, react_2.useRef)(null);
|
|
82
81
|
// Refs for auto-tabbing between inputs
|
|
83
82
|
const dayInputRef = (0, react_2.useRef)(null);
|
|
@@ -466,6 +465,8 @@ exports.DateInput = (0, react_2.forwardRef)(function DateInputNative(_a, ref) {
|
|
|
466
465
|
const inputRefs = getInputRefs();
|
|
467
466
|
return dateOrder.map((field, index) => {
|
|
468
467
|
const nextRef = index < inputRefs.length - 1 ? inputRefs[index + 1] : undefined;
|
|
468
|
+
// Pass id to the first input field only
|
|
469
|
+
const inputId = index === 0 ? id : undefined;
|
|
469
470
|
const getSeparator = () => {
|
|
470
471
|
if (index === dateOrder.length - 1)
|
|
471
472
|
return null;
|
|
@@ -478,31 +479,26 @@ exports.DateInput = (0, react_2.forwardRef)(function DateInputNative(_a, ref) {
|
|
|
478
479
|
};
|
|
479
480
|
switch (field) {
|
|
480
481
|
case "day":
|
|
481
|
-
return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(DayInput, { autoFocus: autoFocus && index === 0, disabled: !enabled, inputRef: dayInputRef, nextInputRef: nextRef, minValue: minValue, maxValue: maxValue, onChange: handleDayChange, onBlur: handleDayBlur, onKeyDown: handleArrowKeys, readOnly: readOnly, required: required, value: day, isInvalid: isDayCurrentlyInvalid, month: month, year: year, emptyCharacter: processedEmptyCharacter }), getSeparator() && (0, jsx_runtime_1.jsx)(InputDivider_1.InputDivider, { separator: getSeparator() })] }, "day"));
|
|
482
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(DayInput, { id: inputId, autoFocus: autoFocus && index === 0, disabled: !enabled, inputRef: dayInputRef, nextInputRef: nextRef, minValue: minValue, maxValue: maxValue, onChange: handleDayChange, onBlur: handleDayBlur, onKeyDown: handleArrowKeys, readOnly: readOnly, required: required, value: day, isInvalid: isDayCurrentlyInvalid, month: month, year: year, emptyCharacter: processedEmptyCharacter }), getSeparator() && (0, jsx_runtime_1.jsx)(InputDivider_1.InputDivider, { separator: getSeparator() })] }, "day"));
|
|
482
483
|
case "month":
|
|
483
|
-
return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(MonthInput, { autoFocus: autoFocus && index === 0, disabled: !enabled, inputRef: monthInputRef, nextInputRef: nextRef, minValue: minValue, maxValue: maxValue, onChange: handleMonthChange, onBlur: handleMonthBlur, onKeyDown: handleArrowKeys, readOnly: readOnly, required: required, value: month, isInvalid: isMonthCurrentlyInvalid, emptyCharacter: processedEmptyCharacter }), getSeparator() && (0, jsx_runtime_1.jsx)(InputDivider_1.InputDivider, { separator: getSeparator() })] }, "month"));
|
|
484
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(MonthInput, { id: inputId, autoFocus: autoFocus && index === 0, disabled: !enabled, inputRef: monthInputRef, nextInputRef: nextRef, minValue: minValue, maxValue: maxValue, onChange: handleMonthChange, onBlur: handleMonthBlur, onKeyDown: handleArrowKeys, readOnly: readOnly, required: required, value: month, isInvalid: isMonthCurrentlyInvalid, emptyCharacter: processedEmptyCharacter }), getSeparator() && (0, jsx_runtime_1.jsx)(InputDivider_1.InputDivider, { separator: getSeparator() })] }, "month"));
|
|
484
485
|
case "year":
|
|
485
|
-
return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(YearInput, { autoFocus: autoFocus && index === 0, disabled: !enabled, inputRef: yearInputRef, nextInputRef: nextRef, minValue: minValue, maxValue: maxValue, onChange: handleYearChange, onBlur: handleYearBlur, onKeyDown: handleArrowKeys, readOnly: readOnly, required: required, value: year, isInvalid: isYearCurrentlyInvalid, dateFormat: dateFormat, emptyCharacter: processedEmptyCharacter }), getSeparator() && (0, jsx_runtime_1.jsx)(InputDivider_1.InputDivider, { separator: getSeparator() })] }, "year"));
|
|
486
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(YearInput, { id: inputId, autoFocus: autoFocus && index === 0, disabled: !enabled, inputRef: yearInputRef, nextInputRef: nextRef, minValue: minValue, maxValue: maxValue, onChange: handleYearChange, onBlur: handleYearBlur, onKeyDown: handleArrowKeys, readOnly: readOnly, required: required, value: year, isInvalid: isYearCurrentlyInvalid, dateFormat: dateFormat, emptyCharacter: processedEmptyCharacter }), getSeparator() && (0, jsx_runtime_1.jsx)(InputDivider_1.InputDivider, { separator: getSeparator() })] }, "year"));
|
|
486
487
|
default:
|
|
487
488
|
return null;
|
|
488
489
|
}
|
|
489
490
|
});
|
|
490
491
|
};
|
|
491
|
-
|
|
492
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ ref: dateInputRef, className: (0, classnames_1.default)(DateInput_module_scss_1.default.dateInputWrapper, {
|
|
492
493
|
[DateInput_module_scss_1.default.error]: validationStatus === "error",
|
|
493
494
|
[DateInput_module_scss_1.default.warning]: validationStatus === "warning",
|
|
494
495
|
[DateInput_module_scss_1.default.valid]: validationStatus === "valid",
|
|
495
496
|
[DateInput_module_scss_1.default.disabled]: !enabled,
|
|
496
497
|
[DateInput_module_scss_1.default.readOnly]: readOnly,
|
|
497
498
|
}, className), style: Object.assign(Object.assign({}, style), { gap }), onFocusCapture: handleComponentFocus, onBlur: handleComponentBlur, "data-validation-status": validationStatus }, rest, { children: [startAdornment, (0, jsx_runtime_1.jsxs)("div", { className: DateInput_module_scss_1.default.wrapper, children: [(0, jsx_runtime_1.jsx)("div", { className: DateInput_module_scss_1.default.inputGroup, children: createDateInputs() }), clearable && ((0, jsx_runtime_1.jsx)("button", { "data-part-id": PART_CLEAR_BUTTON, className: (0, classnames_1.default)(DateInput_module_scss_1.default.clearButton, DateInput_module_scss_1.default.button), disabled: !enabled, onClick: clear, onFocus: stopPropagation, type: "button", children: clearIconElement }))] }), endAdornment] })));
|
|
498
|
-
// Wrap with label if needed
|
|
499
|
-
if (label) {
|
|
500
|
-
return ((0, jsx_runtime_1.jsx)(ItemWithLabel_1.ItemWithLabel, { label: label, labelPosition: labelPosition, labelWidth: labelWidth, labelBreak: labelBreak, required: required, children: dateInputComponent }));
|
|
501
|
-
}
|
|
502
|
-
return dateInputComponent;
|
|
503
499
|
});
|
|
504
500
|
// Input component
|
|
505
|
-
function Input({ ariaLabel, autoFocus, className, disabled, inputRef, max, min, name, nextInputRef, // For auto-tabbing to next input
|
|
501
|
+
function Input({ id, ariaLabel, autoFocus, className, disabled, inputRef, max, min, name, nextInputRef, // For auto-tabbing to next input
|
|
506
502
|
onChange, onBlur, onKeyDown, onKeyUp, placeholder, readOnly, required, step, value, maxLength = 2, isInvalid = false, // To prevent auto-tabbing when value is invalid
|
|
507
503
|
validateFn, // Function to validate the current input value
|
|
508
504
|
onBeep, // Function to handle beep sound and event
|
|
@@ -534,7 +530,7 @@ onBeep, // Function to handle beep sound and event
|
|
|
534
530
|
}
|
|
535
531
|
}
|
|
536
532
|
}, [onChange, nextInputRef, maxLength, validateFn, onBeep]);
|
|
537
|
-
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)("input", { "aria-label": ariaLabel, autoComplete: "off",
|
|
533
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)("input", { id: id, "aria-label": ariaLabel, autoComplete: "off",
|
|
538
534
|
// biome-ignore lint/a11y/noAutofocus: This is up to developers' decision
|
|
539
535
|
autoFocus: autoFocus, className: (0, classnames_1.default)(DateInput_module_scss_1.default.input, className), "data-input": "true", disabled: disabled, inputMode: "numeric", max: max, maxLength: maxLength, min: min, name: name, onChange: handleInputChange, onBlur: onBlur, onFocus: onFocus, onKeyDown: onKeyDown, onKeyUp: onKeyUp, placeholder: placeholder || "--", readOnly: readOnly,
|
|
540
536
|
// Assertion is needed for React 18 compatibility
|
|
@@ -553,7 +549,7 @@ function DayInput(_a) {
|
|
|
553
549
|
}
|
|
554
550
|
return 31; // Default to 31 if month/year not available
|
|
555
551
|
}, [month, year]);
|
|
556
|
-
return ((0, jsx_runtime_1.jsx)(PartialInput_1.PartialInput, { "data-part-id": PART_DAY, value: value, emptyCharacter: emptyCharacter, placeholderLength: 2, max: Math.min(maxDay, 31), min: 1, maxLength: 2, validateFn: (val) => isDayInvalid(val, month, year), onBeep: onBeep, onChange: otherProps.onChange, onBlur: (direction, event) => {
|
|
552
|
+
return ((0, jsx_runtime_1.jsx)(PartialInput_1.PartialInput, { "data-part-id": PART_DAY, id: otherProps.id, value: value, emptyCharacter: emptyCharacter, placeholderLength: 2, max: Math.min(maxDay, 31), min: 1, maxLength: 2, validateFn: (val) => isDayInvalid(val, month, year), onBeep: onBeep, onChange: otherProps.onChange, onBlur: (direction, event) => {
|
|
557
553
|
// PartialInput provides direction, but current onBlur expects just event
|
|
558
554
|
if (otherProps.onBlur) {
|
|
559
555
|
// Provide both direction and event to match the expected signature
|
|
@@ -563,7 +559,7 @@ function DayInput(_a) {
|
|
|
563
559
|
}
|
|
564
560
|
function MonthInput(_a) {
|
|
565
561
|
var { minValue, maxValue, value, isInvalid = false, onBeep, emptyCharacter = "-" } = _a, otherProps = __rest(_a, ["minValue", "maxValue", "value", "isInvalid", "onBeep", "emptyCharacter"]);
|
|
566
|
-
return ((0, jsx_runtime_1.jsx)(PartialInput_1.PartialInput, { "data-part-id": PART_MONTH, max: 12, min: 1, name: "month", value: value, invalidClassName: DateInput_module_scss_1.default.invalid, isInvalid: isInvalid, validateFn: isMonthInvalid, onBeep: onBeep, onChange: otherProps.onChange, emptyCharacter: emptyCharacter, placeholderLength: 2, className: (0, classnames_1.default)(DateInput_module_scss_1.default.input, DateInput_module_scss_1.default.month), maxLength: 2, disabled: otherProps.disabled, required: otherProps.required, onBlur: (direction, event) => {
|
|
562
|
+
return ((0, jsx_runtime_1.jsx)(PartialInput_1.PartialInput, { "data-part-id": PART_MONTH, id: otherProps.id, max: 12, min: 1, name: "month", value: value, invalidClassName: DateInput_module_scss_1.default.invalid, isInvalid: isInvalid, validateFn: isMonthInvalid, onBeep: onBeep, onChange: otherProps.onChange, emptyCharacter: emptyCharacter, placeholderLength: 2, className: (0, classnames_1.default)(DateInput_module_scss_1.default.input, DateInput_module_scss_1.default.month), maxLength: 2, disabled: otherProps.disabled, required: otherProps.required, onBlur: (direction, event) => {
|
|
567
563
|
// PartialInput provides direction, but current onBlur expects just event
|
|
568
564
|
if (otherProps.onBlur) {
|
|
569
565
|
// Provide both direction and event to match the expected signature
|
|
@@ -579,7 +575,7 @@ function YearInput(_a) {
|
|
|
579
575
|
const min = 1900;
|
|
580
576
|
const max = currentYear + 100;
|
|
581
577
|
const { className: originalClassName } = otherProps, restProps = __rest(otherProps, ["className"]);
|
|
582
|
-
return ((0, jsx_runtime_1.jsx)(PartialInput_1.PartialInput, Object.assign({ "data-part-id": PART_YEAR, max: max, min: min, name: "year", value: value, isInvalid: isInvalid, invalidClassName: DateInput_module_scss_1.default.invalid, validateFn: isYearInvalid, onBeep: onBeep, emptyCharacter: emptyCharacter, placeholderLength: 4, className: (0, classnames_1.default)(DateInput_module_scss_1.default.input, DateInput_module_scss_1.default.year, originalClassName), maxLength: maxLength, onBlur: (direction, event) => {
|
|
578
|
+
return ((0, jsx_runtime_1.jsx)(PartialInput_1.PartialInput, Object.assign({ "data-part-id": PART_YEAR, id: otherProps.id, max: max, min: min, name: "year", value: value, isInvalid: isInvalid, invalidClassName: DateInput_module_scss_1.default.invalid, validateFn: isYearInvalid, onBeep: onBeep, emptyCharacter: emptyCharacter, placeholderLength: 4, className: (0, classnames_1.default)(DateInput_module_scss_1.default.input, DateInput_module_scss_1.default.year, originalClassName), maxLength: maxLength, onBlur: (direction, event) => {
|
|
583
579
|
// PartialInput provides direction, but current onBlur expects just event
|
|
584
580
|
if (otherProps.onBlur) {
|
|
585
581
|
// Provide both direction and event to match the expected signature
|
|
@@ -24,10 +24,6 @@ exports.DatePickerMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
24
24
|
readOnly: (0, metadata_helpers_1.dReadonly)(),
|
|
25
25
|
enabled: (0, metadata_helpers_1.dEnabled)(DatePickerNative_1.defaultProps.enabled),
|
|
26
26
|
validationStatus: (0, metadata_helpers_1.dValidationStatus)(DatePickerNative_1.defaultProps.validationStatus),
|
|
27
|
-
label: (0, metadata_helpers_1.dLabel)(),
|
|
28
|
-
labelPosition: (0, metadata_helpers_1.dLabelPosition)("top"),
|
|
29
|
-
labelWidth: (0, metadata_helpers_1.dLabelWidth)(COMP),
|
|
30
|
-
labelBreak: (0, metadata_helpers_1.dLabelBreak)(COMP),
|
|
31
27
|
mode: {
|
|
32
28
|
description: "The mode of the datepicker (single or range)",
|
|
33
29
|
valueType: "string",
|
|
@@ -80,22 +76,27 @@ exports.DatePickerMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
80
76
|
},
|
|
81
77
|
],
|
|
82
78
|
},
|
|
83
|
-
|
|
84
|
-
description: "The
|
|
85
|
-
"allows any dates in the past."
|
|
79
|
+
startDate: {
|
|
80
|
+
description: "The earliest month to start the month navigation from (inclusive). " +
|
|
81
|
+
"If not defined, the component allows any dates in the past. " +
|
|
82
|
+
"Accepts the same date format as the `initialValue`." +
|
|
83
|
+
"Example: '2023-01-01' ensures the first month to select a date from is January 2023.",
|
|
86
84
|
valueType: "string",
|
|
87
85
|
},
|
|
88
|
-
|
|
89
|
-
description: "The
|
|
90
|
-
"any future dates."
|
|
86
|
+
endDate: {
|
|
87
|
+
description: "The latest month to start the month navigation from (inclusive). " +
|
|
88
|
+
"If not defined, the component allows any future dates. " +
|
|
89
|
+
"Accepts the same date format as the `initialValue`." +
|
|
90
|
+
"Example: '2023-12-31' ensures the last month to select a date from is December 2023.",
|
|
91
91
|
valueType: "string",
|
|
92
92
|
},
|
|
93
93
|
disabledDates: {
|
|
94
|
-
description: "An optional array of dates that are disabled",
|
|
94
|
+
description: "An optional array of dates that are to be disabled.",
|
|
95
95
|
valueType: "any",
|
|
96
96
|
},
|
|
97
97
|
inline: {
|
|
98
|
-
description: "
|
|
98
|
+
description: "If set to true, the calendar is always visible and its panel is rendered as part of the layout." +
|
|
99
|
+
" If false, the calendar is shown in a popup when the input is focused or clicked.",
|
|
99
100
|
valueType: "boolean",
|
|
100
101
|
defaultValue: DatePickerNative_1.defaultProps.inline,
|
|
101
102
|
},
|
|
@@ -141,5 +142,5 @@ exports.DatePickerMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
141
142
|
});
|
|
142
143
|
exports.datePickerComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.DatePickerMd, ({ node, state, updateState, extractValue, className, lookupEventHandler, registerComponentApi, }) => {
|
|
143
144
|
var _a;
|
|
144
|
-
return ((0, jsx_runtime_1.jsx)(DatePickerNative_1.DatePicker, {
|
|
145
|
+
return ((0, jsx_runtime_1.jsx)(DatePickerNative_1.DatePicker, { className: className, mode: extractValue((_a = node.props) === null || _a === void 0 ? void 0 : _a.mode), value: state === null || state === void 0 ? void 0 : state.value, initialValue: extractValue(node.props.initialValue), enabled: extractValue.asOptionalBoolean(node.props.enabled), placeholder: extractValue.asOptionalString(node.props.placeholder), validationStatus: extractValue(node.props.validationStatus), updateState: updateState, onDidChange: lookupEventHandler("didChange"), onFocus: lookupEventHandler("gotFocus"), onBlur: lookupEventHandler("lostFocus"), registerComponentApi: registerComponentApi, dateFormat: extractValue(node.props.dateFormat), showWeekNumber: extractValue.asOptionalBoolean(node.props.showWeekNumber), weekStartsOn: extractValue(node.props.weekStartsOn), startDate: extractValue(node.props.startDate), endDate: extractValue(node.props.endDate), disabledDates: extractValue(node.props.disabledDates), inline: extractValue.asOptionalBoolean(node.props.inline), startText: extractValue.asOptionalString(node.props.startText), startIcon: extractValue.asOptionalString(node.props.startIcon), endText: extractValue.asOptionalString(node.props.endText), endIcon: extractValue.asOptionalString(node.props.endIcon), readOnly: extractValue.asOptionalBoolean(node.props.readOnly), autoFocus: extractValue.asOptionalBoolean(node.props.autoFocus) }));
|
|
145
146
|
});
|
|
@@ -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
|
const date_fns_1 = require("date-fns");
|
|
15
14
|
// =============================================================================
|
|
@@ -179,6 +178,13 @@ const date_fns_1 = require("date-fns");
|
|
|
179
178
|
yield page.getByTestId("datePicker").focus();
|
|
180
179
|
yield fixtures_1.expect.poll(testStateDriver.testState).toBe("focused");
|
|
181
180
|
}));
|
|
181
|
+
(0, fixtures_1.test)("component fires proper focus event on label focus", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
182
|
+
const { testStateDriver } = yield initTestBed(`
|
|
183
|
+
<DatePicker testId="datePicker" onGotFocus="testState = 'focused'" label="test" />
|
|
184
|
+
`);
|
|
185
|
+
yield page.getByText("test").click();
|
|
186
|
+
yield fixtures_1.expect.poll(testStateDriver.testState).toBe("focused");
|
|
187
|
+
}));
|
|
182
188
|
(0, fixtures_1.test)("component fires proper blur event on lostFocus", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
183
189
|
const { testStateDriver } = yield initTestBed(`
|
|
184
190
|
<DatePicker testId="datePicker" onLostFocus="testState = 'blurred'" />
|
|
@@ -278,40 +284,37 @@ const date_fns_1 = require("date-fns");
|
|
|
278
284
|
// The date should not change
|
|
279
285
|
yield (0, fixtures_1.expect)(page.getByTestId("datePicker")).toHaveText(initialDate);
|
|
280
286
|
}));
|
|
281
|
-
fixtures_1.test
|
|
287
|
+
(0, fixtures_1.test)("component handles startDate restrictions", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
282
288
|
yield initTestBed(`<DatePicker
|
|
283
289
|
testId="datePicker"
|
|
284
290
|
mode="range"
|
|
285
|
-
|
|
291
|
+
startDate="05/01/2024"
|
|
286
292
|
dateFormat="MM/dd/yyyy"
|
|
287
293
|
initialValue="{{ from: '05/26/2024', to: '05/27/2024' }}"
|
|
288
294
|
/>`);
|
|
289
295
|
yield page.getByTestId("datePicker").click();
|
|
290
|
-
yield page.getByRole(
|
|
291
|
-
yield (0, fixtures_1.expect)(page.getByRole("grid", { name: "May" }).getByLabel("May 24th")).toBeDisabled();
|
|
296
|
+
yield (0, fixtures_1.expect)(page.getByRole('button', { name: 'Go to the Previous Month' })).toBeDisabled();
|
|
292
297
|
}));
|
|
293
|
-
fixtures_1.test
|
|
298
|
+
(0, fixtures_1.test)("component handles endDate restrictions", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
294
299
|
yield initTestBed(`<DatePicker
|
|
295
300
|
testId="datePicker"
|
|
296
301
|
mode="range"
|
|
297
|
-
|
|
302
|
+
endDate="06/01/2024"
|
|
298
303
|
initialValue="{{ from: '05/26/2024', to: '05/27/2024' }}"
|
|
299
304
|
dateFormat="MM/dd/yyyy"
|
|
300
305
|
/>`);
|
|
301
306
|
yield page.getByTestId("datePicker").click();
|
|
302
|
-
yield page.getByRole(
|
|
303
|
-
yield (0, fixtures_1.expect)(page.getByRole("grid", { name: "May" }).getByLabel("May 24th")).toBeDisabled();
|
|
307
|
+
yield (0, fixtures_1.expect)(page.getByRole('button', { name: 'Go to the Next Month' })).toBeDisabled();
|
|
304
308
|
}));
|
|
305
|
-
fixtures_1.test
|
|
309
|
+
(0, fixtures_1.test)("component handles disabledDates correctly", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
310
|
+
const testDay = 15;
|
|
306
311
|
const today = new Date();
|
|
307
|
-
const testDayFormatted = (0, date_fns_1.format)(new Date(today.getFullYear(), today.getMonth(),
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
yield page.
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
const testDayCell = page.locator(".rdp-day").filter({ hasText: testDay }).first();
|
|
314
|
-
yield (0, fixtures_1.expect)(testDayCell).toHaveClass(/disabled/);
|
|
312
|
+
const testDayFormatted = (0, date_fns_1.format)(new Date(today.getFullYear(), today.getMonth(), testDay), "MM/dd/yyyy");
|
|
313
|
+
const testMonthName = (0, date_fns_1.format)(today, "LLLL");
|
|
314
|
+
yield initTestBed(`<DatePicker testId="datePicker" disabledDates="{['${testDayFormatted}']}" />`, {});
|
|
315
|
+
yield page.getByTestId("datePicker").click();
|
|
316
|
+
const testDayCell = page.getByRole("grid", { name: testMonthName }).getByLabel(testDay.toString());
|
|
317
|
+
yield (0, fixtures_1.expect)(testDayCell).toBeDisabled();
|
|
315
318
|
}));
|
|
316
319
|
// =============================================================================
|
|
317
320
|
// INTEGRATION TESTS
|
|
@@ -360,3 +363,32 @@ fixtures_1.test.fixme("component handles disabledDates correctly", (_a) => __awa
|
|
|
360
363
|
// Check that the form was submitted
|
|
361
364
|
yield fixtures_1.expect.poll(testStateDriver.testState).toEqual("05/25/2024");
|
|
362
365
|
}));
|
|
366
|
+
// =============================================================================
|
|
367
|
+
// VISUAL STATE TESTS
|
|
368
|
+
// =============================================================================
|
|
369
|
+
(0, fixtures_1.test)("input has correct width in px", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
370
|
+
yield initTestBed(`<DatePicker width="200px" testId="test"/>`, {});
|
|
371
|
+
const input = page.getByTestId("test");
|
|
372
|
+
const { width } = yield input.boundingBox();
|
|
373
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
374
|
+
}));
|
|
375
|
+
(0, fixtures_1.test)("input with label has correct width in px", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
376
|
+
yield initTestBed(`<DatePicker width="200px" label="test" testId="test"/>`, {});
|
|
377
|
+
const input = page.getByTestId("test");
|
|
378
|
+
const { width } = yield input.boundingBox();
|
|
379
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
380
|
+
}));
|
|
381
|
+
(0, fixtures_1.test)("input has correct width in %", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
382
|
+
yield page.setViewportSize({ width: 400, height: 300 });
|
|
383
|
+
yield initTestBed(`<DatePicker width="50%" testId="test"/>`, {});
|
|
384
|
+
const input = page.getByTestId("test");
|
|
385
|
+
const { width } = yield input.boundingBox();
|
|
386
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
387
|
+
}));
|
|
388
|
+
(0, fixtures_1.test)("input with label has correct width in %", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
389
|
+
yield page.setViewportSize({ width: 400, height: 300 });
|
|
390
|
+
yield initTestBed(`<DatePicker width="50%" label="test" testId="test"/>`, {});
|
|
391
|
+
const input = page.getByTestId("test");
|
|
392
|
+
const { width } = yield input.boundingBox();
|
|
393
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
394
|
+
}));
|