xmlui 0.10.16 → 0.10.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/lib/{index-D4RYJasT.mjs → index-cuh97e2e.mjs} +1603 -1635
  2. package/dist/lib/index.css +1 -1
  3. package/dist/lib/{initMock-qzTZlH-6.mjs → initMock-BMxsanHc.mjs} +1 -1
  4. package/dist/lib/xmlui.mjs +1 -1
  5. package/dist/metadata/{collectedComponentMetadata-BQaefK3f.mjs → collectedComponentMetadata-Cp-9lpnG.mjs} +1716 -1757
  6. package/dist/metadata/{initMock-Cz6QssI3.mjs → initMock-C-cnv--V.mjs} +1 -1
  7. package/dist/metadata/style.css +1 -1
  8. package/dist/metadata/xmlui-metadata.mjs +1 -1
  9. package/dist/metadata/xmlui-metadata.umd.js +3 -3
  10. package/dist/scripts/package.json +1 -1
  11. package/dist/scripts/src/components/Accordion/Accordion.spec.js +1 -1
  12. package/dist/scripts/src/components/Accordion/AccordionItemNative.js +1 -1
  13. package/dist/scripts/src/components/AutoComplete/AutoComplete.spec.js +54 -4
  14. package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +81 -62
  15. package/dist/scripts/src/components/Checkbox/Checkbox.js +1 -5
  16. package/dist/scripts/src/components/Checkbox/Checkbox.spec.js +5 -0
  17. package/dist/scripts/src/components/ColorPicker/ColorPicker.js +2 -6
  18. package/dist/scripts/src/components/ColorPicker/ColorPicker.spec.js +29 -0
  19. package/dist/scripts/src/components/ColorPicker/ColorPickerNative.js +12 -9
  20. package/dist/scripts/src/components/ComponentProvider.js +2 -0
  21. package/dist/scripts/src/components/DateInput/DateInput.js +1 -5
  22. package/dist/scripts/src/components/DateInput/DateInput.spec.js +51 -17
  23. package/dist/scripts/src/components/DateInput/DateInputNative.js +12 -16
  24. package/dist/scripts/src/components/DatePicker/DatePicker.js +14 -13
  25. package/dist/scripts/src/components/DatePicker/DatePicker.spec.js +50 -18
  26. package/dist/scripts/src/components/DatePicker/DatePickerNative.js +34 -32
  27. package/dist/scripts/src/components/FileInput/FileInput.js +1 -5
  28. package/dist/scripts/src/components/FileInput/FileInput.spec.js +36 -0
  29. package/dist/scripts/src/components/FileInput/FileInputNative.js +14 -15
  30. package/dist/scripts/src/components/Form/Form.spec.js +11 -9
  31. package/dist/scripts/src/components/Form/FormNative.js +15 -9
  32. package/dist/scripts/src/components/FormItem/FormItem.spec.js +179 -30
  33. package/dist/scripts/src/components/FormItem/FormItemNative.js +20 -22
  34. package/dist/scripts/src/components/FormItem/ItemWithLabel.js +8 -17
  35. package/dist/scripts/src/components/FormItem/Validations.js +25 -6
  36. package/dist/scripts/src/components/Icon/Icon.js +1 -1
  37. package/dist/scripts/src/components/Input/PartialInput.js +2 -2
  38. package/dist/scripts/src/components/NumberBox/NumberBox.js +1 -5
  39. package/dist/scripts/src/components/NumberBox/NumberBox.spec.js +38 -4
  40. package/dist/scripts/src/components/NumberBox/NumberBoxNative.js +15 -17
  41. package/dist/scripts/src/components/RadioGroup/RadioGroup.js +1 -5
  42. package/dist/scripts/src/components/RadioGroup/RadioGroup.spec.js +9 -0
  43. package/dist/scripts/src/components/RadioGroup/RadioGroupNative.js +4 -5
  44. package/dist/scripts/src/components/RadioGroup/RadioItem.js +28 -0
  45. package/dist/scripts/src/components/Select/Select.js +1 -5
  46. package/dist/scripts/src/components/Select/Select.spec.js +290 -193
  47. package/dist/scripts/src/components/Select/SelectNative.js +26 -32
  48. package/dist/scripts/src/components/Slider/Slider.js +1 -5
  49. package/dist/scripts/src/components/Slider/Slider.spec.js +36 -0
  50. package/dist/scripts/src/components/Slider/SliderNative.js +18 -19
  51. package/dist/scripts/src/components/Switch/Switch.js +1 -5
  52. package/dist/scripts/src/components/Switch/Switch.spec.js +24 -17
  53. package/dist/scripts/src/components/Table/Table.js +11 -1
  54. package/dist/scripts/src/components/Table/Table.spec.js +272 -0
  55. package/dist/scripts/src/components/Table/TableNative.js +162 -5
  56. package/dist/scripts/src/components/TextArea/TextArea.js +1 -5
  57. package/dist/scripts/src/components/TextArea/TextArea.spec.js +80 -0
  58. package/dist/scripts/src/components/TextArea/TextAreaNative.js +8 -29
  59. package/dist/scripts/src/components/TextBox/TextBox.spec.js +45 -7
  60. package/dist/scripts/src/components/TextBox/TextBoxNative.js +2 -2
  61. package/dist/scripts/src/components/TimeInput/TimeInput.spec.js +75 -37
  62. package/dist/scripts/src/components/TimeInput/TimeInputNative.js +6 -20
  63. package/dist/scripts/src/components/Timer/Timer.spec.js +66 -96
  64. package/dist/scripts/src/components/Toggle/Toggle.js +30 -25
  65. package/dist/scripts/src/components/Tree/Tree-icons.spec.js +206 -0
  66. package/dist/scripts/src/components/Tree/Tree.spec.js +1 -94
  67. package/dist/scripts/src/components/Tree/TreeComponent.js +44 -7
  68. package/dist/scripts/src/components/Tree/TreeNative.js +127 -85
  69. package/dist/scripts/src/components/Tree/testData.js +25 -1
  70. package/dist/scripts/src/components-core/behaviors/Behavior.js +2 -0
  71. package/dist/scripts/src/components-core/behaviors/CoreBehaviors.js +8 -5
  72. package/dist/scripts/src/components-core/rendering/AppRoot.js +1 -2
  73. package/dist/scripts/src/components-core/rendering/ComponentAdapter.js +12 -13
  74. package/dist/scripts/src/components-core/utils/treeUtils.js +8 -5
  75. package/dist/scripts/src/testing/ComponentDrivers.js +2 -4
  76. package/dist/standalone/xmlui-standalone.umd.js +15 -15
  77. package/package.json +1 -1
  78. package/dist/scripts/src/components-core/behaviors/BehaviorContext.js +0 -54
