@genesislcap/foundation-ui 14.246.2 → 14.247.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/custom-elements.json +10144 -8953
  2. package/dist/dts/base-components.d.ts +11 -0
  3. package/dist/dts/base-components.d.ts.map +1 -1
  4. package/dist/dts/index.d.ts +1 -0
  5. package/dist/dts/index.d.ts.map +1 -1
  6. package/dist/dts/scheduler-cron-builder/daily-recurrence/daily-recurrence.d.ts +342 -0
  7. package/dist/dts/scheduler-cron-builder/daily-recurrence/daily-recurrence.d.ts.map +1 -0
  8. package/dist/dts/scheduler-cron-builder/daily-recurrence/daily-recurrence.styles.d.ts +3 -0
  9. package/dist/dts/scheduler-cron-builder/daily-recurrence/daily-recurrence.styles.d.ts.map +1 -0
  10. package/dist/dts/scheduler-cron-builder/daily-recurrence/daily-recurrence.template.d.ts +4 -0
  11. package/dist/dts/scheduler-cron-builder/daily-recurrence/daily-recurrence.template.d.ts.map +1 -0
  12. package/dist/dts/scheduler-cron-builder/helpers.d.ts +211 -0
  13. package/dist/dts/scheduler-cron-builder/helpers.d.ts.map +1 -0
  14. package/dist/dts/scheduler-cron-builder/index.d.ts +4 -0
  15. package/dist/dts/scheduler-cron-builder/index.d.ts.map +1 -0
  16. package/dist/dts/scheduler-cron-builder/monthly-yearly-recurrence/monthly-yearly-recurrence.d.ts +400 -0
  17. package/dist/dts/scheduler-cron-builder/monthly-yearly-recurrence/monthly-yearly-recurrence.d.ts.map +1 -0
  18. package/dist/dts/scheduler-cron-builder/monthly-yearly-recurrence/monthly-yearly-recurrence.styles.d.ts +3 -0
  19. package/dist/dts/scheduler-cron-builder/monthly-yearly-recurrence/monthly-yearly-recurrence.styles.d.ts.map +1 -0
  20. package/dist/dts/scheduler-cron-builder/monthly-yearly-recurrence/monthly-yearly-recurrence.template.d.ts +4 -0
  21. package/dist/dts/scheduler-cron-builder/monthly-yearly-recurrence/monthly-yearly-recurrence.template.d.ts.map +1 -0
  22. package/dist/dts/scheduler-cron-builder/scheduler-cron-builder.d.ts +124 -0
  23. package/dist/dts/scheduler-cron-builder/scheduler-cron-builder.d.ts.map +1 -0
  24. package/dist/dts/scheduler-cron-builder/scheduler-cron-builder.styles.d.ts +4 -0
  25. package/dist/dts/scheduler-cron-builder/scheduler-cron-builder.styles.d.ts.map +1 -0
  26. package/dist/dts/scheduler-cron-builder/scheduler-cron-builder.template.d.ts +4 -0
  27. package/dist/dts/scheduler-cron-builder/scheduler-cron-builder.template.d.ts.map +1 -0
  28. package/dist/dts/scheduler-cron-builder/types.d.ts +90 -0
  29. package/dist/dts/scheduler-cron-builder/types.d.ts.map +1 -0
  30. package/dist/dts/scheduler-cron-builder/weekly-recurrence/weekly-recurrence.d.ts +346 -0
  31. package/dist/dts/scheduler-cron-builder/weekly-recurrence/weekly-recurrence.d.ts.map +1 -0
  32. package/dist/dts/scheduler-cron-builder/weekly-recurrence/weekly-recurrence.styles.d.ts +3 -0
  33. package/dist/dts/scheduler-cron-builder/weekly-recurrence/weekly-recurrence.styles.d.ts.map +1 -0
  34. package/dist/dts/scheduler-cron-builder/weekly-recurrence/weekly-recurrence.template.d.ts +4 -0
  35. package/dist/dts/scheduler-cron-builder/weekly-recurrence/weekly-recurrence.template.d.ts.map +1 -0
  36. package/dist/dts/utils/base-datasource.d.ts +1 -1
  37. package/dist/esm/base-components.js +2 -0
  38. package/dist/esm/index.js +1 -0
  39. package/dist/esm/scheduler-cron-builder/daily-recurrence/daily-recurrence.js +38 -0
  40. package/dist/esm/scheduler-cron-builder/daily-recurrence/daily-recurrence.styles.js +5 -0
  41. package/dist/esm/scheduler-cron-builder/daily-recurrence/daily-recurrence.template.js +25 -0
  42. package/dist/esm/scheduler-cron-builder/helpers.js +330 -0
  43. package/dist/esm/scheduler-cron-builder/index.js +3 -0
  44. package/dist/esm/scheduler-cron-builder/monthly-yearly-recurrence/monthly-yearly-recurrence.js +130 -0
  45. package/dist/esm/scheduler-cron-builder/monthly-yearly-recurrence/monthly-yearly-recurrence.styles.js +25 -0
  46. package/dist/esm/scheduler-cron-builder/monthly-yearly-recurrence/monthly-yearly-recurrence.template.js +92 -0
  47. package/dist/esm/scheduler-cron-builder/scheduler-cron-builder.js +289 -0
  48. package/dist/esm/scheduler-cron-builder/scheduler-cron-builder.styles.js +72 -0
  49. package/dist/esm/scheduler-cron-builder/scheduler-cron-builder.template.js +101 -0
  50. package/dist/esm/scheduler-cron-builder/types.js +67 -0
  51. package/dist/esm/scheduler-cron-builder/weekly-recurrence/weekly-recurrence.js +59 -0
  52. package/dist/esm/scheduler-cron-builder/weekly-recurrence/weekly-recurrence.styles.js +9 -0
  53. package/dist/esm/scheduler-cron-builder/weekly-recurrence/weekly-recurrence.template.js +25 -0
  54. package/package.json +17 -16
