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
|
@@ -55,10 +55,10 @@ const react_slider_1 = require("@radix-ui/react-slider");
|
|
|
55
55
|
const Slider_module_scss_1 = __importDefault(require("./Slider.module.scss"));
|
|
56
56
|
const constants_1 = require("../../components-core/constants");
|
|
57
57
|
const misc_1 = require("../../components-core/utils/misc");
|
|
58
|
-
const ItemWithLabel_1 = require("../FormItem/ItemWithLabel");
|
|
59
58
|
const classnames_1 = __importDefault(require("classnames"));
|
|
60
59
|
const TooltipNative_1 = require("../Tooltip/TooltipNative");
|
|
61
60
|
const lodash_es_1 = require("lodash-es");
|
|
61
|
+
const react_compose_refs_1 = require("@radix-ui/react-compose-refs");
|
|
62
62
|
exports.defaultProps = {
|
|
63
63
|
step: 1,
|
|
64
64
|
min: 0,
|
|
@@ -103,12 +103,11 @@ const formatValue = (val, defaultVal = 0, minVal, maxVal) => {
|
|
|
103
103
|
return [clampValue(defaultVal)];
|
|
104
104
|
};
|
|
105
105
|
exports.Slider = (0, react_2.forwardRef)((_a, forwardedRef) => {
|
|
106
|
-
var { id, style, className, step = exports.defaultProps.step, min = exports.defaultProps.min, max = exports.defaultProps.max, inverted, updateState, onDidChange = constants_1.noop, onFocus = constants_1.noop, onBlur = constants_1.noop, registerComponentApi, enabled = exports.defaultProps.enabled, value, autoFocus, readOnly, tabIndex = exports.defaultProps.tabIndex,
|
|
107
|
-
const _id = (0, react_1.useId)();
|
|
108
|
-
id = id || _id;
|
|
106
|
+
var { id, style, className, step = exports.defaultProps.step, min = exports.defaultProps.min, max = exports.defaultProps.max, inverted, updateState, onDidChange = constants_1.noop, onFocus = constants_1.noop, onBlur = constants_1.noop, registerComponentApi, enabled = exports.defaultProps.enabled, value, autoFocus, readOnly, tabIndex = exports.defaultProps.tabIndex, required, validationStatus = exports.defaultProps.validationStatus, initialValue, minStepsBetweenThumbs = exports.defaultProps.minStepsBetweenThumbs, rangeStyle, thumbStyle, showValues = exports.defaultProps.showValues, valueFormat = exports.defaultProps.valueFormat } = _a, rest = __rest(_a, ["id", "style", "className", "step", "min", "max", "inverted", "updateState", "onDidChange", "onFocus", "onBlur", "registerComponentApi", "enabled", "value", "autoFocus", "readOnly", "tabIndex", "required", "validationStatus", "initialValue", "minStepsBetweenThumbs", "rangeStyle", "thumbStyle", "showValues", "valueFormat"]);
|
|
109
107
|
const inputRef = (0, react_1.useRef)(null);
|
|
108
|
+
const ref = forwardedRef ? (0, react_compose_refs_1.composeRefs)(inputRef, forwardedRef) : inputRef;
|
|
110
109
|
const tooltipRef = (0, react_1.useRef)(null);
|
|
111
|
-
const
|
|
110
|
+
const thumbsRef = (0, react_1.useRef)([]);
|
|
112
111
|
min = parseValue(min, exports.defaultProps.min);
|
|
113
112
|
max = parseValue(max, exports.defaultProps.max);
|
|
114
113
|
// Initialize localValue properly
|
|
@@ -181,18 +180,22 @@ exports.Slider = (0, react_2.forwardRef)((_a, forwardedRef) => {
|
|
|
181
180
|
}, [updateValue, readOnly]);
|
|
182
181
|
// Component APIs
|
|
183
182
|
const handleOnFocus = (0, react_1.useCallback)((ev) => {
|
|
184
|
-
|
|
185
|
-
(_a = thumbRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
183
|
+
onShowTooltip();
|
|
186
184
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(ev);
|
|
187
|
-
}, [onFocus]);
|
|
185
|
+
}, [onFocus, onShowTooltip]);
|
|
188
186
|
const handleOnBlur = (0, react_1.useCallback)((ev) => {
|
|
189
|
-
var _a;
|
|
190
|
-
(_a = thumbRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
191
187
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(ev);
|
|
192
188
|
}, [onBlur]);
|
|
193
189
|
const focus = (0, react_1.useCallback)(() => {
|
|
194
190
|
var _a;
|
|
195
|
-
|
|
191
|
+
// Focus the first available thumb
|
|
192
|
+
const firstThumb = thumbsRef.current.find(thumb => thumb !== null);
|
|
193
|
+
if (firstThumb) {
|
|
194
|
+
firstThumb.focus();
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
198
|
+
}
|
|
196
199
|
}, []);
|
|
197
200
|
const setValue = (0, misc_1.useEvent)((newValue) => {
|
|
198
201
|
if (readOnly || !enabled) {
|
|
@@ -210,19 +213,25 @@ exports.Slider = (0, react_2.forwardRef)((_a, forwardedRef) => {
|
|
|
210
213
|
}, [focus, registerComponentApi, setValue]);
|
|
211
214
|
// Ensure we always have at least one thumb
|
|
212
215
|
const displayValue = localValue.length > 0 ? localValue : formatValue(undefined, min, min, max);
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
216
|
+
// Clean up thumbs ref array when number of thumbs changes
|
|
217
|
+
(0, react_1.useEffect)(() => {
|
|
218
|
+
thumbsRef.current = thumbsRef.current.slice(0, displayValue.length);
|
|
219
|
+
}, [displayValue.length]);
|
|
220
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({}, rest, { ref: ref, style: style, className: (0, classnames_1.default)(Slider_module_scss_1.default.sliderContainer, className), "data-slider-container": true, children: (0, jsx_runtime_1.jsxs)(react_slider_1.Root, { ref: inputRef, minStepsBetweenThumbs: minStepsBetweenThumbs, tabIndex: tabIndex, "aria-readonly": readOnly, className: (0, classnames_1.default)(Slider_module_scss_1.default.sliderRoot, {
|
|
221
|
+
[Slider_module_scss_1.default.disabled]: !enabled,
|
|
222
|
+
[Slider_module_scss_1.default.readOnly]: readOnly,
|
|
223
|
+
}), max: max, min: min, inverted: inverted, step: step, disabled: !enabled, onFocus: handleOnFocus, onBlur: handleOnBlur, onValueChange: onInputChange, onMouseOver: onShowTooltip, onMouseLeave: onHideTooltip, onPointerDown: onShowTooltip, value: displayValue, children: [(0, jsx_runtime_1.jsx)(react_slider_1.Track, { "data-track": true, className: (0, classnames_1.default)(Slider_module_scss_1.default.sliderTrack, {
|
|
224
|
+
[Slider_module_scss_1.default.disabled]: !enabled,
|
|
225
|
+
[Slider_module_scss_1.default.readOnly]: readOnly,
|
|
226
|
+
[Slider_module_scss_1.default.error]: validationStatus === "error",
|
|
227
|
+
[Slider_module_scss_1.default.warning]: validationStatus === "warning",
|
|
228
|
+
[Slider_module_scss_1.default.valid]: validationStatus === "valid",
|
|
229
|
+
}), style: rangeStyle ? Object.assign({}, rangeStyle) : undefined, children: (0, jsx_runtime_1.jsx)(react_slider_1.Range, { "data-range": true, className: (0, classnames_1.default)(Slider_module_scss_1.default.sliderRange, {
|
|
230
|
+
[Slider_module_scss_1.default.disabled]: !enabled,
|
|
231
|
+
}) }) }), displayValue.map((_, index) => ((0, jsx_runtime_1.jsx)(TooltipNative_1.Tooltip, { ref: tooltipRef, text: valueFormat(displayValue[index]), delayDuration: 100, open: showValues && showTooltip, children: (0, jsx_runtime_1.jsx)(react_slider_1.Thumb, { id: id, "aria-required": required, ref: (el) => {
|
|
232
|
+
thumbsRef.current[index] = el;
|
|
233
|
+
}, className: (0, classnames_1.default)(Slider_module_scss_1.default.sliderThumb, {
|
|
217
234
|
[Slider_module_scss_1.default.disabled]: !enabled,
|
|
218
|
-
|
|
219
|
-
[Slider_module_scss_1.default.error]: validationStatus === "error",
|
|
220
|
-
[Slider_module_scss_1.default.warning]: validationStatus === "warning",
|
|
221
|
-
[Slider_module_scss_1.default.valid]: validationStatus === "valid",
|
|
222
|
-
}), style: rangeStyle ? Object.assign({}, rangeStyle) : undefined, children: (0, jsx_runtime_1.jsx)(react_slider_1.Range, { "data-range": true, className: (0, classnames_1.default)(Slider_module_scss_1.default.sliderRange, {
|
|
223
|
-
[Slider_module_scss_1.default.disabled]: !enabled,
|
|
224
|
-
}) }) }), displayValue.map((_, index) => ((0, jsx_runtime_1.jsx)(TooltipNative_1.Tooltip, { ref: tooltipRef, text: valueFormat(displayValue[index]), delayDuration: 100, open: showValues && showTooltip, children: (0, jsx_runtime_1.jsx)(react_slider_1.Thumb, { id: id, "aria-required": required, ref: index === 0 ? thumbRef : null, className: (0, classnames_1.default)(Slider_module_scss_1.default.sliderThumb, {
|
|
225
|
-
[Slider_module_scss_1.default.disabled]: !enabled,
|
|
226
|
-
}), style: thumbStyle ? Object.assign({}, thumbStyle) : undefined, "data-thumb-index": index, autoFocus: autoFocus }) }, index)))] }) }) })));
|
|
235
|
+
}), style: thumbStyle ? Object.assign({}, thumbStyle) : undefined, "data-thumb-index": index, autoFocus: autoFocus && index === 0 }) }, index)))] }) })));
|
|
227
236
|
});
|
|
228
237
|
exports.Slider.displayName = "Slider";
|
|
@@ -23,10 +23,6 @@ exports.SwitchMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
23
23
|
},
|
|
24
24
|
},
|
|
25
25
|
props: {
|
|
26
|
-
label: (0, metadata_helpers_1.dLabel)(),
|
|
27
|
-
labelPosition: (0, metadata_helpers_1.dLabelPosition)("end"),
|
|
28
|
-
labelWidth: (0, metadata_helpers_1.dLabelWidth)(COMP),
|
|
29
|
-
labelBreak: (0, metadata_helpers_1.dLabelBreak)(COMP),
|
|
30
26
|
required: (0, metadata_helpers_1.dRequired)(),
|
|
31
27
|
initialValue: (0, metadata_helpers_1.dInitialValue)(Toggle_1.defaultProps.initialValue),
|
|
32
28
|
autoFocus: (0, metadata_helpers_1.dAutoFocus)(),
|
|
@@ -80,5 +76,5 @@ exports.SwitchMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
80
76
|
},
|
|
81
77
|
});
|
|
82
78
|
exports.switchComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.SwitchMd, ({ node, extractValue, className, updateState, state, lookupEventHandler, registerComponentApi, }) => {
|
|
83
|
-
return ((0, jsx_runtime_1.jsx)(Toggle_1.Toggle, { enabled: extractValue.asOptionalBoolean(node.props.enabled), className: className, initialValue: extractValue.asOptionalBoolean(node.props.initialValue, Toggle_1.defaultProps.initialValue), value: state === null || state === void 0 ? void 0 : state.value, readOnly: extractValue.asOptionalBoolean(node.props.readOnly), validationStatus: extractValue(node.props.validationStatus), updateState: updateState, autoFocus: extractValue.asOptionalBoolean(node.props.autoFocus), onClick: lookupEventHandler("click"), onDidChange: lookupEventHandler("didChange"), onFocus: lookupEventHandler("gotFocus"), onBlur: lookupEventHandler("lostFocus"),
|
|
79
|
+
return ((0, jsx_runtime_1.jsx)(Toggle_1.Toggle, { enabled: extractValue.asOptionalBoolean(node.props.enabled), className: className, initialValue: extractValue.asOptionalBoolean(node.props.initialValue, Toggle_1.defaultProps.initialValue), value: state === null || state === void 0 ? void 0 : state.value, readOnly: extractValue.asOptionalBoolean(node.props.readOnly), validationStatus: extractValue(node.props.validationStatus), updateState: updateState, autoFocus: extractValue.asOptionalBoolean(node.props.autoFocus), onClick: lookupEventHandler("click"), onDidChange: lookupEventHandler("didChange"), onFocus: lookupEventHandler("gotFocus"), onBlur: lookupEventHandler("lostFocus"), required: extractValue.asOptionalBoolean(node.props.required), variant: "switch", registerComponentApi: registerComponentApi }));
|
|
84
80
|
});
|
|
@@ -64,10 +64,6 @@ exports.TextAreaMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
64
64
|
},
|
|
65
65
|
placeholder: (0, metadata_helpers_1.dPlaceholder)(),
|
|
66
66
|
initialValue: (0, metadata_helpers_1.dInitialValue)(),
|
|
67
|
-
label: (0, metadata_helpers_1.dLabel)(),
|
|
68
|
-
labelPosition: (0, metadata_helpers_1.dLabelPosition)("top"),
|
|
69
|
-
labelWidth: (0, metadata_helpers_1.dLabelWidth)(COMP),
|
|
70
|
-
labelBreak: (0, metadata_helpers_1.dLabelBreak)(COMP),
|
|
71
67
|
maxLength: (0, metadata_helpers_1.dMaxLength)(),
|
|
72
68
|
autoFocus: (0, metadata_helpers_1.dAutoFocus)(),
|
|
73
69
|
required: (0, metadata_helpers_1.dRequired)(),
|
|
@@ -103,5 +99,5 @@ exports.TextAreaMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
103
99
|
},
|
|
104
100
|
});
|
|
105
101
|
exports.textAreaComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.TextAreaMd, ({ node, extractValue, state, updateState, className, registerComponentApi, lookupEventHandler, }) => {
|
|
106
|
-
return ((0, jsx_runtime_1.jsx)(TextAreaNative_1.TextArea, { value: state === null || state === void 0 ? void 0 : state.value, initialValue: extractValue(node.props.initialValue), updateState: updateState, autoFocus: extractValue.asOptionalBoolean(node.props.autoFocus), enabled: extractValue.asOptionalBoolean(node.props.enabled), placeholder: extractValue(node.props.placeholder), onDidChange: lookupEventHandler("didChange"), onFocus: lookupEventHandler("gotFocus"), onBlur: lookupEventHandler("lostFocus"), readOnly: extractValue.asOptionalBoolean(node.props.readOnly), resize: node.props.resize, enterSubmits: extractValue.asOptionalBoolean(node.props.enterSubmits), escResets: extractValue.asOptionalBoolean(node.props.escResets), className: className, registerComponentApi: registerComponentApi, maxRows: extractValue.asOptionalNumber(node.props.maxRows), minRows: extractValue.asOptionalNumber(node.props.minRows), maxLength: extractValue.asOptionalNumber(node.props.maxLength), rows: extractValue.asOptionalNumber(node.props.rows), autoSize: extractValue.asOptionalBoolean(node.props.autoSize), validationStatus: extractValue(node.props.validationStatus),
|
|
102
|
+
return ((0, jsx_runtime_1.jsx)(TextAreaNative_1.TextArea, { value: state === null || state === void 0 ? void 0 : state.value, initialValue: extractValue(node.props.initialValue), updateState: updateState, autoFocus: extractValue.asOptionalBoolean(node.props.autoFocus), enabled: extractValue.asOptionalBoolean(node.props.enabled), placeholder: extractValue(node.props.placeholder), onDidChange: lookupEventHandler("didChange"), onFocus: lookupEventHandler("gotFocus"), onBlur: lookupEventHandler("lostFocus"), readOnly: extractValue.asOptionalBoolean(node.props.readOnly), resize: node.props.resize, enterSubmits: extractValue.asOptionalBoolean(node.props.enterSubmits), escResets: extractValue.asOptionalBoolean(node.props.escResets), className: className, registerComponentApi: registerComponentApi, maxRows: extractValue.asOptionalNumber(node.props.maxRows), minRows: extractValue.asOptionalNumber(node.props.minRows), maxLength: extractValue.asOptionalNumber(node.props.maxLength), rows: extractValue.asOptionalNumber(node.props.rows), autoSize: extractValue.asOptionalBoolean(node.props.autoSize), validationStatus: extractValue(node.props.validationStatus), required: extractValue.asOptionalBoolean(node.props.required) }));
|
|
107
103
|
});
|
|
@@ -712,3 +712,32 @@ fixtures_1.test.describe("Regression", () => {
|
|
|
712
712
|
yield (0, fixtures_1.expect)(driver.component).toHaveValue("abcde");
|
|
713
713
|
}));
|
|
714
714
|
});
|
|
715
|
+
// =============================================================================
|
|
716
|
+
// VISUAL STATE TESTS
|
|
717
|
+
// =============================================================================
|
|
718
|
+
(0, fixtures_1.test)("input has correct width in px", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
719
|
+
yield initTestBed(`<TextArea width="200px" testId="test"/>`, {});
|
|
720
|
+
const input = page.getByTestId("test");
|
|
721
|
+
const { width } = yield input.boundingBox();
|
|
722
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
723
|
+
}));
|
|
724
|
+
(0, fixtures_1.test)("input with label has correct width in px", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
725
|
+
yield initTestBed(`<TextArea width="200px" label="test" testId="test"/>`, {});
|
|
726
|
+
const input = page.getByTestId("test");
|
|
727
|
+
const { width } = yield input.boundingBox();
|
|
728
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
729
|
+
}));
|
|
730
|
+
(0, fixtures_1.test)("input has correct width in %", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
731
|
+
yield page.setViewportSize({ width: 400, height: 300 });
|
|
732
|
+
yield initTestBed(`<TextArea width="50%" testId="test"/>`, {});
|
|
733
|
+
const input = page.getByTestId("test");
|
|
734
|
+
const { width } = yield input.boundingBox();
|
|
735
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
736
|
+
}));
|
|
737
|
+
(0, fixtures_1.test)("input with label has correct width in %", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
738
|
+
yield page.setViewportSize({ width: 400, height: 300 });
|
|
739
|
+
yield initTestBed(`<TextArea width="50%" label="test" testId="test"/>`, {});
|
|
740
|
+
const input = page.getByTestId("test");
|
|
741
|
+
const { width } = yield input.boundingBox();
|
|
742
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
743
|
+
}));
|
|
@@ -56,15 +56,10 @@ const lodash_es_1 = require("lodash-es");
|
|
|
56
56
|
const TextArea_module_scss_1 = __importDefault(require("./TextArea.module.scss"));
|
|
57
57
|
const constants_1 = require("../../components-core/constants");
|
|
58
58
|
const misc_1 = require("../../components-core/utils/misc");
|
|
59
|
-
const ItemWithLabel_1 = require("../FormItem/ItemWithLabel");
|
|
60
59
|
const TextAreaResizable_1 = __importDefault(require("./TextAreaResizable"));
|
|
61
60
|
const parts_1 = require("../../components-core/parts");
|
|
61
|
+
const react_compose_refs_1 = require("@radix-ui/react-compose-refs");
|
|
62
62
|
exports.resizeOptionKeys = ["horizontal", "vertical", "both"];
|
|
63
|
-
const resizeMap = {
|
|
64
|
-
horizontal: TextArea_module_scss_1.default.resizeHorizontal,
|
|
65
|
-
vertical: TextArea_module_scss_1.default.resizeVertical,
|
|
66
|
-
both: TextArea_module_scss_1.default.resizeBoth,
|
|
67
|
-
};
|
|
68
63
|
exports.defaultProps = {
|
|
69
64
|
value: "",
|
|
70
65
|
placeholder: "",
|
|
@@ -83,9 +78,10 @@ exports.defaultProps = {
|
|
|
83
78
|
enabled: true,
|
|
84
79
|
};
|
|
85
80
|
exports.TextArea = (0, react_1.forwardRef)(function TextArea(_a, forwardedRef) {
|
|
86
|
-
var { id, value = exports.defaultProps.value, placeholder = exports.defaultProps.placeholder, required = exports.defaultProps.required, readOnly = exports.defaultProps.readOnly, allowCopy = exports.defaultProps.allowCopy, updateState = exports.defaultProps.updateState, validationStatus, autoFocus = exports.defaultProps.autoFocus, initialValue = exports.defaultProps.initialValue, resize, onDidChange = exports.defaultProps.onDidChange, onFocus = exports.defaultProps.onFocus, onBlur = exports.defaultProps.onBlur, controlled = exports.defaultProps.controlled, enterSubmits = exports.defaultProps.enterSubmits, escResets, style, className, registerComponentApi, autoSize, maxRows, minRows, maxLength, rows = exports.defaultProps.rows, enabled = exports.defaultProps.enabled
|
|
81
|
+
var { id, value = exports.defaultProps.value, placeholder = exports.defaultProps.placeholder, required = exports.defaultProps.required, readOnly = exports.defaultProps.readOnly, allowCopy = exports.defaultProps.allowCopy, updateState = exports.defaultProps.updateState, validationStatus, autoFocus = exports.defaultProps.autoFocus, initialValue = exports.defaultProps.initialValue, resize, onDidChange = exports.defaultProps.onDidChange, onFocus = exports.defaultProps.onFocus, onBlur = exports.defaultProps.onBlur, controlled = exports.defaultProps.controlled, enterSubmits = exports.defaultProps.enterSubmits, escResets, style, className, registerComponentApi, autoSize, maxRows, minRows, maxLength, rows = exports.defaultProps.rows, enabled = exports.defaultProps.enabled } = _a, rest = __rest(_a, ["id", "value", "placeholder", "required", "readOnly", "allowCopy", "updateState", "validationStatus", "autoFocus", "initialValue", "resize", "onDidChange", "onFocus", "onBlur", "controlled", "enterSubmits", "escResets", "style", "className", "registerComponentApi", "autoSize", "maxRows", "minRows", "maxLength", "rows", "enabled"]);
|
|
87
82
|
// --- The component is initially unfocused
|
|
88
83
|
const inputRef = (0, react_1.useRef)(null);
|
|
84
|
+
const ref = react_1.forwardRef ? (0, react_compose_refs_1.composeRefs)(forwardedRef, inputRef) : inputRef;
|
|
89
85
|
const [cursorPosition, setCursorPosition] = (0, react_1.useState)(null);
|
|
90
86
|
const [focused, setFocused] = react_1.default.useState(false);
|
|
91
87
|
const updateValue = (0, react_1.useCallback)((value) => {
|
|
@@ -187,31 +183,14 @@ exports.TextArea = (0, react_1.forwardRef)(function TextArea(_a, forwardedRef) {
|
|
|
187
183
|
[TextArea_module_scss_1.default.warning]: validationStatus === "warning",
|
|
188
184
|
[TextArea_module_scss_1.default.valid]: validationStatus === "valid",
|
|
189
185
|
});
|
|
190
|
-
const textareaProps = {
|
|
191
|
-
className: classes,
|
|
192
|
-
ref: inputRef,
|
|
193
|
-
style: style,
|
|
194
|
-
value: controlled ? value || "" : undefined,
|
|
195
|
-
disabled: !enabled,
|
|
196
|
-
name: id,
|
|
197
|
-
placeholder,
|
|
186
|
+
const textareaProps = Object.assign(Object.assign({}, rest), { id, className: classes, ref, style: style, value: controlled ? value || "" : undefined, disabled: !enabled, name: id, placeholder,
|
|
198
187
|
required,
|
|
199
|
-
maxLength,
|
|
200
|
-
"aria-multiline": true,
|
|
201
|
-
"aria-readonly": readOnly,
|
|
202
|
-
readOnly: readOnly,
|
|
203
|
-
onChange: onInputChange,
|
|
204
|
-
onCopy: handleCopy,
|
|
205
|
-
onFocus: handleOnFocus,
|
|
206
|
-
onBlur: handleOnBlur,
|
|
207
|
-
onKeyDown: handleEnter,
|
|
208
|
-
autoComplete: "off",
|
|
209
|
-
};
|
|
188
|
+
maxLength, "aria-multiline": true, "aria-readonly": readOnly, readOnly: readOnly, onChange: onInputChange, onCopy: handleCopy, onFocus: handleOnFocus, onBlur: handleOnBlur, onKeyDown: handleEnter, autoComplete: "off" });
|
|
210
189
|
if (resize === "both" || resize === "horizontal" || resize === "vertical") {
|
|
211
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
190
|
+
return ((0, jsx_runtime_1.jsx)(TextAreaResizable_1.default, Object.assign({}, textareaProps, { "data-part-id": parts_1.PART_INPUT, style: style, className: (0, classnames_1.default)(classes), maxRows: maxRows, minRows: minRows, rows: rows })));
|
|
212
191
|
}
|
|
213
192
|
if (autoSize || !(0, lodash_es_1.isNil)(maxRows) || !(0, lodash_es_1.isNil)(minRows)) {
|
|
214
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
193
|
+
return ((0, jsx_runtime_1.jsx)(react_textarea_autosize_1.default, Object.assign({}, textareaProps, { "data-part-id": parts_1.PART_INPUT, style: style, className: (0, classnames_1.default)(classes), maxRows: maxRows, minRows: minRows, rows: rows })));
|
|
215
194
|
}
|
|
216
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
195
|
+
return ((0, jsx_runtime_1.jsx)("textarea", Object.assign({}, textareaProps, { "data-part-id": parts_1.PART_INPUT, rows: rows, className: (0, classnames_1.default)(classes) })));
|
|
217
196
|
});
|
|
@@ -209,13 +209,6 @@ fixtures_1.test.describe("Label", () => {
|
|
|
209
209
|
const { top: labelTop } = yield (0, component_test_helpers_1.getBounds)(driver.label);
|
|
210
210
|
(0, fixtures_1.expect)(labelTop).toBeGreaterThan(textboxBottom);
|
|
211
211
|
}));
|
|
212
|
-
(0, fixtures_1.test)("labelWidth applies custom label width", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createTextBoxDriver }) {
|
|
213
|
-
const expected = 200;
|
|
214
|
-
yield initTestBed(`<TextBox testId="test" label="test test" labelWidth="${expected}px" />`);
|
|
215
|
-
const driver = yield createTextBoxDriver("test");
|
|
216
|
-
const { width } = yield (0, component_test_helpers_1.getBounds)(driver.label);
|
|
217
|
-
(0, fixtures_1.expect)(width).toEqual(expected);
|
|
218
|
-
}));
|
|
219
212
|
(0, fixtures_1.test)("labelBreak enables label line breaks", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createTextBoxDriver }) {
|
|
220
213
|
const labelText = "Very long label text that should break";
|
|
221
214
|
const commonProps = `label="${labelText}" labelWidth="100px"`;
|
|
@@ -685,3 +678,41 @@ fixtures_1.test.describe("Integration", () => {
|
|
|
685
678
|
yield (0, fixtures_1.expect)(driver.label).not.toBeVisible();
|
|
686
679
|
}));
|
|
687
680
|
});
|
|
681
|
+
(0, fixtures_1.test)("labelWidth applies custom label width", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createTextBoxDriver }) {
|
|
682
|
+
const expected = 200;
|
|
683
|
+
yield initTestBed(`<TextBox testId="test" label="test test" labelWidth="${expected}px" />`);
|
|
684
|
+
const driver = yield createTextBoxDriver("test");
|
|
685
|
+
const { width } = yield (0, component_test_helpers_1.getBounds)(driver.label);
|
|
686
|
+
(0, fixtures_1.expect)(width).toEqual(expected);
|
|
687
|
+
}));
|
|
688
|
+
// =============================================================================
|
|
689
|
+
// VISUAL STATE TESTS
|
|
690
|
+
// =============================================================================
|
|
691
|
+
(0, fixtures_1.test)("input has correct width", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
692
|
+
yield initTestBed(`
|
|
693
|
+
<TextBox width="200px" testId="test"/>
|
|
694
|
+
`);
|
|
695
|
+
const { width } = yield page.getByTestId("test").boundingBox();
|
|
696
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
697
|
+
}));
|
|
698
|
+
(0, fixtures_1.test)("input with label has correct width", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
699
|
+
yield initTestBed(`
|
|
700
|
+
<TextBox width="200px" label="test" testId="test"/>
|
|
701
|
+
`);
|
|
702
|
+
const { width } = yield page.getByTestId("test").boundingBox();
|
|
703
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
704
|
+
}));
|
|
705
|
+
(0, fixtures_1.test)("input has correct width in %", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
706
|
+
yield page.setViewportSize({ width: 400, height: 300 });
|
|
707
|
+
yield initTestBed(`<TextBox width="50%" testId="test"/>`, {});
|
|
708
|
+
const input = page.getByTestId("test");
|
|
709
|
+
const { width } = yield input.boundingBox();
|
|
710
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
711
|
+
}));
|
|
712
|
+
(0, fixtures_1.test)("input with label has correct width in %", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
713
|
+
yield page.setViewportSize({ width: 400, height: 300 });
|
|
714
|
+
yield initTestBed(`<TextBox width="50%" label="test" testId="test"/>`, {});
|
|
715
|
+
const input = page.getByTestId("test");
|
|
716
|
+
const { width } = yield input.boundingBox();
|
|
717
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
718
|
+
}));
|
|
@@ -130,13 +130,13 @@ exports.TextBox = (0, react_1.forwardRef)(function TextBox(_a, ref) {
|
|
|
130
130
|
setValue,
|
|
131
131
|
});
|
|
132
132
|
}, [focus, registerComponentApi, setValue]);
|
|
133
|
-
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, rest, { ref: ref, className: (0, classnames_1.default)(TextBox_module_scss_1.default.inputRoot, {
|
|
133
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, rest, { ref: ref, className: (0, classnames_1.default)(className, TextBox_module_scss_1.default.inputRoot, {
|
|
134
134
|
[TextBox_module_scss_1.default.disabled]: !enabled,
|
|
135
135
|
[TextBox_module_scss_1.default.readOnly]: readOnly,
|
|
136
136
|
[TextBox_module_scss_1.default.error]: validationStatus === "error",
|
|
137
137
|
[TextBox_module_scss_1.default.warning]: validationStatus === "warning",
|
|
138
138
|
[TextBox_module_scss_1.default.valid]: validationStatus === "valid",
|
|
139
|
-
}), tabIndex: -1, onFocus: focus, style: { gap }, children: [(0, jsx_runtime_1.jsx)(InputAdornment_1.Adornment, { "data-part-id": parts_1.PART_START_ADORNMENT, text: startText, iconName: startIcon, className: (0, classnames_1.default)(TextBox_module_scss_1.default.adornment) }), (0, jsx_runtime_1.jsx)("input", { id: id, ref: inputRef, "data-part-id": parts_1.PART_INPUT, type: actualType, className: (0, classnames_1.default)(TextBox_module_scss_1.default.input, {
|
|
139
|
+
}), tabIndex: -1, onFocus: focus, style: Object.assign(Object.assign({}, style), { gap }), children: [(0, jsx_runtime_1.jsx)(InputAdornment_1.Adornment, { "data-part-id": parts_1.PART_START_ADORNMENT, text: startText, iconName: startIcon, className: (0, classnames_1.default)(TextBox_module_scss_1.default.adornment) }), (0, jsx_runtime_1.jsx)("input", { id: id, ref: inputRef, "data-part-id": parts_1.PART_INPUT, type: actualType, className: (0, classnames_1.default)(TextBox_module_scss_1.default.input, {
|
|
140
140
|
[TextBox_module_scss_1.default.readOnly]: readOnly,
|
|
141
141
|
}), disabled: !enabled, value: localValue, maxLength: maxLength, placeholder: placeholder, onChange: onInputChange, onFocus: handleOnFocus, onBlur: handleOnBlur, onKeyDown: onKeyDown, readOnly: readOnly, autoFocus: autoFocus, tabIndex: enabled ? tabIndex : -1, required: required }), type === "password" && showPasswordToggle ? ((0, jsx_runtime_1.jsx)(InputAdornment_1.Adornment, { "data-part-id": parts_1.PART_END_ADORNMENT, iconName: showPassword ? passwordVisibleIcon : passwordHiddenIcon, className: (0, classnames_1.default)(TextBox_module_scss_1.default.adornment, TextBox_module_scss_1.default.passwordToggle), onClick: togglePasswordVisibility })) : ((0, jsx_runtime_1.jsx)(InputAdornment_1.Adornment, { "data-part-id": parts_1.PART_END_ADORNMENT, text: endText, iconName: endIcon, className: TextBox_module_scss_1.default.adornment }))] })));
|
|
142
142
|
});
|
|
@@ -1120,3 +1120,34 @@ fixtures_1.test.describe("Layout", () => {
|
|
|
1120
1120
|
(0, fixtures_1.expect)(Math.abs(hourToMinuteGap - minuteToSecondGap)).toBeLessThan(5); // Allow small differences
|
|
1121
1121
|
}));
|
|
1122
1122
|
});
|
|
1123
|
+
// =============================================================================
|
|
1124
|
+
// VISUAL STATE TESTS
|
|
1125
|
+
// =============================================================================
|
|
1126
|
+
(0, fixtures_1.test)("input has correct width", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
1127
|
+
yield initTestBed(`
|
|
1128
|
+
<TimeInput width="200px" testId="test"/>
|
|
1129
|
+
`);
|
|
1130
|
+
const { width } = yield page.getByTestId("test").boundingBox();
|
|
1131
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
1132
|
+
}));
|
|
1133
|
+
(0, fixtures_1.test)("input with label has correct width", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
1134
|
+
yield initTestBed(`
|
|
1135
|
+
<TimeInput width="200px" label="test" testId="test"/>
|
|
1136
|
+
`);
|
|
1137
|
+
const { width } = yield page.getByTestId("test").boundingBox();
|
|
1138
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
1139
|
+
}));
|
|
1140
|
+
(0, fixtures_1.test)("input has correct width in %", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
1141
|
+
yield page.setViewportSize({ width: 400, height: 300 });
|
|
1142
|
+
yield initTestBed(`<TimeInput width="50%" testId="test"/>`, {});
|
|
1143
|
+
const input = page.getByTestId("test");
|
|
1144
|
+
const { width } = yield input.boundingBox();
|
|
1145
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
1146
|
+
}));
|
|
1147
|
+
(0, fixtures_1.test)("input with label has correct width in %", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
|
|
1148
|
+
yield page.setViewportSize({ width: 400, height: 300 });
|
|
1149
|
+
yield initTestBed(`<TimeInput width="50%" label="test" testId="test"/>`, {});
|
|
1150
|
+
const input = page.getByTestId("test");
|
|
1151
|
+
const { width } = yield input.boundingBox();
|
|
1152
|
+
(0, fixtures_1.expect)(width).toBe(200);
|
|
1153
|
+
}));
|