@beweco/aurora-ui 0.6.55 → 0.6.57
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/index.cjs.js
CHANGED
|
@@ -6766,6 +6766,33 @@ var DrawerFiltersHeader = function (_a) {
|
|
|
6766
6766
|
};
|
|
6767
6767
|
|
|
6768
6768
|
var NO_YEAR_CLASS = "[&_[data-type='year']]:hidden [&_[data-type='literal']:has(+[data-type='year'])]:hidden";
|
|
6769
|
+
// Year used to construct CalendarDate values. React Aria's onChange only fires when
|
|
6770
|
+
// ALL segments (including hidden year) are user-confirmed. Since users can't type year
|
|
6771
|
+
// (it's CSS-hidden), we read month+day directly from the DOM via data-placeholder
|
|
6772
|
+
// attributes when the picker loses focus, bypassing the year-confirmation requirement.
|
|
6773
|
+
var FILLER_YEAR = new Date().getFullYear();
|
|
6774
|
+
/**
|
|
6775
|
+
* Reads month and day from segment DOM elements.
|
|
6776
|
+
* Returns null if any segment is still in placeholder state (user hasn't typed it yet).
|
|
6777
|
+
* React Aria marks unconfirmed segments with data-placeholder="true".
|
|
6778
|
+
*/
|
|
6779
|
+
function readConfirmedMonthDay(container, monthSelector, daySelector) {
|
|
6780
|
+
if (monthSelector === void 0) { monthSelector = '[data-type="month"]'; }
|
|
6781
|
+
if (daySelector === void 0) { daySelector = '[data-type="day"]'; }
|
|
6782
|
+
var monthEl = container.querySelector(monthSelector);
|
|
6783
|
+
var dayEl = container.querySelector(daySelector);
|
|
6784
|
+
if (!monthEl || !dayEl)
|
|
6785
|
+
return null;
|
|
6786
|
+
if (monthEl.getAttribute("data-placeholder") === "true")
|
|
6787
|
+
return null;
|
|
6788
|
+
if (dayEl.getAttribute("data-placeholder") === "true")
|
|
6789
|
+
return null;
|
|
6790
|
+
var month = Number(monthEl.getAttribute("aria-valuenow"));
|
|
6791
|
+
var day = Number(dayEl.getAttribute("aria-valuenow"));
|
|
6792
|
+
if (month >= 1 && month <= 12 && day >= 1 && day <= 31)
|
|
6793
|
+
return { month: month, day: day };
|
|
6794
|
+
return null;
|
|
6795
|
+
}
|
|
6769
6796
|
var DayMonthPicker = function (_a) {
|
|
6770
6797
|
var value = _a.value, onChange = _a.onChange, translations = _a.translations;
|
|
6771
6798
|
var t = __assign({ dayMonthAriaLabel: "Seleccionar mes y día", dayMonthRangeAriaLabel: "Seleccionar rango de mes y día", dayMonthSingleOption: "Día específico", dayMonthRangeOption: "Rango de fechas" }, translations);
|
|
@@ -6773,6 +6800,17 @@ var DayMonthPicker = function (_a) {
|
|
|
6773
6800
|
React.useEffect(function () {
|
|
6774
6801
|
setMode((value === null || value === void 0 ? void 0 : value.type) === "dayMonthRange" ? "range" : "single");
|
|
6775
6802
|
}, [value === null || value === void 0 ? void 0 : value.type]);
|
|
6803
|
+
var pickerValue = (value === null || value === void 0 ? void 0 : value.type) === "dayMonth" ? value.dayMonth : null;
|
|
6804
|
+
var rangeValue = (value === null || value === void 0 ? void 0 : value.type) === "dayMonthRange" ? value.dayMonthRange : null;
|
|
6805
|
+
// Refs to DOM wrappers — used by the DOM-reading fallback for manual input.
|
|
6806
|
+
var singleRef = React.useRef(null);
|
|
6807
|
+
var rangeRef = React.useRef(null);
|
|
6808
|
+
// Stable refs so focus-change callbacks always read current values without
|
|
6809
|
+
// needing to be recreated on every render.
|
|
6810
|
+
var pickerValueRef = React.useRef(pickerValue);
|
|
6811
|
+
pickerValueRef.current = pickerValue;
|
|
6812
|
+
var rangeValueRef = React.useRef(rangeValue);
|
|
6813
|
+
rangeValueRef.current = rangeValue;
|
|
6776
6814
|
var handleModeChange = function (newMode) {
|
|
6777
6815
|
var nextMode = newMode === "range" ? "range" : "single";
|
|
6778
6816
|
setMode(nextMode);
|
|
@@ -6783,22 +6821,50 @@ var DayMonthPicker = function (_a) {
|
|
|
6783
6821
|
onChange({ type: "dayMonthRange", dayMonth: null, dayMonthRange: null });
|
|
6784
6822
|
};
|
|
6785
6823
|
var handleSingleChange = function (date) {
|
|
6786
|
-
onChange({
|
|
6787
|
-
type: "dayMonth",
|
|
6788
|
-
dayMonth: date,
|
|
6789
|
-
dayMonthRange: null,
|
|
6790
|
-
});
|
|
6824
|
+
onChange({ type: "dayMonth", dayMonth: date, dayMonthRange: null });
|
|
6791
6825
|
};
|
|
6792
6826
|
var handleRangeChange = function (range) {
|
|
6793
|
-
onChange({
|
|
6794
|
-
type: "dayMonthRange",
|
|
6795
|
-
dayMonth: null,
|
|
6796
|
-
dayMonthRange: range,
|
|
6797
|
-
});
|
|
6827
|
+
onChange({ type: "dayMonthRange", dayMonth: null, dayMonthRange: range });
|
|
6798
6828
|
};
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6829
|
+
// Called by React Aria when the DatePicker gains/loses focus.
|
|
6830
|
+
// When value=null (placeholder mode) React Aria never fires onChange because the
|
|
6831
|
+
// hidden year segment is never user-confirmed. On blur we read the confirmed
|
|
6832
|
+
// month/day directly from the DOM as a workaround.
|
|
6833
|
+
var handleSingleFocusChange = function (isFocused) {
|
|
6834
|
+
if (isFocused || pickerValueRef.current)
|
|
6835
|
+
return;
|
|
6836
|
+
if (!singleRef.current)
|
|
6837
|
+
return;
|
|
6838
|
+
var result = readConfirmedMonthDay(singleRef.current);
|
|
6839
|
+
if (result) {
|
|
6840
|
+
handleSingleChange(new $35ea8db9cb2ccb90$export$99faa760c7908e4f(FILLER_YEAR, result.month, result.day));
|
|
6841
|
+
}
|
|
6842
|
+
};
|
|
6843
|
+
var handleRangeFocusChange = function (isFocused) {
|
|
6844
|
+
if (isFocused || rangeValueRef.current)
|
|
6845
|
+
return;
|
|
6846
|
+
if (!rangeRef.current)
|
|
6847
|
+
return;
|
|
6848
|
+
var monthEls = rangeRef.current.querySelectorAll('[data-type="month"]');
|
|
6849
|
+
var dayEls = rangeRef.current.querySelectorAll('[data-type="day"]');
|
|
6850
|
+
if (monthEls.length < 2 || dayEls.length < 2)
|
|
6851
|
+
return;
|
|
6852
|
+
var allConfirmed = __spreadArray(__spreadArray([], monthEls, true), dayEls, true).every(function (el) { return el.getAttribute("data-placeholder") !== "true"; });
|
|
6853
|
+
if (!allConfirmed)
|
|
6854
|
+
return;
|
|
6855
|
+
var startMonth = Number(monthEls[0].getAttribute("aria-valuenow"));
|
|
6856
|
+
var startDay = Number(dayEls[0].getAttribute("aria-valuenow"));
|
|
6857
|
+
var endMonth = Number(monthEls[1].getAttribute("aria-valuenow"));
|
|
6858
|
+
var endDay = Number(dayEls[1].getAttribute("aria-valuenow"));
|
|
6859
|
+
var valid = function (m, d) { return m >= 1 && m <= 12 && d >= 1 && d <= 31; };
|
|
6860
|
+
if (valid(startMonth, startDay) && valid(endMonth, endDay)) {
|
|
6861
|
+
handleRangeChange({
|
|
6862
|
+
start: new $35ea8db9cb2ccb90$export$99faa760c7908e4f(FILLER_YEAR, startMonth, startDay),
|
|
6863
|
+
end: new $35ea8db9cb2ccb90$export$99faa760c7908e4f(FILLER_YEAR, endMonth, endDay),
|
|
6864
|
+
});
|
|
6865
|
+
}
|
|
6866
|
+
};
|
|
6867
|
+
return (jsxRuntime.jsxs("div", { className: "w-full flex flex-wrap xs:gap-5 justify-between items-center", children: [jsxRuntime.jsxs(react.RadioGroup, { color: "primary", orientation: "horizontal", size: "sm", value: mode, onValueChange: handleModeChange, children: [jsxRuntime.jsx(react.Radio, { value: "single", children: t.dayMonthSingleOption }), jsxRuntime.jsx(react.Radio, { value: "range", children: t.dayMonthRangeOption })] }), mode === "single" ? (jsxRuntime.jsx("div", { ref: singleRef, children: jsxRuntime.jsx(DatePicker, { value: pickerValue, onChange: handleSingleChange, onFocusChange: handleSingleFocusChange, "aria-label": t.dayMonthAriaLabel, endContent: jsxRuntime.jsx(IconComponent, { icon: "solar:calendar-outline" }), className: "w-full md:w-auto md:max-w-40 ".concat(NO_YEAR_CLASS) }, "dmp") })) : (jsxRuntime.jsx("div", { ref: rangeRef, children: jsxRuntime.jsx(DateRangePicker, { value: rangeValue, onChange: handleRangeChange, onFocusChange: handleRangeFocusChange, "aria-label": t.dayMonthRangeAriaLabel, endContent: jsxRuntime.jsx(IconComponent, { icon: "solar:calendar-outline" }), className: "w-full md:w-auto md:max-w-xs ".concat(NO_YEAR_CLASS) }, "dmpr") }))] }));
|
|
6802
6868
|
};
|
|
6803
6869
|
|
|
6804
6870
|
/**
|
package/dist/index.esm.js
CHANGED
|
@@ -6767,6 +6767,33 @@ var DrawerFiltersHeader = function (_a) {
|
|
|
6767
6767
|
};
|
|
6768
6768
|
|
|
6769
6769
|
var NO_YEAR_CLASS = "[&_[data-type='year']]:hidden [&_[data-type='literal']:has(+[data-type='year'])]:hidden";
|
|
6770
|
+
// Year used to construct CalendarDate values. React Aria's onChange only fires when
|
|
6771
|
+
// ALL segments (including hidden year) are user-confirmed. Since users can't type year
|
|
6772
|
+
// (it's CSS-hidden), we read month+day directly from the DOM via data-placeholder
|
|
6773
|
+
// attributes when the picker loses focus, bypassing the year-confirmation requirement.
|
|
6774
|
+
var FILLER_YEAR = new Date().getFullYear();
|
|
6775
|
+
/**
|
|
6776
|
+
* Reads month and day from segment DOM elements.
|
|
6777
|
+
* Returns null if any segment is still in placeholder state (user hasn't typed it yet).
|
|
6778
|
+
* React Aria marks unconfirmed segments with data-placeholder="true".
|
|
6779
|
+
*/
|
|
6780
|
+
function readConfirmedMonthDay(container, monthSelector, daySelector) {
|
|
6781
|
+
if (monthSelector === void 0) { monthSelector = '[data-type="month"]'; }
|
|
6782
|
+
if (daySelector === void 0) { daySelector = '[data-type="day"]'; }
|
|
6783
|
+
var monthEl = container.querySelector(monthSelector);
|
|
6784
|
+
var dayEl = container.querySelector(daySelector);
|
|
6785
|
+
if (!monthEl || !dayEl)
|
|
6786
|
+
return null;
|
|
6787
|
+
if (monthEl.getAttribute("data-placeholder") === "true")
|
|
6788
|
+
return null;
|
|
6789
|
+
if (dayEl.getAttribute("data-placeholder") === "true")
|
|
6790
|
+
return null;
|
|
6791
|
+
var month = Number(monthEl.getAttribute("aria-valuenow"));
|
|
6792
|
+
var day = Number(dayEl.getAttribute("aria-valuenow"));
|
|
6793
|
+
if (month >= 1 && month <= 12 && day >= 1 && day <= 31)
|
|
6794
|
+
return { month: month, day: day };
|
|
6795
|
+
return null;
|
|
6796
|
+
}
|
|
6770
6797
|
var DayMonthPicker = function (_a) {
|
|
6771
6798
|
var value = _a.value, onChange = _a.onChange, translations = _a.translations;
|
|
6772
6799
|
var t = __assign({ dayMonthAriaLabel: "Seleccionar mes y día", dayMonthRangeAriaLabel: "Seleccionar rango de mes y día", dayMonthSingleOption: "Día específico", dayMonthRangeOption: "Rango de fechas" }, translations);
|
|
@@ -6774,6 +6801,17 @@ var DayMonthPicker = function (_a) {
|
|
|
6774
6801
|
useEffect(function () {
|
|
6775
6802
|
setMode((value === null || value === void 0 ? void 0 : value.type) === "dayMonthRange" ? "range" : "single");
|
|
6776
6803
|
}, [value === null || value === void 0 ? void 0 : value.type]);
|
|
6804
|
+
var pickerValue = (value === null || value === void 0 ? void 0 : value.type) === "dayMonth" ? value.dayMonth : null;
|
|
6805
|
+
var rangeValue = (value === null || value === void 0 ? void 0 : value.type) === "dayMonthRange" ? value.dayMonthRange : null;
|
|
6806
|
+
// Refs to DOM wrappers — used by the DOM-reading fallback for manual input.
|
|
6807
|
+
var singleRef = useRef(null);
|
|
6808
|
+
var rangeRef = useRef(null);
|
|
6809
|
+
// Stable refs so focus-change callbacks always read current values without
|
|
6810
|
+
// needing to be recreated on every render.
|
|
6811
|
+
var pickerValueRef = useRef(pickerValue);
|
|
6812
|
+
pickerValueRef.current = pickerValue;
|
|
6813
|
+
var rangeValueRef = useRef(rangeValue);
|
|
6814
|
+
rangeValueRef.current = rangeValue;
|
|
6777
6815
|
var handleModeChange = function (newMode) {
|
|
6778
6816
|
var nextMode = newMode === "range" ? "range" : "single";
|
|
6779
6817
|
setMode(nextMode);
|
|
@@ -6784,22 +6822,50 @@ var DayMonthPicker = function (_a) {
|
|
|
6784
6822
|
onChange({ type: "dayMonthRange", dayMonth: null, dayMonthRange: null });
|
|
6785
6823
|
};
|
|
6786
6824
|
var handleSingleChange = function (date) {
|
|
6787
|
-
onChange({
|
|
6788
|
-
type: "dayMonth",
|
|
6789
|
-
dayMonth: date,
|
|
6790
|
-
dayMonthRange: null,
|
|
6791
|
-
});
|
|
6825
|
+
onChange({ type: "dayMonth", dayMonth: date, dayMonthRange: null });
|
|
6792
6826
|
};
|
|
6793
6827
|
var handleRangeChange = function (range) {
|
|
6794
|
-
onChange({
|
|
6795
|
-
type: "dayMonthRange",
|
|
6796
|
-
dayMonth: null,
|
|
6797
|
-
dayMonthRange: range,
|
|
6798
|
-
});
|
|
6828
|
+
onChange({ type: "dayMonthRange", dayMonth: null, dayMonthRange: range });
|
|
6799
6829
|
};
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6830
|
+
// Called by React Aria when the DatePicker gains/loses focus.
|
|
6831
|
+
// When value=null (placeholder mode) React Aria never fires onChange because the
|
|
6832
|
+
// hidden year segment is never user-confirmed. On blur we read the confirmed
|
|
6833
|
+
// month/day directly from the DOM as a workaround.
|
|
6834
|
+
var handleSingleFocusChange = function (isFocused) {
|
|
6835
|
+
if (isFocused || pickerValueRef.current)
|
|
6836
|
+
return;
|
|
6837
|
+
if (!singleRef.current)
|
|
6838
|
+
return;
|
|
6839
|
+
var result = readConfirmedMonthDay(singleRef.current);
|
|
6840
|
+
if (result) {
|
|
6841
|
+
handleSingleChange(new $35ea8db9cb2ccb90$export$99faa760c7908e4f(FILLER_YEAR, result.month, result.day));
|
|
6842
|
+
}
|
|
6843
|
+
};
|
|
6844
|
+
var handleRangeFocusChange = function (isFocused) {
|
|
6845
|
+
if (isFocused || rangeValueRef.current)
|
|
6846
|
+
return;
|
|
6847
|
+
if (!rangeRef.current)
|
|
6848
|
+
return;
|
|
6849
|
+
var monthEls = rangeRef.current.querySelectorAll('[data-type="month"]');
|
|
6850
|
+
var dayEls = rangeRef.current.querySelectorAll('[data-type="day"]');
|
|
6851
|
+
if (monthEls.length < 2 || dayEls.length < 2)
|
|
6852
|
+
return;
|
|
6853
|
+
var allConfirmed = __spreadArray(__spreadArray([], monthEls, true), dayEls, true).every(function (el) { return el.getAttribute("data-placeholder") !== "true"; });
|
|
6854
|
+
if (!allConfirmed)
|
|
6855
|
+
return;
|
|
6856
|
+
var startMonth = Number(monthEls[0].getAttribute("aria-valuenow"));
|
|
6857
|
+
var startDay = Number(dayEls[0].getAttribute("aria-valuenow"));
|
|
6858
|
+
var endMonth = Number(monthEls[1].getAttribute("aria-valuenow"));
|
|
6859
|
+
var endDay = Number(dayEls[1].getAttribute("aria-valuenow"));
|
|
6860
|
+
var valid = function (m, d) { return m >= 1 && m <= 12 && d >= 1 && d <= 31; };
|
|
6861
|
+
if (valid(startMonth, startDay) && valid(endMonth, endDay)) {
|
|
6862
|
+
handleRangeChange({
|
|
6863
|
+
start: new $35ea8db9cb2ccb90$export$99faa760c7908e4f(FILLER_YEAR, startMonth, startDay),
|
|
6864
|
+
end: new $35ea8db9cb2ccb90$export$99faa760c7908e4f(FILLER_YEAR, endMonth, endDay),
|
|
6865
|
+
});
|
|
6866
|
+
}
|
|
6867
|
+
};
|
|
6868
|
+
return (jsxs("div", { className: "w-full flex flex-wrap xs:gap-5 justify-between items-center", children: [jsxs(RadioGroup, { color: "primary", orientation: "horizontal", size: "sm", value: mode, onValueChange: handleModeChange, children: [jsx(Radio, { value: "single", children: t.dayMonthSingleOption }), jsx(Radio, { value: "range", children: t.dayMonthRangeOption })] }), mode === "single" ? (jsx("div", { ref: singleRef, children: jsx(DatePicker, { value: pickerValue, onChange: handleSingleChange, onFocusChange: handleSingleFocusChange, "aria-label": t.dayMonthAriaLabel, endContent: jsx(IconComponent, { icon: "solar:calendar-outline" }), className: "w-full md:w-auto md:max-w-40 ".concat(NO_YEAR_CLASS) }, "dmp") })) : (jsx("div", { ref: rangeRef, children: jsx(DateRangePicker, { value: rangeValue, onChange: handleRangeChange, onFocusChange: handleRangeFocusChange, "aria-label": t.dayMonthRangeAriaLabel, endContent: jsx(IconComponent, { icon: "solar:calendar-outline" }), className: "w-full md:w-auto md:max-w-xs ".concat(NO_YEAR_CLASS) }, "dmpr") }))] }));
|
|
6803
6869
|
};
|
|
6804
6870
|
|
|
6805
6871
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DayMonthPicker.d.ts","sourceRoot":"","sources":["../../../../../src/components/drawer-filters/_internal/DayMonthPicker.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DayMonthPicker.d.ts","sourceRoot":"","sources":["../../../../../src/components/drawer-filters/_internal/DayMonthPicker.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAgCxE,UAAU,mBAAmB;IAC5B,IAAI,EAAE,UAAU,GAAG,eAAe,CAAC;IACnC,QAAQ,EAAE,SAAS,GAAG,IAAI,CAAC;IAC3B,aAAa,EAAE,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;CAC5C;AAED,UAAU,mBAAmB;IAC5B,KAAK,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACnC,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC/C,YAAY,CAAC,EAAE,yBAAyB,CAAC;CACzC;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAqIxD,CAAC"}
|