@@ -0,0 +1,289 @@
1
+ import { __decorate } from "tslib";
2
+ import { showNotificationToast } from '@genesislcap/foundation-notifications';
3
+ import { attr, observable, volatile } from '@microsoft/fast-element';
4
+ import { FoundationElement } from '@microsoft/fast-foundation';
5
+ import { getPrefix } from '../utils';
6
+ import { buildConfigForDailyRecurrence, buildConfigForMonthlyRecurrence, buildConfigForWeeklyRecurrence, buildConfigForYearlyRecurrence, formatFrequency, getCronExpressionForDaily, getCronExpressionForMonth, getCronExpressionForWeekly, getCronExpressionForYear, isValidCron, parseCronExpression, } from './helpers';
7
+ import { schedulerCronBuilderStyles as styles } from './scheduler-cron-builder.styles';
8
+ import { foundationSchedulerCronBuilderTemplate as template } from './scheduler-cron-builder.template';
9
+ import { CronBuilderEvents, DateOrDay, MAX_DAYS, MAX_MONTHS, RecurrenceType, WeekType, } from './types';
10
+ /**
11
+ * @tagname %%prefix%%-scheduler-cron-builder
12
+ */
13
+ export class SchedulerCronBuilder extends FoundationElement {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.getConfigs = {
17
+ buildConfigForDailyRecurrence,
18
+ buildConfigForWeeklyRecurrence,
19
+ buildConfigForMonthlyRecurrence,
20
+ buildConfigForYearlyRecurrence,
21
+ };
22
+ /**
23
+ * Used to store the recurrence type of an event.
24
+ * This variable determines how often an event repeats including Daily, Weekly, Monthly, Yearly.
25
+ * See {@link RecurrenceType}
26
+ * @internal
27
+ */
28
+ this.recurrence = RecurrenceType.DAILY;
29
+ /**
30
+ * used to store the cron string generated as result of selected input
31
+ * @example
32
+ * `"0 30 10 ? * 2-6"` runs on weekdays from monday-friday at 10:30
33
+ *
34
+ */
35
+ this.cron = '';
36
+ /**
37
+ * Used to store the cron expression
38
+ * added to make sync directive work as it checks value field in the change event
39
+ * @internal
40
+ */
41
+ this.value = this.cron;
42
+ /**
43
+ * Used to store the config for each recurrence type in form of an object.
44
+ * See {@link CronConfig}
45
+ * @internal
46
+ */
47
+ this.cronConfig = {
48
+ type: RecurrenceType.DAILY,
49
+ weekType: WeekType.WEEK,
50
+ hours: '0',
51
+ minutes: '0',
52
+ seconds: '0',
53
+ };
54
+ /**
55
+ * Used to store the frequency of an event's recurrence
56
+ *
57
+ * Represents the interval between recurrences, based on the {@link RecurrenceType}
58
+ *
59
+ * e.g. a value of '3' means that the event occurs every third occurrence (every 3 months for 'MONTHLY' recurrence)
60
+ * MUST contain a positive value from {@link frequencyList}
61
+ * @internal
62
+ */
63
+ this.frequency = '1';
64
+ /**
65
+ * The hour at which the event should occurs
66
+ * @internal
67
+ */
68
+ this.hours = '0';
69
+ /**
70
+ * The minute at which the event should occurs
71
+ * @internal
72
+ */
73
+ this.minutes = '0';
74
+ /**
75
+ * The second at which the event should occurs
76
+ * @internal
77
+ */
78
+ this.seconds = '0';
79
+ this.timezone = '';
80
+ }
81
+ cronChanged() {
82
+ if (!this.cron)
83
+ return;
84
+ try {
85
+ if (!isValidCron(this.cron)) {
86
+ showNotificationToast({
87
+ title: 'Cron Scheduler',
88
+ body: `Invalid Cron Expression`,
89
+ toast: { type: 'critical' },
90
+ }, getPrefix(this));
91
+ return;
92
+ }
93
+ this.setsFieldsFromCronEx();
94
+ }
95
+ catch (error) {
96
+ console.error('Error:', error);
97
+ showNotificationToast({
98
+ title: 'Cron Scheduler',
99
+ body: error,
100
+ toast: { type: 'critical' },
101
+ }, getPrefix(this));
102
+ return;
103
+ }
104
+ }
105
+ /**
106
+ * The suffix that appears with frequency field
107
+ *
108
+ * @remarks This property updates every time recurrence is changed.
109
+ * Use it to determine the suffix specific to selected recurrence (e.g. `Days` for `DAILY` recurrenceType).
110
+ */
111
+ get frequencySuffix() {
112
+ switch (this.cronConfig.type) {
113
+ case RecurrenceType.DAILY:
114
+ return 'Day(s)';
115
+ case RecurrenceType.MONTHLY:
116
+ return 'Month(s)';
117
+ default:
118
+ return '';
119
+ }
120
+ }
121
+ /**
122
+ * The frequency dropdown list
123
+ *
124
+ * @remarks This property updates every time recurrence type is changed.
125
+ * Used to update the list size on basis of recurrence type e.g. 12 for month recurrence
126
+ */
127
+ get frequencyList() {
128
+ switch (this.cronConfig.type) {
129
+ case RecurrenceType.DAILY:
130
+ return Array.from({ length: MAX_DAYS }, (_, i) => i + 1);
131
+ case RecurrenceType.MONTHLY:
132
+ return Array.from({ length: MAX_MONTHS }, (_, i) => i + 1);
133
+ case RecurrenceType.YEARLY:
134
+ return Array.from({ length: MAX_MONTHS }, (_, i) => i + 1);
135
+ default:
136
+ return [];
137
+ }
138
+ }
139
+ connectedCallback() {
140
+ super.connectedCallback();
141
+ this.addEventListener(CronBuilderEvents.updateCronConfig, this.handleCronConfigUpdate);
142
+ }
143
+ disconnectedCallback() {
144
+ this.removeEventListener(CronBuilderEvents.updateCronConfig, this.handleCronConfigUpdate);
145
+ }
146
+ getBaseConfigFields() {
147
+ return {
148
+ frequency: this.frequency,
149
+ hours: this.hours,
150
+ minutes: this.minutes,
151
+ seconds: this.seconds,
152
+ };
153
+ }
154
+ /**
155
+ * sets default value for recurrence in cronConfig and generates cron expression
156
+ * @internal
157
+ */
158
+ handleRecurrenceChange() {
159
+ switch (this.recurrence) {
160
+ case RecurrenceType.DAILY:
161
+ this.cronConfig = Object.assign(Object.assign({ type: RecurrenceType.DAILY }, this.getBaseConfigFields()), { weekType: WeekType.WEEK });
162
+ this.generateCronExpressionFromConfig(this.cronConfig);
163
+ break;
164
+ case RecurrenceType.WEEKLY:
165
+ this.cronConfig = Object.assign(Object.assign({ type: RecurrenceType.WEEKLY }, this.getBaseConfigFields()), { selectedDays: new Set() });
166
+ this.generateCronExpressionFromConfig(this.cronConfig);
167
+ break;
168
+ case RecurrenceType.MONTHLY:
169
+ this.cronConfig = Object.assign(Object.assign({ type: RecurrenceType.MONTHLY }, this.getBaseConfigFields()), { dateOrDay: {
170
+ type: DateOrDay.DATE,
171
+ dayDate: '1',
172
+ } });
173
+ this.generateCronExpressionFromConfig(this.cronConfig);
174
+ break;
175
+ case RecurrenceType.YEARLY:
176
+ this.cronConfig = Object.assign(Object.assign({ type: RecurrenceType.YEARLY }, this.getBaseConfigFields()), { dateOrDay: {
177
+ type: DateOrDay.DATE,
178
+ dayDate: '1',
179
+ month: '1',
180
+ } });
181
+ this.generateCronExpressionFromConfig(this.cronConfig);
182
+ break;
183
+ default:
184
+ showNotificationToast({
185
+ title: 'Cron Scheduler',
186
+ body: `Recurrence type should be one of the known types: Daily, Weekly,Monthly or Yearly`,
187
+ toast: { type: 'critical' },
188
+ }, getPrefix(this));
189
+ }
190
+ }
191
+ /**
192
+ * change event for each input field including frequency, hours, minutes and seconds
193
+ * @internal
194
+ */
195
+ handleChange(fieldName) {
196
+ this.cronConfig[fieldName] = this[fieldName];
197
+ this.generateCronExpressionFromConfig(this.cronConfig);
198
+ }
199
+ /**
200
+ * event listener used to update cron config and cron expression
201
+ * @internal
202
+ */
203
+ handleCronConfigUpdate({ detail }) {
204
+ this.cronConfig = Object.assign(Object.assign({}, this.getBaseConfigFields()), detail);
205
+ this.generateCronExpressionFromConfig(this.cronConfig);
206
+ }
207
+ /**
208
+ * method that updates cron string on basis of config for each recurrence type
209
+ * @internal
210
+ */
211
+ generateCronExpressionFromConfig(config) {
212
+ switch (config.type) {
213
+ case RecurrenceType.DAILY:
214
+ this.cron = getCronExpressionForDaily(config, formatFrequency);
215
+ break;
216
+ case RecurrenceType.WEEKLY:
217
+ this.cron = getCronExpressionForWeekly(config);
218
+ break;
219
+ case RecurrenceType.MONTHLY:
220
+ this.cron = getCronExpressionForMonth(config, formatFrequency);
221
+ break;
222
+ case RecurrenceType.YEARLY:
223
+ this.cron = getCronExpressionForYear(config);
224
+ break;
225
+ default:
226
+ showNotificationToast({
227
+ title: 'Cron Scheduler',
228
+ body: `Recurrence type should be one of the known types: Daily, Weekly,Monthly or Yearly`,
229
+ toast: { type: 'critical' },
230
+ }, getPrefix(this));
231
+ }
232
+ this.value = this.cron;
233
+ this.$emit('change');
234
+ }
235
+ /**
236
+ * parses a cron expression and sets fields from it
237
+ * @internal
238
+ */
239
+ setsFieldsFromCronEx() {
240
+ this.cronConfig = parseCronExpression(this.cron, this.getConfigs);
241
+ this.recurrence = this.cronConfig.type;
242
+ this.frequency = this.cronConfig.frequency;
243
+ this.hours = this.cronConfig.hours;
244
+ this.minutes = this.cronConfig.minutes;
245
+ this.seconds = this.cronConfig.seconds;
246
+ }
247
+ }
248
+ __decorate([
249
+ observable
250
+ ], SchedulerCronBuilder.prototype, "recurrence", void 0);
251
+ __decorate([
252
+ observable
253
+ ], SchedulerCronBuilder.prototype, "cron", void 0);
254
+ __decorate([
255
+ observable
256
+ ], SchedulerCronBuilder.prototype, "cronConfig", void 0);
257
+ __decorate([
258
+ observable
259
+ ], SchedulerCronBuilder.prototype, "frequency", void 0);
260
+ __decorate([
261
+ observable
262
+ ], SchedulerCronBuilder.prototype, "hours", void 0);
263
+ __decorate([
264
+ observable
265
+ ], SchedulerCronBuilder.prototype, "minutes", void 0);
266
+ __decorate([
267
+ observable
268
+ ], SchedulerCronBuilder.prototype, "seconds", void 0);
269
+ __decorate([
270
+ volatile
271
+ ], SchedulerCronBuilder.prototype, "frequencySuffix", null);
272
+ __decorate([
273
+ volatile
274
+ ], SchedulerCronBuilder.prototype, "frequencyList", null);
275
+ __decorate([
276
+ attr
277
+ ], SchedulerCronBuilder.prototype, "timezone", void 0);
278
+ // explicitly declaring for extensibility
279
+ export const foundationSchedulerCronBuilderShadowOptions = undefined;
280
+ export const defaultCronBuilderConfig = {};
281
+ /**
282
+ * The Foundation Cron Scheduler Builder
283
+ *
284
+ * @public
285
+ * @remarks
286
+ * HTML Element: \<foundation-scheduler-cron-builder\>
287
+ */
288
+ export const foundationSchedulerCronBuilder = SchedulerCronBuilder.compose(Object.assign({ baseName: 'scheduler-cron-builder', styles,
289
+ template, shadowOptions: foundationSchedulerCronBuilderShadowOptions }, defaultCronBuilderConfig));
@@ -0,0 +1,72 @@
1
+ import { css } from '@microsoft/fast-element';
2
+ export const inputControls = css `
3
+ .input-container {
4
+ display: flex;
5
+ flex-direction: column;
6
+ gap: calc(var(--design-unit) * 2px);
7
+ }
8
+
9
+ .label {
10
+ color: var(--neutral-foreground-hint);
11
+ display: block;
12
+ cursor: pointer;
13
+ font-size: var(--type-ramp-base-font-size);
14
+ line-height: var(--type-ramp-base-line-height);
15
+ font-style: normal;
16
+ }
17
+
18
+ .row {
19
+ display: flex;
20
+ width: 50%;
21
+ align-items: center;
22
+ gap: calc(var(--design-unit) * 4px);
23
+ }
24
+ `;
25
+ export const schedulerCronBuilderStyles = css `
26
+ ${inputControls}
27
+ /* Host */
28
+ :host {
29
+ display: flex;
30
+ flex-direction: column;
31
+ width: 100%;
32
+ }
33
+
34
+ .container {
35
+ padding: calc(var(--design-unit) * 2px) calc(var(--design-unit) * 4px);
36
+ display: flex;
37
+ flex-direction: column;
38
+ gap: calc(var(--design-unit) * 4px);
39
+ }
40
+
41
+ .flex-row {
42
+ display: flex;
43
+ align-items: center;
44
+ gap: calc(var(--design-unit) * 4px);
45
+ }
46
+
47
+ .time-select {
48
+ min-width: 110px;
49
+ position: relative;
50
+ }
51
+
52
+ .frequency-select {
53
+ position: relative;
54
+ }
55
+
56
+ .frequency-select::part(end),
57
+ .time-select::part(end) {
58
+ min-width: 0;
59
+ width: 0;
60
+ }
61
+
62
+ .suffix-label {
63
+ position: absolute;
64
+ right: 35px; /* Move it before the icon */
65
+ top: 50%;
66
+ transform: translateY(-50%);
67
+ padding: 0 calc(var(--design-unit) * 1px);
68
+ color: var(--neutral-foreground-hint);
69
+ font-size: var(--type-ramp-minus-1-font-size);
70
+ white-space: nowrap;
71
+ }
72
+ `;
@@ -0,0 +1,101 @@
1
+ import { sync } from '@genesislcap/foundation-utils';
2
+ import { html, repeat, when } from '@microsoft/fast-element';
3
+ import { getPrefix } from '../utils';
4
+ import { DailyRecurrence } from './daily-recurrence/daily-recurrence';
5
+ import { MonthlyYearlyRecurrence } from './monthly-yearly-recurrence/monthly-yearly-recurrence';
6
+ import { MAX_HOURS, MAX_MINS_SEC, RecurrenceType } from './types';
7
+ import { WeeklyRecurrence } from './weekly-recurrence/weekly-recurrence';
8
+ DailyRecurrence;
9
+ WeeklyRecurrence;
10
+ MonthlyYearlyRecurrence;
11
+ const dailyTemplate = (prefix) => html `
12
+ <daily-recurrence :prefix=${() => prefix} :config=${(x) => x.cronConfig}></daily-recurrence>
13
+ `;
14
+ const weeklyTemplate = (prefix) => html `
15
+ <weekly-recurrence :prefix=${() => prefix} :config=${(x) => x.cronConfig}></weekly-recurrence>
16
+ `;
17
+ const monthlyOrYearlyTemplate = (prefix) => html `
18
+ <monthly-yearly-recurrence
19
+ :prefix=${() => prefix}
20
+ :config=${(x) => x.cronConfig}
21
+ ></monthly-yearly-recurrence>
22
+ `;
23
+ export const getPrefixedCronBuilder = (prefix) => html `
24
+ <template>
25
+ <div class="container">
26
+ <div class="input-container">
27
+ <label class="label">Recurrence</label>
28
+ <${prefix}-select
29
+ data-test-id="select-recurrence"
30
+ :value=${sync((x) => x.recurrence)}
31
+ @change="${(x) => x.handleRecurrenceChange()}"
32
+ >
33
+ <${prefix}-option data-test-id="${RecurrenceType.DAILY}">
34
+ ${RecurrenceType.DAILY}
35
+ </${prefix}-option>
36
+ <${prefix}-option data-test-id="${RecurrenceType.WEEKLY}">
37
+ ${RecurrenceType.WEEKLY}
38
+ </${prefix}-option>
39
+ <${prefix}-option data-test-id="${RecurrenceType.MONTHLY}">
40
+ ${RecurrenceType.MONTHLY}
41
+ </${prefix}-option>
42
+ <${prefix}-option data-test-id="${RecurrenceType.YEARLY}">
43
+ ${RecurrenceType.YEARLY}
44
+ </${prefix}-option>
45
+ </${prefix}-select>
46
+ </div>
47
+ <div class="row">
48
+ ${when((x) => x.recurrence === RecurrenceType.DAILY || x.recurrence === RecurrenceType.MONTHLY, html `
49
+ <div class="input-container">
50
+ <label class="label"> Frequency in ${(x) => x.frequencySuffix}</label>
51
+ <${prefix}-select class="frequency-select" data-test-id="frequency-dropdown" :value=${sync((x) => x.frequency)} @change="${(x) => x.handleChange('frequency')}" >
52
+ ${repeat((x) => x.frequencyList, html `
53
+ <${prefix}-option value="${(x) => x}">
54
+ ${(x) => x}
55
+ </${prefix}-option>
56
+ `)}
57
+ <div slot="end" class="suffix-label">${(x) => x.frequencySuffix}</div>
58
+ </${prefix}-select>
59
+ </div>`)}
60
+ <div class="input-container">
61
+ <label class="label">Time </label>
62
+ <div class="flex-row">
63
+ <${prefix}-select class="time-select" data-test-id="hours-dropdown" :value=${sync((x) => x.hours)} @change="${(x) => x.handleChange('hours')}" >
64
+ ${repeat(() => Array.from({ length: MAX_HOURS }, (_, i) => i), html `
65
+ <${prefix}-option value="${(x) => x}">
66
+ ${(x) => x}
67
+ </${prefix}-option>
68
+ `)}
69
+ <div slot="end" class="suffix-label">hr</div>
70
+ </${prefix}-select>
71
+ <${prefix}-select class="time-select" data-test-id="mins-dropdown" :value=${sync((x) => x.minutes)} @change="${(x) => x.handleChange('minutes')}" >
72
+ ${repeat(() => Array.from({ length: MAX_MINS_SEC }, (_, i) => i), html `
73
+ <${prefix}-option value="${(x) => x}">
74
+ ${(x) => x}
75
+ </${prefix}-option>
76
+ `)}
77
+ <div slot="end" class="suffix-label">min</div>
78
+ </${prefix}-select>
79
+ <${prefix}-select class="time-select" data-test-id="seconds-dropdown" :value=${sync((x) => x.seconds)} @change="${(x) => x.handleChange('seconds')}" >
80
+ ${repeat(() => Array.from({ length: MAX_MINS_SEC }, (_, i) => i), html `
81
+ <${prefix}-option value="${(x) => x}">
82
+ ${(x) => x}
83
+ </${prefix}-option>
84
+ `)}
85
+ <div slot="end" class="suffix-label">sec</div>
86
+ </${prefix}-select>
87
+ </div>
88
+ </div>
89
+ </div>
90
+
91
+ ${when((x) => x.recurrence === RecurrenceType.DAILY, dailyTemplate(prefix))}
92
+ ${when((x) => x.recurrence === RecurrenceType.WEEKLY, weeklyTemplate(prefix))}
93
+ ${when((x) => x.recurrence === RecurrenceType.MONTHLY || x.recurrence === RecurrenceType.YEARLY, monthlyOrYearlyTemplate(prefix))}
94
+
95
+ </div>
96
+
97
+ </template>
98
+ `;
99
+ export const foundationSchedulerCronBuilderTemplate = html `
100
+ ${(x) => getPrefixedCronBuilder(getPrefix(x))}
101
+ `;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Defines allowed recurrence types including Daily, Weekly, Monthly, Yearly.
3
+ * @internal
4
+ */
5
+ export var RecurrenceType;
6
+ (function (RecurrenceType) {
7
+ RecurrenceType["DAILY"] = "Daily";
8
+ RecurrenceType["WEEKLY"] = "Weekly";
9
+ RecurrenceType["MONTHLY"] = "Monthly";
10
+ RecurrenceType["YEARLY"] = "Yearly";
11
+ })(RecurrenceType || (RecurrenceType = {}));
12
+ /** @internal */
13
+ export var WeekType;
14
+ (function (WeekType) {
15
+ WeekType["WEEK"] = "Week";
16
+ WeekType["WORK_WEEK"] = "Work week";
17
+ })(WeekType || (WeekType = {}));
18
+ /** @internal */
19
+ export var DateOrDay;
20
+ (function (DateOrDay) {
21
+ DateOrDay["DATE"] = "Date";
22
+ DateOrDay["DAY_OF_MONTH"] = "Day of month";
23
+ })(DateOrDay || (DateOrDay = {}));
24
+ /** @internal */
25
+ export const daysOfWeek = [
26
+ { value: '2', label: 'Monday' },
27
+ { value: '3', label: 'Tuesday' },
28
+ { value: '4', label: 'Wednesday' },
29
+ { value: '5', label: 'Thursday' },
30
+ { value: '6', label: 'Friday' },
31
+ { value: '7', label: 'Saturday' },
32
+ { value: '1', label: 'Sunday' },
33
+ ];
34
+ /** @internal */
35
+ export const weekNumber = [
36
+ { value: '1', label: 'First' },
37
+ { value: '2', label: 'Second' },
38
+ { value: '3', label: 'Third' },
39
+ { value: '4', label: 'Fourth' },
40
+ { value: '-1', label: 'Last' },
41
+ ];
42
+ /** @internal */
43
+ export const months = [
44
+ { value: '1', label: 'January' },
45
+ { value: '2', label: 'February' },
46
+ { value: '3', label: 'March' },
47
+ { value: '4', label: 'April' },
48
+ { value: '5', label: 'May' },
49
+ { value: '6', label: 'June' },
50
+ { value: '7', label: 'July' },
51
+ { value: '8', label: 'August' },
52
+ { value: '9', label: 'September' },
53
+ { value: '10', label: 'October' },
54
+ { value: '11', label: 'November' },
55
+ { value: '12', label: 'December' },
56
+ ];
57
+ export const MAX_MONTHS = 12;
58
+ export const MAX_DAYS = 31;
59
+ export const CRON_LENGTH = 6;
60
+ export const MAX_WEEK_DAYS = 7;
61
+ export const MAX_HOURS = 24;
62
+ export const MAX_MINS_SEC = 60;
63
+ export const MAX_WEEK_NUMBER = 4;
64
+ export var CronBuilderEvents;
65
+ (function (CronBuilderEvents) {
66
+ CronBuilderEvents["updateCronConfig"] = "update-cron-config";
67
+ })(CronBuilderEvents || (CronBuilderEvents = {}));
@@ -0,0 +1,59 @@
1
+ import { __decorate } from "tslib";
2
+ import { EventEmitter } from '@genesislcap/foundation-events';
3
+ import { customElement, observable } from '@microsoft/fast-element';
4
+ import { FoundationElement } from '@microsoft/fast-foundation';
5
+ import { CronBuilderEvents } from '../types';
6
+ import { weeklyRecurrenceStyles as styles } from './weekly-recurrence.styles';
7
+ import { weeklyRecurrenceTemplate as template } from './weekly-recurrence.template';
8
+ let WeeklyRecurrence = class WeeklyRecurrence extends EventEmitter(FoundationElement) {
9
+ constructor() {
10
+ super(...arguments);
11
+ /**
12
+ * Used for storing specific Week days (Monday-Sunday) on which the event should occurs
13
+ */
14
+ this.selectedDays = new Set();
15
+ }
16
+ configChanged() {
17
+ var _a;
18
+ this.selectedDays = ((_a = this.config) === null || _a === void 0 ? void 0 : _a.selectedDays)
19
+ ? new Set([...this.config.selectedDays])
20
+ : new Set();
21
+ }
22
+ /**
23
+ * used to add or remove days of week in set on basis of user selection,
24
+ * and update cron expression as well
25
+ * @internal
26
+ * */
27
+ checkboxChangeHandler(event) {
28
+ const { checked, value } = event.target;
29
+ if (checked) {
30
+ this.selectedDays.add(value);
31
+ }
32
+ else {
33
+ this.selectedDays.delete(value);
34
+ }
35
+ this.updateCronConfig();
36
+ }
37
+ /**
38
+ * emits an event to update cron config and cron expression for weekly config
39
+ * @internal
40
+ * */
41
+ updateCronConfig() {
42
+ this.config = Object.assign(Object.assign({}, this.config), { selectedDays: this.selectedDays });
43
+ this.$emit(CronBuilderEvents.updateCronConfig, this.config);
44
+ }
45
+ };
46
+ __decorate([
47
+ observable
48
+ ], WeeklyRecurrence.prototype, "prefix", void 0);
49
+ __decorate([
50
+ observable
51
+ ], WeeklyRecurrence.prototype, "config", void 0);
52
+ WeeklyRecurrence = __decorate([
53
+ customElement({
54
+ name: 'weekly-recurrence',
55
+ template,
56
+ styles,
57
+ })
58
+ ], WeeklyRecurrence);
59
+ export { WeeklyRecurrence };
@@ -0,0 +1,9 @@
1
+ import { css } from '@microsoft/fast-element';
2
+ import { inputControls } from '../scheduler-cron-builder.styles';
3
+ export const weeklyRecurrenceStyles = css `
4
+ ${inputControls}
5
+ .weekdays-row {
6
+ display: flex;
7
+ gap: calc(var(--design-unit) * 3px);
8
+ }
9
+ `;
@@ -0,0 +1,25 @@
1
+ import { html, repeat } from '@microsoft/fast-element';
2
+ import { daysOfWeek } from '../types';
3
+ export const getPrefixedWeeklyRecurrence = (prefix) => html `
4
+ <template>
5
+ <div class="input-container">
6
+ <label class="label">On</label>
7
+ <div class="weekdays-row">
8
+ ${repeat(() => daysOfWeek, html `
9
+ <${prefix}-checkbox
10
+ part="weekdays-checkbox"
11
+ class="weekdays-checkbox"
12
+ :value=${(x) => x.value}
13
+ ?checked=${(x, c) => c.parent.selectedDays.has(x.value)}
14
+ @change=${(x, c) => c.parent.checkboxChangeHandler(c.event)}
15
+ >
16
+ ${(x) => x.label}
17
+ </${prefix}-checkbox>
18
+ `)}
19
+ </div>
20
+ </div>
21
+ </template>
22
+ `;
23
+ export const weeklyRecurrenceTemplate = html `
24
+ ${(x) => getPrefixedWeeklyRecurrence(x.prefix)}
25
+ `;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/foundation-ui",
3
3
  "description": "Genesis Foundation UI",
