@descope/web-components-ui 1.0.378 → 1.0.379

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. package/dist/cjs/index.cjs.js +3166 -1257
  2. package/dist/cjs/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +2 -0
  4. package/dist/index.esm.js +4738 -2826
  5. package/dist/index.esm.js.map +1 -1
  6. package/dist/umd/1224.js +1 -1
  7. package/dist/umd/1438.js +3 -3
  8. package/dist/umd/1612.js +1 -1
  9. package/dist/umd/2773.js +4 -4
  10. package/dist/umd/3830.js +1 -1
  11. package/dist/umd/3951.js +1 -1
  12. package/dist/umd/3966.js +319 -0
  13. package/dist/umd/4024.js +1 -1
  14. package/dist/umd/4052.js +1 -1
  15. package/dist/umd/4392.js +1 -1
  16. package/dist/umd/4525.js +1 -1
  17. package/dist/umd/4978.js +1 -1
  18. package/dist/umd/5135.js +2 -2
  19. package/dist/umd/5517.js +1 -1
  20. package/dist/umd/5778.js +275 -0
  21. package/dist/umd/5806.js +1 -1
  22. package/dist/umd/5977.js +140 -0
  23. package/dist/umd/5977.js.LICENSE.txt +29 -0
  24. package/dist/umd/63.js +4 -4
  25. package/dist/umd/6770.js +1 -1
  26. package/dist/umd/7056.js +3 -3
  27. package/dist/umd/7284.js +1 -1
  28. package/dist/umd/7541.js +449 -0
  29. package/dist/umd/7541.js.LICENSE.txt +17 -0
  30. package/dist/umd/7911.js +2 -2
  31. package/dist/umd/{4028.js → 8060.js} +3 -3
  32. package/dist/umd/8137.js +1 -1
  33. package/dist/umd/8191.js +2 -2
  34. package/dist/umd/8655.js +123 -0
  35. package/dist/umd/9314.js +2 -2
  36. package/dist/umd/9423.js +6 -6
  37. package/dist/umd/9562.js +1 -1
  38. package/dist/umd/DescopeDev.js +1 -1
  39. package/dist/umd/descope-apps-list-index-js.js +1 -1
  40. package/dist/umd/descope-avatar-index-js.js +1 -1
  41. package/dist/umd/descope-button-index-js.js +1 -1
  42. package/dist/umd/descope-combo-box-index-js.js +5 -5
  43. package/dist/umd/descope-date-field-descope-calendar-index-js.js +1 -0
  44. package/dist/umd/descope-date-field-index-js.js +1 -0
  45. package/dist/umd/descope-email-field-index-js.js +1 -1
  46. package/dist/umd/descope-grid-descope-grid-custom-column-index-js.js +2 -2
  47. package/dist/umd/descope-grid-descope-grid-item-details-column-index-js.js +2 -2
  48. package/dist/umd/descope-grid-descope-grid-selection-column-index-js.js +1 -1
  49. package/dist/umd/descope-grid-descope-grid-text-column-index-js.js +4 -4
  50. package/dist/umd/descope-new-password-index-js.js +1 -1
  51. package/dist/umd/descope-number-field-index-js.js +1 -1
  52. package/dist/umd/descope-passcode-index-js.js +1 -1
  53. package/dist/umd/descope-radio-group-index-js.js +1 -1
  54. package/dist/umd/descope-text-field-index-js.js +1 -1
  55. package/dist/umd/index.js +1 -1
  56. package/dist/umd/mapping-fields-descope-mappings-field-index-js.js +1 -1
  57. package/dist/umd/phone-fields-descope-phone-field-descope-phone-field-internal-index-js.js +1 -1
  58. package/dist/umd/phone-fields-descope-phone-field-index-js.js +1 -1
  59. package/dist/umd/phone-fields-descope-phone-input-box-field-descope-phone-input-box-internal-index-js.js +1 -1
  60. package/dist/umd/phone-fields-descope-phone-input-box-field-index-js.js +1 -1
  61. package/package.json +11 -5
  62. package/src/components/descope-combo-box/ComboBoxClass.js +7 -1
  63. package/src/components/descope-date-field/DateCounterClass.js +83 -0
  64. package/src/components/descope-date-field/DateFieldClass.js +675 -0
  65. package/src/components/descope-date-field/consts.js +55 -0
  66. package/src/components/descope-date-field/descope-calendar/CalendarClass.js +666 -0
  67. package/src/components/descope-date-field/descope-calendar/helpers.js +186 -0
  68. package/src/components/descope-date-field/descope-calendar/index.js +9 -0
  69. package/src/components/descope-date-field/formats.js +49 -0
  70. package/src/components/descope-date-field/helpers.js +72 -0
  71. package/src/components/descope-date-field/icons.js +14 -0
  72. package/src/components/descope-date-field/index.js +10 -0
  73. package/src/components/descope-text-field/textFieldMappings.js +2 -0
  74. package/src/index.cjs.js +2 -0
  75. package/src/index.d.ts +2 -0
  76. package/src/index.js +2 -1
  77. package/src/mixins/inputValidationMixin.js +8 -2
  78. package/src/mixins/portalMixin.js +6 -3
  79. package/src/theme/components/calendar.js +94 -0
  80. package/src/theme/components/dateField.js +63 -0
  81. package/src/theme/components/index.js +4 -0
  82. package/src/theme/components/inputWrapper.js +6 -0
  83. package/src/theme/components/textField.js +1 -0
  84. package/dist/umd/4746.js +0 -124
  85. package/dist/umd/7531.js +0 -319
  86. package/dist/umd/8866.js +0 -275
  87. package/dist/umd/9092.js +0 -1086
  88. package/dist/umd/9092.js.LICENSE.txt +0 -27
  89. package/dist/umd/descope-date-picker-index-js.js +0 -1
  90. package/src/components/descope-date-picker/index.js +0 -20
  91. /package/dist/umd/{7531.js.LICENSE.txt → 3966.js.LICENSE.txt} +0 -0
  92. /package/dist/umd/{8866.js.LICENSE.txt → 5778.js.LICENSE.txt} +0 -0
  93. /package/dist/umd/{4028.js.LICENSE.txt → 8060.js.LICENSE.txt} +0 -0
  94. /package/dist/umd/{4746.js.LICENSE.txt → 8655.js.LICENSE.txt} +0 -0
