xmlui 0.10.15 → 0.10.18
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-axjeT2uJ.mjs → index-Cy6Emsex.mjs} +3452 -1954
- package/dist/lib/index.css +1 -1
- package/dist/lib/{initMock-BoTWMs19.mjs → initMock-B-rmnC-t.mjs} +1 -1
- package/dist/lib/xmlui-parser.d.ts +1 -1
- package/dist/lib/xmlui.d.ts +4 -6
- package/dist/lib/xmlui.mjs +1 -1
- package/dist/metadata/{collectedComponentMetadata-CQywuPDB.mjs → collectedComponentMetadata-CB63ngkU.mjs} +3845 -2357
- package/dist/metadata/{initMock-Bi5kF5Af.mjs → initMock-D0wDKF_I.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/Animation/AnimationNative.js +5 -1
- package/dist/scripts/src/components/AutoComplete/AutoComplete.js +1 -5
- package/dist/scripts/src/components/AutoComplete/AutoComplete.spec.js +29 -0
- package/dist/scripts/src/components/AutoComplete/AutoCompleteContext.js +2 -0
- package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +262 -62
- package/dist/scripts/src/components/Checkbox/Checkbox.js +1 -5
- 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 +29 -0
- package/dist/scripts/src/components/DateInput/DateInputNative.js +12 -16
- package/dist/scripts/src/components/DatePicker/DatePicker.js +1 -5
- package/dist/scripts/src/components/DatePicker/DatePicker.spec.js +29 -0
- package/dist/scripts/src/components/DatePicker/DatePickerNative.js +12 -13
- package/dist/scripts/src/components/FileInput/FileInput.js +1 -5
- package/dist/scripts/src/components/FileInput/FileInput.spec.js +29 -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 +41 -27
- 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/IconNative.js +18 -15
- package/dist/scripts/src/components/Input/PartialInput.js +2 -2
- package/dist/scripts/src/components/NestedApp/AppWithCodeViewNative.js +1 -1
- package/dist/scripts/src/components/NumberBox/NumberBox.js +5 -9
- package/dist/scripts/src/components/NumberBox/NumberBox.spec.js +142 -430
- package/dist/scripts/src/components/NumberBox/NumberBoxNative.js +33 -21
- package/dist/scripts/src/components/Option/Option.js +3 -1
- package/dist/scripts/src/components/RadioGroup/RadioGroup.js +1 -5
- 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/HiddenOption.js +1 -1
- package/dist/scripts/src/components/Select/Select.js +1 -5
- package/dist/scripts/src/components/Select/Select.spec.js +31 -3
- 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 +75 -13
- package/dist/scripts/src/components/Slider/SliderNative.js +33 -24
- package/dist/scripts/src/components/Switch/Switch.js +1 -5
- package/dist/scripts/src/components/TextArea/TextArea.js +1 -5
- package/dist/scripts/src/components/TextArea/TextArea.spec.js +29 -0
- package/dist/scripts/src/components/TextArea/TextAreaNative.js +8 -29
- package/dist/scripts/src/components/TextBox/TextBox.spec.js +38 -7
- package/dist/scripts/src/components/TextBox/TextBoxNative.js +2 -2
- package/dist/scripts/src/components/TimeInput/TimeInput.spec.js +31 -0
- package/dist/scripts/src/components/Timer/Timer.spec.js +66 -96
- package/dist/scripts/src/components/Toggle/Toggle.js +28 -25
- package/dist/scripts/src/components/Tree/Tree-dynamic.spec.js +2894 -0
- package/dist/scripts/src/components/Tree/Tree-icons.spec.js +206 -0
- package/dist/scripts/src/components/Tree/Tree.spec.js +2839 -0
- package/dist/scripts/src/components/Tree/TreeComponent.js +303 -10
- package/dist/scripts/src/components/Tree/TreeNative.js +1090 -23
- package/dist/scripts/src/components/Tree/testData.js +296 -0
- package/dist/scripts/src/components-core/behaviors/Behavior.js +2 -0
- package/dist/scripts/src/components-core/behaviors/CoreBehaviors.js +8 -4
- package/dist/scripts/src/components-core/rendering/AppRoot.js +1 -2
- package/dist/scripts/src/components-core/rendering/ComponentAdapter.js +13 -15
- package/dist/scripts/src/components-core/utils/treeUtils.js +190 -12
- package/dist/scripts/src/testing/ComponentDrivers.js +79 -7
- package/dist/scripts/src/testing/drivers/NumberBoxDriver.js +2 -2
- package/dist/scripts/src/testing/drivers/TreeDriver.js +13 -0
- package/dist/scripts/src/testing/fixtures.js +7 -2
- package/dist/standalone/xmlui-standalone.es.d.ts +4 -6
- package/dist/standalone/xmlui-standalone.umd.js +36 -36
- package/package.json +1 -1
- package/dist/scripts/src/components/Animation/Animation.js +0 -50
- package/dist/scripts/src/components-core/behaviors/BehaviorContext.js +0 -54
- package/dist/scripts/src/testing/drivers/SliderDriver.js +0 -20
|
@@ -281,3 +281,32 @@ const fixtures_1 = require("../../testing/fixtures");
|
|
|
281
281
|
// Verify the focus event fired
|
|
282
282
|
yield fixtures_1.expect.poll(testStateDriver.testState).toEqual("focused");
|
|
283
283
|
}));
|
|
284
|
+
// =============================================================================
|
|
285
|
+
// VISUAL STATE TESTS
|
|
286
|
+
// =============================================================================
|
|
287
|
+
(0, fixtures_1.test)("input has correct width in px", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
288
|
+
yield initTestBed(`<ColorPicker width="200px" testId="test"/>`, {});
|
|
289
|
+
const input = page.getByTestId("test");
|
|
290
|
+
const { width } = yield input.boundingBox();
|
|
291
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
292
|
+
}));
|
|
293
|
+
(0, fixtures_1.test)("input with label has correct width in px", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
294
|
+
yield initTestBed(`<ColorPicker width="200px" label="test" testId="test"/>`, {});
|
|
295
|
+
const input = page.getByTestId("test");
|
|
296
|
+
const { width } = yield input.boundingBox();
|
|
297
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
298
|
+
}));
|
|
299
|
+
(0, fixtures_1.test)("input has correct width in %", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
300
|
+
yield page.setViewportSize({ width: 400, height: 300 });
|
|
301
|
+
yield initTestBed(`<ColorPicker width="50%" testId="test"/>`, {});
|
|
302
|
+
const input = page.getByTestId("test");
|
|
303
|
+
const { width } = yield input.boundingBox();
|
|
304
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
305
|
+
}));
|
|
306
|
+
(0, fixtures_1.test)("input with label has correct width in %", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
307
|
+
yield page.setViewportSize({ width: 400, height: 300 });
|
|
308
|
+
yield initTestBed(`<ColorPicker width="50%" label="test" testId="test"/>`, {});
|
|
309
|
+
const input = page.getByTestId("test");
|
|
310
|
+
const { width } = yield input.boundingBox();
|
|
311
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
312
|
+
}));
|
|
@@ -18,11 +18,12 @@ exports.ColorPicker = exports.defaultProps = void 0;
|
|
|
18
18
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
19
|
const react_1 = require("react");
|
|
20
20
|
const react_2 = require("react");
|
|
21
|
-
const ItemWithLabel_1 = require("../FormItem/ItemWithLabel");
|
|
22
21
|
const constants_1 = require("../../components-core/constants");
|
|
23
22
|
const misc_1 = require("../../components-core/utils/misc");
|
|
24
23
|
const ColorPicker_module_scss_1 = __importDefault(require("./ColorPicker.module.scss"));
|
|
25
24
|
const classnames_1 = __importDefault(require("classnames"));
|
|
25
|
+
const react_compose_refs_1 = require("@radix-ui/react-compose-refs");
|
|
26
|
+
const parts_1 = require("../../components-core/parts");
|
|
26
27
|
exports.defaultProps = {
|
|
27
28
|
initialValue: "#000000",
|
|
28
29
|
value: "#000000",
|
|
@@ -30,9 +31,10 @@ exports.defaultProps = {
|
|
|
30
31
|
validationStatus: "none",
|
|
31
32
|
};
|
|
32
33
|
exports.ColorPicker = (0, react_2.forwardRef)((_a, forwardedRef) => {
|
|
33
|
-
var { style, className, updateState, onDidChange = constants_1.noop, onFocus = constants_1.noop, onBlur = constants_1.noop, registerComponentApi, enabled = exports.defaultProps.enabled, readOnly, value = exports.defaultProps.value, autoFocus, tabIndex = 0,
|
|
34
|
-
const inputRef = (0, react_2.useRef)(null);
|
|
34
|
+
var { id, style, className, updateState, onDidChange = constants_1.noop, onFocus = constants_1.noop, onBlur = constants_1.noop, registerComponentApi, enabled = exports.defaultProps.enabled, readOnly, value = exports.defaultProps.value, autoFocus, tabIndex = 0, required, validationStatus = exports.defaultProps.validationStatus, initialValue = exports.defaultProps.initialValue } = _a, rest = __rest(_a, ["id", "style", "className", "updateState", "onDidChange", "onFocus", "onBlur", "registerComponentApi", "enabled", "readOnly", "value", "autoFocus", "tabIndex", "required", "validationStatus", "initialValue"]);
|
|
35
35
|
const [isPending, startTransition] = (0, react_1.useTransition)();
|
|
36
|
+
const inputRef = (0, react_2.useRef)(null);
|
|
37
|
+
const composedRef = forwardedRef ? (0, react_compose_refs_1.composeRefs)(forwardedRef, inputRef) : inputRef;
|
|
36
38
|
const updateValue = (0, react_2.useCallback)((value) => {
|
|
37
39
|
updateState({ value });
|
|
38
40
|
onDidChange(value);
|
|
@@ -73,11 +75,12 @@ exports.ColorPicker = (0, react_2.forwardRef)((_a, forwardedRef) => {
|
|
|
73
75
|
setValue,
|
|
74
76
|
});
|
|
75
77
|
}, [focus, registerComponentApi, setValue]);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
{ /* Produces a 7 character RGB color output in hex as a string type */ }
|
|
79
|
+
return ((0, jsx_runtime_1.jsx)("input", Object.assign({}, rest, { id: id, className: (0, classnames_1.default)(className, ColorPicker_module_scss_1.default.colorInput, {
|
|
80
|
+
[ColorPicker_module_scss_1.default.disabled]: !enabled,
|
|
81
|
+
[ColorPicker_module_scss_1.default.error]: validationStatus === "error",
|
|
82
|
+
[ColorPicker_module_scss_1.default.warning]: validationStatus === "warning",
|
|
83
|
+
[ColorPicker_module_scss_1.default.valid]: validationStatus === "valid",
|
|
84
|
+
}), "data-part-id": parts_1.PART_INPUT, style: style, disabled: !enabled, onFocus: handleOnFocus, onChange: onInputChange, readOnly: readOnly, autoFocus: autoFocus, tabIndex: tabIndex, onBlur: handleOnBlur, required: required, type: "color", inputMode: "text", ref: composedRef, value: value })));
|
|
82
85
|
});
|
|
83
86
|
exports.ColorPicker.displayName = "ColorPicker";
|
|
@@ -53,6 +53,7 @@ const Footer_1 = require("./Footer/Footer");
|
|
|
53
53
|
const NavGroup_1 = require("./NavGroup/NavGroup");
|
|
54
54
|
const Logo_1 = require("./Logo/Logo");
|
|
55
55
|
const RadioGroup_1 = require("./RadioGroup/RadioGroup");
|
|
56
|
+
const RadioItem_1 = require("./RadioGroup/RadioItem");
|
|
56
57
|
const Slot_1 = require("./Slot/Slot");
|
|
57
58
|
const FileInput_1 = require("./FileInput/FileInput");
|
|
58
59
|
const Spinner_1 = require("./Spinner/Spinner");
|
|
@@ -412,6 +413,7 @@ class ComponentRegistry {
|
|
|
412
413
|
this.registerCoreComponent(NumberBox_1.numberBoxComponentRenderer);
|
|
413
414
|
this.registerCoreComponent(HoverCard_1.hoverCardComponentRenderer);
|
|
414
415
|
this.registerCoreComponent(RadioGroup_1.radioGroupRenderer);
|
|
416
|
+
this.registerCoreComponent(RadioItem_1.radioItemComponentRenderer);
|
|
415
417
|
this.registerCoreComponent(FileInput_1.fileInputRenderer);
|
|
416
418
|
this.registerCoreComponent(Spinner_1.spinnerComponentRenderer);
|
|
417
419
|
this.registerCoreComponent(Select_1.selectComponentRenderer);
|
|
@@ -36,10 +36,6 @@ exports.DateInputMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
36
36
|
readOnly: (0, metadata_helpers_1.dReadonly)(),
|
|
37
37
|
enabled: (0, metadata_helpers_1.dEnabled)(DateInputNative_1.defaultProps.enabled),
|
|
38
38
|
validationStatus: (0, metadata_helpers_1.dValidationStatus)(DateInputNative_1.defaultProps.validationStatus),
|
|
39
|
-
label: (0, metadata_helpers_1.dLabel)(),
|
|
40
|
-
labelPosition: (0, metadata_helpers_1.dLabelPosition)("top"),
|
|
41
|
-
labelWidth: (0, metadata_helpers_1.dLabelWidth)(COMP),
|
|
42
|
-
labelBreak: (0, metadata_helpers_1.dLabelBreak)(COMP),
|
|
43
39
|
mode: {
|
|
44
40
|
description: "The mode of the date input (single or range)",
|
|
45
41
|
valueType: "string",
|
|
@@ -197,5 +193,5 @@ exports.DateInputMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
197
193
|
});
|
|
198
194
|
exports.dateInputComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.DateInputMd, ({ node, state, updateState, extractValue, className, lookupEventHandler, registerComponentApi, }) => {
|
|
199
195
|
var _a;
|
|
200
|
-
return ((0, jsx_runtime_1.jsx)(DateInputNative_1.DateInput, { id: node.uid, 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), 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.asOptionalNumber(node.props.weekStartsOn), minValue: extractValue.asOptionalString(node.props.minValue), maxValue: extractValue.asOptionalString(node.props.maxValue), disabledDates: extractValue(node.props.disabledDates), inline: extractValue.asOptionalBoolean(node.props.inline, DateInputNative_1.defaultProps.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),
|
|
196
|
+
return ((0, jsx_runtime_1.jsx)(DateInputNative_1.DateInput, { id: node.uid, 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), 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.asOptionalNumber(node.props.weekStartsOn), minValue: extractValue.asOptionalString(node.props.minValue), maxValue: extractValue.asOptionalString(node.props.maxValue), disabledDates: extractValue(node.props.disabledDates), inline: extractValue.asOptionalBoolean(node.props.inline, DateInputNative_1.defaultProps.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), required: extractValue.asOptionalBoolean(node.props.required), clearable: extractValue.asOptionalBoolean(node.props.clearable, DateInputNative_1.defaultProps.clearable), clearIcon: extractValue.asOptionalString(node.props.clearIcon), clearToInitialValue: extractValue.asOptionalBoolean(node.props.clearToInitialValue, DateInputNative_1.defaultProps.clearToInitialValue), gap: extractValue.asOptionalString(node.props.gap), emptyCharacter: extractValue.asOptionalString(node.props.emptyCharacter) }));
|
|
201
197
|
});
|
|
@@ -916,3 +916,32 @@ fixtures_1.test.describe("Other Edge Cases", () => {
|
|
|
916
916
|
yield (0, fixtures_1.expect)(driver.monthInput).toBeFocused();
|
|
917
917
|
}));
|
|
918
918
|
});
|
|
919
|
+
// =============================================================================
|
|
920
|
+
// VISUAL STATE TESTS
|
|
921
|
+
// =============================================================================
|
|
922
|
+
(0, fixtures_1.test)("input has correct width in px", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
923
|
+
yield initTestBed(`<DateInput width="200px" testId="test"/>`, {});
|
|
924
|
+
const input = page.getByTestId("test");
|
|
925
|
+
const { width } = yield input.boundingBox();
|
|
926
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
927
|
+
}));
|
|
928
|
+
(0, fixtures_1.test)("input with label has correct width in px", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
929
|
+
yield initTestBed(`<DateInput width="200px" label="test" testId="test"/>`, {});
|
|
930
|
+
const input = page.getByTestId("test");
|
|
931
|
+
const { width } = yield input.boundingBox();
|
|
932
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
933
|
+
}));
|
|
934
|
+
(0, fixtures_1.test)("input has correct width in %", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
935
|
+
yield page.setViewportSize({ width: 400, height: 300 });
|
|
936
|
+
yield initTestBed(`<DateInput width="50%" testId="test"/>`, {});
|
|
937
|
+
const input = page.getByTestId("test");
|
|
938
|
+
const { width } = yield input.boundingBox();
|
|
939
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
940
|
+
}));
|
|
941
|
+
(0, fixtures_1.test)("input with label has correct width in %", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
942
|
+
yield page.setViewportSize({ width: 400, height: 300 });
|
|
943
|
+
yield initTestBed(`<DateInput width="50%" label="test" testId="test"/>`, {});
|
|
944
|
+
const input = page.getByTestId("test");
|
|
945
|
+
const { width } = yield input.boundingBox();
|
|
946
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
947
|
+
}));
|
|
@@ -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",
|
|
@@ -141,5 +137,5 @@ exports.DatePickerMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
141
137
|
});
|
|
142
138
|
exports.datePickerComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.DatePickerMd, ({ node, state, updateState, extractValue, className, lookupEventHandler, registerComponentApi, }) => {
|
|
143
139
|
var _a;
|
|
144
|
-
return ((0, jsx_runtime_1.jsx)(DatePickerNative_1.DatePicker, {
|
|
140
|
+
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), minValue: extractValue(node.props.minValue), maxValue: extractValue(node.props.maxValue), 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
141
|
});
|
|
@@ -360,3 +360,32 @@ fixtures_1.test.fixme("component handles disabledDates correctly", (_a) => __awa
|
|
|
360
360
|
// Check that the form was submitted
|
|
361
361
|
yield fixtures_1.expect.poll(testStateDriver.testState).toEqual("05/25/2024");
|
|
362
362
|
}));
|
|
363
|
+
// =============================================================================
|
|
364
|
+
// VISUAL STATE TESTS
|
|
365
|
+
// =============================================================================
|
|
366
|
+
(0, fixtures_1.test)("input has correct width in px", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
367
|
+
yield initTestBed(`<DatePicker width="200px" testId="test"/>`, {});
|
|
368
|
+
const input = page.getByTestId("test");
|
|
369
|
+
const { width } = yield input.boundingBox();
|
|
370
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
371
|
+
}));
|
|
372
|
+
(0, fixtures_1.test)("input with label has correct width in px", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
373
|
+
yield initTestBed(`<DatePicker width="200px" label="test" testId="test"/>`, {});
|
|
374
|
+
const input = page.getByTestId("test");
|
|
375
|
+
const { width } = yield input.boundingBox();
|
|
376
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
377
|
+
}));
|
|
378
|
+
(0, fixtures_1.test)("input has correct width in %", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
379
|
+
yield page.setViewportSize({ width: 400, height: 300 });
|
|
380
|
+
yield initTestBed(`<DatePicker width="50%" testId="test"/>`, {});
|
|
381
|
+
const input = page.getByTestId("test");
|
|
382
|
+
const { width } = yield input.boundingBox();
|
|
383
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
384
|
+
}));
|
|
385
|
+
(0, fixtures_1.test)("input with label has correct width in %", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
386
|
+
yield page.setViewportSize({ width: 400, height: 300 });
|
|
387
|
+
yield initTestBed(`<DatePicker width="50%" label="test" testId="test"/>`, {});
|
|
388
|
+
const input = page.getByTestId("test");
|
|
389
|
+
const { width } = yield input.boundingBox();
|
|
390
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
391
|
+
}));
|
|
@@ -26,9 +26,9 @@ const ThemeContext_1 = require("../../components-core/theming/ThemeContext");
|
|
|
26
26
|
const constants_1 = require("../../components-core/constants");
|
|
27
27
|
const misc_1 = require("../../components-core/utils/misc");
|
|
28
28
|
const InputAdornment_1 = require("../Input/InputAdornment");
|
|
29
|
-
const ItemWithLabel_1 = require("../FormItem/ItemWithLabel");
|
|
30
29
|
const react_popover_1 = require("@radix-ui/react-popover");
|
|
31
30
|
const IconNative_1 = __importDefault(require("../Icon/IconNative"));
|
|
31
|
+
const react_compose_refs_1 = require("@radix-ui/react-compose-refs");
|
|
32
32
|
exports.DatePickerModeValues = ["single", "range"];
|
|
33
33
|
var WeekDays;
|
|
34
34
|
(function (WeekDays) {
|
|
@@ -76,14 +76,14 @@ const Chevron = (_a) => {
|
|
|
76
76
|
return (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevronright", size: "lg" });
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
|
-
exports.DatePicker = (0, react_2.forwardRef)(function DatePicker(_a,
|
|
79
|
+
exports.DatePicker = (0, react_2.forwardRef)(function DatePicker(_a, forwardedRef) {
|
|
80
80
|
var { id, initialValue, value, mode = exports.defaultProps.mode, enabled = exports.defaultProps.enabled, placeholder, updateState = constants_1.noop, validationStatus = exports.defaultProps.validationStatus, onDidChange = constants_1.noop, onFocus = constants_1.noop, onBlur = constants_1.noop, dateFormat = exports.defaultProps.dateFormat, showWeekNumber = exports.defaultProps.showWeekNumber, weekStartsOn = exports.defaultProps.weekStartsOn, minValue, maxValue, disabledDates = exports.defaultProps.disabledDates, style, className, registerComponentApi, inline = exports.defaultProps.inline, startText, startIcon, endText, endIcon, label, labelPosition, labelWidth, labelBreak, readOnly = false, required, autoFocus = false } = _a, rest = __rest(_a, ["id", "initialValue", "value", "mode", "enabled", "placeholder", "updateState", "validationStatus", "onDidChange", "onFocus", "onBlur", "dateFormat", "showWeekNumber", "weekStartsOn", "minValue", "maxValue", "disabledDates", "style", "className", "registerComponentApi", "inline", "startText", "startIcon", "endText", "endIcon", "label", "labelPosition", "labelWidth", "labelBreak", "readOnly", "required", "autoFocus"]);
|
|
81
81
|
const _weekStartsOn = weekStartsOn >= 0 && weekStartsOn <= 6 ? weekStartsOn : WeekDays.Sunday;
|
|
82
82
|
const [_, setIsMenuFocused] = (0, react_2.useState)(false);
|
|
83
83
|
const [referenceElement, setReferenceElement] = (0, react_2.useState)(null);
|
|
84
84
|
const [inlineMonth, setInlineMonth] = (0, react_2.useState)();
|
|
85
|
-
const
|
|
86
|
-
const
|
|
85
|
+
const inputRef = (0, react_1.useRef)(null);
|
|
86
|
+
const ref = forwardedRef ? (0, react_compose_refs_1.composeRefs)(forwardedRef, inputRef) : inputRef;
|
|
87
87
|
const selected = (0, react_2.useMemo)(() => {
|
|
88
88
|
if (mode === "single" && typeof value === "string") {
|
|
89
89
|
return parseISODate(value) || parseDate(value);
|
|
@@ -102,7 +102,6 @@ exports.DatePicker = (0, react_2.forwardRef)(function DatePicker(_a, ref) {
|
|
|
102
102
|
}
|
|
103
103
|
}, [dateFormat]);
|
|
104
104
|
const startDate = (0, react_2.useMemo)(() => {
|
|
105
|
-
console.log(minValue, (0, date_fns_1.parse)(minValue, dateFormat, new Date()));
|
|
106
105
|
return minValue ? (0, date_fns_1.parse)(minValue, dateFormat, new Date()) : undefined;
|
|
107
106
|
}, [minValue, dateFormat]);
|
|
108
107
|
const endDate = (0, react_2.useMemo)(() => {
|
|
@@ -290,14 +289,14 @@ exports.DatePicker = (0, react_2.forwardRef)(function DatePicker(_a, ref) {
|
|
|
290
289
|
setOpen(false);
|
|
291
290
|
}
|
|
292
291
|
}, [onDidChange, updateState, mode, dateFormat, readOnly]);
|
|
293
|
-
return inline ? ((0, jsx_runtime_1.jsx)(
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
292
|
+
return inline ? ((0, jsx_runtime_1.jsx)("div", Object.assign({ ref: ref }, rest, { style: style, className: (0, classnames_1.default)(DatePicker_module_scss_1.default.inlinePickerMenu, className), tabIndex: 0, children: (0, jsx_runtime_1.jsx)(react_day_picker_1.DayPicker, { id: id, required: undefined, captionLayout: "dropdown", fixedWeeks: true, startMonth: startDate, endMonth: endDate, month: inlineMonth, onMonthChange: setInlineMonth, disabled: disabled, weekStartsOn: _weekStartsOn, showWeekNumber: showWeekNumber, showOutsideDays: true, classNames: DatePicker_module_scss_1.default, mode: mode === "single" ? "single" : "range", selected: selected, onSelect: handleSelect, autoFocus: autoFocus, numberOfMonths: mode === "range" ? 2 : 1, components: {
|
|
293
|
+
Chevron,
|
|
294
|
+
} }) }))) : ((0, jsx_runtime_1.jsxs)(react_popover_1.Popover, { open: open, onOpenChange: setOpen, modal: false, children: [(0, jsx_runtime_1.jsxs)(react_popover_1.PopoverTrigger, { id: id, ref: (0, react_compose_refs_1.composeRefs)(setReferenceElement, ref), "aria-haspopup": true, disabled: !enabled, style: style, "aria-expanded": open, className: (0, classnames_1.default)(className, DatePicker_module_scss_1.default.datePicker, {
|
|
295
|
+
[DatePicker_module_scss_1.default.disabled]: !enabled,
|
|
296
|
+
[DatePicker_module_scss_1.default.error]: validationStatus === "error",
|
|
297
|
+
[DatePicker_module_scss_1.default.warning]: validationStatus === "warning",
|
|
298
|
+
[DatePicker_module_scss_1.default.valid]: validationStatus === "valid",
|
|
299
|
+
}, className), autoFocus: autoFocus, onFocus: onFocus, onBlur: onBlur, children: [(0, jsx_runtime_1.jsx)(InputAdornment_1.Adornment, { text: startText, iconName: startIcon, className: DatePicker_module_scss_1.default.adornment }), (0, jsx_runtime_1.jsx)("div", { className: DatePicker_module_scss_1.default.datePickerValue, children: mode === "single" && selected ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, date_fns_1.format)(selected, dateFormat) })) : mode === "range" && typeof selected === "object" && selected.from ? (selected.to ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, date_fns_1.format)(selected.from, dateFormat), " - ", (0, date_fns_1.format)(selected.to, dateFormat)] })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, date_fns_1.format)(selected.from, dateFormat) }))) : placeholder ? ((0, jsx_runtime_1.jsx)("span", { className: DatePicker_module_scss_1.default.placeholder, placeholder: placeholder, children: placeholder })) : ((0, jsx_runtime_1.jsx)("span", { children: "\u00A0" })) }), (0, jsx_runtime_1.jsx)(InputAdornment_1.Adornment, { text: endText, iconName: endIcon, className: DatePicker_module_scss_1.default.adornment })] }), (0, jsx_runtime_1.jsx)(react_popover_1.PopoverPortal, { container: root, children: (0, jsx_runtime_1.jsx)(react_popover_1.PopoverContent, { role: "menu", align: "start", sideOffset: 5, className: DatePicker_module_scss_1.default.datePickerMenu, onFocus: handleOnMenuFocus, onBlur: handleOnMenuBlur, onInteractOutside: handleOnMenuBlur, children: (0, jsx_runtime_1.jsx)(react_day_picker_1.DayPicker, { required: undefined, animate: true, fixedWeeks: true, autoFocus: autoFocus, classNames: DatePicker_module_scss_1.default, captionLayout: "dropdown", startMonth: startDate, endMonth: endDate, defaultMonth: defaultMonth, disabled: disabled, weekStartsOn: _weekStartsOn, showWeekNumber: showWeekNumber, showOutsideDays: true, mode: mode === "single" ? "single" : "range", selected: selected, onSelect: handleSelect, numberOfMonths: mode === "range" ? 2 : 1, components: {
|
|
301
300
|
Chevron,
|
|
302
301
|
} }) }) })] }));
|
|
303
302
|
});
|
|
@@ -28,10 +28,6 @@ exports.FileInputMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
28
28
|
readOnly: (0, metadata_helpers_1.dReadonly)(),
|
|
29
29
|
enabled: (0, metadata_helpers_1.dEnabled)(),
|
|
30
30
|
validationStatus: (0, metadata_helpers_1.dValidationStatus)(),
|
|
31
|
-
label: (0, metadata_helpers_1.dLabel)(),
|
|
32
|
-
labelPosition: (0, metadata_helpers_1.dLabelPosition)("top"),
|
|
33
|
-
labelWidth: (0, metadata_helpers_1.dLabelWidth)(COMP),
|
|
34
|
-
labelBreak: (0, metadata_helpers_1.dLabelBreak)(COMP),
|
|
35
31
|
buttonVariant: (0, metadata_helpers_1.d)("The button variant to use", abstractions_1.buttonVariantNames),
|
|
36
32
|
buttonLabel: (0, metadata_helpers_1.d)(`This property is an optional string to set a label for the button part.`),
|
|
37
33
|
buttonIcon: (0, metadata_helpers_1.d)(`The ID of the icon to display in the button. You can change the default icon for all ${COMP} ` +
|
|
@@ -80,5 +76,5 @@ exports.FileInputMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
80
76
|
});
|
|
81
77
|
exports.fileInputRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.FileInputMd, ({ node, state, updateState, extractValue, lookupEventHandler, registerComponentApi, className }) => {
|
|
82
78
|
const iconName = extractValue.asOptionalString(node.props.buttonIcon) || DEFAULT_ICON;
|
|
83
|
-
return ((0, jsx_runtime_1.jsx)(FileInputNative_1.FileInput, { enabled: extractValue.asOptionalBoolean(node.props.enabled), variant: extractValue(node.props.buttonVariant), buttonThemeColor: extractValue(node.props.buttonThemeColor), buttonSize: extractValue(node.props.buttonSize), buttonIcon: (0, jsx_runtime_1.jsx)(IconNative_1.Icon, { name: iconName, fallback: "folder-open" }), buttonIconPosition: extractValue(node.props.buttonIconPosition), buttonLabel: extractValue.asOptionalString(node.props.buttonLabel), updateState: updateState, value: (0, FileInputNative_1.isFileArray)(state === null || state === void 0 ? void 0 : state.value) ? state === null || state === void 0 ? void 0 : state.value : undefined, autoFocus: extractValue.asOptionalBoolean(node.props.autoFocus), onDidChange: lookupEventHandler("didChange"), onFocus: lookupEventHandler("gotFocus"), onBlur: lookupEventHandler("lostFocus"), validationStatus: extractValue(node.props.validationStatus), registerComponentApi: registerComponentApi, multiple: extractValue.asOptionalBoolean(node.props.multiple), directory: extractValue.asOptionalBoolean(node.props.directory), placeholder: extractValue.asOptionalString(node.props.placeholder), buttonPosition: extractValue.asOptionalString(node.props.buttonPosition), initialValue: extractValue(node.props.initialValue), acceptsFileType: extractValue(node.props.acceptsFileType),
|
|
79
|
+
return ((0, jsx_runtime_1.jsx)(FileInputNative_1.FileInput, { enabled: extractValue.asOptionalBoolean(node.props.enabled), variant: extractValue(node.props.buttonVariant), buttonThemeColor: extractValue(node.props.buttonThemeColor), buttonSize: extractValue(node.props.buttonSize), buttonIcon: (0, jsx_runtime_1.jsx)(IconNative_1.Icon, { name: iconName, fallback: "folder-open" }), buttonIconPosition: extractValue(node.props.buttonIconPosition), buttonLabel: extractValue.asOptionalString(node.props.buttonLabel), updateState: updateState, value: (0, FileInputNative_1.isFileArray)(state === null || state === void 0 ? void 0 : state.value) ? state === null || state === void 0 ? void 0 : state.value : undefined, autoFocus: extractValue.asOptionalBoolean(node.props.autoFocus), onDidChange: lookupEventHandler("didChange"), onFocus: lookupEventHandler("gotFocus"), onBlur: lookupEventHandler("lostFocus"), validationStatus: extractValue(node.props.validationStatus), registerComponentApi: registerComponentApi, multiple: extractValue.asOptionalBoolean(node.props.multiple), directory: extractValue.asOptionalBoolean(node.props.directory), placeholder: extractValue.asOptionalString(node.props.placeholder), buttonPosition: extractValue.asOptionalString(node.props.buttonPosition), initialValue: extractValue(node.props.initialValue), acceptsFileType: extractValue(node.props.acceptsFileType), required: extractValue.asOptionalBoolean(node.props.required), className: className }));
|
|
84
80
|
});
|
|
@@ -247,3 +247,32 @@ const fixtures_1 = require("../../testing/fixtures");
|
|
|
247
247
|
const driver = yield createFileInputDriver();
|
|
248
248
|
yield (0, fixtures_1.expect)(driver.component).toBeVisible();
|
|
249
249
|
}));
|
|
250
|
+
// =============================================================================
|
|
251
|
+
// VISUAL STATE TESTS
|
|
252
|
+
// =============================================================================
|
|
253
|
+
(0, fixtures_1.test)("input has correct width in px", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
254
|
+
yield initTestBed(`<FileInput width="200px" testId="test"/>`, {});
|
|
255
|
+
const input = page.getByTestId("test");
|
|
256
|
+
const { width } = yield input.boundingBox();
|
|
257
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
258
|
+
}));
|
|
259
|
+
(0, fixtures_1.test)("input with label has correct width in px", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
260
|
+
yield initTestBed(`<FileInput width="200px" label="test" testId="test"/>`, {});
|
|
261
|
+
const input = page.getByTestId("test");
|
|
262
|
+
const { width } = yield input.boundingBox();
|
|
263
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
264
|
+
}));
|
|
265
|
+
(0, fixtures_1.test)("input has correct width in %", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
266
|
+
yield page.setViewportSize({ width: 400, height: 300 });
|
|
267
|
+
yield initTestBed(`<FileInput width="50%" testId="test"/>`, {});
|
|
268
|
+
const input = page.getByTestId("test");
|
|
269
|
+
const { width } = yield input.boundingBox();
|
|
270
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
271
|
+
}));
|
|
272
|
+
(0, fixtures_1.test)("input with label has correct width in %", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
273
|
+
yield page.setViewportSize({ width: 400, height: 300 });
|
|
274
|
+
yield initTestBed(`<FileInput width="50%" label="test" testId="test"/>`, {});
|
|
275
|
+
const input = page.getByTestId("test");
|
|
276
|
+
const { width } = yield input.boundingBox();
|
|
277
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
278
|
+
}));
|
|
@@ -60,7 +60,6 @@ const constants_1 = require("../../components-core/constants");
|
|
|
60
60
|
const misc_1 = require("../../components-core/utils/misc");
|
|
61
61
|
const ButtonNative_1 = require("../Button/ButtonNative");
|
|
62
62
|
const TextBoxNative_1 = require("../TextBox/TextBoxNative");
|
|
63
|
-
const ItemWithLabel_1 = require("../FormItem/ItemWithLabel");
|
|
64
63
|
// https://github.com/react-dropzone/react-dropzone/issues/1259
|
|
65
64
|
const { useDropzone } = dropzone;
|
|
66
65
|
exports.defaultProps = {
|
|
@@ -76,7 +75,7 @@ exports.defaultProps = {
|
|
|
76
75
|
onBlur: constants_1.noop,
|
|
77
76
|
};
|
|
78
77
|
const FileInput = (_a) => {
|
|
79
|
-
var { id, enabled = exports.defaultProps.enabled, style, className, placeholder, buttonPosition = exports.defaultProps.buttonPosition, buttonLabel = exports.defaultProps.buttonLabel, buttonIcon, buttonIconPosition, variant, buttonThemeColor, buttonSize, autoFocus, validationStatus, updateState = exports.defaultProps.updateState, onDidChange = exports.defaultProps.onDidChange, onFocus = exports.defaultProps.onFocus, onBlur = exports.defaultProps.onBlur, registerComponentApi, value, initialValue, acceptsFileType, multiple = exports.defaultProps.multiple, directory = exports.defaultProps.directory,
|
|
78
|
+
var { id, enabled = exports.defaultProps.enabled, style, className, placeholder, buttonPosition = exports.defaultProps.buttonPosition, buttonLabel = exports.defaultProps.buttonLabel, buttonIcon, buttonIconPosition, variant, buttonThemeColor, buttonSize, autoFocus, validationStatus, updateState = exports.defaultProps.updateState, onDidChange = exports.defaultProps.onDidChange, onFocus = exports.defaultProps.onFocus, onBlur = exports.defaultProps.onBlur, registerComponentApi, value, initialValue, acceptsFileType, multiple = exports.defaultProps.multiple, directory = exports.defaultProps.directory, required } = _a, rest = __rest(_a, ["id", "enabled", "style", "className", "placeholder", "buttonPosition", "buttonLabel", "buttonIcon", "buttonIconPosition", "variant", "buttonThemeColor", "buttonSize", "autoFocus", "validationStatus", "updateState", "onDidChange", "onFocus", "onBlur", "registerComponentApi", "value", "initialValue", "acceptsFileType", "multiple", "directory", "required"]);
|
|
80
79
|
const _id = (0, react_1.useId)();
|
|
81
80
|
id = id || _id;
|
|
82
81
|
// Don't accept any (initial) value if it is not a File array explicitly
|
|
@@ -139,19 +138,19 @@ const FileInput = (_a) => {
|
|
|
139
138
|
});
|
|
140
139
|
}, [focus, doOpen, registerComponentApi]);
|
|
141
140
|
// Solution source: https://stackoverflow.com/questions/1084925/input-type-file-show-only-button
|
|
142
|
-
return ((0, jsx_runtime_1.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
141
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: (0, classnames_1.default)(FileInput_module_scss_1.default.container, className, {
|
|
142
|
+
[FileInput_module_scss_1.default.buttonStart]: buttonPosition === "start",
|
|
143
|
+
[FileInput_module_scss_1.default.buttonEnd]: buttonPosition === "end",
|
|
144
|
+
}), style: style, onFocus: handleOnFocus, onBlur: handleOnBlur, tabIndex: -1 }, rest, { children: [(0, jsx_runtime_1.jsxs)("button", Object.assign({ id: id }, getRootProps({
|
|
145
|
+
tabIndex: 0,
|
|
146
|
+
disabled: !enabled,
|
|
147
|
+
className: FileInput_module_scss_1.default.textBoxWrapper,
|
|
148
|
+
onClick: open,
|
|
149
|
+
ref: buttonRef,
|
|
150
|
+
type: "button",
|
|
151
|
+
}), { children: [(0, jsx_runtime_1.jsx)(VisuallyHidden.Root, { children: (0, jsx_runtime_1.jsx)("input", Object.assign({}, getInputProps({
|
|
152
|
+
webkitdirectory: directory ? "true" : undefined,
|
|
153
|
+
}), { accept: _acceptsFileType })) }), (0, jsx_runtime_1.jsx)(TextBoxNative_1.TextBox, { placeholder: placeholder, enabled: enabled, value: (_value === null || _value === void 0 ? void 0 : _value.map((v) => v.name).join(", ")) || "", validationStatus: validationStatus, readOnly: true, tabIndex: -1 })] })), (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { disabled: !enabled, type: "button", onClick: open, icon: buttonIcon, iconPosition: buttonIconPosition, variant: variant, themeColor: buttonThemeColor, size: buttonSize, className: FileInput_module_scss_1.default.button, autoFocus: autoFocus, children: buttonLabel })] })));
|
|
155
154
|
};
|
|
156
155
|
exports.FileInput = FileInput;
|
|
157
156
|
function isFile(value) {
|
|
@@ -1090,7 +1090,7 @@ fixtures_1.test.describe("Edge Cases", () => {
|
|
|
1090
1090
|
const formDriver = yield createFormDriver();
|
|
1091
1091
|
const fieldDriver = yield createFormItemDriver("testField");
|
|
1092
1092
|
yield formDriver.submitForm();
|
|
1093
|
-
yield (0, fixtures_1.expect)(
|
|
1093
|
+
yield (0, fixtures_1.expect)(fieldDriver.validationStatusIndicator).toHaveAttribute(fieldDriver.validationStatusTag, "warning");
|
|
1094
1094
|
}));
|
|
1095
1095
|
(0, fixtures_1.test)("field-related errors map to correct FormItems", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createFormDriver, createFormItemDriver, }) {
|
|
1096
1096
|
yield initTestBed(`
|
|
@@ -1103,9 +1103,9 @@ fixtures_1.test.describe("Edge Cases", () => {
|
|
|
1103
1103
|
const formDriver = yield createFormDriver();
|
|
1104
1104
|
const fieldDriver = yield createFormItemDriver("testField");
|
|
1105
1105
|
yield formDriver.submitForm();
|
|
1106
|
-
yield (0, fixtures_1.expect)(
|
|
1106
|
+
yield (0, fixtures_1.expect)(fieldDriver.validationStatusIndicator).toHaveAttribute(fieldDriver.validationStatusTag, "warning");
|
|
1107
1107
|
}));
|
|
1108
|
-
|
|
1108
|
+
fixtures_1.test.skip("field-related errors disappear if user updates FormItems", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, createFormItemDriver }) {
|
|
1109
1109
|
yield initTestBed(`
|
|
1110
1110
|
<Form testId="form">
|
|
1111
1111
|
<FormItem testId="testField" bindTo="test" label="test" required />
|
|
@@ -1115,15 +1115,17 @@ fixtures_1.test.describe("Edge Cases", () => {
|
|
|
1115
1115
|
const fieldDriver2 = yield createFormItemDriver("testField2");
|
|
1116
1116
|
yield fieldDriver.component.focus();
|
|
1117
1117
|
yield fieldDriver.textBox.fill("a");
|
|
1118
|
-
yield fieldDriver.textBox.fill(""
|
|
1119
|
-
yield
|
|
1120
|
-
//
|
|
1118
|
+
yield fieldDriver.textBox.fill("");
|
|
1119
|
+
yield fieldDriver.textBox.blur();
|
|
1120
|
+
// Should show required error now
|
|
1121
|
+
yield (0, fixtures_1.expect)(fieldDriver.textBox).toHaveValue("");
|
|
1122
|
+
yield (0, fixtures_1.expect)(fieldDriver.validationStatusIndicator).toHaveAttribute(fieldDriver.validationStatusTag, "error");
|
|
1121
1123
|
yield fieldDriver.textBox.fill("a");
|
|
1122
1124
|
yield fieldDriver.textBox.blur();
|
|
1123
|
-
yield fieldDriver2.
|
|
1124
|
-
yield
|
|
1125
|
+
yield fieldDriver2.textBox.focus();
|
|
1126
|
+
yield (0, fixtures_1.expect)(fieldDriver2.textBox).toBeFocused();
|
|
1125
1127
|
yield fieldDriver2.textBox.fill("b");
|
|
1126
|
-
(0, fixtures_1.expect)(
|
|
1128
|
+
yield (0, fixtures_1.expect)(fieldDriver.validationStatusIndicator).not.toBeVisible();
|
|
1127
1129
|
}));
|
|
1128
1130
|
const smartCrudInterceptor = {
|
|
1129
1131
|
initialize: `
|