4
- "version": "14.246.2",
4
+ "version": "14.247.1",
5
5
  "sideEffects": false,
6
6
  "license": "SEE LICENSE IN license.txt",
7
7
  "main": "dist/esm/index.js",
@@ -83,13 +83,13 @@
83
83
  }
84
84
  },
85
85
  "devDependencies": {
86
- "@genesislcap/foundation-testing": "14.246.2",
87
- "@genesislcap/genx": "14.246.2",
88
- "@genesislcap/rollup-builder": "14.246.2",
89
- "@genesislcap/ts-builder": "14.246.2",
90
- "@genesislcap/uvu-playwright-builder": "14.246.2",
91
- "@genesislcap/vite-builder": "14.246.2",
92
- "@genesislcap/webpack-builder": "14.246.2",
86
+ "@genesislcap/foundation-testing": "14.247.1",
87
+ "@genesislcap/genx": "14.247.1",
88
+ "@genesislcap/rollup-builder": "14.247.1",
89
+ "@genesislcap/ts-builder": "14.247.1",
90
+ "@genesislcap/uvu-playwright-builder": "14.247.1",
91
+ "@genesislcap/vite-builder": "14.247.1",
92
+ "@genesislcap/webpack-builder": "14.247.1",
93
93
  "copyfiles": "^2.4.1",
94
94
  "rimraf": "^5.0.0",
95
95
  "rxjs": "^7.5.4"
@@ -100,13 +100,14 @@
100
100
  "@fortawesome/free-regular-svg-icons": "^6.2.1",
101
101
  "@fortawesome/free-solid-svg-icons": "^6.2.1",
102
102
  "@genesiscommunitysuccess/analyzer-import-alias-plugin": "^5.0.3",
103
- "@genesislcap/foundation-comms": "14.246.2",
104
- "@genesislcap/foundation-criteria": "14.246.2",
105
- "@genesislcap/foundation-errors": "14.246.2",
106
- "@genesislcap/foundation-logger": "14.246.2",
107
- "@genesislcap/foundation-notifications": "14.246.2",
108
- "@genesislcap/foundation-user": "14.246.2",
109
- "@genesislcap/foundation-utils": "14.246.2",
103
+ "@genesislcap/foundation-comms": "14.247.1",
104
+ "@genesislcap/foundation-criteria": "14.247.1",
105
+ "@genesislcap/foundation-errors": "14.247.1",
106
+ "@genesislcap/foundation-events": "14.247.1",
107
+ "@genesislcap/foundation-logger": "14.247.1",
108
+ "@genesislcap/foundation-notifications": "14.247.1",
109
+ "@genesislcap/foundation-user": "14.247.1",
110
+ "@genesislcap/foundation-utils": "14.247.1",
110
111
  "@microsoft/fast-colors": "5.3.1",
111
112
  "@microsoft/fast-components": "2.30.6",
112
113
  "@microsoft/fast-element": "1.14.0",
@@ -128,5 +129,5 @@
128
129
  "access": "public"
129
130
  },
130
131
  "customElements": "dist/custom-elements.json",
131
- "gitHead": "c6f8e26357a167f660fbb7f8ac4873ca358335fd"
132
+ "gitHead": "e5f84bbc09e62919c3c5cc40a6c28353443827de"
132
133
  }