@@ -0,0 +1,186 @@
1
+ import { months, weekdays } from '../consts';
2
+ import { getTimestampParts, newDate } from '../helpers';
3
+
4
+ const isValidAttrArr = (arr, count) =>
5
+ Array.isArray(arr) && arr.length === count && arr.filter(Boolean).length === count;
6
+
7
+ const generateYearList = (range) => {
8
+ const [start, end] = range;
9
+ const years = [];
10
+
11
+ for (let year = start; year <= end; year++) {
12
+ years.push(year);
13
+ }
14
+
15
+ return years;
16
+ };
17
+
18
+ const getMaxDaysInMonth = (year, month) => {
19
+ return new Date(year, month, 0).getDate();
20
+ };
21
+
22
+ const comboBoxItemTpl = ({ label, dataId, dataName }) => `
23
+ <div
24
+ style="display:flex; flex-direction: column;"
25
+ data-id="${dataId}"
26
+ data-name="${dataName}"
27
+ >
28
+ ${label}
29
+ </div>
30
+ `;
31
+
32
+ export const createMonthView = (year, month, shortWeekdays) => {
33
+ const daysInMonth = getMaxDaysInMonth(year, month);
34
+
35
+ // Get day of the week (0 = Sunday, 1 = Monday, etc.)
36
+ const firstDayOfMonth = new Date(year, month - 1, 1).getDay();
37
+
38
+ let monthView = '<table>';
39
+
40
+ // Add the table headers (days of the week)
41
+ monthView += `<thead><tr>${shortWeekdays.reduce(
42
+ (acc, d) => `${acc}<th><span class="weekday">${d}</span></th>`,
43
+ ''
44
+ )}</tr></thead>`;
45
+
46
+ monthView += '<tbody>';
47
+
48
+ // Add empty cells for the days before the start of the month
49
+ monthView += '<tr>';
50
+ for (let i = 0; i < firstDayOfMonth; i++) {
51
+ monthView += '<td></td>';
52
+ }
53
+
54
+ // Add days of the month
55
+ let dayOfWeek = firstDayOfMonth;
56
+ for (let i = 1; i <= daysInMonth; i++) {
57
+ if (dayOfWeek === 7) {
58
+ dayOfWeek = 0;
59
+ monthView += '</tr><tr>';
60
+ }
61
+
62
+ monthView += `
63
+ <td
64
+ data-date-day="${i}"
65
+ class="day-entry">
66
+ <span class="day" data-date-day=${i}>
67
+ ${i}
68
+ </span>
69
+ </td>
70
+ `;
71
+ dayOfWeek++;
72
+ }
73
+
74
+ // Add empty cells for the days after the end of the month
75
+ while (dayOfWeek < 7) {
76
+ monthView += '<td></td>';
77
+ dayOfWeek++;
78
+ }
79
+
80
+ monthView += '</tr></tbody></table>';
81
+
82
+ return monthView;
83
+ };
84
+
85
+ export const getYearOptions = (range) =>
86
+ generateYearList(range)
87
+ .map((item) => comboBoxItemTpl({ label: item, dataId: item, dataName: item }))
88
+ .join('');
89
+
90
+ export const getMonthsOptions = (customMonths = months) =>
91
+ customMonths
92
+ .map((item, index) => comboBoxItemTpl({ label: item, dataId: index + 1, dataName: item }))
93
+ .join('');
94
+
95
+ export const isViewVisible = (selectionTimestamp, previewTimestamp) => {
96
+ const [previewYear, previewMonth] = getTimestampParts(previewTimestamp);
97
+ const [selectedYear, selectedMonth] = getTimestampParts(selectionTimestamp);
98
+ return selectedYear === previewYear && selectedMonth === previewMonth;
99
+ };
100
+
101
+ export const createInputs = () => {
102
+ const ele = document.createElement('span');
103
+
104
+ ele.innerHTML = `
105
+ <descope-combo-box
106
+ label-type="static"
107
+ bordered="true"
108
+ item-label-path="data-name"
109
+ item-value-path="data-id"
110
+ class="month-input"
111
+ >
112
+ ${getMonthsOptions()}
113
+ </descope-combo-box>
114
+ <descope-combo-box
115
+ allow-custom-value="true"
116
+ label-type="static"
117
+ bordered="true"
118
+ item-label-path="data-name"
119
+ item-value-path="data-id"
120
+ class="year-input"
121
+ no-empty-value="true"
122
+ >
123
+ </descope-combo-box>
124
+ `;
125
+
126
+ return ele;
127
+ };
128
+
129
+ export const initComboBox = (input, onChange, onBlur) => {
130
+ input.addEventListener('input', onChange);
131
+ input.addEventListener('focusout', onBlur);
132
+ return input;
133
+ };
134
+
135
+ export const ensureMonthNamesArr = (attrVal) => {
136
+ const monthArr = attrVal?.split(',');
137
+ return isValidAttrArr(monthArr, 12) ? monthArr : months;
138
+ };
139
+
140
+ export const ensureWeekdayNamesArr = (attrVal) => {
141
+ const customWeekdayArr = attrVal?.split?.(',');
142
+ const isCustomValid = isValidAttrArr(customWeekdayArr, 7);
143
+ return isCustomValid ? customWeekdayArr : weekdays;
144
+ };
145
+
146
+ export const ensureShortWeekdayNamesArr = (attrVal) => {
147
+ const customShortWeekdays = attrVal;
148
+
149
+ if (!attrVal || !isValidAttrArr(customShortWeekdays, 7)) {
150
+ return weekdays.map((d) => d.substring(0, 3));
151
+ }
152
+
153
+ return customShortWeekdays.map((d) => d.substring(0, 3));
154
+ };
155
+
156
+ export const truncateWeekdays = (arr) => arr.map((d) => d.substring(0, 3));
157
+
158
+ export const prevMonth = (timestamp) => {
159
+ const date = newDate(timestamp);
160
+ const month = date.getMonth();
161
+
162
+ if (month === 0) {
163
+ const year = date.getFullYear();
164
+ date.setFullYear(year - 1);
165
+ date.setMonth(11);
166
+ } else {
167
+ date.setMonth(month - 1);
168
+ }
169
+
170
+ return date;
171
+ };
172
+
173
+ export const nextMonth = (timestamp) => {
174
+ const date = newDate(timestamp);
175
+ const month = date.getMonth();
176
+
177
+ if (month === 11) {
178
+ const year = date.getFullYear();
179
+ date.setFullYear(year + 1);
180
+ date.setMonth(0);
181
+ } else {
182
+ date.setMonth(month + 1);
183
+ }
184
+
185
+ return date;
186
+ };
@@ -0,0 +1,9 @@
1
+ import '../../descope-combo-box';
2
+ import '../../descope-icon';
3
+ import '../../descope-button';
4
+
5
+ import { componentName, CalendarClass } from './CalendarClass';
6
+
7
+ customElements.define(componentName, CalendarClass);
8
+
9
+ export { CalendarClass };
@@ -0,0 +1,49 @@
1
+ import { DIVIDER, SUPPORTED_FORMATS } from './consts';
2
+ import { newDate } from './helpers';
3
+
4
+ const patterns = {
5
+ MM: '(0?[1-9]|1[0-2])',
6
+ DD: '(0?[1-9]|[12][0-9]|3[01])',
7
+ YYYY: '([0-9]{4})',
8
+ };
9
+
10
+ const createPattern = (format) => {
11
+ const pattern = format
12
+ .split(DIVIDER)
13
+ .map((part) => patterns[part])
14
+ .join('\\D');
15
+
16
+ return `^${pattern}$`;
17
+ };
18
+
19
+ const createToValuesFn = (format) => {
20
+ const order = format.split(DIVIDER);
21
+ return (match) => {
22
+ const values = {};
23
+ order.forEach((part, index) => {
24
+ values[part] = match[index + 1];
25
+ });
26
+ return [values.YYYY, values.MM, values.DD];
27
+ };
28
+ };
29
+
30
+ const createDate = (val, regexp, toValuesFn) => {
31
+ const match = regexp.exec(val);
32
+ if (!match) return null;
33
+ const [year, month, day] = toValuesFn(match);
34
+ return newDate([year, month, day].join(DIVIDER));
35
+ };
36
+
37
+ const createFormat = (format) => {
38
+ const pattern = createPattern(format);
39
+ const toValuesFn = createToValuesFn(format);
40
+ const regexp = new RegExp(pattern);
41
+
42
+ return {
43
+ pattern,
44
+ validate: (val) => regexp.test(val),
45
+ getDate: (val) => createDate(val, regexp, toValuesFn),
46
+ };
47
+ };
48
+
49
+ export const formats = Object.fromEntries(SUPPORTED_FORMATS.map((f) => [f, createFormat(f)]));
@@ -0,0 +1,72 @@
1
+ import { COUNTER_SUPPORTED_KEYS } from './consts';
2
+
3
+ export const isValidTimestamp = (val) => !Number.isNaN(Number(val));
4
+
5
+ export const isNumber = (val) => !Number.isNaN(Number(val));
6
+
7
+ export const getTimestampParts = (timestamp) => {
8
+ const date = new Date(timestamp);
9
+ const year = date.getFullYear();
10
+ const month = date.getMonth() + 1;
11
+ const day = date.getDate();
12
+ return [year, month, day];
13
+ };
14
+
15
+ export const formatTimestamp = (timestamp, format) => {
16
+ const [year, month, day] = getTimestampParts(timestamp);
17
+
18
+ const parts = {
19
+ DD: String(day).padStart(2, '0'),
20
+ MM: String(month).padStart(2, '0'),
21
+ YYYY: String(year),
22
+ };
23
+
24
+ return format.replace(/DD|MM|YYYY/g, (match) => parts[match]);
25
+ };
26
+
27
+ // polyfill for safari Date API (which doesn't accept "YYYY-MM-DD" string as value)
28
+ export const newDate = (date) => {
29
+ if (typeof date === 'number') {
30
+ return new Date(date);
31
+ }
32
+ if (typeof date === 'string') {
33
+ return new Date(date.replace(/-/g, '/'));
34
+ }
35
+ return new Date();
36
+ };
37
+
38
+ export const isSupportedKey = (key) => COUNTER_SUPPORTED_KEYS.includes(key);
39
+
40
+ export const getKeyMap = (key, shiftKey, metaKey) => {
41
+ return {
42
+ refresh: metaKey && key.toLowerCase() === 'r',
43
+ tab: key === 'Tab',
44
+ shiftTab: shiftKey && key === 'Tab',
45
+ backspace: key === 'Backspace',
46
+ arrowUp: !shiftKey && key === 'ArrowUp',
47
+ arrowDown: !shiftKey && key === 'ArrowDown',
48
+ arrowLeft: !shiftKey && key === 'ArrowLeft',
49
+ arrowRight: !shiftKey && key === 'ArrowRight',
50
+ pageUp: !shiftKey && key === 'PageUp',
51
+ pageDown: !shiftKey && key === 'PageDown',
52
+ shiftArrowUp: shiftKey && key === 'ArrowUp',
53
+ shiftArrowDown: shiftKey && key === 'ArrowDown',
54
+ shiftPageUp: shiftKey && key === 'PageUp',
55
+ shiftPageDown: shiftKey && key === 'PageDown',
56
+ };
57
+ };
58
+
59
+ export const getCurrentTime = () => newDate().getTime();
60
+ export const getFullYear = (timestamp) => newDate(timestamp).getFullYear().toString();
61
+ export const getMonth = (timestamp) => (newDate(timestamp).getMonth() + 1).toString();
62
+ export const getCurrentDay = () => newDate().getDate();
63
+ export const getCurrentYear = () => newDate().getFullYear().toString();
64
+
65
+ // Vaadin uses "constructed stylesheet" to hide the host in dialog components.
66
+ // To override it, we need to push an overriding constructed stylesheet to the shadow DOM
67
+ // opened issue in vaadin: https://github.com/vaadin/web-components/issues/7979
68
+ export const overrideConstructedStylesheet = (ele) => {
69
+ const cs = new CSSStyleSheet();
70
+ cs.insertRule(':host{display:block!important;}');
71
+ ele?.shadowRoot?.adoptedStyleSheets?.push(cs);
72
+ };
@@ -0,0 +1,14 @@
1
+ export const calendarIcon = `
2
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M9 5H15V4.50468C15 4.21404 15.226 4 15.5047 4H16.4953C16.786 4 17 4.22595 17 4.50468V5H18.7568C19.3028 5 19.75 5.44725 19.75 5.99896V7.00104C19.75 7.55734 19.3053 8 18.7568 8H5.24317C4.69717 8 4.25 7.55275 4.25 7.00104V5.99896C4.25 5.44266 4.69466 5 5.24317 5H7V4.50468C7 4.21404 7.22596 4 7.50468 4H8.49532C8.78596 4 9 4.22595 9 4.50468V5ZM5.50468 9H6.49532C6.78596 9 7 9.22596 7 9.50468V10.4953C7 10.786 6.77404 11 6.49532 11H5.50468C5.21404 11 5 10.774 5 10.4953V9.50468C5 9.21404 5.22595 9 5.50468 9ZM8.50468 9H9.49532C9.78596 9 10 9.22596 10 9.50468V10.4953C10 10.786 9.77404 11 9.49532 11H8.50468C8.21404 11 8 10.774 8 10.4953V9.50468C8 9.21404 8.22596 9 8.50468 9ZM11.5047 9H12.4953C12.786 9 13 9.22596 13 9.50468V10.4953C13 10.786 12.774 11 12.4953 11H11.5047C11.214 11 11 10.774 11 10.4953V9.50468C11 9.21404 11.226 9 11.5047 9ZM5.50468 12H6.49532C6.78596 12 7 12.226 7 12.5047V13.4953C7 13.786 6.77404 14 6.49532 14H5.50468C5.21404 14 5 13.774 5 13.4953V12.5047C5 12.214 5.22595 12 5.50468 12ZM8.50468 12H9.49532C9.78596 12 10 12.226 10 12.5047V13.4953C10 13.786 9.77404 14 9.49532 14H8.50468C8.21404 14 8 13.774 8 13.4953V12.5047C8 12.214 8.22596 12 8.50468 12ZM11.5047 12H12.4953C12.786 12 13 12.226 13 12.5047V13.4953C13 13.786 12.774 14 12.4953 14H11.5047C11.214 14 11 13.774 11 13.4953V12.5047C11 12.214 11.226 12 11.5047 12ZM5.50468 15H6.49532C6.78596 15 7 15.226 7 15.5047V16.4953C7 16.786 6.77404 17 6.49532 17H5.50468C5.21404 17 5 16.774 5 16.4953V15.5047C5 15.214 5.22595 15 5.50468 15ZM8.50468 15H9.49532C9.78596 15 10 15.226 10 15.5047V16.4953C10 16.786 9.77404 17 9.49532 17H8.50468C8.21404 17 8 16.774 8 16.4953V15.5047C8 15.214 8.22596 15 8.50468 15ZM11.5047 15H12.4953C12.786 15 13 15.226 13 15.5047V16.4953C13 16.786 12.774 17 12.4953 17H11.5047C11.214 17 11 16.774 11 16.4953V15.5047C11 15.214 11.226 15 11.5047 15ZM14.5047 9H15.4953C15.786 9 16 9.22596 16 9.50468V10.4953C16 10.786 15.774 11 15.4953 11H14.5047C14.214 11 14 10.774 14 10.4953V9.50468C14 9.21404 14.226 9 14.5047 9ZM14.5047 12H15.4953C15.786 12 16 12.226 16 12.5047V13.4953C16 13.786 15.774 14 15.4953 14H14.5047C14.214 14 14 13.774 14 13.4953V12.5047C14 12.214 14.226 12 14.5047 12ZM14.5047 15H15.4953C15.786 15 16 15.226 16 15.5047V16.4953C16 16.786 15.774 17 15.4953 17H14.5047C14.214 17 14 16.774 14 16.4953V15.5047C14 15.214 14.226 15 14.5047 15ZM17.5047 15H18.4953C18.786 15 19 15.226 19 15.5047V16.4953C19 16.786 18.774 17 18.4953 17H17.5047C17.214 17 17 16.774 17 16.4953V15.5047C17 15.214 17.226 15 17.5047 15ZM5.50468 18H6.49532C6.78596 18 7 18.226 7 18.5047V19.4953C7 19.786 6.77404 20 6.49532 20H5.50468C5.21404 20 5 19.774 5 19.4953V18.5047C5 18.214 5.22595 18 5.50468 18ZM8.50468 18H9.49532C9.78596 18 10 18.226 10 18.5047V19.4953C10 19.786 9.77404 20 9.49532 20H8.50468C8.21404 20 8 19.774 8 19.4953V18.5047C8 18.214 8.22596 18 8.50468 18ZM11.5047 18H12.4953C12.786 18 13 18.226 13 18.5047V19.4953C13 19.786 12.774 20 12.4953 20H11.5047C11.214 20 11 19.774 11 19.4953V18.5047C11 18.214 11.226 18 11.5047 18ZM14.5047 18H15.4953C15.786 18 16 18.226 16 18.5047V19.4953C16 19.786 15.774 20 15.4953 20H14.5047C14.214 20 14 19.774 14 19.4953V18.5047C14 18.214 14.226 18 14.5047 18ZM17.5047 18H18.4953C18.786 18 19 18.226 19 18.5047V19.4953C19 19.786 18.774 20 18.4953 20H17.5047C17.214 20 17 19.774 17 19.4953V18.5047C17 18.214 17.226 18 17.5047 18ZM17.5047 12H18.4953C18.786 12 19 12.226 19 12.5047V13.4953C19 13.786 18.774 14 18.4953 14H17.5047C17.214 14 17 13.774 17 13.4953V12.5047C17 12.214 17.226 12 17.5047 12ZM17.5047 9H18.4953C18.786 9 19 9.22596 19 9.50468V10.4953C19 10.786 18.774 11 18.4953 11H17.5047C17.214 11 17 10.774 17 10.4953V9.50468C17 9.21404 17.226 9 17.5047 9Z" fill="#808080"/>
4
+ </svg>
5
+ `;
6
+
7
+ export const arrowRightIcon = `
8
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
9
+ <path d="M9.27283 6.78069C8.87912 6.34164 8.91587 5.66655 9.35492 5.27283C9.79397 4.87912 10.4691 4.91587 10.8628 5.35492C10.8628 5.35492 16.0022 10.9543 16.366 11.36C16.7298 11.7657 16.7298 12.2392 16.366 12.6448L10.8628 18.6451C10.4691 19.0841 9.79397 19.1209 9.35492 18.7272C8.91587 18.3334 8.87912 17.6584 9.27283 17.2193L14.1368 12L9.27283 6.78069Z" fill="#808080"/>
10
+ </svg>`;
11
+
12
+ export const arrowLeftIcon = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
13
+ <path d="M14.7272 17.2193C15.1209 17.6584 15.0841 18.3334 14.6451 18.7272C14.206 19.1209 13.5309 19.0841 13.1372 18.6451C13.1372 18.6451 7.99776 13.0457 7.63399 12.64C7.27023 12.2343 7.27023 11.7608 7.63399 11.3552L13.1372 5.35492C13.5309 4.91587 14.206 4.87912 14.6451 5.27283C15.0841 5.66655 15.1209 6.34164 14.7272 6.78069L9.86322 12L14.7272 17.2193Z" fill="#808080"/>
14
+ </svg>`;
@@ -0,0 +1,10 @@
1
+ import '@vaadin/popover/src/vaadin-popover';
2
+ import './descope-calendar';
3
+ import '../descope-text-field';
4
+ import '../descope-icon';
5
+
6
+ import { componentName, DateFieldClass } from './DateFieldClass';
7
+
8
+ customElements.define(componentName, DateFieldClass);
9
+
10
+ export { DateFieldClass };
@@ -94,6 +94,8 @@ export default {
94
94
  inputOutlineWidth: { ...inputField, property: 'outline-width' },
95
95
  inputOutlineOffset: { ...inputField, property: 'outline-offset' },
96
96
 
97
+ textAlign: {},
98
+
97
99
  inputTextAlign: [
98
100
  { ...input, property: 'text-align' },
99
101
  { ...externalInput, property: 'text-align' },
package/src/index.cjs.js CHANGED
@@ -47,6 +47,8 @@ export { PolicyValidationClass } from './components/descope-policy-validation/Po
47
47
  export { CodeSnippetClass } from './components/descope-code-snippet/CodeSnippetClass';
48
48
  export { RadioGroupClass } from './components/descope-radio-group/RadioGroupClass';
49
49
  export { RadioButtonClass } from './components/descope-radio-group/RadioButtonClass';
50
+ export { DateFieldClass } from './components/descope-date-field/DateFieldClass';
51
+ export { CalendarClass } from './components/descope-date-field/descope-calendar/CalendarClass';
50
52
  export { ListClass } from './components/descope-list/ListClass';
51
53
  export { ListItemClass } from './components/descope-list/ListItemClass';
52
54
  export { AppsListClass } from './components/descope-apps-list/AppsListClass';
package/src/index.d.ts CHANGED
@@ -47,6 +47,8 @@ export { MappingsFieldClass } from './components/mapping-fields/descope-mappings
47
47
  export { SamlGroupMappingsClass } from './components/mapping-fields/descope-saml-group-mappings/';
48
48
  export { PolicyValidationClass } from './components/descope-policy-validation/';
49
49
  export { CodeSnippetClass } from './components/descope-code-snippet/';
50
+ export { CalendarClass } from './components/descope-date-field/descope-calendar';
51
+ export { DateFieldClass } from './components/descope-date-field/';
50
52
 
51
53
  export type Theme = {
52
54
  globals: {
package/src/index.js CHANGED
@@ -4,7 +4,8 @@ export * from './components/boolean-fields/descope-switch-toggle';
4
4
  export * from './components/descope-loader-linear';
5
5
  export * from './components/descope-loader-radial';
6
6
  export * from './components/descope-container';
7
- // export * from './components/descope-date-picker';
7
+ export * from './components/descope-date-field/descope-calendar';
8
+ export * from './components/descope-date-field';
8
9
  export * from './components/descope-divider';
9
10
  export * from './components/descope-email-field';
10
11
  export * from './components/descope-link';
@@ -7,6 +7,8 @@ const errorAttributes = {
7
7
  patternMismatch: 'data-errormessage-pattern-mismatch',
8
8
  tooShort: 'data-errormessage-pattern-mismatch-too-short',
9
9
  tooLong: 'data-errormessage-pattern-mismatch-too-long',
10
+ rangeUnderflow: 'data-errormessage-pattern-range-underflow',
11
+ rangeOverflow: 'data-errormessage-pattern-range-overflow',
10
12
  typeMismatch: 'data-errormessage-type-mismatch',
11
13
  };
12
14
 
@@ -106,9 +108,13 @@ export const inputValidationMixin = (superclass) =>
106
108
  case tooLong:
107
109
  return this.getAttribute(errorAttributes.tooLong) || this.defaultErrorMsgTooLong;
108
110
  case rangeUnderflow:
109
- return this.defaultErrorMsgRangeUnderflow;
111
+ return (
112
+ this.getAttribute(errorAttributes.rangeUnderflow) || this.defaultErrorMsgRangeUnderflow
113
+ );
110
114
  case rangeOverflow:
111
- return this.defaultErrorMsgRangeOverflow;
115
+ return (
116
+ this.getAttribute(errorAttributes.rangeOverflow) || this.defaultErrorMsgRangeOverflow
117
+ );
112
118
  case customError:
113
119
  return this.validationMessage;
114
120
  default:
@@ -30,8 +30,11 @@ const withWaitForShadowRoot = (getRootElementFn) => async (that) => {
30
30
 
31
31
  counter++;
32
32
 
33
- if (!ele?.shadowRoot) setTimeout(check);
34
- else res(ele.shadowRoot);
33
+ if (!ele?.shadowRoot) {
34
+ setTimeout(check);
35
+ } else {
36
+ res(ele.shadowRoot);
37
+ }
35
38
  };
36
39
  check();
37
40
  });
@@ -62,7 +65,7 @@ export const portalMixin =
62
65
  constructor() {
63
66
  // we cannot use "this" before calling "super"
64
67
  const getRootElement = async (that) => {
65
- const baseEle = that.shadowRoot.querySelector(that.baseSelector);
68
+ const baseEle = (that.shadowRoot || that).querySelector(that.baseSelector);
66
69
  if (!selector) {
67
70
  return baseEle;
68
71
  }
@@ -0,0 +1,94 @@
1
+ import globals from '../globals';
2
+ import { CalendarClass } from '../../components/descope-date-field/descope-calendar/CalendarClass';
3
+ import { getThemeRefs } from '../../helpers/themeHelpers';
4
+ import { refs } from './inputWrapper';
5
+
6
+ const globalRefs = getThemeRefs(globals);
7
+
8
+ const vars = CalendarClass.cssVarList;
9
+
10
+ const calendar = {
11
+ [vars.fontFamily]: refs.fontFamily,
12
+ [vars.fontSize]: refs.fontSize,
13
+ [vars.hostDirection]: refs.direction,
14
+
15
+ [vars.calendarPadding]: '1em',
16
+
17
+ [vars.topNavVerticalPadding]: '1em',
18
+ [vars.topNavHorizontalPadding]: '1em',
19
+ [vars.topNavAlignment]: 'space-between',
20
+ [vars.topNavGap]: '0',
21
+ [vars.topNavSelectorsGap]: '0.5em',
22
+
23
+ [vars.bottomNavVerticalPadding]: '0.75em',
24
+ [vars.bottomNavHorizontalPadding]: '1.5em',
25
+ [vars.bottomNavAlignment]: 'space-between',
26
+ [vars.bottomNavGap]: '0.5em',
27
+
28
+ [vars.navMarginBottom]: '0.75em',
29
+ [vars.navBorderBottomWidth]: '1px',
30
+ [vars.navBorderBottomColor]: globalRefs.colors.surface.highlight,
31
+ [vars.navBorderBottomStyle]: 'solid',
32
+
33
+ [vars.yearInputWidth]: '6em',
34
+ [vars.monthInputWidth]: '8em',
35
+
36
+ [vars.navButtonSize]: '24px',
37
+ [vars.navButtonCursor]: 'pointer',
38
+
39
+ [vars.weekdayFontSize]: '0.875em',
40
+ [vars.weekdayFontWeight]: '500',
41
+ [vars.weekdayTextColor]: globalRefs.colors.surface.dark,
42
+
43
+ // day table cell
44
+ [vars.dayWidth]: '2.705em',
45
+ [vars.dayHeight]: '3.125em',
46
+
47
+ // day value
48
+ [vars.daySize]: '2.125em',
49
+ [vars.dayFontSize]: '1em',
50
+ [vars.dayRadius]: '50%',
51
+ [vars.dayTextAlign]: 'center',
52
+ [vars.dayPadding]: '0',
53
+ [vars.dayTextColor]: globalRefs.colors.surface.contrast,
54
+ [vars.dayFontWeight]: '500',
55
+ [vars.dayBackgroundColor]: 'transparent',
56
+ [vars.dayCursor]: 'pointer',
57
+ [vars.dayBackgroundColorHover]: globalRefs.colors.primary.highlight,
58
+
59
+ // selected day
60
+ [vars.daySelectedBackgroundColor]: globalRefs.colors.primary.main,
61
+ [vars.daySelectedTextdColor]: globalRefs.colors.primary.contrast,
62
+
63
+ // disabled day (out of min/max range)
64
+ [vars.dayDisabledTextdColor]: globalRefs.colors.surface.light,
65
+
66
+ // today
67
+ [vars.currentDayBorderColor]: globalRefs.colors.surface.light,
68
+ [vars.currentDayBorderWidth]: '1px',
69
+ [vars.currentDayBorderStyle]: 'solid',
70
+
71
+ size: {
72
+ xs: { [vars.fontSize]: '12px' },
73
+ sm: { [vars.fontSize]: '14px' },
74
+ md: { [vars.fontSize]: '16px' },
75
+ lg: { [vars.fontSize]: '18px' },
76
+ },
77
+
78
+ [vars.navButtonRotation]: 'rotate(180deg)',
79
+
80
+ _disabled: {
81
+ [vars.navButtonOpacity]: '0.5',
82
+ [vars.dayBackgroundColorHover]: 'none',
83
+ [vars.navButtonCursor]: 'default',
84
+ [vars.dayCursor]: 'default',
85
+ },
86
+
87
+ _fullWidth: {
88
+ [vars.hostWidth]: '100%',
89
+ [vars.dayBlockAlign]: '0 auto',
90
+ },
91
+ };
92
+
93
+ export default calendar;
94
+ export { vars };
@@ -0,0 +1,63 @@
1
+ import { DateFieldClass } from '../../components/descope-date-field/DateFieldClass';
2
+ import { refs } from './inputWrapper';
3
+ import globals from '../globals';
4
+ import { getThemeRefs } from '../../helpers/themeHelpers';
5
+
6
+ const globalRefs = getThemeRefs(globals);
7
+
8
+ const shadowColor = '#00000020';
9
+ const { shadow } = globalRefs;
10
+
11
+ const vars = DateFieldClass.cssVarList;
12
+
13
+ const dateField = {
14
+ [vars.hostWidth]: refs.width,
15
+ [vars.hostMinWidth]: refs.minWidth,
16
+ [vars.hostDirection]: refs.direction,
17
+ [vars.fontSize]: refs.fontSize,
18
+ [vars.fontFamily]: refs.fontFamily,
19
+ [vars.labelFontSize]: refs.labelFontSize,
20
+ [vars.labelFontWeight]: refs.labelFontWeight,
21
+ [vars.labelTextColor]: refs.labelTextColor,
22
+ [vars.errorMessageTextColor]: refs.errorMessageTextColor,
23
+ [vars.inputValueTextColor]: refs.valueTextColor,
24
+ [vars.inputPlaceholderColor]: refs.placeholderTextColor,
25
+ [vars.inputBorderWidth]: refs.borderWidth,
26
+ [vars.inputBorderStyle]: refs.borderStyle,
27
+ [vars.inputBorderColor]: refs.borderColor,
28
+ [vars.inputBorderRadius]: refs.borderRadius,
29
+ [vars.inputOutlineWidth]: refs.outlineWidth,
30
+ [vars.inputOutlineStyle]: refs.outlineStyle,
31
+ [vars.inputOutlineColor]: refs.outlineColor,
32
+ [vars.inputOutlineOffset]: refs.outlineOffset,
33
+ [vars.inputBackgroundColor]: refs.backgroundColor,
34
+ [vars.labelRequiredIndicator]: refs.requiredIndicator,
35
+ [vars.inputHorizontalPadding]: refs.horizontalPadding,
36
+ [vars.inputHeight]: refs.inputHeight,
37
+ [vars.labelPosition]: refs.labelPosition,
38
+ [vars.labelTopPosition]: refs.labelTopPosition,
39
+ [vars.labelHorizontalPosition]: refs.labelHorizontalPosition,
40
+ [vars.inputTransformY]: refs.inputTransformY,
41
+ [vars.inputTransition]: refs.inputTransition,
42
+ [vars.marginInlineStart]: refs.marginInlineStart,
43
+ [vars.placeholderOpacity]: refs.placeholderOpacity,
44
+ [vars.inputVerticalAlignment]: refs.inputVerticalAlignment,
45
+ [vars.valueInputHeight]: refs.valueInputHeight,
46
+ [vars.valueInputMarginBottom]: refs.valueInputMarginBottom,
47
+
48
+ [vars.iconMargin]: '0.375em',
49
+
50
+ [vars.overlay.marginTop]: `calc(${refs.outlineWidth} + 1px)`,
51
+ [vars.overlay.backgroundColor]: refs.backgroundColor,
52
+ [vars.overlay.backdropBackgroundColor]: 'transparent',
53
+ [vars.overlay.backdropPointerEvents]: 'all',
54
+ [vars.overlay.boxShadow]: `${shadow.wide.xl} ${shadowColor}, ${shadow.narrow.xl} ${shadowColor}`,
55
+ [vars.overlay.outlineWidth]: '0',
56
+ [vars.overlay.outlineColor]: 'transparent',
57
+ [vars.overlay.outlineStyle]: 'none',
58
+ [vars.overlay.direction]: refs.direction,
59
+ [vars.overlay.padding]: '0',
60
+ };
61
+
62
+ export default dateField;
63
+ export { vars };
@@ -41,6 +41,8 @@ import * as icon from './icon';
41
41
  import * as codeSnippet from './codeSnippet';
42
42
  import * as radioGroup from './radioGroup/radioGroup';
43
43
  import * as radioButton from './radioGroup/radioButton';
44
+ import * as calendar from './calendar';
45
+ import * as dateField from './dateField';
44
46
  import * as list from './list/list';
45
47
  import * as listItem from './list/listItem';
46
48
  import * as appsList from './appsList';
@@ -90,6 +92,8 @@ const components = {
90
92
  codeSnippet,
91
93
  radioGroup,
92
94
  radioButton,
95
+ calendar,
96
+ dateField,
93
97
  list,
94
98
  listItem,
95
99
  appsList,
@@ -33,6 +33,8 @@ const [theme, refs, vars] = createHelperVars(
33
33
  horizontalPadding: '0.5em',
34
34
  verticalPadding: '0.5em',
35
35
 
36
+ textAlign: 'start',
37
+
36
38
  backgroundColor: globalRefs.colors.surface.main,
37
39
 
38
40
  fontFamily: globalRefs.fonts.font1.family,
@@ -49,6 +51,10 @@ const [theme, refs, vars] = createHelperVars(
49
51
  },
50
52
 
51
53
  labelType: {
54
+ static: {
55
+ valueInputHeight: '3em',
56
+ valueInputMarginBottom: 'auto',
57
+ },
52
58
  floating: {
53
59
  labelPosition: 'absolute',
54
60
  labelTopPosition: '0',
@@ -31,6 +31,7 @@ export const textField = {
31
31
  [vars.inputHeight]: refs.inputHeight,
32
32
  [vars.inputHorizontalPadding]: refs.horizontalPadding,
33
33
  [vars.helperTextColor]: refs.helperTextColor,
34
+ [vars.textAlign]: refs.textAlign,
34
35
  textAlign: {
35
36
  right: { [vars.inputTextAlign]: 'right' },
36
37
  left: { [vars.inputTextAlign]: 'left' },