@schedule-x/date-picker
Advanced tools
Comparing version 1.41.1 to 1.41.2
'use strict'; | ||
var preact = require('preact'); | ||
var jsxRuntime = require('preact/jsx-runtime'); | ||
var hooks = require('preact/hooks'); | ||
@@ -8,4 +9,2 @@ var compat = require('preact/compat'); | ||
var f=0;function u(e,t,n,o,i,u){var a,c,p={};for(c in t)"ref"==c?a=t[c]:p[c]=t[c];var l={type:e,props:p,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--f,__i:-1,__u:0,__source:i,__self:u};if("function"==typeof e&&(a=e.defaultProps))for(c in a)void 0===p[c]&&(p[c]=a[c]);return preact.options.vnode&&preact.options.vnode(l),l} | ||
const AppContext = preact.createContext({}); | ||
@@ -144,3 +143,3 @@ | ||
}; | ||
return (u(preact.Fragment, { children: u("div", { className: wrapperClasses.join(' '), id: inputWrapperId, children: [u("label", { for: datePickerInputId, id: datePickerLabelId, className: "sx__date-input-label", children: $app.config.label || $app.translate('Date') }), u("input", { id: datePickerInputId, "aria-describedby": datePickerLabelId, value: $app.datePickerState.inputDisplayedValue.value, "data-testid": "date-picker-input", className: "sx__date-input", onClick: handleClick, onKeyUp: handleKeyUp, type: "text" }), u("button", { "aria-label": $app.translate('Choose Date'), onKeyDown: handleButtonKeyDown, className: "sx__date-input-chevron-wrapper", children: u("img", { className: "sx__date-input-chevron", src: img, alt: "" }) })] }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", { className: wrapperClasses.join(' '), id: inputWrapperId, children: [jsxRuntime.jsx("label", { for: datePickerInputId, id: datePickerLabelId, className: "sx__date-input-label", children: $app.config.label || $app.translate('Date') }), jsxRuntime.jsx("input", { id: datePickerInputId, "aria-describedby": datePickerLabelId, value: $app.datePickerState.inputDisplayedValue.value, "data-testid": "date-picker-input", className: "sx__date-input", onClick: handleClick, onKeyUp: handleKeyUp, type: "text" }), jsxRuntime.jsx("button", { "aria-label": $app.translate('Choose Date'), onKeyDown: handleButtonKeyDown, className: "sx__date-input-chevron-wrapper", children: jsxRuntime.jsx("img", { className: "sx__date-input-chevron", src: img, alt: "" }) })] }) })); | ||
} | ||
@@ -231,3 +230,3 @@ | ||
}; | ||
return (u("button", { disabled: disabled, className: "sx__chevron-wrapper sx__ripple", onMouseUp: onClick, onKeyDown: handleKeyDown, tabIndex: 0, children: u("i", { className: `sx__chevron sx__chevron--${direction}`, children: buttonText }) })); | ||
return (jsxRuntime.jsx("button", { disabled: disabled, className: "sx__chevron-wrapper sx__ripple", onMouseUp: onClick, onKeyDown: handleKeyDown, tabIndex: 0, children: jsxRuntime.jsx("i", { className: `sx__chevron sx__chevron--${direction}`, children: buttonText }) })); | ||
} | ||
@@ -260,3 +259,3 @@ | ||
}; | ||
return (u(preact.Fragment, { children: u("header", { className: "sx__date-picker__month-view-header", children: [u(Chevron, { direction: 'previous', onClick: () => setPreviousMonth(), buttonText: $app.translate('Previous month') }), u("button", { className: "sx__date-picker__month-view-header__month-year", onClick: (event) => handleOpenYearsView(event), children: selectedDateMonthName + ' ' + datePickerYear }), u(Chevron, { direction: 'next', onClick: () => setNextMonth(), buttonText: $app.translate('Next month') })] }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("header", { className: "sx__date-picker__month-view-header", children: [jsxRuntime.jsx(Chevron, { direction: 'previous', onClick: () => setPreviousMonth(), buttonText: $app.translate('Previous month') }), jsxRuntime.jsx("button", { className: "sx__date-picker__month-view-header__month-year", onClick: (event) => handleOpenYearsView(event), children: selectedDateMonthName + ' ' + datePickerYear }), jsxRuntime.jsx(Chevron, { direction: 'next', onClick: () => setNextMonth(), buttonText: $app.translate('Next month') })] }) })); | ||
} | ||
@@ -268,3 +267,3 @@ | ||
const dayNames = getOneLetterOrShortDayNames(aWeek, $app.config.locale); | ||
return (u("div", { className: "sx__date-picker__day-names", children: dayNames.map((dayName) => (u("span", { "data-testid": "day-name", className: "sx__date-picker__day-name", children: dayName }))) })); | ||
return (jsxRuntime.jsx("div", { className: "sx__date-picker__day-names", children: dayNames.map((dayName) => (jsxRuntime.jsx("span", { "data-testid": "day-name", className: "sx__date-picker__day-name", children: dayName }))) })); | ||
} | ||
@@ -346,3 +345,3 @@ | ||
}; | ||
return (u(preact.Fragment, { children: u("div", { "data-testid": DATE_PICKER_WEEK, className: "sx__date-picker__week", children: weekDays.map((weekDay) => (u("button", { tabIndex: hasFocus(weekDay) ? 0 : -1, disabled: !isDateSelectable(weekDay.day), "aria-label": getLocalizedDate($app.datePickerState.datePickerDate.value, $app.config.locale), className: weekDay.classes.join(' '), "data-focus": hasFocus(weekDay) ? 'true' : undefined, onClick: () => selectDate(weekDay.day), onKeyDown: handleKeyDown, children: weekDay.day.getDate() }))) }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("div", { "data-testid": DATE_PICKER_WEEK, className: "sx__date-picker__week", children: weekDays.map((weekDay) => (jsxRuntime.jsx("button", { tabIndex: hasFocus(weekDay) ? 0 : -1, disabled: !isDateSelectable(weekDay.day), "aria-label": getLocalizedDate($app.datePickerState.datePickerDate.value, $app.config.locale), className: weekDay.classes.join(' '), "data-focus": hasFocus(weekDay) ? 'true' : undefined, onClick: () => selectDate(weekDay.day), onKeyDown: handleKeyDown, children: weekDay.day.getDate() }))) }) })); | ||
} | ||
@@ -377,3 +376,3 @@ | ||
}, []); | ||
return (u(preact.Fragment, { children: u("div", { id: elementId, "data-testid": MONTH_VIEW, className: "sx__date-picker__month-view", children: [u(MonthViewHeader, { setYearsView: seatYearsView }), u(DayNames, {}), month.map((week) => (u(MonthViewWeek, { week: week })))] }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", { id: elementId, "data-testid": MONTH_VIEW, className: "sx__date-picker__month-view", children: [jsxRuntime.jsx(MonthViewHeader, { setYearsView: seatYearsView }), jsxRuntime.jsx(DayNames, {}), month.map((week) => (jsxRuntime.jsx(MonthViewWeek, { week: week })))] }) })); | ||
} | ||
@@ -388,3 +387,3 @@ | ||
}; | ||
return (u(preact.Fragment, { children: u("li", { className: isExpanded ? 'sx__is-expanded' : '', children: [u("button", { className: "sx__date-picker__years-accordion__expand-button sx__ripple--wide", onClick: () => expand(year), children: year }), isExpanded && (u("div", { className: "sx__date-picker__years-view-accordion__panel", children: yearWithDates.map((month) => (u("button", { className: "sx__date-picker__years-view-accordion__month", onClick: (event) => handleClickOnMonth(event, month), children: toLocalizedMonth(month, $app.config.locale) }))) }))] }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("li", { className: isExpanded ? 'sx__is-expanded' : '', children: [jsxRuntime.jsx("button", { className: "sx__date-picker__years-accordion__expand-button sx__ripple--wide", onClick: () => expand(year), children: year }), isExpanded && (jsxRuntime.jsx("div", { className: "sx__date-picker__years-view-accordion__panel", children: yearWithDates.map((month) => (jsxRuntime.jsx("button", { className: "sx__date-picker__years-view-accordion__month", onClick: (event) => handleClickOnMonth(event, month), children: toLocalizedMonth(month, $app.config.locale) }))) }))] }) })); | ||
} | ||
@@ -413,3 +412,3 @@ | ||
}, []); | ||
return (u(preact.Fragment, { children: u("ul", { className: "sx__date-picker__years-view", "data-testid": YEARS_VIEW, children: years.map((year) => (u(YearsViewAccordion, { year: year, setYearAndMonth: (year, month) => setNewDatePickerDate(year, month), isExpanded: expandedYear === year, expand: (year) => setExpandedYear(year) }))) }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("ul", { className: "sx__date-picker__years-view", "data-testid": YEARS_VIEW, children: years.map((year) => (jsxRuntime.jsx(YearsViewAccordion, { year: year, setYearAndMonth: (year, month) => setNewDatePickerDate(year, month), isExpanded: expandedYear === year, expand: (year) => setExpandedYear(year) }))) }) })); | ||
} | ||
@@ -484,3 +483,3 @@ | ||
}, []); | ||
return (u(preact.Fragment, { children: u("div", { style: $app.config.teleportTo ? fixedPositionStyle : undefined, "data-testid": "date-picker-popup", className: popupClasses.join(' '), children: datePickerView === DatePickerView.MONTH_DAYS ? (u(MonthView, { seatYearsView: () => setDatePickerView(DatePickerView.YEARS) })) : (u(YearsView, { setMonthView: () => setDatePickerView(DatePickerView.MONTH_DAYS) })) }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("div", { style: $app.config.teleportTo ? fixedPositionStyle : undefined, "data-testid": "date-picker-popup", className: popupClasses.join(' '), children: datePickerView === DatePickerView.MONTH_DAYS ? (jsxRuntime.jsx(MonthView, { seatYearsView: () => setDatePickerView(DatePickerView.YEARS) })) : (jsxRuntime.jsx(YearsView, { setMonthView: () => setDatePickerView(DatePickerView.MONTH_DAYS) })) }) })); | ||
} | ||
@@ -495,6 +494,6 @@ | ||
classes.push('has-full-width'); | ||
let appPopupJSX = u(AppPopup, {}); | ||
let appPopupJSX = jsxRuntime.jsx(AppPopup, {}); | ||
if ($app.config.teleportTo) | ||
appPopupJSX = compat.createPortal(appPopupJSX, $app.config.teleportTo); | ||
return (u(preact.Fragment, { children: u("div", { className: classes.join(' '), children: u(AppContext.Provider, { value: $app, children: [u(AppInput, {}), $app.datePickerState.isOpen.value && appPopupJSX] }) }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("div", { className: classes.join(' '), children: jsxRuntime.jsxs(AppContext.Provider, { value: $app, children: [jsxRuntime.jsx(AppInput, {}), $app.datePickerState.isOpen.value && appPopupJSX] }) }) })); | ||
} | ||
@@ -501,0 +500,0 @@ |
'use strict'; | ||
var preact = require('preact'); | ||
var jsxRuntime = require('preact/jsx-runtime'); | ||
var hooks = require('preact/hooks'); | ||
@@ -8,4 +9,2 @@ var compat = require('preact/compat'); | ||
var f=0;function u(e,t,n,o,i,u){var a,c,p={};for(c in t)"ref"==c?a=t[c]:p[c]=t[c];var l={type:e,props:p,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--f,__i:-1,__u:0,__source:i,__self:u};if("function"==typeof e&&(a=e.defaultProps))for(c in a)void 0===p[c]&&(p[c]=a[c]);return preact.options.vnode&&preact.options.vnode(l),l} | ||
const AppContext = preact.createContext({}); | ||
@@ -144,3 +143,3 @@ | ||
}; | ||
return (u(preact.Fragment, { children: u("div", { className: wrapperClasses.join(' '), id: inputWrapperId, children: [u("label", { for: datePickerInputId, id: datePickerLabelId, className: "sx__date-input-label", children: $app.config.label || $app.translate('Date') }), u("input", { id: datePickerInputId, "aria-describedby": datePickerLabelId, value: $app.datePickerState.inputDisplayedValue.value, "data-testid": "date-picker-input", className: "sx__date-input", onClick: handleClick, onKeyUp: handleKeyUp, type: "text" }), u("button", { "aria-label": $app.translate('Choose Date'), onKeyDown: handleButtonKeyDown, className: "sx__date-input-chevron-wrapper", children: u("img", { className: "sx__date-input-chevron", src: img, alt: "" }) })] }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", { className: wrapperClasses.join(' '), id: inputWrapperId, children: [jsxRuntime.jsx("label", { for: datePickerInputId, id: datePickerLabelId, className: "sx__date-input-label", children: $app.config.label || $app.translate('Date') }), jsxRuntime.jsx("input", { id: datePickerInputId, "aria-describedby": datePickerLabelId, value: $app.datePickerState.inputDisplayedValue.value, "data-testid": "date-picker-input", className: "sx__date-input", onClick: handleClick, onKeyUp: handleKeyUp, type: "text" }), jsxRuntime.jsx("button", { "aria-label": $app.translate('Choose Date'), onKeyDown: handleButtonKeyDown, className: "sx__date-input-chevron-wrapper", children: jsxRuntime.jsx("img", { className: "sx__date-input-chevron", src: img, alt: "" }) })] }) })); | ||
} | ||
@@ -231,3 +230,3 @@ | ||
}; | ||
return (u("button", { disabled: disabled, className: "sx__chevron-wrapper sx__ripple", onMouseUp: onClick, onKeyDown: handleKeyDown, tabIndex: 0, children: u("i", { className: `sx__chevron sx__chevron--${direction}`, children: buttonText }) })); | ||
return (jsxRuntime.jsx("button", { disabled: disabled, className: "sx__chevron-wrapper sx__ripple", onMouseUp: onClick, onKeyDown: handleKeyDown, tabIndex: 0, children: jsxRuntime.jsx("i", { className: `sx__chevron sx__chevron--${direction}`, children: buttonText }) })); | ||
} | ||
@@ -260,3 +259,3 @@ | ||
}; | ||
return (u(preact.Fragment, { children: u("header", { className: "sx__date-picker__month-view-header", children: [u(Chevron, { direction: 'previous', onClick: () => setPreviousMonth(), buttonText: $app.translate('Previous month') }), u("button", { className: "sx__date-picker__month-view-header__month-year", onClick: (event) => handleOpenYearsView(event), children: selectedDateMonthName + ' ' + datePickerYear }), u(Chevron, { direction: 'next', onClick: () => setNextMonth(), buttonText: $app.translate('Next month') })] }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("header", { className: "sx__date-picker__month-view-header", children: [jsxRuntime.jsx(Chevron, { direction: 'previous', onClick: () => setPreviousMonth(), buttonText: $app.translate('Previous month') }), jsxRuntime.jsx("button", { className: "sx__date-picker__month-view-header__month-year", onClick: (event) => handleOpenYearsView(event), children: selectedDateMonthName + ' ' + datePickerYear }), jsxRuntime.jsx(Chevron, { direction: 'next', onClick: () => setNextMonth(), buttonText: $app.translate('Next month') })] }) })); | ||
} | ||
@@ -268,3 +267,3 @@ | ||
const dayNames = getOneLetterOrShortDayNames(aWeek, $app.config.locale); | ||
return (u("div", { className: "sx__date-picker__day-names", children: dayNames.map((dayName) => (u("span", { "data-testid": "day-name", className: "sx__date-picker__day-name", children: dayName }))) })); | ||
return (jsxRuntime.jsx("div", { className: "sx__date-picker__day-names", children: dayNames.map((dayName) => (jsxRuntime.jsx("span", { "data-testid": "day-name", className: "sx__date-picker__day-name", children: dayName }))) })); | ||
} | ||
@@ -346,3 +345,3 @@ | ||
}; | ||
return (u(preact.Fragment, { children: u("div", { "data-testid": DATE_PICKER_WEEK, className: "sx__date-picker__week", children: weekDays.map((weekDay) => (u("button", { tabIndex: hasFocus(weekDay) ? 0 : -1, disabled: !isDateSelectable(weekDay.day), "aria-label": getLocalizedDate($app.datePickerState.datePickerDate.value, $app.config.locale), className: weekDay.classes.join(' '), "data-focus": hasFocus(weekDay) ? 'true' : undefined, onClick: () => selectDate(weekDay.day), onKeyDown: handleKeyDown, children: weekDay.day.getDate() }))) }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("div", { "data-testid": DATE_PICKER_WEEK, className: "sx__date-picker__week", children: weekDays.map((weekDay) => (jsxRuntime.jsx("button", { tabIndex: hasFocus(weekDay) ? 0 : -1, disabled: !isDateSelectable(weekDay.day), "aria-label": getLocalizedDate($app.datePickerState.datePickerDate.value, $app.config.locale), className: weekDay.classes.join(' '), "data-focus": hasFocus(weekDay) ? 'true' : undefined, onClick: () => selectDate(weekDay.day), onKeyDown: handleKeyDown, children: weekDay.day.getDate() }))) }) })); | ||
} | ||
@@ -377,3 +376,3 @@ | ||
}, []); | ||
return (u(preact.Fragment, { children: u("div", { id: elementId, "data-testid": MONTH_VIEW, className: "sx__date-picker__month-view", children: [u(MonthViewHeader, { setYearsView: seatYearsView }), u(DayNames, {}), month.map((week) => (u(MonthViewWeek, { week: week })))] }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", { id: elementId, "data-testid": MONTH_VIEW, className: "sx__date-picker__month-view", children: [jsxRuntime.jsx(MonthViewHeader, { setYearsView: seatYearsView }), jsxRuntime.jsx(DayNames, {}), month.map((week) => (jsxRuntime.jsx(MonthViewWeek, { week: week })))] }) })); | ||
} | ||
@@ -388,3 +387,3 @@ | ||
}; | ||
return (u(preact.Fragment, { children: u("li", { className: isExpanded ? 'sx__is-expanded' : '', children: [u("button", { className: "sx__date-picker__years-accordion__expand-button sx__ripple--wide", onClick: () => expand(year), children: year }), isExpanded && (u("div", { className: "sx__date-picker__years-view-accordion__panel", children: yearWithDates.map((month) => (u("button", { className: "sx__date-picker__years-view-accordion__month", onClick: (event) => handleClickOnMonth(event, month), children: toLocalizedMonth(month, $app.config.locale) }))) }))] }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("li", { className: isExpanded ? 'sx__is-expanded' : '', children: [jsxRuntime.jsx("button", { className: "sx__date-picker__years-accordion__expand-button sx__ripple--wide", onClick: () => expand(year), children: year }), isExpanded && (jsxRuntime.jsx("div", { className: "sx__date-picker__years-view-accordion__panel", children: yearWithDates.map((month) => (jsxRuntime.jsx("button", { className: "sx__date-picker__years-view-accordion__month", onClick: (event) => handleClickOnMonth(event, month), children: toLocalizedMonth(month, $app.config.locale) }))) }))] }) })); | ||
} | ||
@@ -413,3 +412,3 @@ | ||
}, []); | ||
return (u(preact.Fragment, { children: u("ul", { className: "sx__date-picker__years-view", "data-testid": YEARS_VIEW, children: years.map((year) => (u(YearsViewAccordion, { year: year, setYearAndMonth: (year, month) => setNewDatePickerDate(year, month), isExpanded: expandedYear === year, expand: (year) => setExpandedYear(year) }))) }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("ul", { className: "sx__date-picker__years-view", "data-testid": YEARS_VIEW, children: years.map((year) => (jsxRuntime.jsx(YearsViewAccordion, { year: year, setYearAndMonth: (year, month) => setNewDatePickerDate(year, month), isExpanded: expandedYear === year, expand: (year) => setExpandedYear(year) }))) }) })); | ||
} | ||
@@ -484,3 +483,3 @@ | ||
}, []); | ||
return (u(preact.Fragment, { children: u("div", { style: $app.config.teleportTo ? fixedPositionStyle : undefined, "data-testid": "date-picker-popup", className: popupClasses.join(' '), children: datePickerView === DatePickerView.MONTH_DAYS ? (u(MonthView, { seatYearsView: () => setDatePickerView(DatePickerView.YEARS) })) : (u(YearsView, { setMonthView: () => setDatePickerView(DatePickerView.MONTH_DAYS) })) }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("div", { style: $app.config.teleportTo ? fixedPositionStyle : undefined, "data-testid": "date-picker-popup", className: popupClasses.join(' '), children: datePickerView === DatePickerView.MONTH_DAYS ? (jsxRuntime.jsx(MonthView, { seatYearsView: () => setDatePickerView(DatePickerView.YEARS) })) : (jsxRuntime.jsx(YearsView, { setMonthView: () => setDatePickerView(DatePickerView.MONTH_DAYS) })) }) })); | ||
} | ||
@@ -495,6 +494,6 @@ | ||
classes.push('has-full-width'); | ||
let appPopupJSX = u(AppPopup, {}); | ||
let appPopupJSX = jsxRuntime.jsx(AppPopup, {}); | ||
if ($app.config.teleportTo) | ||
appPopupJSX = compat.createPortal(appPopupJSX, $app.config.teleportTo); | ||
return (u(preact.Fragment, { children: u("div", { className: classes.join(' '), children: u(AppContext.Provider, { value: $app, children: [u(AppInput, {}), $app.datePickerState.isOpen.value && appPopupJSX] }) }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("div", { className: classes.join(' '), children: jsxRuntime.jsxs(AppContext.Provider, { value: $app, children: [jsxRuntime.jsx(AppInput, {}), $app.datePickerState.isOpen.value && appPopupJSX] }) }) })); | ||
} | ||
@@ -501,0 +500,0 @@ |
@@ -1,2 +0,3 @@ | ||
import { options, createContext, Fragment, render, createElement } from 'preact'; | ||
import { createContext, render, createElement } from 'preact'; | ||
import { jsx, Fragment, jsxs } from 'preact/jsx-runtime'; | ||
import { useContext, useEffect, useState } from 'preact/hooks'; | ||
@@ -6,4 +7,2 @@ import { createPortal } from 'preact/compat'; | ||
var f=0;function u(e,t,n,o,i,u){var a,c,p={};for(c in t)"ref"==c?a=t[c]:p[c]=t[c];var l={type:e,props:p,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--f,__i:-1,__u:0,__source:i,__self:u};if("function"==typeof e&&(a=e.defaultProps))for(c in a)void 0===p[c]&&(p[c]=a[c]);return options.vnode&&options.vnode(l),l} | ||
const AppContext = createContext({}); | ||
@@ -142,3 +141,3 @@ | ||
}; | ||
return (u(Fragment, { children: u("div", { className: wrapperClasses.join(' '), id: inputWrapperId, children: [u("label", { for: datePickerInputId, id: datePickerLabelId, className: "sx__date-input-label", children: $app.config.label || $app.translate('Date') }), u("input", { id: datePickerInputId, "aria-describedby": datePickerLabelId, value: $app.datePickerState.inputDisplayedValue.value, "data-testid": "date-picker-input", className: "sx__date-input", onClick: handleClick, onKeyUp: handleKeyUp, type: "text" }), u("button", { "aria-label": $app.translate('Choose Date'), onKeyDown: handleButtonKeyDown, className: "sx__date-input-chevron-wrapper", children: u("img", { className: "sx__date-input-chevron", src: img, alt: "" }) })] }) })); | ||
return (jsx(Fragment, { children: jsxs("div", { className: wrapperClasses.join(' '), id: inputWrapperId, children: [jsx("label", { for: datePickerInputId, id: datePickerLabelId, className: "sx__date-input-label", children: $app.config.label || $app.translate('Date') }), jsx("input", { id: datePickerInputId, "aria-describedby": datePickerLabelId, value: $app.datePickerState.inputDisplayedValue.value, "data-testid": "date-picker-input", className: "sx__date-input", onClick: handleClick, onKeyUp: handleKeyUp, type: "text" }), jsx("button", { "aria-label": $app.translate('Choose Date'), onKeyDown: handleButtonKeyDown, className: "sx__date-input-chevron-wrapper", children: jsx("img", { className: "sx__date-input-chevron", src: img, alt: "" }) })] }) })); | ||
} | ||
@@ -229,3 +228,3 @@ | ||
}; | ||
return (u("button", { disabled: disabled, className: "sx__chevron-wrapper sx__ripple", onMouseUp: onClick, onKeyDown: handleKeyDown, tabIndex: 0, children: u("i", { className: `sx__chevron sx__chevron--${direction}`, children: buttonText }) })); | ||
return (jsx("button", { disabled: disabled, className: "sx__chevron-wrapper sx__ripple", onMouseUp: onClick, onKeyDown: handleKeyDown, tabIndex: 0, children: jsx("i", { className: `sx__chevron sx__chevron--${direction}`, children: buttonText }) })); | ||
} | ||
@@ -258,3 +257,3 @@ | ||
}; | ||
return (u(Fragment, { children: u("header", { className: "sx__date-picker__month-view-header", children: [u(Chevron, { direction: 'previous', onClick: () => setPreviousMonth(), buttonText: $app.translate('Previous month') }), u("button", { className: "sx__date-picker__month-view-header__month-year", onClick: (event) => handleOpenYearsView(event), children: selectedDateMonthName + ' ' + datePickerYear }), u(Chevron, { direction: 'next', onClick: () => setNextMonth(), buttonText: $app.translate('Next month') })] }) })); | ||
return (jsx(Fragment, { children: jsxs("header", { className: "sx__date-picker__month-view-header", children: [jsx(Chevron, { direction: 'previous', onClick: () => setPreviousMonth(), buttonText: $app.translate('Previous month') }), jsx("button", { className: "sx__date-picker__month-view-header__month-year", onClick: (event) => handleOpenYearsView(event), children: selectedDateMonthName + ' ' + datePickerYear }), jsx(Chevron, { direction: 'next', onClick: () => setNextMonth(), buttonText: $app.translate('Next month') })] }) })); | ||
} | ||
@@ -266,3 +265,3 @@ | ||
const dayNames = getOneLetterOrShortDayNames(aWeek, $app.config.locale); | ||
return (u("div", { className: "sx__date-picker__day-names", children: dayNames.map((dayName) => (u("span", { "data-testid": "day-name", className: "sx__date-picker__day-name", children: dayName }))) })); | ||
return (jsx("div", { className: "sx__date-picker__day-names", children: dayNames.map((dayName) => (jsx("span", { "data-testid": "day-name", className: "sx__date-picker__day-name", children: dayName }))) })); | ||
} | ||
@@ -344,3 +343,3 @@ | ||
}; | ||
return (u(Fragment, { children: u("div", { "data-testid": DATE_PICKER_WEEK, className: "sx__date-picker__week", children: weekDays.map((weekDay) => (u("button", { tabIndex: hasFocus(weekDay) ? 0 : -1, disabled: !isDateSelectable(weekDay.day), "aria-label": getLocalizedDate($app.datePickerState.datePickerDate.value, $app.config.locale), className: weekDay.classes.join(' '), "data-focus": hasFocus(weekDay) ? 'true' : undefined, onClick: () => selectDate(weekDay.day), onKeyDown: handleKeyDown, children: weekDay.day.getDate() }))) }) })); | ||
return (jsx(Fragment, { children: jsx("div", { "data-testid": DATE_PICKER_WEEK, className: "sx__date-picker__week", children: weekDays.map((weekDay) => (jsx("button", { tabIndex: hasFocus(weekDay) ? 0 : -1, disabled: !isDateSelectable(weekDay.day), "aria-label": getLocalizedDate($app.datePickerState.datePickerDate.value, $app.config.locale), className: weekDay.classes.join(' '), "data-focus": hasFocus(weekDay) ? 'true' : undefined, onClick: () => selectDate(weekDay.day), onKeyDown: handleKeyDown, children: weekDay.day.getDate() }))) }) })); | ||
} | ||
@@ -375,3 +374,3 @@ | ||
}, []); | ||
return (u(Fragment, { children: u("div", { id: elementId, "data-testid": MONTH_VIEW, className: "sx__date-picker__month-view", children: [u(MonthViewHeader, { setYearsView: seatYearsView }), u(DayNames, {}), month.map((week) => (u(MonthViewWeek, { week: week })))] }) })); | ||
return (jsx(Fragment, { children: jsxs("div", { id: elementId, "data-testid": MONTH_VIEW, className: "sx__date-picker__month-view", children: [jsx(MonthViewHeader, { setYearsView: seatYearsView }), jsx(DayNames, {}), month.map((week) => (jsx(MonthViewWeek, { week: week })))] }) })); | ||
} | ||
@@ -386,3 +385,3 @@ | ||
}; | ||
return (u(Fragment, { children: u("li", { className: isExpanded ? 'sx__is-expanded' : '', children: [u("button", { className: "sx__date-picker__years-accordion__expand-button sx__ripple--wide", onClick: () => expand(year), children: year }), isExpanded && (u("div", { className: "sx__date-picker__years-view-accordion__panel", children: yearWithDates.map((month) => (u("button", { className: "sx__date-picker__years-view-accordion__month", onClick: (event) => handleClickOnMonth(event, month), children: toLocalizedMonth(month, $app.config.locale) }))) }))] }) })); | ||
return (jsx(Fragment, { children: jsxs("li", { className: isExpanded ? 'sx__is-expanded' : '', children: [jsx("button", { className: "sx__date-picker__years-accordion__expand-button sx__ripple--wide", onClick: () => expand(year), children: year }), isExpanded && (jsx("div", { className: "sx__date-picker__years-view-accordion__panel", children: yearWithDates.map((month) => (jsx("button", { className: "sx__date-picker__years-view-accordion__month", onClick: (event) => handleClickOnMonth(event, month), children: toLocalizedMonth(month, $app.config.locale) }))) }))] }) })); | ||
} | ||
@@ -411,3 +410,3 @@ | ||
}, []); | ||
return (u(Fragment, { children: u("ul", { className: "sx__date-picker__years-view", "data-testid": YEARS_VIEW, children: years.map((year) => (u(YearsViewAccordion, { year: year, setYearAndMonth: (year, month) => setNewDatePickerDate(year, month), isExpanded: expandedYear === year, expand: (year) => setExpandedYear(year) }))) }) })); | ||
return (jsx(Fragment, { children: jsx("ul", { className: "sx__date-picker__years-view", "data-testid": YEARS_VIEW, children: years.map((year) => (jsx(YearsViewAccordion, { year: year, setYearAndMonth: (year, month) => setNewDatePickerDate(year, month), isExpanded: expandedYear === year, expand: (year) => setExpandedYear(year) }))) }) })); | ||
} | ||
@@ -482,3 +481,3 @@ | ||
}, []); | ||
return (u(Fragment, { children: u("div", { style: $app.config.teleportTo ? fixedPositionStyle : undefined, "data-testid": "date-picker-popup", className: popupClasses.join(' '), children: datePickerView === DatePickerView.MONTH_DAYS ? (u(MonthView, { seatYearsView: () => setDatePickerView(DatePickerView.YEARS) })) : (u(YearsView, { setMonthView: () => setDatePickerView(DatePickerView.MONTH_DAYS) })) }) })); | ||
return (jsx(Fragment, { children: jsx("div", { style: $app.config.teleportTo ? fixedPositionStyle : undefined, "data-testid": "date-picker-popup", className: popupClasses.join(' '), children: datePickerView === DatePickerView.MONTH_DAYS ? (jsx(MonthView, { seatYearsView: () => setDatePickerView(DatePickerView.YEARS) })) : (jsx(YearsView, { setMonthView: () => setDatePickerView(DatePickerView.MONTH_DAYS) })) }) })); | ||
} | ||
@@ -493,6 +492,6 @@ | ||
classes.push('has-full-width'); | ||
let appPopupJSX = u(AppPopup, {}); | ||
let appPopupJSX = jsx(AppPopup, {}); | ||
if ($app.config.teleportTo) | ||
appPopupJSX = createPortal(appPopupJSX, $app.config.teleportTo); | ||
return (u(Fragment, { children: u("div", { className: classes.join(' '), children: u(AppContext.Provider, { value: $app, children: [u(AppInput, {}), $app.datePickerState.isOpen.value && appPopupJSX] }) }) })); | ||
return (jsx(Fragment, { children: jsx("div", { className: classes.join(' '), children: jsxs(AppContext.Provider, { value: $app, children: [jsx(AppInput, {}), $app.datePickerState.isOpen.value && appPopupJSX] }) }) })); | ||
} | ||
@@ -499,0 +498,0 @@ |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('preact'), require('preact/hooks'), require('preact/compat'), require('@preact/signals')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'preact', 'preact/hooks', 'preact/compat', '@preact/signals'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@schedule-x/date-picker"] = {}, global.preact, global.hooks, global.compat, global.signals)); | ||
})(this, (function (exports, preact, hooks, compat, signals) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('preact'), require('preact/jsx-runtime'), require('preact/hooks'), require('preact/compat'), require('@preact/signals')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'preact', 'preact/jsx-runtime', 'preact/hooks', 'preact/compat', '@preact/signals'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@schedule-x/date-picker"] = {}, global.preact, global.jsxRuntime, global.hooks, global.compat, global.signals)); | ||
})(this, (function (exports, preact, jsxRuntime, hooks, compat, signals) { 'use strict'; | ||
var f=0;function u(e,t,n,o,i,u){var a,c,p={};for(c in t)"ref"==c?a=t[c]:p[c]=t[c];var l={type:e,props:p,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--f,__i:-1,__u:0,__source:i,__self:u};if("function"==typeof e&&(a=e.defaultProps))for(c in a)void 0===p[c]&&(p[c]=a[c]);return preact.options.vnode&&preact.options.vnode(l),l} | ||
const AppContext = preact.createContext({}); | ||
@@ -142,3 +140,3 @@ | ||
}; | ||
return (u(preact.Fragment, { children: u("div", { className: wrapperClasses.join(' '), id: inputWrapperId, children: [u("label", { for: datePickerInputId, id: datePickerLabelId, className: "sx__date-input-label", children: $app.config.label || $app.translate('Date') }), u("input", { id: datePickerInputId, "aria-describedby": datePickerLabelId, value: $app.datePickerState.inputDisplayedValue.value, "data-testid": "date-picker-input", className: "sx__date-input", onClick: handleClick, onKeyUp: handleKeyUp, type: "text" }), u("button", { "aria-label": $app.translate('Choose Date'), onKeyDown: handleButtonKeyDown, className: "sx__date-input-chevron-wrapper", children: u("img", { className: "sx__date-input-chevron", src: img, alt: "" }) })] }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", { className: wrapperClasses.join(' '), id: inputWrapperId, children: [jsxRuntime.jsx("label", { for: datePickerInputId, id: datePickerLabelId, className: "sx__date-input-label", children: $app.config.label || $app.translate('Date') }), jsxRuntime.jsx("input", { id: datePickerInputId, "aria-describedby": datePickerLabelId, value: $app.datePickerState.inputDisplayedValue.value, "data-testid": "date-picker-input", className: "sx__date-input", onClick: handleClick, onKeyUp: handleKeyUp, type: "text" }), jsxRuntime.jsx("button", { "aria-label": $app.translate('Choose Date'), onKeyDown: handleButtonKeyDown, className: "sx__date-input-chevron-wrapper", children: jsxRuntime.jsx("img", { className: "sx__date-input-chevron", src: img, alt: "" }) })] }) })); | ||
} | ||
@@ -229,3 +227,3 @@ | ||
}; | ||
return (u("button", { disabled: disabled, className: "sx__chevron-wrapper sx__ripple", onMouseUp: onClick, onKeyDown: handleKeyDown, tabIndex: 0, children: u("i", { className: `sx__chevron sx__chevron--${direction}`, children: buttonText }) })); | ||
return (jsxRuntime.jsx("button", { disabled: disabled, className: "sx__chevron-wrapper sx__ripple", onMouseUp: onClick, onKeyDown: handleKeyDown, tabIndex: 0, children: jsxRuntime.jsx("i", { className: `sx__chevron sx__chevron--${direction}`, children: buttonText }) })); | ||
} | ||
@@ -258,3 +256,3 @@ | ||
}; | ||
return (u(preact.Fragment, { children: u("header", { className: "sx__date-picker__month-view-header", children: [u(Chevron, { direction: 'previous', onClick: () => setPreviousMonth(), buttonText: $app.translate('Previous month') }), u("button", { className: "sx__date-picker__month-view-header__month-year", onClick: (event) => handleOpenYearsView(event), children: selectedDateMonthName + ' ' + datePickerYear }), u(Chevron, { direction: 'next', onClick: () => setNextMonth(), buttonText: $app.translate('Next month') })] }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("header", { className: "sx__date-picker__month-view-header", children: [jsxRuntime.jsx(Chevron, { direction: 'previous', onClick: () => setPreviousMonth(), buttonText: $app.translate('Previous month') }), jsxRuntime.jsx("button", { className: "sx__date-picker__month-view-header__month-year", onClick: (event) => handleOpenYearsView(event), children: selectedDateMonthName + ' ' + datePickerYear }), jsxRuntime.jsx(Chevron, { direction: 'next', onClick: () => setNextMonth(), buttonText: $app.translate('Next month') })] }) })); | ||
} | ||
@@ -266,3 +264,3 @@ | ||
const dayNames = getOneLetterOrShortDayNames(aWeek, $app.config.locale); | ||
return (u("div", { className: "sx__date-picker__day-names", children: dayNames.map((dayName) => (u("span", { "data-testid": "day-name", className: "sx__date-picker__day-name", children: dayName }))) })); | ||
return (jsxRuntime.jsx("div", { className: "sx__date-picker__day-names", children: dayNames.map((dayName) => (jsxRuntime.jsx("span", { "data-testid": "day-name", className: "sx__date-picker__day-name", children: dayName }))) })); | ||
} | ||
@@ -344,3 +342,3 @@ | ||
}; | ||
return (u(preact.Fragment, { children: u("div", { "data-testid": DATE_PICKER_WEEK, className: "sx__date-picker__week", children: weekDays.map((weekDay) => (u("button", { tabIndex: hasFocus(weekDay) ? 0 : -1, disabled: !isDateSelectable(weekDay.day), "aria-label": getLocalizedDate($app.datePickerState.datePickerDate.value, $app.config.locale), className: weekDay.classes.join(' '), "data-focus": hasFocus(weekDay) ? 'true' : undefined, onClick: () => selectDate(weekDay.day), onKeyDown: handleKeyDown, children: weekDay.day.getDate() }))) }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("div", { "data-testid": DATE_PICKER_WEEK, className: "sx__date-picker__week", children: weekDays.map((weekDay) => (jsxRuntime.jsx("button", { tabIndex: hasFocus(weekDay) ? 0 : -1, disabled: !isDateSelectable(weekDay.day), "aria-label": getLocalizedDate($app.datePickerState.datePickerDate.value, $app.config.locale), className: weekDay.classes.join(' '), "data-focus": hasFocus(weekDay) ? 'true' : undefined, onClick: () => selectDate(weekDay.day), onKeyDown: handleKeyDown, children: weekDay.day.getDate() }))) }) })); | ||
} | ||
@@ -375,3 +373,3 @@ | ||
}, []); | ||
return (u(preact.Fragment, { children: u("div", { id: elementId, "data-testid": MONTH_VIEW, className: "sx__date-picker__month-view", children: [u(MonthViewHeader, { setYearsView: seatYearsView }), u(DayNames, {}), month.map((week) => (u(MonthViewWeek, { week: week })))] }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", { id: elementId, "data-testid": MONTH_VIEW, className: "sx__date-picker__month-view", children: [jsxRuntime.jsx(MonthViewHeader, { setYearsView: seatYearsView }), jsxRuntime.jsx(DayNames, {}), month.map((week) => (jsxRuntime.jsx(MonthViewWeek, { week: week })))] }) })); | ||
} | ||
@@ -386,3 +384,3 @@ | ||
}; | ||
return (u(preact.Fragment, { children: u("li", { className: isExpanded ? 'sx__is-expanded' : '', children: [u("button", { className: "sx__date-picker__years-accordion__expand-button sx__ripple--wide", onClick: () => expand(year), children: year }), isExpanded && (u("div", { className: "sx__date-picker__years-view-accordion__panel", children: yearWithDates.map((month) => (u("button", { className: "sx__date-picker__years-view-accordion__month", onClick: (event) => handleClickOnMonth(event, month), children: toLocalizedMonth(month, $app.config.locale) }))) }))] }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("li", { className: isExpanded ? 'sx__is-expanded' : '', children: [jsxRuntime.jsx("button", { className: "sx__date-picker__years-accordion__expand-button sx__ripple--wide", onClick: () => expand(year), children: year }), isExpanded && (jsxRuntime.jsx("div", { className: "sx__date-picker__years-view-accordion__panel", children: yearWithDates.map((month) => (jsxRuntime.jsx("button", { className: "sx__date-picker__years-view-accordion__month", onClick: (event) => handleClickOnMonth(event, month), children: toLocalizedMonth(month, $app.config.locale) }))) }))] }) })); | ||
} | ||
@@ -411,3 +409,3 @@ | ||
}, []); | ||
return (u(preact.Fragment, { children: u("ul", { className: "sx__date-picker__years-view", "data-testid": YEARS_VIEW, children: years.map((year) => (u(YearsViewAccordion, { year: year, setYearAndMonth: (year, month) => setNewDatePickerDate(year, month), isExpanded: expandedYear === year, expand: (year) => setExpandedYear(year) }))) }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("ul", { className: "sx__date-picker__years-view", "data-testid": YEARS_VIEW, children: years.map((year) => (jsxRuntime.jsx(YearsViewAccordion, { year: year, setYearAndMonth: (year, month) => setNewDatePickerDate(year, month), isExpanded: expandedYear === year, expand: (year) => setExpandedYear(year) }))) }) })); | ||
} | ||
@@ -482,3 +480,3 @@ | ||
}, []); | ||
return (u(preact.Fragment, { children: u("div", { style: $app.config.teleportTo ? fixedPositionStyle : undefined, "data-testid": "date-picker-popup", className: popupClasses.join(' '), children: datePickerView === DatePickerView.MONTH_DAYS ? (u(MonthView, { seatYearsView: () => setDatePickerView(DatePickerView.YEARS) })) : (u(YearsView, { setMonthView: () => setDatePickerView(DatePickerView.MONTH_DAYS) })) }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("div", { style: $app.config.teleportTo ? fixedPositionStyle : undefined, "data-testid": "date-picker-popup", className: popupClasses.join(' '), children: datePickerView === DatePickerView.MONTH_DAYS ? (jsxRuntime.jsx(MonthView, { seatYearsView: () => setDatePickerView(DatePickerView.YEARS) })) : (jsxRuntime.jsx(YearsView, { setMonthView: () => setDatePickerView(DatePickerView.MONTH_DAYS) })) }) })); | ||
} | ||
@@ -493,6 +491,6 @@ | ||
classes.push('has-full-width'); | ||
let appPopupJSX = u(AppPopup, {}); | ||
let appPopupJSX = jsxRuntime.jsx(AppPopup, {}); | ||
if ($app.config.teleportTo) | ||
appPopupJSX = compat.createPortal(appPopupJSX, $app.config.teleportTo); | ||
return (u(preact.Fragment, { children: u("div", { className: classes.join(' '), children: u(AppContext.Provider, { value: $app, children: [u(AppInput, {}), $app.datePickerState.isOpen.value && appPopupJSX] }) }) })); | ||
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("div", { className: classes.join(' '), children: jsxRuntime.jsxs(AppContext.Provider, { value: $app, children: [jsxRuntime.jsx(AppInput, {}), $app.datePickerState.isOpen.value && appPopupJSX] }) }) })); | ||
} | ||
@@ -499,0 +497,0 @@ |
{ | ||
"name": "@schedule-x/date-picker", | ||
"version": "1.41.1", | ||
"version": "1.41.2", | ||
"description": "Schedule-X date picker component", | ||
@@ -34,3 +34,3 @@ "author": { | ||
"homepage": "https://schedule-x.dev", | ||
"gitHead": "39207d1d1bf751cf5c21945ca69604d78d06f6a9" | ||
"gitHead": "7a6909e2f46441f004b724ead7f91a5c25f3b522" | ||
} |
237856
6390