@@ -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, ref) {
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"]);
79
+ exports.DatePicker = (0, react_2.forwardRef)(function DatePicker(_a, forwardedRef) {
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, startDate, endDate, 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", "startDate", "endDate", "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 generatedId = (0, react_1.useId)();
86
- const inputId = id || generatedId;
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);
@@ -101,13 +101,12 @@ exports.DatePicker = (0, react_2.forwardRef)(function DatePicker(_a, ref) {
101
101
  throw new Error(`Invalid dateFormat: ${dateFormat}. Supported formats are: ${exports.dateFormats.join(", ")}`);
102
102
  }
103
103
  }, [dateFormat]);
104
- const startDate = (0, react_2.useMemo)(() => {
105
- console.log(minValue, (0, date_fns_1.parse)(minValue, dateFormat, new Date()));
106
- return minValue ? (0, date_fns_1.parse)(minValue, dateFormat, new Date()) : undefined;
107
- }, [minValue, dateFormat]);
108
- const endDate = (0, react_2.useMemo)(() => {
109
- return maxValue ? (0, date_fns_1.parse)(maxValue, dateFormat, new Date()) : undefined;
110
- }, [maxValue, dateFormat]);
104
+ const _startDate = (0, react_2.useMemo)(() => {
105
+ return startDate ? (0, date_fns_1.parse)(startDate, dateFormat, new Date()) : undefined;
106
+ }, [startDate, dateFormat]);
107
+ const _endDate = (0, react_2.useMemo)(() => {
108
+ return endDate ? (0, date_fns_1.parse)(endDate, dateFormat, new Date()) : undefined;
109
+ }, [endDate, dateFormat]);
111
110
  const defaultMonth = (0, react_2.useMemo)(() => {
112
111
  if (mode === "single" && selected) {
113
112
  return selected;
@@ -125,7 +124,7 @@ exports.DatePicker = (0, react_2.forwardRef)(function DatePicker(_a, ref) {
125
124
  if (dateValue instanceof Date) {
126
125
  return dateValue;
127
126
  }
128
- if (typeof dateValue === 'string') {
127
+ if (typeof dateValue === "string") {
129
128
  // Try to parse as ISO date first
130
129
  const isoDate = parseISODate(dateValue);
131
130
  if (isoDate) {
@@ -141,15 +140,15 @@ exports.DatePicker = (0, react_2.forwardRef)(function DatePicker(_a, ref) {
141
140
  };
142
141
  const convertMatcher = (matcher) => {
143
142
  // Handle boolean - disable all dates
144
- if (typeof matcher === 'boolean') {
143
+ if (typeof matcher === "boolean") {
145
144
  return matcher;
146
145
  }
147
146
  // Handle function matcher - pass through as is
148
- if (typeof matcher === 'function') {
147
+ if (typeof matcher === "function") {
149
148
  return matcher;
150
149
  }
151
150
  // Handle single Date or string
152
- if (matcher instanceof Date || typeof matcher === 'string') {
151
+ if (matcher instanceof Date || typeof matcher === "string") {
153
152
  const convertedDate = convertStringToDate(matcher);
154
153
  return convertedDate || undefined;
155
154
  }
@@ -157,14 +156,17 @@ exports.DatePicker = (0, react_2.forwardRef)(function DatePicker(_a, ref) {
157
156
  if (Array.isArray(matcher)) {
158
157
  const convertedMatchers = [];
159
158
  for (const item of matcher) {
160
- if (typeof item === 'object' && item !== null && !Array.isArray(item) && !(item instanceof Date)) {
159
+ if (typeof item === "object" &&
160
+ item !== null &&
161
+ !Array.isArray(item) &&
162
+ !(item instanceof Date)) {
161
163
  // Handle nested matcher objects in array (e.g., {dayOfWeek: [0,6]}, {from: date, to: date})
162
164
  const nestedResult = convertMatcher(item);
163
165
  if (nestedResult) {
164
166
  convertedMatchers.push(nestedResult);
165
167
  }
166
168
  }
167
- else if (item instanceof Date || typeof item === 'string') {
169
+ else if (item instanceof Date || typeof item === "string") {
168
170
  // Handle individual dates in the array
169
171
  const convertedDate = convertStringToDate(item);
170
172
  if (convertedDate) {
@@ -176,9 +178,9 @@ exports.DatePicker = (0, react_2.forwardRef)(function DatePicker(_a, ref) {
176
178
  return convertedMatchers.length > 0 ? convertedMatchers : undefined;
177
179
  }
178
180
  // Handle object matchers (DateRange, DateBefore, DateAfter, DateInterval, DayOfWeek)
179
- if (typeof matcher === 'object' && matcher !== null) {
181
+ if (typeof matcher === "object" && matcher !== null) {
180
182
  // Handle DateRange: { from: Date, to?: Date }
181
- if ('from' in matcher) {
183
+ if ("from" in matcher) {
182
184
  const fromDate = convertStringToDate(matcher.from);
183
185
  const toDate = matcher.to ? convertStringToDate(matcher.to) : undefined;
184
186
  if (fromDate) {
@@ -186,21 +188,21 @@ exports.DatePicker = (0, react_2.forwardRef)(function DatePicker(_a, ref) {
186
188
  }
187
189
  }
188
190
  // Handle DateBefore: { before: Date }
189
- if ('before' in matcher && !('after' in matcher)) {
191
+ if ("before" in matcher && !("after" in matcher)) {
190
192
  const beforeDate = convertStringToDate(matcher.before);
191
193
  if (beforeDate) {
192
194
  return { before: beforeDate };
193
195
  }
194
196
  }
195
197
  // Handle DateAfter: { after: Date }
196
- if ('after' in matcher && !('before' in matcher)) {
198
+ if ("after" in matcher && !("before" in matcher)) {
197
199
  const afterDate = convertStringToDate(matcher.after);
198
200
  if (afterDate) {
199
201
  return { after: afterDate };
200
202
  }
201
203
  }
202
204
  // Handle DateInterval: { before: Date, after: Date }
203
- if ('before' in matcher && 'after' in matcher) {
205
+ if ("before" in matcher && "after" in matcher) {
204
206
  const beforeDate = convertStringToDate(matcher.before);
205
207
  const afterDate = convertStringToDate(matcher.after);
206
208
  if (beforeDate && afterDate) {
@@ -208,7 +210,7 @@ exports.DatePicker = (0, react_2.forwardRef)(function DatePicker(_a, ref) {
208
210
  }
209
211
  }
210
212
  // Handle DayOfWeek: { dayOfWeek: number | number[] }
211
- if ('dayOfWeek' in matcher) {
213
+ if ("dayOfWeek" in matcher) {
212
214
  return { dayOfWeek: matcher.dayOfWeek };
213
215
  }
214
216
  }
@@ -290,14 +292,14 @@ exports.DatePicker = (0, react_2.forwardRef)(function DatePicker(_a, ref) {
290
292
  setOpen(false);
291
293
  }
292
294
  }, [onDidChange, updateState, mode, dateFormat, readOnly]);
293
- return inline ? ((0, jsx_runtime_1.jsx)(ItemWithLabel_1.ItemWithLabel, { id: inputId, labelPosition: labelPosition, label: label, labelWidth: labelWidth, labelBreak: labelBreak, required: required, enabled: enabled, onFocus: onFocus, onBlur: onBlur, style: style, className: className, ref: ref, children: (0, jsx_runtime_1.jsx)("div", Object.assign({}, rest, { className: DatePicker_module_scss_1.default.inlinePickerMenu, ref: (ref) => setReferenceElement(ref), children: (0, jsx_runtime_1.jsx)(react_day_picker_1.DayPicker, { id: inputId, 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: {
294
- Chevron,
295
- } }) })) })) : ((0, jsx_runtime_1.jsxs)(react_popover_1.Popover, { open: open, onOpenChange: setOpen, modal: false, children: [(0, jsx_runtime_1.jsx)(ItemWithLabel_1.ItemWithLabel, Object.assign({}, rest, { id: inputId, labelPosition: labelPosition, label: label, labelWidth: labelWidth, labelBreak: labelBreak, required: required, enabled: enabled, onFocus: onFocus, onBlur: onBlur, style: style, className: className, ref: ref, children: (0, jsx_runtime_1.jsxs)(react_popover_1.PopoverTrigger, { ref: setReferenceElement, id: inputId, "aria-haspopup": true, disabled: !enabled, style: style, "aria-expanded": open, className: (0, classnames_1.default)(DatePicker_module_scss_1.default.datePicker, {
296
- [DatePicker_module_scss_1.default.disabled]: !enabled,
297
- [DatePicker_module_scss_1.default.error]: validationStatus === "error",
298
- [DatePicker_module_scss_1.default.warning]: validationStatus === "warning",
299
- [DatePicker_module_scss_1.default.valid]: validationStatus === "valid",
300
- }, 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: {
295
+ 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: {
296
+ Chevron,
297
+ } }) }))) : ((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, {
298
+ [DatePicker_module_scss_1.default.disabled]: !enabled,
299
+ [DatePicker_module_scss_1.default.error]: validationStatus === "error",
300
+ [DatePicker_module_scss_1.default.warning]: validationStatus === "warning",
301
+ [DatePicker_module_scss_1.default.valid]: validationStatus === "valid",
302
+ }, 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
303
  Chevron,
302
304
  } }) }) })] }));
303
305
  });
@@ -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), label: extractValue.asOptionalString(node.props.label), labelPosition: extractValue(node.props.labelPosition), labelWidth: extractValue.asOptionalString(node.props.labelWidth), labelBreak: extractValue.asOptionalBoolean(node.props.labelBreak), required: extractValue.asOptionalBoolean(node.props.required), className: className }));
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
  });
@@ -215,6 +215,13 @@ const fixtures_1 = require("../../testing/fixtures");
215
215
  yield driver.getTextBox().focus();
216
216
  yield fixtures_1.expect.poll(testStateDriver.testState).toEqual("focused");
217
217
  }));
218
+ (0, fixtures_1.test)("gotFocus event fires on label focus", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
219
+ const { testStateDriver } = yield initTestBed(`
220
+ <FileInput testId="fileInput" onGotFocus="testState = 'focused'" label="test" />
221
+ `);
222
+ yield page.getByText("test").click();
223
+ yield fixtures_1.expect.poll(testStateDriver.testState).toEqual("focused");
224
+ }));
218
225
  (0, fixtures_1.test)("lostFocus event fires on blue", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, createFileInputDriver }) {
219
226
  const { testStateDriver } = yield initTestBed(`
220
227
  <FileInput testId="fileInput" onLostFocus="testState = 'blurred'" />
@@ -247,3 +254,32 @@ const fixtures_1 = require("../../testing/fixtures");
247
254
  const driver = yield createFileInputDriver();
248
255
  yield (0, fixtures_1.expect)(driver.component).toBeVisible();
249
256
  }));
257
+ // =============================================================================
258
+ // VISUAL STATE TESTS
259
+ // =============================================================================
260
+ (0, fixtures_1.test)("input has correct width in px", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
261
+ yield initTestBed(`<FileInput width="200px" testId="test"/>`, {});
262
+ const input = page.getByTestId("test");
263
+ const { width } = yield input.boundingBox();
264
+ (0, fixtures_1.expect)(width).toBe(200);
265
+ }));
266
+ (0, fixtures_1.test)("input with label has correct width in px", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
267
+ yield initTestBed(`<FileInput width="200px" label="test" 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 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%" testId="test"/>`, {});
275
+ const input = page.getByTestId("test");
276
+ const { width } = yield input.boundingBox();
277
+ (0, fixtures_1.expect)(width).toBe(200);
278
+ }));
279
+ (0, fixtures_1.test)("input with label has correct width in %", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed }) {
280
+ yield page.setViewportSize({ width: 400, height: 300 });
281
+ yield initTestBed(`<FileInput width="50%" label="test" testId="test"/>`, {});
282
+ const input = page.getByTestId("test");
283
+ const { width } = yield input.boundingBox();
284
+ (0, fixtures_1.expect)(width).toBe(200);
285
+ }));
@@ -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, label, labelPosition, labelWidth, labelBreak, 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", "label", "labelPosition", "labelWidth", "labelBreak", "required"]);
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.jsx)(ItemWithLabel_1.ItemWithLabel, Object.assign({}, rest, { id: id, labelPosition: labelPosition, label: label, labelWidth: labelWidth, labelBreak: labelBreak, required: required, enabled: enabled, style: style, className: className, isInputTemplateUsed: true, children: (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(FileInput_module_scss_1.default.container, {
143
- [FileInput_module_scss_1.default.buttonStart]: buttonPosition === "start",
144
- [FileInput_module_scss_1.default.buttonEnd]: buttonPosition === "end",
145
- }), onFocus: handleOnFocus, onBlur: handleOnBlur, tabIndex: -1, children: [(0, jsx_runtime_1.jsxs)("button", Object.assign({ id: id }, getRootProps({
146
- tabIndex: 0,
147
- disabled: !enabled,
148
- className: FileInput_module_scss_1.default.textBoxWrapper,
149
- onClick: open,
150
- ref: buttonRef,
151
- type: "button",
152
- }), { children: [(0, jsx_runtime_1.jsx)(VisuallyHidden.Root, { children: (0, jsx_runtime_1.jsx)("input", Object.assign({}, getInputProps({
153
- webkitdirectory: directory ? "true" : undefined,
154
- }), { 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 })] }) })));
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)(yield fieldDriver.getValidationStatusIndicator()).toHaveAttribute(fieldDriver.validationStatusTag, "warning");
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)(yield fieldDriver.getValidationStatusIndicator()).toHaveAttribute(fieldDriver.validationStatusTag, "warning");
1106
+ yield (0, fixtures_1.expect)(fieldDriver.validationStatusIndicator).toHaveAttribute(fieldDriver.validationStatusTag, "warning");
1107
1107
  }));
1108
- (0, fixtures_1.test)("field-related errors disappear if user updates FormItems", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, createFormItemDriver }) {
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("", { timeout: 500 }); // trigger 'required' error
1119
- yield (0, fixtures_1.expect)(yield fieldDriver.getValidationStatusIndicator()).toHaveAttribute(fieldDriver.validationStatusTag, "error");
1120
- //await fieldDriver.component.focus();
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.component.focus();
1124
- yield page.waitForTimeout(200);
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)(yield fieldDriver.getValidationStatusIndicator()).not.toBeVisible();
1128
+ yield (0, fixtures_1.expect)(fieldDriver.validationStatusIndicator).not.toBeVisible();
1127
1129
  }));
1128
1130
  const smartCrudInterceptor = {
1129
1131
  initialize: `
@@ -61,6 +61,7 @@ const formReducer = (0, immer_1.default)((state, action) => {
61
61
  isValidOnFocus: false,
62
62
  isValidLostFocus: false,
63
63
  focused: false,
64
+ afterFirstDirtyBlur: false,
64
65
  forceShowValidationResult: false,
65
66
  };
66
67
  }
@@ -100,8 +101,10 @@ const formReducer = (0, immer_1.default)((state, action) => {
100
101
  else {
101
102
  state.validationResults[uid] = action.payload.validationResult;
102
103
  }
103
- state.interactionFlags[uid].invalidToValid =
104
- !prevValid && state.validationResults[uid].isValid;
104
+ const currentIsInvalidToValid = !prevValid && state.validationResults[uid].isValid;
105
+ if (currentIsInvalidToValid) {
106
+ state.interactionFlags[uid].invalidToValid = true;
107
+ }
105
108
  break;
106
109
  }
107
110
  case formActions_1.FormActionKind.FIELD_FOCUSED: {
@@ -112,6 +115,8 @@ const formReducer = (0, immer_1.default)((state, action) => {
112
115
  case formActions_1.FormActionKind.FIELD_LOST_FOCUS: {
113
116
  state.interactionFlags[uid].isValidLostFocus = !!((_d = state.validationResults[uid]) === null || _d === void 0 ? void 0 : _d.isValid);
114
117
  state.interactionFlags[uid].focused = false;
118
+ state.interactionFlags[uid].afterFirstDirtyBlur = state.interactionFlags[uid].isDirty;
119
+ state.interactionFlags[uid].invalidToValid = false;
115
120
  break;
116
121
  }
117
122
  case formActions_1.FormActionKind.TRIED_TO_SUBMIT: {
@@ -240,14 +245,14 @@ const Form = (0, react_2.forwardRef)(function (_a, ref) {
240
245
  });
241
246
  const doSubmit = (0, misc_1.useEvent)((event) => __awaiter(this, void 0, void 0, function* () {
242
247
  var _a;
243
- console.log(`🚀 Form submit started`);
248
+ /* console.log(`🚀 Form submit started`);
244
249
  console.log(`🔍 Initial values:`, {
245
- initialValue,
246
- EMPTY_OBJECT: constants_1.EMPTY_OBJECT,
247
- isEqual: initialValue === constants_1.EMPTY_OBJECT,
248
- initialValueType: typeof initialValue,
249
- emptyObjectType: typeof constants_1.EMPTY_OBJECT
250
- });
250
+ initialValue,
251
+ EMPTY_OBJECT,
252
+ isEqual: initialValue === EMPTY_OBJECT,
253
+ initialValueType: typeof initialValue,
254
+ emptyObjectType: typeof EMPTY_OBJECT
255
+ }); */
251
256
  event === null || event === void 0 ? void 0 : event.preventDefault();
252
257
  if (!isEnabled) {
253
258
  return;
@@ -412,3 +417,4 @@ exports.FormWithContextVar = (0, react_2.forwardRef)(function ({ node, renderChi
412
417
  }), initialValue: initialValue, buttonRow: renderChild(node.props.buttonRowTemplate), registerComponentApi: registerComponentApi, enabled: extractValue.asOptionalBoolean(node.props.enabled, true) &&
413
418
  !extractValue.asOptionalBoolean(node.props.loading, false), children: renderChild(nodeWithItem) }) }));
414
419
  });
420
+ exports.FormWithContextVar.displayName = "FormWithContextVar";