@ukic/canary-web-components 2.0.0-canary.37 → 2.0.0-canary.39
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/cjs/core.cjs.js +1 -1
- package/dist/cjs/ic-data-table.cjs.entry.js +6 -2
- package/dist/cjs/ic-data-table.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-date-picker.cjs.entry.js +110 -57
- package/dist/cjs/ic-date-picker.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-navigation-group.cjs.entry.js +9 -0
- package/dist/cjs/ic-navigation-group.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-radio-option.cjs.entry.js +1 -1
- package/dist/cjs/ic-radio-option.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-tree-item.cjs.entry.js +1 -1
- package/dist/cjs/ic-tree-item.cjs.entry.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/ic-card-horizontal/ic-card-horizontal.stories.js +605 -0
- package/dist/collection/components/ic-card-horizontal/ic-card-horizontal.stories.js.map +1 -0
- package/dist/collection/components/ic-data-table/ic-data-table.js +6 -2
- package/dist/collection/components/ic-data-table/ic-data-table.js.map +1 -1
- package/dist/collection/components/ic-data-table/ic-data-table.stories.js +414 -0
- package/dist/collection/components/ic-data-table/ic-data-table.stories.js.map +1 -0
- package/dist/collection/components/ic-data-table/story-data.js +155 -0
- package/dist/collection/components/ic-data-table/story-data.js.map +1 -1
- package/dist/collection/components/ic-data-table-title-bar/ic-data-table-title-bar.stories.js +98 -0
- package/dist/collection/components/ic-data-table-title-bar/ic-data-table-title-bar.stories.js.map +1 -0
- package/dist/collection/components/ic-date-input/ic-date-input.stories.js +341 -0
- package/dist/collection/components/ic-date-input/ic-date-input.stories.js.map +1 -0
- package/dist/collection/components/ic-date-picker/ic-date-picker.css +10 -3
- package/dist/collection/components/ic-date-picker/ic-date-picker.js +152 -57
- package/dist/collection/components/ic-date-picker/ic-date-picker.js.map +1 -1
- package/dist/collection/components/ic-date-picker/ic-date-picker.stories.js +167 -0
- package/dist/collection/components/ic-date-picker/ic-date-picker.stories.js.map +1 -0
- package/dist/collection/components/ic-date-picker/story-data.js +34 -3
- package/dist/collection/components/ic-date-picker/story-data.js.map +1 -1
- package/dist/collection/components/ic-pagination-bar/ic-pagination-bar.stories.js +260 -0
- package/dist/collection/components/ic-pagination-bar/ic-pagination-bar.stories.js.map +1 -0
- package/dist/collection/components/ic-select-with-multi/ic-select-multi.stories.js +144 -0
- package/dist/collection/components/ic-select-with-multi/ic-select-multi.stories.js.map +1 -0
- package/dist/collection/components/ic-tree-item/ic-tree-item.css +22 -3
- package/dist/collection/components/ic-tree-view/ic-tree-view.stories.js +456 -0
- package/dist/collection/components/ic-tree-view/ic-tree-view.stories.js.map +1 -0
- package/dist/components/ic-data-table.js +6 -2
- package/dist/components/ic-data-table.js.map +1 -1
- package/dist/components/ic-date-picker.js +112 -57
- package/dist/components/ic-date-picker.js.map +1 -1
- package/dist/components/ic-navigation-group.js +11 -2
- package/dist/components/ic-navigation-group.js.map +1 -1
- package/dist/components/ic-radio-option.js +1 -1
- package/dist/components/ic-radio-option.js.map +1 -1
- package/dist/components/ic-tree-item.js +1 -1
- package/dist/components/ic-tree-item.js.map +1 -1
- package/dist/core/core.esm.js +1 -1
- package/dist/core/core.esm.js.map +1 -1
- package/dist/core/p-04fe848d.entry.js +2 -0
- package/dist/core/p-04fe848d.entry.js.map +1 -0
- package/dist/core/{p-b4f824a6.entry.js → p-3ebd4703.entry.js} +2 -2
- package/dist/core/p-3ebd4703.entry.js.map +1 -0
- package/dist/core/p-bd0328f3.entry.js +2 -0
- package/dist/core/p-bd0328f3.entry.js.map +1 -0
- package/dist/core/p-cc0e0b46.entry.js +2 -0
- package/dist/core/p-cc0e0b46.entry.js.map +1 -0
- package/dist/core/p-fac387e8.entry.js +2 -0
- package/dist/core/p-fac387e8.entry.js.map +1 -0
- package/dist/esm/core.js +1 -1
- package/dist/esm/ic-data-table.entry.js +6 -2
- package/dist/esm/ic-data-table.entry.js.map +1 -1
- package/dist/esm/ic-date-picker.entry.js +110 -57
- package/dist/esm/ic-date-picker.entry.js.map +1 -1
- package/dist/esm/ic-navigation-group.entry.js +10 -1
- package/dist/esm/ic-navigation-group.entry.js.map +1 -1
- package/dist/esm/ic-radio-option.entry.js +1 -1
- package/dist/esm/ic-radio-option.entry.js.map +1 -1
- package/dist/esm/ic-tree-item.entry.js +1 -1
- package/dist/esm/ic-tree-item.entry.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/ic-card-horizontal/ic-card-horizontal.stories.d.ts +82 -0
- package/dist/types/components/ic-data-table/ic-data-table.stories.d.ts +239 -0
- package/dist/types/components/ic-data-table/story-data.d.ts +57 -0
- package/dist/types/components/ic-data-table-title-bar/ic-data-table-title-bar.stories.d.ts +47 -0
- package/dist/types/components/ic-date-input/ic-date-input.stories.d.ts +124 -0
- package/dist/types/components/ic-date-picker/ic-date-picker.d.ts +18 -1
- package/dist/types/components/ic-date-picker/ic-date-picker.stories.d.ts +153 -0
- package/dist/types/components/ic-date-picker/story-data.d.ts +2 -0
- package/dist/types/components/ic-pagination-bar/ic-pagination-bar.stories.d.ts +106 -0
- package/dist/types/components/ic-select-with-multi/ic-select-multi.stories.d.ts +106 -0
- package/dist/types/components/ic-tree-view/ic-tree-view.stories.d.ts +99 -0
- package/dist/types/components.d.ts +13 -0
- package/hydrate/index.js +129 -62
- package/package.json +12 -12
- package/dist/core/p-4084bce2.entry.js +0 -2
- package/dist/core/p-4084bce2.entry.js.map +0 -1
- package/dist/core/p-71bbb583.entry.js +0 -2
- package/dist/core/p-71bbb583.entry.js.map +0 -1
- package/dist/core/p-89112e37.entry.js +0 -2
- package/dist/core/p-89112e37.entry.js.map +0 -1
- package/dist/core/p-b4f824a6.entry.js.map +0 -1
- package/dist/core/p-fe105ed0.entry.js +0 -2
- package/dist/core/p-fe105ed0.entry.js.map +0 -1
@@ -118,7 +118,7 @@ const YearPicker = ({ decadeView, size, focussedYear, yearInView, onSelectYear,
|
|
118
118
|
index.h("path", { d: "M11.3333 5.33341H3.21996L6.94663 1.60675L5.99996 0.666748L0.666626 6.00008L5.99996 11.3334L6.93996 10.3934L3.21996 6.66675H11.3333V5.33341Z", fill: "currentColor" }))))));
|
119
119
|
};
|
120
120
|
|
121
|
-
const icDatePickerCss = "/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%;}body{margin:0}main{display:block}h1{font-size:2em;margin:0.67em 0}hr{box-sizing:content-box;height:0;overflow:visible;}pre{font-family:monospace, monospace;font-size:1em;}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace, monospace;font-size:1em;}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0;}button,input{overflow:visible}button,select{text-transform:none}button,[type=\"button\"],[type=\"reset\"],[type=\"submit\"]{-webkit-appearance:button}button::-moz-focus-inner,[type=\"button\"]::-moz-focus-inner,[type=\"reset\"]::-moz-focus-inner,[type=\"submit\"]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type=\"button\"]:-moz-focusring,[type=\"reset\"]:-moz-focusring,[type=\"submit\"]:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:0.35em 0.75em 0.625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal;}progress{vertical-align:baseline}textarea{overflow:auto}[type=\"checkbox\"],[type=\"radio\"]{box-sizing:border-box;padding:0;}[type=\"number\"]::-webkit-inner-spin-button,[type=\"number\"]::-webkit-outer-spin-button{height:auto}[type=\"search\"]{-webkit-appearance:textfield;outline-offset:-2px;}[type=\"search\"]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit;}details{display:block}summary{display:list-item}template{display:none}[hidden]{display:none}html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font-style:inherit;vertical-align:baseline}:host{display:block;position:relative;--month-year-picker-button-width:5rem;--month-button-width:5.5rem;--input-field-width:var(--input-width, 19.125rem)}:host(.large){--month-button-width:6.3125rem;--input-field-width:var(--input-width, 21.125rem)}:host(.small){--month-button-width:6.25rem;--input-field-width:var(--input-width, 17.125rem)}:host .date-input-container{position:relative}ic-date-input{--input-width:var(--input-field-width)}:host .calendar-container{min-width:19rem;max-width:23.5rem;width:var(--input-width);display:flex;flex-direction:column;gap:var(--ic-space-xs);position:absolute;
|
121
|
+
const icDatePickerCss = "/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%;}body{margin:0}main{display:block}h1{font-size:2em;margin:0.67em 0}hr{box-sizing:content-box;height:0;overflow:visible;}pre{font-family:monospace, monospace;font-size:1em;}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace, monospace;font-size:1em;}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0;}button,input{overflow:visible}button,select{text-transform:none}button,[type=\"button\"],[type=\"reset\"],[type=\"submit\"]{-webkit-appearance:button}button::-moz-focus-inner,[type=\"button\"]::-moz-focus-inner,[type=\"reset\"]::-moz-focus-inner,[type=\"submit\"]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type=\"button\"]:-moz-focusring,[type=\"reset\"]:-moz-focusring,[type=\"submit\"]:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:0.35em 0.75em 0.625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal;}progress{vertical-align:baseline}textarea{overflow:auto}[type=\"checkbox\"],[type=\"radio\"]{box-sizing:border-box;padding:0;}[type=\"number\"]::-webkit-inner-spin-button,[type=\"number\"]::-webkit-outer-spin-button{height:auto}[type=\"search\"]{-webkit-appearance:textfield;outline-offset:-2px;}[type=\"search\"]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit;}details{display:block}summary{display:list-item}template{display:none}[hidden]{display:none}html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font-style:inherit;vertical-align:baseline}:host{display:block;position:relative;--month-year-picker-button-width:5rem;--month-button-width:5.5rem;--input-field-width:var(--input-width, 19.125rem)}:host(.large){--month-button-width:6.3125rem;--input-field-width:var(--input-width, 21.125rem)}:host(.small){--month-button-width:6.25rem;--input-field-width:var(--input-width, 17.125rem)}:host .date-input-container{position:relative}ic-date-input{--input-width:var(--input-field-width)}:host .calendar-container{min-width:19rem;max-width:23.5rem;width:var(--input-width);display:flex;flex-direction:column;gap:var(--ic-space-xs);position:absolute;align-items:center;background-color:var(--ic-architectural-white);z-index:var(--ic-z-index-date-picker);box-sizing:border-box;margin-top:var(--ic-space-xxxs);padding:var(--ic-space-xs);animation:fade-in-calendar var(--ic-transition-duration-slow)}:host .calendar-container.show-date-input{border:var(--ic-border-default);border-radius:var(--ic-border-radius);box-shadow:var(--ic-elevation-overlay)}:host .calendar-container.hide-date-input{position:static}:host(.small) .calendar-container{min-width:17rem;max-width:21.5rem}:host(.large) .calendar-container{min-width:21rem;max-width:25.5rem}:host .calendar-container.above{bottom:calc(var(--ic-space-xxl) - var(--ic-space-xxs))}:host .month-year-nav-container{display:flex;justify-content:space-between;align-items:center;align-self:stretch}:host .month-year-nav-container.hidden{display:none}:host .month-year-nav{display:flex;justify-content:space-between;align-items:center;flex:1 0 0}:host .month-picker,:host .year-picker{flex-wrap:wrap;display:inline-flex;align-items:center;width:17.5rem;-moz-column-gap:var(--ic-space-xs);column-gap:var(--ic-space-xs);row-gap:var(--ic-space-xxs)}:host(.small) .month-picker,:host(.small) .year-picker{width:13.125rem}:host(.large) .month-picker,:host(.large) .year-picker{width:20rem}:host .month-picker-button,:host .year-picker-button{width:5rem;--min-width:5rem}:host .month-button,:host .year-button{width:var(--month-button-width)}:host .month-button.focussed,:host .year-button.focussed{z-index:1}:host .month-button::part(button),:host .year-button::part(button){min-width:var(--month-button-width)}:host .prev-decade .year-button svg{margin-right:calc(-1 * var(--ic-space-xl));padding-top:var(--ic-space-sm)}:host .prev-decade .year-button::part(button){padding-left:0;padding-right:var(--ic-space-lg)}:host(.small) .prev-decade .year-button::part(button){padding-left:0;padding-right:calc(var(--ic-space-lg) + var(--ic-space-xxs))}:host .next-decade .year-button svg{margin-left:calc(-1 * var(--ic-space-xl));padding-top:var(--ic-space-sm)}:host .next-decade .year-button::part(button){padding-right:0;padding-left:var(--ic-space-lg)}:host(.small) .next-decade .year-button::part(button),:host(.large) .next-decade .year-button::part(button){padding-left:var(--ic-space-xl)}:host .bottom-buttons{padding-top:var(--ic-space-xs);display:flex;justify-content:space-between;align-items:center;align-self:stretch;animation:fade-in-buttons var(--ic-transition-duration-slow)}:host(.small) .bottom-buttons{padding-top:var(--ic-space-xxs)}:host .bottom-buttons.no-today{align-items:flex-end;flex-direction:column}:host .bottom-buttons.hidden{display:none}:host .calendar{display:flex;flex-direction:column;align-items:flex-start;width:15.75rem;animation:fade-in-buttons var(--ic-transition-duration-slow)}:host(.large) .calendar{width:19.25rem}:host(.small) .calendar{padding-bottom:var(--ic-space-xxs);width:14rem}:host .hidden{display:none}:host .weekdays{display:flex;justify-content:space-between;align-items:flex-start;padding-bottom:var(--ic-space-xs);align-self:stretch}:host .calendar-days-container{display:flex;flex-wrap:wrap;justify-content:space-between;row-gap:var(--ic-space-xs);padding:var(--ic-space-xxs) 0}:host(.small) .calendar-days-container{padding:var(--ic-space-xxxs) 0}:host(.large) .calendar-days-container{padding:var(--ic-space-xs) 0}:host .calendar-day-header{display:flex;width:2rem;padding:var(--ic-space-xxs) 0;justify-content:center;align-items:center}:host(.small) .calendar-day-header,:host(.large) .calendar-day-header{padding:var(--ic-space-xxs)}:host .calendar-day-header ic-typography{color:var(--ic-color-tertiary-text);text-align:center}:host .day-button-container{display:flex;justify-content:center;align-items:center;width:2.25rem;height:2.25rem}:host(.small) .day-button-container{width:2rem;height:2rem}:host(.large) .day-button-container{width:2.5rem;height:2.5rem}:host .day-button{display:flex;position:relative;justify-content:center;align-items:center;border:0;border-radius:2rem;background-color:var(--ic-architectural-white);width:2rem;height:2rem;cursor:pointer;transition:var(--ic-easing-transition-fast);z-index:0}:host .day-button.disabled{cursor:default}:host(.large) .day-button{width:2.25rem;height:2.25rem}:host(.small) .day-button{width:1.75rem;height:1.75rem}:host .day-button ic-typography{width:1.75rem;color:var(--ic-color-primary-text)}:host .day-button.outside-range ic-typography{color:var(--ic-architectural-400)}:host .day-button.outside-month ic-typography{font-weight:var(--ic-font-weight-regular) !important}:host .day-button.outside-month:not(.outside-range):not(.selected) ic-typography{color:var(--ic-color-primary-text)}:host .day-button:hover:not(.disabled){background-color:var(--ic-action-dark-bg-hover)}:host .day-button:active:not(.disabled){background-color:var(--ic-action-dark-bg-active)}@media (prefers-reduced-motion: no-preference){:host .day-button:hover:not(.disabled):not(.focussed),:host .day-button:active:not(.disabled):not(.focussed){transition:background-color var(--ic-transition-duration-slow) ease-in-out}}:host .day-button.selected:not(.hidden){background-color:var(--ic-action-default)}:host .day-button.selected ic-typography{color:var(--ic-color-white-text)}:host .day-button.selected:not(.hidden):hover{background-color:var(--ic-action-default-hover)}:host .day-button.selected:not(.hidden):active{background-color:var(--ic-action-default-active)}:host .day-button.focussed{z-index:1}:host .day-button:focus{outline:none}:host .day-button.focussed:focus{box-shadow:var(--ic-border-focus)}:host .day-button.today:not(.hidden)::after{content:\"\";position:absolute;width:0.875rem;height:0.125rem;bottom:0.4rem;border-radius:var(--ic-border-radius);background-color:var(--ic-action-default)}:host(.small) .day-button.today::after{bottom:0.35rem}:host(.large) .day-button.today::after{width:1rem}:host .day-button.today.selected::after{background-color:var(--ic-architectural-white)}:host #select-month-hint,:host #select-year-hint{display:none}.sr-only{position:absolute;left:-9999px}@media (prefers-reduced-motion: reduce){:host .calendar-container,:host .calendar,:host .bottom-buttons{animation:none}}@keyframes fade-in-buttons{0%{opacity:0}50%{opacity:0}100%{opacity:1}}@keyframes fade-in-calendar{0%{display:flex;max-height:0}100%{display:flex;max-height:600px}}@media (forced-colors: active){:host .day-button.today:not(.hidden)::after{background-color:highlight}:host .day-button.selected:not(.hidden){background-color:highlight}:host .day-button.focussed:focus{border:var(--ic-hc-border)}:host .month-button.selected::part(button),:host .year-button.selected::part(button){background-color:highlight}}";
|
122
122
|
|
123
123
|
const DEFAULT_DATE_FORMAT = "DD/MM/YYYY";
|
124
124
|
const DEFAULT_DISABLE_DATES_FROM_NOW_MSG = "Dates in the future are not allowed. Please select a date in the past.";
|
@@ -132,6 +132,7 @@ const DatePicker = class {
|
|
132
132
|
constructor(hostRef) {
|
133
133
|
index.registerInstance(this, hostRef);
|
134
134
|
this.icChange = index.createEvent(this, "icChange", 7);
|
135
|
+
this.icSelectedDateChange = index.createEvent(this, "icSelectedDateChange", 7);
|
135
136
|
this.clearButtonEl = null;
|
136
137
|
this.daysOfWeek = [];
|
137
138
|
this.dayButtonFocussed = false;
|
@@ -157,12 +158,30 @@ const DatePicker = class {
|
|
157
158
|
this.decadeStart = decadeArr[1];
|
158
159
|
this.decadeEnd = decadeArr[10];
|
159
160
|
};
|
161
|
+
this.notifyScreenReaderSelectedDate = () => {
|
162
|
+
const dayNames = helpers.stringEnumToArray(helpers.IcDayNames);
|
163
|
+
const months = helpers.stringEnumToArray(helpers.IcDateInputMonths);
|
164
|
+
this.selectedDateInfoEl.textContent = this.selectedDate
|
165
|
+
? `Selected date: ${dayNames[this.selectedDate.getDay()]}, ${this.selectedDate.getDate()} ${months[this.selectedDate.getMonth()]} ${this.selectedDate.getFullYear()}`
|
166
|
+
: "Selected date cleared";
|
167
|
+
};
|
160
168
|
this.setSelectedDate = (d, emit = true) => {
|
161
169
|
if (d === null || !dateHelpers.dateMatches(d, this.selectedDate)) {
|
162
170
|
this.selectedDate = d;
|
163
171
|
this.value = d;
|
164
172
|
if (emit) {
|
165
|
-
this.inputEl
|
173
|
+
if (this.inputEl) {
|
174
|
+
this.inputEl.triggerIcChange(d);
|
175
|
+
}
|
176
|
+
else {
|
177
|
+
if (this.selectedDate) {
|
178
|
+
this.setFocussedDate(this.selectedDate);
|
179
|
+
}
|
180
|
+
this.icSelectedDateChange.emit({ value: d });
|
181
|
+
if (!this.showDateInput && this.selectedDateInfoEl) {
|
182
|
+
this.notifyScreenReaderSelectedDate();
|
183
|
+
}
|
184
|
+
}
|
166
185
|
}
|
167
186
|
}
|
168
187
|
};
|
@@ -177,13 +196,17 @@ const DatePicker = class {
|
|
177
196
|
event.stopImmediatePropagation();
|
178
197
|
};
|
179
198
|
this.handleDocumentClick = () => {
|
180
|
-
this.
|
199
|
+
if (this.showDateInput) {
|
200
|
+
this.calendarOpen = false;
|
201
|
+
}
|
181
202
|
};
|
182
203
|
this.keyDownHandler = (event) => {
|
183
204
|
if (event.key === "Escape") {
|
184
205
|
if (this.calendarOpen) {
|
185
206
|
this.closeButtonClickHandler();
|
186
|
-
this.inputEl
|
207
|
+
if (this.inputEl) {
|
208
|
+
this.inputEl.setCalendarFocus();
|
209
|
+
}
|
187
210
|
event.stopImmediatePropagation();
|
188
211
|
}
|
189
212
|
}
|
@@ -193,7 +216,9 @@ const DatePicker = class {
|
|
193
216
|
}
|
194
217
|
};
|
195
218
|
this.closeButtonClickHandler = () => {
|
196
|
-
this.
|
219
|
+
if (this.showDateInput) {
|
220
|
+
this.calendarOpen = false;
|
221
|
+
}
|
197
222
|
};
|
198
223
|
this.focusFirstElement = () => {
|
199
224
|
this.monthButtonEl.setFocus();
|
@@ -403,8 +428,12 @@ const DatePicker = class {
|
|
403
428
|
};
|
404
429
|
this.handleSelectDay = (day) => {
|
405
430
|
this.setSelectedDate(day);
|
406
|
-
this.
|
407
|
-
|
431
|
+
if (this.showDateInput) {
|
432
|
+
this.calendarOpen = false;
|
433
|
+
if (this.inputEl) {
|
434
|
+
this.inputEl.setCalendarFocus();
|
435
|
+
}
|
436
|
+
}
|
408
437
|
};
|
409
438
|
this.handleSelectMonth = (month) => {
|
410
439
|
this.moveMonths(month - this.monthInView);
|
@@ -817,6 +846,60 @@ const DatePicker = class {
|
|
817
846
|
}
|
818
847
|
return inputProps;
|
819
848
|
};
|
849
|
+
this.renderHiddenInput = () => !this.showDateInput ? (index.h("span", { id: this.selectedDateInfoId, class: "sr-only", "aria-live": "polite" }, index.h("span", { ref: (el) => (this.selectedDateInfoEl = el), role: "status" }))) : ("");
|
850
|
+
this.renderCalendar = () => {
|
851
|
+
const { monthNames, size, focussedMonth, focussedYear, monthInView, yearInView, monthPickerVisible, yearPickerVisible, orderedDaysOfWeek, decadeView, minDate, maxDate, showPickerClearButton, showPickerTodayButton, dialogDescription, } = this;
|
852
|
+
let monthButtonText = "";
|
853
|
+
if (monthPickerVisible) {
|
854
|
+
monthButtonText = `Use the arrow keys to change the selected month. To return to day picker view, press Enter or Space to select a month, or press Escape.`;
|
855
|
+
}
|
856
|
+
else {
|
857
|
+
monthButtonText = `Press Enter or Space to open month picker view or use the arrow keys to change month.`;
|
858
|
+
}
|
859
|
+
let yearButtonText = "";
|
860
|
+
if (yearPickerVisible) {
|
861
|
+
yearButtonText = `Use the arrow keys to change the selected year. To return to day picker view, press Enter or Space to select a year, or press Escape.`;
|
862
|
+
}
|
863
|
+
else {
|
864
|
+
yearButtonText = `Press Enter or Space to open year picker view or use the arrow keys to change the selected year.`;
|
865
|
+
}
|
866
|
+
const dialogLabel = "choose date";
|
867
|
+
const monthLabel = monthNames && monthNames[monthInView]
|
868
|
+
? monthNames[monthInView]
|
869
|
+
: "Open month picker";
|
870
|
+
const yearLabel = this.yearInView ? this.yearInView : "Open year picker";
|
871
|
+
let minDay = minDate;
|
872
|
+
if (this.disablePast) {
|
873
|
+
const yesterday = new Date(minDate);
|
874
|
+
yesterday.setDate(minDate.getDate() - 1);
|
875
|
+
minDay = yesterday;
|
876
|
+
}
|
877
|
+
return (index.h("div", null, index.h("span", { id: "dialog-description", class: "sr-only" }, dialogDescription), index.h("div", { role: "dialog", "aria-modal": "true", "aria-label": dialogLabel, "aria-describedBy": "dialog-description", class: {
|
878
|
+
"calendar-container": true,
|
879
|
+
"show-date-input": this.showDateInput,
|
880
|
+
"hide-date-input": !this.showDateInput,
|
881
|
+
above: this.showPickerAbove,
|
882
|
+
}, onMouseDown: this.handleCalendarMouseDown, onClick: this.handleCalendarClick }, index.h("span", { ref: (el) => (this.liveRegionEl = el), id: "live-region", "aria-live": "assertive", class: "sr-only" }), index.h("div", { class: {
|
883
|
+
"month-year-nav-container": true,
|
884
|
+
} }, index.h("div", { class: "month-year-nav" }, this.previousMonthButton(), index.h("span", { id: "select-month-hint", "aria-hidden": "true" }, monthButtonText), index.h("ic-button", { ref: (el) => (this.monthButtonEl = el), size: size, class: "month-picker-button", "aria-haspopup": "menu", "aria-expanded": monthPickerVisible ? "true" : "false", "full-width": "true", variant: "tertiary", "aria-label": monthLabel, "aria-describedby": "select-month-hint", onKeyDown: this.monthButtonKeyDownHandler, onClick: this.monthButtonClickHandler }, monthNames[monthInView]), this.nextMonthButton()), index.h("div", { class: "month-year-nav" }, this.previousYearButton(), index.h("span", { id: "select-year-hint", "aria-hidden": "true" }, yearButtonText), index.h("ic-button", { ref: (el) => (this.yearButtonEl = el), size: size, class: "year-picker-button", "aria-haspopup": "menu", "aria-expanded": yearPickerVisible ? "true" : "false", "full-width": "true", variant: "tertiary", "aria-label": yearLabel, "aria-describedby": "select-year-hint", onKeyDown: this.yearButtonKeyDownHandler, onClick: this.yearButtonClickHandler }, this.yearInView), this.nextYearButton())), !(monthPickerVisible || yearPickerVisible) && (index.h("div", { class: {
|
885
|
+
calendar: true,
|
886
|
+
hidden: monthPickerVisible || yearPickerVisible,
|
887
|
+
}, onKeyDown: this.handleCalendarKeyDown }, index.h("div", { class: "weekdays", "aria-hidden": "true" }, orderedDaysOfWeek.map((dayName) => {
|
888
|
+
const header = size === "small" ? dayName.charAt(0) : dayName;
|
889
|
+
return (index.h("div", { class: "calendar-day-header" }, index.h("ic-typography", { variant: "caption" }, header)));
|
890
|
+
})), index.h("div", { class: "calendar-days-container" }, this.currMonthView.map((day) => (index.h(DayButton, { day: day, disableDay: this.disableDays.includes(Number(day.getDay())), today: dateHelpers.dateMatches(day, this.today), selected: dateHelpers.dateMatches(day, this.selectedDate), focussed: dateHelpers.dateMatches(day, this.focussedDate), inRange: dateHelpers.dateInRange(day, minDay, maxDate), monthInView: monthInView, onSelectDay: this.handleSelectDay, focussedDayRef: this.setFocussedDayEl, onFocusDay: this.onDayButtonFocusHandler, onBlurDay: this.onDayButtonBlurHandler, showDaysOutsideMonth: this.showDaysOutsideMonth })))))), index.h("div", { class: {
|
891
|
+
"month-picker-container": true,
|
892
|
+
hidden: !monthPickerVisible,
|
893
|
+
} }, monthPickerVisible && (index.h(MonthPicker, { size: size, onSelectMonth: this.handleSelectMonth, monthInView: monthInView, focussedMonth: focussedMonth, onKeyDown: this.monthPickerKeyDownHandler, focussedMonthRef: this.setFocussedMonthEl, minDate: minDate, maxDate: maxDate, yearInView: yearInView }))), index.h("div", { class: {
|
894
|
+
"year-picker-container": true,
|
895
|
+
hidden: !yearPickerVisible,
|
896
|
+
} }, yearPickerVisible && (index.h(YearPicker, { decadeView: decadeView, size: size, focussedYear: focussedYear, onSelectYear: this.handleSelectYear, onKeyDown: this.yearPickerKeyDownHandler, onFocusYear: this.onYearButtonFocusHandler, onBlurYear: this.onYearButtonBlurHandler, yearInView: yearInView, minDate: minDate, maxDate: maxDate, focussedYearRef: this.setFocussedYearEl }))), index.h("div", { class: {
|
897
|
+
"bottom-buttons": true,
|
898
|
+
"no-today": !showPickerTodayButton,
|
899
|
+
} }, showPickerTodayButton && (index.h("ic-button", { id: "today-button", variant: "tertiary", ref: (el) => (this.todayButtonEl = el), size: size, "aria-label": "Navigate to current date", onClick: this.todayButtonClickHandler, onKeyDown: this.todayButtonKeyDownHandler, disabled: this.isCurrentMonth() }, "Go to today")), showPickerClearButton && (index.h("ic-button", { id: "clear-button", "aria-label": "clear selected date", ref: (el) => (this.clearButtonEl = el), variant: "tertiary", size: size, onClick: this.clearButtonClickHandler, onKeyDown: this.clearButtonKeyDownHandler, disabled: this.value === "" ||
|
900
|
+
this.value === null ||
|
901
|
+
this.value === undefined }, "Clear")))), this.renderHiddenInput()));
|
902
|
+
};
|
820
903
|
this.calendarOpen = false;
|
821
904
|
this.currMonthView = [];
|
822
905
|
this.currYearPickerView = [];
|
@@ -854,6 +937,7 @@ const DatePicker = class {
|
|
854
937
|
this.name = undefined;
|
855
938
|
this.openAtDate = "";
|
856
939
|
this.required = false;
|
940
|
+
this.showDateInput = true;
|
857
941
|
this.showDaysOutsideMonth = true;
|
858
942
|
this.showPickerClearButton = true;
|
859
943
|
this.showPickerTodayButton = true;
|
@@ -888,6 +972,11 @@ const DatePicker = class {
|
|
888
972
|
this.minDate = dateHelpers.createDate(this.min, this.dateFormat);
|
889
973
|
}
|
890
974
|
}
|
975
|
+
watchShowDateInputHandler() {
|
976
|
+
if (!this.showDateInput) {
|
977
|
+
this.calendarOpen = true;
|
978
|
+
}
|
979
|
+
}
|
891
980
|
watchStartOfWeekHandler() {
|
892
981
|
this.orderedDaysOfWeek = this.daysOfWeek
|
893
982
|
.slice(this.startOfWeek)
|
@@ -979,13 +1068,23 @@ const DatePicker = class {
|
|
979
1068
|
this.watchMaxHandler();
|
980
1069
|
this.watchMinHandler();
|
981
1070
|
helpers.removeDisabledFalse(this.disabled, this.el);
|
1071
|
+
this.selectedDateInfoId = `${this.inputId}-selected-date-info`;
|
982
1072
|
}
|
983
1073
|
componentWillRender() {
|
984
1074
|
this.dateInputProps = this.setDateInputProps();
|
1075
|
+
if (!this.showDateInput) {
|
1076
|
+
this.calendarOpen = true;
|
1077
|
+
}
|
985
1078
|
}
|
986
1079
|
componentWillUpdate() {
|
987
1080
|
this.dateInputProps = this.setDateInputProps();
|
988
1081
|
}
|
1082
|
+
componentDidLoad() {
|
1083
|
+
if (!this.showDateInput && this.value) {
|
1084
|
+
this.setSelectedDate(new Date(this.value));
|
1085
|
+
this.setFocussedDate(this.selectedDate);
|
1086
|
+
}
|
1087
|
+
}
|
989
1088
|
localCalendarButtonClickHandler(ev) {
|
990
1089
|
this.myCalendarButtonClicked = true;
|
991
1090
|
if (!this.calendarOpen) {
|
@@ -995,61 +1094,14 @@ const DatePicker = class {
|
|
995
1094
|
}
|
996
1095
|
calendarButtonClickHandler() {
|
997
1096
|
//closes this picker if calendar button in another clicked
|
998
|
-
if (!this.myCalendarButtonClicked) {
|
1097
|
+
if (!this.myCalendarButtonClicked && this.showDateInput) {
|
999
1098
|
this.calendarOpen = false;
|
1000
1099
|
}
|
1001
1100
|
this.myCalendarButtonClicked = false;
|
1002
1101
|
}
|
1003
1102
|
render() {
|
1004
|
-
const { calendarOpen, dateInputProps,
|
1005
|
-
|
1006
|
-
if (monthPickerVisible) {
|
1007
|
-
monthButtonText = `Use the arrow keys to change the selected month. To return to day picker view, press Enter or Space to select a month, or press Escape.`;
|
1008
|
-
}
|
1009
|
-
else {
|
1010
|
-
monthButtonText = `Press Enter or Space to open month picker view or use the arrow keys to change month.`;
|
1011
|
-
}
|
1012
|
-
let yearButtonText = "";
|
1013
|
-
if (yearPickerVisible) {
|
1014
|
-
yearButtonText = `Use the arrow keys to change the selected year. To return to day picker view, press Enter or Space to select a year, or press Escape.`;
|
1015
|
-
}
|
1016
|
-
else {
|
1017
|
-
yearButtonText = `Press Enter or Space to open year picker view or use the arrow keys to change the selected year.`;
|
1018
|
-
}
|
1019
|
-
const dialogLabel = "choose date";
|
1020
|
-
const monthLabel = monthNames && monthNames[monthInView]
|
1021
|
-
? monthNames[monthInView]
|
1022
|
-
: "Open month picker";
|
1023
|
-
const yearLabel = this.yearInView ? this.yearInView : "Open year picker";
|
1024
|
-
let minDay = minDate;
|
1025
|
-
if (this.disablePast) {
|
1026
|
-
const yesterday = new Date(minDate);
|
1027
|
-
yesterday.setDate(minDate.getDate() - 1);
|
1028
|
-
minDay = yesterday;
|
1029
|
-
}
|
1030
|
-
return (index.h(index.Host, { onKeyDown: this.keyDownHandler, class: size }, index.h("div", { class: "date-input-container" }, index.h("ic-date-input", Object.assign({ ref: (el) => (this.inputEl = el) }, dateInputProps))), calendarOpen && (index.h("div", null, index.h("span", { id: "dialog-description", class: "sr-only" }, dialogDescription), index.h("div", { role: "dialog", "aria-modal": "true", "aria-label": dialogLabel, "aria-describedBy": "dialog-description", class: {
|
1031
|
-
"calendar-container": true,
|
1032
|
-
above: this.showPickerAbove,
|
1033
|
-
}, onMouseDown: this.handleCalendarMouseDown, onClick: this.handleCalendarClick }, index.h("span", { ref: (el) => (this.liveRegionEl = el), id: "live-region", "aria-live": "assertive", class: "sr-only" }), index.h("div", { class: {
|
1034
|
-
"month-year-nav-container": true,
|
1035
|
-
} }, index.h("div", { class: "month-year-nav" }, this.previousMonthButton(), index.h("span", { id: "select-month-hint", "aria-hidden": "true" }, monthButtonText), index.h("ic-button", { ref: (el) => (this.monthButtonEl = el), size: size, class: "month-picker-button", "aria-haspopup": "menu", "aria-expanded": monthPickerVisible ? "true" : "false", "full-width": "true", variant: "tertiary", "aria-label": monthLabel, "aria-describedby": "select-month-hint", onKeyDown: this.monthButtonKeyDownHandler, onClick: this.monthButtonClickHandler }, monthNames[monthInView]), this.nextMonthButton()), index.h("div", { class: "month-year-nav" }, this.previousYearButton(), index.h("span", { id: "select-year-hint", "aria-hidden": "true" }, yearButtonText), index.h("ic-button", { ref: (el) => (this.yearButtonEl = el), size: size, class: "year-picker-button", "aria-haspopup": "menu", "aria-expanded": yearPickerVisible ? "true" : "false", "full-width": "true", variant: "tertiary", "aria-label": yearLabel, "aria-describedby": "select-year-hint", onKeyDown: this.yearButtonKeyDownHandler, onClick: this.yearButtonClickHandler }, this.yearInView), this.nextYearButton())), !(monthPickerVisible || yearPickerVisible) && (index.h("div", { class: {
|
1036
|
-
calendar: true,
|
1037
|
-
hidden: monthPickerVisible || yearPickerVisible,
|
1038
|
-
}, onKeyDown: this.handleCalendarKeyDown }, index.h("div", { class: "weekdays", "aria-hidden": "true" }, orderedDaysOfWeek.map((dayName) => {
|
1039
|
-
const header = size === "small" ? dayName.charAt(0) : dayName;
|
1040
|
-
return (index.h("div", { class: "calendar-day-header" }, index.h("ic-typography", { variant: "caption" }, header)));
|
1041
|
-
})), index.h("div", { class: "calendar-days-container" }, this.currMonthView.map((day) => (index.h(DayButton, { day: day, disableDay: this.disableDays.includes(Number(day.getDay())), today: dateHelpers.dateMatches(day, this.today), selected: dateHelpers.dateMatches(day, this.selectedDate), focussed: dateHelpers.dateMatches(day, this.focussedDate), inRange: dateHelpers.dateInRange(day, minDay, maxDate), monthInView: monthInView, onSelectDay: this.handleSelectDay, focussedDayRef: this.setFocussedDayEl, onFocusDay: this.onDayButtonFocusHandler, onBlurDay: this.onDayButtonBlurHandler, showDaysOutsideMonth: this.showDaysOutsideMonth })))))), index.h("div", { class: {
|
1042
|
-
"month-picker-container": true,
|
1043
|
-
hidden: !monthPickerVisible,
|
1044
|
-
} }, monthPickerVisible && (index.h(MonthPicker, { size: size, onSelectMonth: this.handleSelectMonth, monthInView: monthInView, focussedMonth: focussedMonth, onKeyDown: this.monthPickerKeyDownHandler, focussedMonthRef: this.setFocussedMonthEl, minDate: minDate, maxDate: maxDate, yearInView: yearInView }))), index.h("div", { class: {
|
1045
|
-
"year-picker-container": true,
|
1046
|
-
hidden: !yearPickerVisible,
|
1047
|
-
} }, yearPickerVisible && (index.h(YearPicker, { decadeView: decadeView, size: size, focussedYear: focussedYear, onSelectYear: this.handleSelectYear, onKeyDown: this.yearPickerKeyDownHandler, onFocusYear: this.onYearButtonFocusHandler, onBlurYear: this.onYearButtonBlurHandler, yearInView: yearInView, minDate: minDate, maxDate: maxDate, focussedYearRef: this.setFocussedYearEl }))), index.h("div", { class: {
|
1048
|
-
"bottom-buttons": true,
|
1049
|
-
"no-today": !showPickerTodayButton,
|
1050
|
-
} }, showPickerTodayButton && (index.h("ic-button", { id: "today-button", variant: "tertiary", ref: (el) => (this.todayButtonEl = el), size: size, "aria-label": "Navigate to current date", onClick: this.todayButtonClickHandler, onKeyDown: this.todayButtonKeyDownHandler, disabled: this.isCurrentMonth() }, "Go to today")), showPickerClearButton && (index.h("ic-button", { id: "clear-button", "aria-label": "clear selected date", ref: (el) => (this.clearButtonEl = el), variant: "tertiary", size: size, onClick: this.clearButtonClickHandler, onKeyDown: this.clearButtonKeyDownHandler, disabled: this.value === "" ||
|
1051
|
-
this.value === null ||
|
1052
|
-
this.value === undefined }, "Clear"))))))));
|
1103
|
+
const { calendarOpen, dateInputProps, keyDownHandler, renderCalendar, showDateInput, size, } = this;
|
1104
|
+
return (index.h(index.Host, { onKeyDown: keyDownHandler, class: size }, showDateInput && (index.h("div", { class: "date-input-container" }, index.h("ic-date-input", Object.assign({ ref: (el) => (this.inputEl = el) }, dateInputProps)))), calendarOpen && renderCalendar()));
|
1053
1105
|
}
|
1054
1106
|
static get delegatesFocus() { return true; }
|
1055
1107
|
get el() { return index.getElement(this); }
|
@@ -1059,6 +1111,7 @@ const DatePicker = class {
|
|
1059
1111
|
"disablePast": ["watchDisablePastHandler"],
|
1060
1112
|
"max": ["watchMaxHandler"],
|
1061
1113
|
"min": ["watchMinHandler"],
|
1114
|
+
"showDateInput": ["watchShowDateInputHandler"],
|
1062
1115
|
"startOfWeek": ["watchStartOfWeekHandler"],
|
1063
1116
|
"calendarOpen": ["watchOpenHandler"],
|
1064
1117
|
"focussedDate": ["watchFocussedDateHandler"],
|