@openremote/or-scheduler 1.13.0 → 1.14.0-snapshot

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/lib/index.d.ts CHANGED
@@ -1,11 +1,25 @@
1
+ import "@openremote/or-icon";
2
+ import "@openremote/or-translate";
3
+ import "@openremote/or-vaadin-components/or-vaadin-button";
4
+ import "@openremote/or-vaadin-components/or-vaadin-checkbox";
5
+ import "@openremote/or-vaadin-components/or-vaadin-checkbox-group";
6
+ import "@openremote/or-vaadin-components/or-vaadin-date-picker";
7
+ import "@openremote/or-vaadin-components/or-vaadin-date-time-picker";
8
+ import "@openremote/or-vaadin-components/or-vaadin-dialog";
9
+ import "@openremote/or-vaadin-components/or-vaadin-icon";
10
+ import "@openremote/or-vaadin-components/or-vaadin-number-field";
11
+ import "@openremote/or-vaadin-components/or-vaadin-radio-group";
12
+ import "@openremote/or-vaadin-components/or-vaadin-select";
13
+ import "@openremote/or-vaadin-components/or-vaadin-multi-select-combo-box";
14
+ import "@openremote/or-vaadin-components/or-vaadin-time-picker";
1
15
  import { LitElement, PropertyValues, TemplateResult } from "lit";
2
16
  import { CalendarEvent } from "@openremote/model";
3
- import { InputType } from "@openremote/or-mwc-components/or-mwc-input";
4
- import { OrMwcDialog } from "@openremote/or-mwc-components/or-mwc-dialog";
17
+ import { InputType } from "@openremote/or-vaadin-components/util";
18
+ import { OrVaadinDialog } from "@openremote/or-vaadin-components/or-vaadin-dialog";
5
19
  import { RRule } from "rrule";
6
- import { EventTypes, rruleEnds } from "./util";
7
- import type { RulePartKey, RuleParts, LabeledEventTypes, Frequency } from "./types";
8
- export { RuleParts, RulePartKey, Frequency, LabeledEventTypes };
20
+ import { EventTypes, RRULE_ENDS } from "./util";
21
+ import type { PartKeys, RRulePartKeys, Frequency, ByRRuleCombination, ByRRulePartsKeys } from "./types";
22
+ export type * from "./types";
9
23
  export * from "./util";
10
24
  export interface OrSchedulerChangedEventDetail {
11
25
  value?: CalendarEvent;
@@ -14,9 +28,14 @@ export declare class OrSchedulerChangedEvent extends CustomEvent<OrSchedulerChan
14
28
  static readonly NAME = "or-scheduler-changed";
15
29
  constructor(value?: CalendarEvent);
16
30
  }
31
+ export declare class OrSchedulerRemovedEvent extends CustomEvent<void> {
32
+ static readonly NAME = "or-scheduler-removed";
33
+ constructor();
34
+ }
17
35
  declare global {
18
36
  export interface HTMLElementEventMap {
19
37
  [OrSchedulerChangedEvent.NAME]: OrSchedulerChangedEvent;
38
+ [OrSchedulerRemovedEvent.NAME]: OrSchedulerRemovedEvent;
20
39
  }
21
40
  }
22
41
  declare const OrScheduler_base: (new (...args: any[]) => {
@@ -30,55 +49,68 @@ declare const OrScheduler_base: (new (...args: any[]) => {
30
49
  readonly isConnected: boolean;
31
50
  }) & typeof LitElement;
32
51
  export declare class OrScheduler extends OrScheduler_base {
52
+ static styles: import("lit").CSSResult;
33
53
  defaultSchedule?: CalendarEvent;
34
54
  defaultEventTypeLabel: string;
55
+ disableNegativeByPartValues: boolean;
35
56
  disabledFrequencies: Frequency[];
36
- disabledRRuleParts: RulePartKey[];
57
+ disabledRRuleParts: RRulePartKeys[];
58
+ disabledByPartCombinations: ByRRuleCombination;
37
59
  header: string;
38
60
  isAllDay: boolean;
61
+ open: boolean;
62
+ removable: boolean;
39
63
  schedule?: CalendarEvent;
40
64
  timezoneOffset: number;
41
- protected _ends: keyof typeof rruleEnds;
42
- protected _normalizedSchedule: CalendarEvent | undefined;
43
- protected _rrule?: RRule;
44
- protected dialog?: OrMwcDialog;
45
- protected _byRRuleParts?: RulePartKey[];
46
65
  protected _count: number;
47
- protected _dialog?: OrMwcDialog;
66
+ protected _ends: keyof typeof RRULE_ENDS;
48
67
  protected _eventType: EventTypes;
49
- protected _eventTypes: LabeledEventTypes;
68
+ protected _rrule?: RRule;
69
+ protected _dialog: OrVaadinDialog;
70
+ protected _byRRuleParts?: RRulePartKeys[];
50
71
  protected _until: Date;
51
- protected firstUpdated(_changedProps: PropertyValues): void;
52
- protected willUpdate(changedProps: PropertyValues): void;
53
- protected updated(changedProps: PropertyValues): void;
72
+ protected get _scheduleWithOffset(): CalendarEvent | undefined;
73
+ protected set _scheduleWithOffset(schedule: CalendarEvent | undefined);
74
+ protected get _timeLabel(): TemplateResult | undefined;
75
+ connectedCallback(): void;
76
+ shouldUpdate(changedProps: PropertyValues): any;
77
+ protected _setAllDay(): void;
54
78
  /**
55
79
  * Converts the recurrence rule to string and normalizes it.
56
80
  *
57
81
  * The UTC timezone offset 'Z' for the UNTIL rule part is removed,
58
- * because the backend uses a `LocalDateTime` object to compare.
82
+ * because the timezone is configurable.
59
83
  * @param rrule The recurrence rule to normalize.
60
84
  * @returns String representation of the defined Recurrence Rule
61
85
  */
62
- protected getRRule(rrule?: RRule | undefined): string | undefined;
63
- protected setRRuleValue(value: any, key: keyof RuleParts | "start" | "end" | "start-time" | "end-time" | "all-day" | "recurrence-ends"): void;
64
- protected timeLabel(): string | undefined;
65
- protected setCalendarEventType(value: any): void;
86
+ protected _getRRule(rrule?: RRule | undefined): string | undefined;
87
+ protected _setRRuleValue(value: any, key: PartKeys): void;
88
+ protected _setCalendarEventType(event: any): void;
66
89
  /**
67
90
  * Apply the timezone offset to the calendarEvent
68
91
  * @param schedule The schedule for which to add/substract the offset
69
- * @param substract Whether to substract the offset
92
+ * @param offset The timezone offset in millis to apply
70
93
  * @returns The transformed calendar event
71
94
  */
72
- protected applyTimezoneOffset(schedule?: CalendarEvent, substract?: boolean): CalendarEvent | undefined;
95
+ protected _applyTimezoneOffset(schedule: CalendarEvent | undefined, offset: number): CalendarEvent | undefined;
96
+ protected _getDefaultMessageOptions(): {
97
+ date: string;
98
+ time: string;
99
+ };
73
100
  protected render(): TemplateResult<1>;
74
- protected showDialog(): void;
75
- protected getDialogContent(): TemplateResult;
101
+ protected _getDialogHeader(): TemplateResult;
102
+ protected _getDialogContent(): TemplateResult;
103
+ protected _getDialogFooter(): TemplateResult;
104
+ protected _onClose(): void;
105
+ protected _onDelete(): void;
106
+ protected _onSave(): void;
107
+ protected _onPartChange(part: PartKeys, valueProp: "checked" | "value" | "detail", value?: any): (e: any) => void;
76
108
  /**
77
109
  * Check if this frequency is allowed
78
110
  * @param freq The frequency to check
79
111
  * @returns Whether the frequency is allowed
80
112
  */
81
- protected isAllowedFrequency(freq: Frequency): boolean;
113
+ protected _isAllowedFrequency(freq: Frequency): boolean;
82
114
  /**
83
115
  * Displays the interval, frequency and BY_XXX RRule part fields
84
116
  *
@@ -98,20 +130,19 @@ export declare class OrScheduler extends OrScheduler_base {
98
130
  *
99
131
  * @returns Inputs for the applicable rule parts
100
132
  */
101
- protected getRepeatTemplate(): TemplateResult;
133
+ protected _getRepeatTemplate(): TemplateResult;
102
134
  /**
103
135
  * Displays the BY_XXX RRule part fields if allowed by the frequency
104
136
  *
105
137
  * @returns The specified BY_XXX RRule part field or undefined if not applicable
106
138
  */
107
- protected getByRulePart<T>(part: RulePartKey, type: InputType, options: T[]): TemplateResult | undefined;
139
+ protected _getByRulePart<T extends number | [string, string]>(part: ByRRulePartsKeys, type: InputType, options: T[]): TemplateResult | undefined;
108
140
  /**
109
141
  * Displays the fields that define when and how long the particular event is
110
142
  *
111
- * @param calendar The specified calendar event
112
143
  * @returns The periods allDay and from/to date and time fields
113
144
  */
114
- protected getPeriodTemplate(calendar: CalendarEvent): TemplateResult;
145
+ protected _getPeriodTemplate(): TemplateResult;
115
146
  /**
116
147
  * Displays the fields that define how a recurring event should end
117
148
  *
@@ -120,6 +151,6 @@ export declare class OrScheduler extends OrScheduler_base {
120
151
  * - `count`
121
152
  * @returns The recurrence ends fields
122
153
  */
123
- protected getEndsTemplate(): TemplateResult;
154
+ protected _getEndsTemplate(): TemplateResult;
124
155
  }
125
156
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAQ,UAAU,EAAE,cAAc,EAAE,cAAc,E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AgB,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,cAAc,GAAG,SAAS;IAuBhJ;;;;OAIG;IACH,SAAS,CAAC,kBAAkB,IAAI,cAAc;IA6B9C;;;;;;;OAOG;IACH,SAAS,CAAC,gBAAgB,IAAI,cAAc;CAkC/C"}
package/lib/index.js CHANGED
@@ -1,131 +1,185 @@
1
- var __decorate=this&&this.__decorate||function(e,t,i,l){var r,n=arguments.length,s=n<3?t:null===l?l=Object.getOwnPropertyDescriptor(t,i):l;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,l);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(s=(n<3?r(s):n>3?r(t,i,s):r(t,i))||s);return n>3&&s&&Object.defineProperty(t,i,s),s};import{html as e,LitElement as t}from"lit";import{customElement as i,property as l,query as r,state as n}from"lit/decorators.js";import{InputType as s}from"@openremote/or-mwc-components/or-mwc-input";import{translate as a,i18next as o}from"@openremote/or-translate";import{OrMwcDialog as d,showDialog as u}from"@openremote/or-mwc-components/or-mwc-dialog";import{Frequency as c,RRule as h}from"rrule";import p from"moment";import{Days as m}from"rrule/dist/esm/rrule";import{BY_RRULE_PARTS as y,EventTypes as v,FREQUENCIES as _,MONTHS as f,NOT_APPLICABLE_BY_RRULE_PARTS as g,rruleEnds as S}from"./util";import{when as b}from"lit/directives/when.js";export*from"./util";function range(e,t){return Array.from({length:t-e+1},(t,i)=>e+i)}function toSpliced(e,t,i){let l=[...e];return l.splice(t,i),l}let byWeekNoOptions=toSpliced(range(-53,53),53,1),byYearDayOptions=toSpliced(range(-366,366),366,1),byMonthDayOptions=toSpliced(range(-31,31),31,1),byHourOptions=range(1,24),byMinuteOrSecondsOptions=range(1,60);export class OrSchedulerChangedEvent extends CustomEvent{constructor(e){super(OrSchedulerChangedEvent.NAME,{detail:{value:e},bubbles:!0,composed:!0})}}OrSchedulerChangedEvent.NAME="or-scheduler-changed";let OrScheduler=class extends a(o)(t){constructor(){super(...arguments),this.defaultEventTypeLabel="default",this.disabledFrequencies=[],this.disabledRRuleParts=[],this.header="scheduleActivity",this.isAllDay=!0,this.schedule=this.defaultSchedule,this.timezoneOffset=0,this._ends="never",this._normalizedSchedule=this.applyTimezoneOffset(this.schedule),this._count=1,this._eventType=v.default,this._eventTypes=v,this._until=p().toDate()}firstUpdated(e){var t,i,l;if(this._eventTypes={default:o.t(this.defaultEventTypeLabel),period:o.t("planPeriod"),recurrence:o.t("planRecurrence")},(null==(t=this._normalizedSchedule)?void 0:t.start)&&(null==(i=this._normalizedSchedule)?void 0:i.end)&&(this._normalizedSchedule.recurrence?this._eventType=v.recurrence:this._eventType=v.period,this.isAllDay=this._normalizedSchedule&&p(this._normalizedSchedule.start).isSame(p(this._normalizedSchedule.start).clone().startOf("day"))&&p(this._normalizedSchedule.end).isSame(p(this._normalizedSchedule.end).clone().endOf("day"))),null==(l=this._normalizedSchedule)?void 0:l.recurrence){let e=h.fromString(this._normalizedSchedule.recurrence).origOptions;e.until?this._until=p(e.until).toDate():e.count&&(this._count=e.count)}}willUpdate(e){e.has("schedule")&&(this._normalizedSchedule=this.applyTimezoneOffset(this.schedule))}updated(e){var t,i,l,r,n,s;super.updated(e),e.has("_rrule")&&this._rrule&&(this._byRRuleParts=y.filter(e=>{var t;return!(null==(t=g[c[this._rrule.options.freq]])?void 0:t.includes(e.toUpperCase()))}).filter(e=>!this.disabledRRuleParts.includes(e)),this._ends=(null==(i=null==(t=this._rrule)?void 0:t.origOptions)?void 0:i.until)&&"until"||(null==(r=null==(l=this._rrule)?void 0:l.origOptions)?void 0:r.count)&&"count"||"never"),e.has("_normalizedSchedule")&&((null==(n=this._normalizedSchedule)?void 0:n.recurrence)?this._rrule=h.fromString(this._normalizedSchedule.recurrence):this._eventType===v.default&&(null==(s=this.defaultSchedule)?void 0:s.recurrence)?this._rrule=h.fromString(this.defaultSchedule.recurrence):this._rrule=void 0)}getRRule(e=this._rrule){var t,i,l;return null==(l=null==(i=null==(t=null==e?void 0:e.toString())?void 0:t.split("RRULE:"))?void 0:i[1])?void 0:l.replace(/(UNTIL=\d+T\d+)Z/,"$1")}setRRuleValue(e,t){var i;let l=null==(i=this._rrule)?void 0:i.origOptions,r=this._normalizedSchedule;if("interval"===t||"freq"===t||t.startsWith("by"))"byweekday"===t?l.byweekday=e.map(e=>h[e]):l[t]=e,this._eventType===v.recurrence&&(this._rrule=new h(l));else if("start"===t&&l){let[t,i,n]=e.split("-").map(Number);l.dtstart=p(r.start).set({year:t,month:i-1,date:n}).toDate(),r.start=l.dtstart.getTime(),this._eventType===v.recurrence&&(this._rrule=new h(l))}else if("end"===t){let[t,i,l]=e.split("-").map(Number);r.end=p(r.end).set({year:t,month:i-1,date:l}).toDate().getTime()}else if("start-time"===t){let[t,i]=e.split(":");l?l.dtstart=p(r.start).set({hour:t,minute:i,second:0,millisecond:0}).toDate():l=new h({dtstart:p(r.start).set({hour:t,minute:i,second:0,millisecond:0}).toDate()}).origOptions,r.start=p(l.dtstart).toDate().getTime(),this._eventType===v.recurrence&&(this._rrule=new h(l))}else if("end-time"===t){let[t,i]=e.split(":");r.end=p(r.end).set({hour:t,minute:i,second:0,millisecond:0}).toDate().getTime()}else switch(t){case"all-day":this.isAllDay=e;break;case"recurrence-ends":"until"===e?(l.until=this._until,delete l.count):("count"===e?l.count=this._count:delete l.count,delete l.until),this._ends=e,this._eventType===v.recurrence&&(this._rrule=new h(l));break;case"until":this._until=new Date(e),l.until=this._until,this._eventType===v.recurrence&&(this._rrule=new h(l));break;case"count":this._count=e,l.count=this._count,this._eventType===v.recurrence&&(this._rrule=new h(l))}this._normalizedSchedule=Object.assign({},r),this._dialog.requestUpdate(),this._normalizedSchedule.recurrence=this.getRRule()}timeLabel(){if(this._eventType===v.default)return o.t(this.defaultEventTypeLabel);if(this._normalizedSchedule&&this._rrule){let e=this._normalizedSchedule,t=p(e.end).diff(e.start,"days"),i="";return this.isAllDay?(t>0&&(i=" "+o.t("forDays",{days:t})),this._rrule.toText()+i):(t>0&&(i=o.t("fromToDays",{start:p(e.start).format("HH:mm"),end:p(e.end).format("HH:mm"),days:t})),0===t&&(i=o.t("fromTo",{start:p(e.start).format("HH:mm"),end:p(e.end).format("HH:mm")})),this._rrule.toText()+" "+i)}if(this._normalizedSchedule){let e="DD-MM-YYYY";return this.isAllDay||(e="DD-MM-YYYY HH:mm"),o.t("activeFromTo",{start:p(this._normalizedSchedule.start).format(e),end:p(this._normalizedSchedule.end).format(e)})}}setCalendarEventType(e){var t,i,l,r,n,s,a,o,d,u;switch(e){case v.default:this._normalizedSchedule=this.defaultSchedule,this._rrule=h.fromString(null!=(i=null==(t=this.defaultSchedule)?void 0:t.recurrence)?i:"")||void 0;break;case v.period:this._normalizedSchedule={start:null!=(r=null==(l=this._normalizedSchedule)?void 0:l.start)?r:p().startOf("day").toDate().getTime(),end:null!=(s=null==(n=this._normalizedSchedule)?void 0:n.end)?s:p().startOf("day").endOf("day").toDate().getTime()},this._rrule=void 0;break;case v.recurrence:this._normalizedSchedule={start:null!=(o=null==(a=this._normalizedSchedule)?void 0:a.start)?o:p().startOf("day").toDate().getTime(),end:null!=(u=null==(d=this._normalizedSchedule)?void 0:d.end)?u:p().startOf("day").endOf("day").toDate().getTime(),recurrence:"FREQ=DAILY"}}this._eventType=e,this._dialog.requestUpdate()}applyTimezoneOffset(e,t=!1){if(e){let i=t?-this.timezoneOffset:this.timezoneOffset,{start:l,end:r,recurrence:n}=Object.assign({},e);if(l&&(l+=i),r&&(r+=i),n&&h.fromString(n).origOptions.until){let e=h.fromString(n).origOptions;e.until=new Date(Number(e.until)+i),n=this.getRRule(new h(e))}return{start:l,end:r,recurrence:n}}}render(){return e`
2
- <or-mwc-input outlined .type="${s.BUTTON}" label="${this.timeLabel()}" @or-mwc-input-changed="${()=>this.showDialog()}"></or-mwc-input>
3
- `}showDialog(){this._dialog=u(new d().setHeading(o.t(this.header)).setStyles(e`
4
- <style>
5
- #dialog-content {
6
- max-height: 100vh;
7
- overflow: auto;
8
- background-color: #f5f5f5;
9
- }
1
+ var __decorate=this&&this.__decorate||function(e,t,i,a){var r,l=arguments.length,s=l<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(s=(l<3?r(s):l>3?r(t,i,s):r(t,i))||s);return l>3&&s&&Object.defineProperty(t,i,s),s};import"@openremote/or-icon";import{translate as e,i18next as t}from"@openremote/or-translate";import"@openremote/or-vaadin-components/or-vaadin-button";import"@openremote/or-vaadin-components/or-vaadin-checkbox";import"@openremote/or-vaadin-components/or-vaadin-checkbox-group";import"@openremote/or-vaadin-components/or-vaadin-date-picker";import"@openremote/or-vaadin-components/or-vaadin-date-time-picker";import{dialogRenderer as i,dialogHeaderRenderer as a,dialogFooterRenderer as r}from"@openremote/or-vaadin-components/or-vaadin-dialog";import"@openremote/or-vaadin-components/or-vaadin-icon";import"@openremote/or-vaadin-components/or-vaadin-number-field";import"@openremote/or-vaadin-components/or-vaadin-radio-group";import"@openremote/or-vaadin-components/or-vaadin-select";import"@openremote/or-vaadin-components/or-vaadin-multi-select-combo-box";import"@openremote/or-vaadin-components/or-vaadin-time-picker";import{css as l,html as s,LitElement as o}from"lit";import{customElement as n,property as d,query as u,state as c}from"lit/decorators.js";import{when as h}from"lit/directives/when.js";import{Util as p}from"@openremote/core";import{InputType as v}from"@openremote/or-vaadin-components/util";import{Frequency as m,RRule as f}from"rrule";import{BY_RRULE_PARTS as y,EventTypes as _,FREQUENCIES as b,MONTHS as g,RFC_STRICT_NOT_APPLICABLE as O,RRULE_ENDS as $,WEEKDAYS as S}from"./util";import D from"moment";export*from"./util";function range(e,t){return Array.from({length:t-e+1},(t,i)=>e+i)}let byWeekNoOptions=range(-53,53).filter(Boolean),byYearDayOptions=range(-366,366).filter(Boolean),byMonthDayOptions=range(-31,31).filter(Boolean),byHourOptions=range(1,24),byMinuteOrSecondsOptions=range(1,60);export class OrSchedulerChangedEvent extends CustomEvent{constructor(e){super(OrSchedulerChangedEvent.NAME,{detail:{value:e},bubbles:!0,composed:!0})}}OrSchedulerChangedEvent.NAME="or-scheduler-changed";export class OrSchedulerRemovedEvent extends CustomEvent{constructor(){super(OrSchedulerRemovedEvent.NAME,{bubbles:!0,composed:!0})}}OrSchedulerRemovedEvent.NAME="or-scheduler-removed";let OrScheduler=class extends e(t)(o){constructor(){super(...arguments),this.defaultEventTypeLabel="default",this.disableNegativeByPartValues=!1,this.disabledFrequencies=[],this.disabledRRuleParts=[],this.disabledByPartCombinations=O,this.header="scheduleActivity",this.isAllDay=!0,this.open=!1,this.removable=!1,this.schedule=this.defaultSchedule,this.timezoneOffset=0,this._count=1,this._ends="never",this._eventType=_.default,this._until=D().toDate()}get _scheduleWithOffset(){return this._applyTimezoneOffset(this.schedule,this.timezoneOffset)}set _scheduleWithOffset(e){this.schedule=this._applyTimezoneOffset(e,-this.timezoneOffset)}get _timeLabel(){if(this._eventType===_.default)return s`<or-translate value="${this.defaultEventTypeLabel}" .options="${this._getDefaultMessageOptions()}"></or-translate>`;if(this._scheduleWithOffset){let e=this._scheduleWithOffset;if(e.recurrence){let i=D(e.end).diff(e.start,"days"),a={start:D(e.start).format("HH:mm"),end:D(e.end).format("HH:mm")},r=s``;this.isAllDay&&i>0?r=s`<or-translate value="forDays" .options="${{days:i,count:i}}"></or-translate>`:i>0?r=s`<or-translate value="fromToDays" .options="${Object.assign(Object.assign({},a),{days:i,count:i})}"></or-translate>`:0===i&&(r=s`<or-translate value="fromTo" .options="${a}"></or-translate>`);let l=s`<span>&nbsp;${r}</span>`,o=Object.values(g).map(t.t),n=Object.values(S).map(t.t),d=[n.pop(),...n],u=this._rrule.toText(e=>t.t(`rrule.${e}`),{dayNames:d,monthNames:o,tokens:{}});return s`<span class="time-label"><span>${u}</span>${l}</span>`}let i=this.isAllDay?"DD-MM-YYYY":"DD-MM-YYYY HH:mm";return s`<or-translate value="activeFromTo" .options="${{start:D(e.start).format(i),end:D(e.end).format(i)}}"></or-translate>`}}connectedCallback(){var e,t,i;super.connectedCallback();let a=this._applyTimezoneOffset(null!=(e=this.schedule)?e:this.defaultSchedule,this.timezoneOffset);if((null==a?void 0:a.start)&&(null==a?void 0:a.start)){let e=D(null==a?void 0:a.start),t=D(null==a?void 0:a.end);this.isAllDay=e.isSame(e.clone().startOf("day"))&&t.isSame(t.clone().endOf("day"))}if(null==(t=this.schedule)?void 0:t.recurrence){let e=f.fromString(this.schedule.recurrence).origOptions;e.until?this._until=D(e.until).toDate():e.count&&(this._count=e.count)}!this.schedule||p.objectsEqual(this.schedule,this.defaultSchedule)?this._eventType=_.default:this._eventType=(null==(i=this.schedule)?void 0:i.recurrence)?_.recurrence:_.period}shouldUpdate(e){var t,i,a,r,l,s,o;return this.schedule&&!this.schedule.end&&(null==(t=this.defaultSchedule)?void 0:t.end)&&(this.schedule=Object.assign(Object.assign({},this.schedule),{end:this.defaultSchedule.end})),e.has("schedule")&&((null==(i=this._scheduleWithOffset)?void 0:i.recurrence)?this._rrule=f.fromString(this._scheduleWithOffset.recurrence):this._eventType===_.default&&(null==(a=this.defaultSchedule)?void 0:a.recurrence)&&(this._rrule=f.fromString(this.defaultSchedule.recurrence))),e.has("_rrule")&&this._rrule&&(this._byRRuleParts=y.filter(e=>{var t;return!(null==(t=this.disabledByPartCombinations[m[this._rrule.options.freq]])?void 0:t.includes(e))}).filter(e=>!this.disabledRRuleParts.includes(e)),this._ends=(null==(l=null==(r=this._rrule)?void 0:r.origOptions)?void 0:l.until)&&"until"||(null==(o=null==(s=this._rrule)?void 0:s.origOptions)?void 0:o.count)&&"count"||"never"),super.shouldUpdate(e)}_setAllDay(){let e=this._scheduleWithOffset;if(this.isAllDay&&this._eventType!==_.default){let t=D(null==e?void 0:e.start).startOf("day").valueOf(),i=D(null==e?void 0:e.end).endOf("day").valueOf();this._scheduleWithOffset=Object.assign(Object.assign({},e),{start:t,end:i})}}_getRRule(e=this._rrule){var t,i,a;return null==(a=null==(i=null==(t=null==e?void 0:e.toString())?void 0:t.split("RRULE:"))?void 0:i[1])?void 0:a.replace(/(UNTIL=\d+T\d+)Z/,"$1")}_setRRuleValue(e,t){var i;let a=null==(i=this._rrule)?void 0:i.origOptions,r=this._scheduleWithOffset;if("interval"===t||"freq"===t||t.startsWith("by"))if("byweekday"===t)a.byweekday=e.map(e=>f[e]);else if("freq"===t){for(let e of y)delete a[e];a[t]=e}else a[t]=e;else if("start"===t&&a){let[t,i,l]=e.split("-").map(Number);a.dtstart=D(r.start).set({year:t,month:i-1,date:l}).toDate(),r.start=a.dtstart.getTime()}else if("end"===t){let[t,i,a]=e.split("-").map(Number);r.end=D(r.end).set({year:t,month:i-1,date:a}).toDate().getTime()}else if("start-time"===t){let[t,i]=e.split(":");a?a.dtstart=D(r.start).set({hour:t,minute:i,second:0,millisecond:0}).toDate():a=new f({dtstart:D(r.start).set({hour:t,minute:i,second:0,millisecond:0}).toDate()}).origOptions,r.start=D(a.dtstart).toDate().getTime()}else if("end-time"===t){let[t,i]=e.split(":");r.end=D(r.end).set({hour:t,minute:i,second:0,millisecond:0}).toDate().getTime()}else switch(t){case"all-day":this.isAllDay=e;break;case"recurrence-ends":"until"===e?(a.until=this._until,delete a.count):("count"===e?a.count=this._count:delete a.count,delete a.until),this._ends=e;break;case"until":this._until=new Date(e),a.until=this._until;break;case"count":this._count=e,a.count=this._count}this._eventType===_.recurrence?(this._rrule=new f(a),this._scheduleWithOffset=Object.assign(Object.assign({},r),{recurrence:this._getRRule()})):this._scheduleWithOffset=Object.assign({},r)}_setCalendarEventType(e){var t,i,a,r,l,s,o,n,d,u;let c=e.target.value;this._eventType=c;let h=D().startOf("day");if(c===_.default){this.schedule={start:null!=(i=null==(t=this.defaultSchedule)?void 0:t.start)?i:h.valueOf()-this.timezoneOffset,end:null!=(r=null==(a=this.defaultSchedule)?void 0:a.end)?r:h.endOf("day").valueOf()-this.timezoneOffset};let e=null==(l=this.defaultSchedule)?void 0:l.recurrence;this._rrule=e?f.fromString(e):void 0;return}let p={start:null!=(o=null==(s=this._scheduleWithOffset)?void 0:s.start)?o:h.valueOf(),end:null!=(d=null==(n=this._scheduleWithOffset)?void 0:n.end)?d:h.endOf("day").valueOf()};c===_.period?this._scheduleWithOffset=p:this._scheduleWithOffset=Object.assign(Object.assign({},p),{recurrence:null!=(u=this._getRRule())?u:"FREQ=DAILY"})}_applyTimezoneOffset(e,t){if(e){let{start:i,end:a,recurrence:r}=Object.assign({},e);if(r&&f.fromString(r).origOptions.until){let e=f.fromString(r).origOptions;e.until=new Date(Number(e.until)+t),r=this._getRRule(new f(e))}return{start:null!=i?i+t:i,end:null!=a?a+t:a,recurrence:r}}}_getDefaultMessageOptions(){var e,t;return{date:D.utc(null==(e=this.defaultSchedule)?void 0:e.start).format("YYYY-MM-DD"),time:D.utc(null==(t=this.defaultSchedule)?void 0:t.start).format("HH:mm")}}render(){return s`
2
+ <or-vaadin-button style="max-width: 100%" @click="${()=>this._dialog.open()}">${this._timeLabel}</or-vaadin-button>
3
+ <or-vaadin-dialog id="scheduler" header-title="${t.t(this.header)}" ?opened="${this.open}" @closed="${this._onClose}"
4
+ ${a(this._getDialogHeader,[])}
5
+ ${i(this._getDialogContent,[this.defaultSchedule,this.defaultEventTypeLabel,this.disabledFrequencies,this.disabledRRuleParts,this.header,this.isAllDay,this.schedule,this.timezoneOffset,this._count,this._ends,this._rrule])}
6
+ ${r(this._getDialogFooter,[])}
7
+ ></or-vaadin-dialog>
8
+ `}_getDialogHeader(){return s`
9
+ <vaadin-button theme="tertiary" @click="${this._onClose}">
10
+ <vaadin-icon icon="lumo:cross"></vaadin-icon>
11
+ </vaadin-button>
12
+ `}_getDialogContent(){let e=[{value:"default",label:t.t(this.defaultEventTypeLabel,this._getDefaultMessageOptions())},{value:"period",label:t.t("planPeriod")},{value:"recurrence",label:t.t("planRecurrence")}];return s`
13
+ <style>
14
+ /* Showing just a number is not intuitive when using numbers as options */
15
+ vaadin-multi-select-combo-box-chip[slot="overflow"]::part(label)::before {
16
+ content: "+";
17
+ }
10
18
 
11
- .mdc-dialog .mdc-dialog__content {
12
- padding: 8px 16px !important;
13
- }
19
+ vaadin-checkbox {
20
+ font-weight: 600;
21
+ }
14
22
 
15
- @media only screen and (max-width: 1279px) {
16
- .mdc-dialog__surface {
17
- overflow-x: auto !important;
18
- overflow-y: auto !important;
19
- }
23
+ .period {
24
+ display: flex;
25
+ flex: 1;
26
+ gap: 2px;
27
+ }
20
28
 
21
- #dialog-content {
22
- min-height: 230px;
23
- overflow: auto;
24
- }
25
- }
29
+ .section {
30
+ background-color: white;
31
+ border-radius: var(--lumo-border-radius-m);
32
+ display: flex;
33
+ flex-direction: column;
34
+ padding: var(--lumo-space-l);
35
+ }
26
36
 
27
- .section {
28
- background-color: white;
29
- margin-top: 10px;
30
- padding: 8px 16px;
31
- border-radius: 4px;
32
- }
33
- .section > * {
34
- margin: 8px 0;
35
- }
36
- .section:first-child {
37
- margin-top: 0;
37
+ .title {
38
+ padding-bottom: var(--lumo-space-m);
39
+ font-size: var(--lumo-font-size-l);
40
+ font-style: normal;
41
+ font-weight: 600;
42
+ line-height: 125.303%; /* 22.554px */
43
+ }
44
+
45
+ .label {
46
+ margin-left: 10px;
47
+ }
48
+ or-vaadin-number-field[disabled] + .label {
49
+ color: var(--lumo-contrast-20pct);
50
+ user-select: revert;
51
+ -webkit-user-select: none;
52
+ }
53
+
54
+ @media only screen and (min-width: 768px) {
55
+ or-vaadin-date-picker[combined] {
56
+ --vaadin-input-field-top-end-radius: 0;
57
+ --vaadin-input-field-bottom-end-radius: 0;
38
58
  }
39
- .section:last-child {
40
- margin-bottom: 0;
59
+ or-vaadin-time-picker {
60
+ --vaadin-input-field-top-start-radius: 0;
61
+ --vaadin-input-field-bottom-start-radius: 0;
41
62
  }
63
+ }
42
64
 
43
- .title {
44
- display: block;
45
- font-weight: bold;
65
+ @media only screen and (max-width: 768px) {
66
+ .period {
67
+ flex-wrap: wrap;
46
68
  }
47
- </style>`).setActions([{actionName:"cancel",content:e`<or-mwc-input class="button" .type="${s.BUTTON}" label="cancel"></or-mwc-input>`,action:()=>{this._dialog=void 0}},{actionName:"ok",default:!0,content:e`<or-mwc-input class="button" .type="${s.BUTTON}" label="apply"></or-mwc-input>`,action:()=>{var e;this._normalizedSchedule&&this.isAllDay&&(this._normalizedSchedule.start=p(this._normalizedSchedule.start).startOf("day").toDate().getTime(),this._normalizedSchedule.end=p(this._normalizedSchedule.end).startOf("day").endOf("day").toDate().getTime()),this._eventType===v.default?delete this._normalizedSchedule:this._eventType===v.recurrence&&(this._normalizedSchedule.recurrence=this.getRRule());let t=this.applyTimezoneOffset(null!=(e=this._normalizedSchedule)?e:this.defaultSchedule,!0);this.dispatchEvent(new OrSchedulerChangedEvent(t)),this._dialog=void 0}}]).setContent(()=>this.getDialogContent()).setDismissAction(null))}getDialogContent(){let t=this._normalizedSchedule;return e`
48
- <div style="min-width: 635px; display:grid; flex-direction: row;">
69
+ }
70
+ </style>
71
+ <div style="display: flex; flex-direction: column; gap: var(--lumo-space-m)">
49
72
  <div id="event-type" class="section">
50
73
  <label class="title"><or-translate value="schedule.type"></or-translate></label>
51
- <div class="layout horizontal">
52
- <or-mwc-input style="width: 100%"
53
- .value="${this._eventType}"
54
- .type="${s.SELECT}"
55
- .options="${Object.entries(this._eventTypes)}"
56
- @or-mwc-input-changed="${e=>this.setCalendarEventType(e.detail.value)}"></or-mwc-input>
57
- </div>
74
+ <or-vaadin-select style="flex: 1" .value="${this._eventType}" .items="${e}" @change="${this._setCalendarEventType}"></or-vaadin-select>
58
75
  </div>
59
- ${this._eventType===v.recurrence?this.getRepeatTemplate():""}
60
- ${t&&(this._eventType===v.period||this._eventType===v.recurrence)?this.getPeriodTemplate(t):""}
61
- ${this._eventType===v.recurrence?this.getEndsTemplate():""}
62
- </div>`}isAllowedFrequency(e){return"SECONDLY"!==e&&!this.disabledFrequencies.includes(e)}getRepeatTemplate(){var t,i,l,r,n;let a=null!=(i=null==(t=this._rrule)?void 0:t.origOptions.interval)?i:1,d=null!=(r=null==(l=this._rrule)?void 0:l.origOptions.freq)?r:c.DAILY,u=Object.entries(_).map(([e,t])=>[String(c[e]),o.t(t,{count:a})]).filter(([e])=>this.isAllowedFrequency(c[e]));return e`
76
+ ${h(this._eventType!==_.default,()=>this._getPeriodTemplate())}
77
+ ${h(this._eventType===_.recurrence,()=>this._getRepeatTemplate())}
78
+ ${h(this._eventType===_.recurrence,()=>this._getEndsTemplate())}
79
+ </div>`}_getDialogFooter(){return s`
80
+ ${h(this.removable,()=>s`
81
+ <or-vaadin-button style="background-color: unset; margin-right: auto" theme="error" @click="${this._onDelete}">
82
+ <or-icon icon="or:trash" style="--or-icon-fill: white"></or-icon>
83
+ <or-translate value="schedule.delete"></or-translate>
84
+ </or-vaadin-button>`)}
85
+ <or-vaadin-button theme="primary" @click="${this._onSave}"><or-translate value="schedule.save"></or-translate></or-vaadin-button>
86
+ `}_onClose(){this._dialog.close()}_onDelete(){this._dialog.close(),this.dispatchEvent(new OrSchedulerRemovedEvent)}_onSave(){var e;this._setAllDay(),this.dispatchEvent(new OrSchedulerChangedEvent(null!=(e=this.schedule)?e:this.defaultSchedule)),this._dialog.close()}_onPartChange(e,t,i){return a=>{if("detail"===t){p.objectsEqual(a.detail.value,i,!0)||this._setRRuleValue(a.detail.value,e);return}this._setRRuleValue(a.target[t],e)}}_isAllowedFrequency(e){return"SECONDLY"!==e&&!this.disabledFrequencies.includes(e)}_getRepeatTemplate(){var e,i,a,r,l;let o=null!=(i=null==(e=this._rrule)?void 0:e.origOptions.interval)?i:1,n=null!=(r=null==(a=this._rrule)?void 0:a.origOptions.freq)?r:m.DAILY,d=Object.entries(b).map(([e,i])=>({value:String(m[e]),label:t.t(i,{count:o})})).filter(({value:e})=>this._isAllowedFrequency(m[e]));return s`
63
87
  <div id="recurrence" class="section">
64
88
  <label class="title"><or-translate value="schedule.repeat"></or-translate></label>
65
- <div class="layout horizontal" style="display: flex; gap: 8px;">
66
- ${b(!(null==(n=this.disabledRRuleParts)?void 0:n.includes("interval")),()=>e`
67
- <or-mwc-input style="width: 60px;" min="1" max="9" .value="${a}" .type="${s.NUMBER}"
68
- @or-mwc-input-changed="${e=>this.setRRuleValue(e.detail.value,"interval")}"></or-mwc-input>
89
+ <div style="display: flex; gap: 8px">
90
+ ${h(!(null==(l=this.disabledRRuleParts)?void 0:l.includes("interval")),()=>s`
91
+ <or-vaadin-number-field min="1" max="9" step-buttons-visible style="width: 106px" .value="${o}"
92
+ @change="${this._onPartChange("interval","value")}">
93
+ </or-vaadin-number-field>
69
94
  `)}
70
- <or-mwc-input style="flex: 1;" .value="${d.toString()}" .type="${s.SELECT}" .options="${u}"
71
- @or-mwc-input-changed="${e=>this.setRRuleValue(e.detail.value,"freq")}"></or-mwc-input>
72
- </div>
73
- <div>${this.getByRulePart("bymonth",s.CHECKBOX_LIST,Object.entries(f))}</div>
74
- <div>
75
- ${this.getByRulePart("byweekno",s.SELECT,byWeekNoOptions)}
76
- ${this.getByRulePart("byyearday",s.SELECT,byYearDayOptions)}
77
- ${this.getByRulePart("bymonthday",s.SELECT,byMonthDayOptions)}
95
+ <or-vaadin-select style="flex: 1;" .value="${n.toString()}" .items="${d}"
96
+ @change="${this._onPartChange("freq","value")}">
97
+ </or-vaadin-select>
78
98
  </div>
79
- <div>${this.getByRulePart("byweekday",s.CHECKBOX_LIST,Object.keys(m))}</div>
80
- <div>
81
- ${this.getByRulePart("byhour",s.SELECT,byHourOptions)}
82
- ${this.getByRulePart("byminute",s.SELECT,byMinuteOrSecondsOptions)}
83
- ${this.getByRulePart("bysecond",s.SELECT,byMinuteOrSecondsOptions)}
84
- </div>
85
- </div>`}getByRulePart(t,i,l){var r,n,s,a,o;if(!(null==(r=this._byRRuleParts)?void 0:r.includes(t)))return;let d="byweekday"===t?null==(a=null==(s=null==(n=this._rrule)?void 0:n.origOptions)?void 0:s.byweekday)?void 0:a.map(String):null==(o=this._rrule)?void 0:o.origOptions[t];return e`<or-mwc-input style="min-width: 30%"
86
- .value="${null!=d?d:[]}"
87
- .type="${i}"
88
- .options="${l}"
89
- .label="${t}"
90
- multiple
91
- @or-mwc-input-changed="${e=>{this.setRRuleValue(e.detail.value,t)}}"></or-mwc-input>`}getPeriodTemplate(t){return e`
92
- <div id="period" class="section">
93
- <label class="title"><or-translate value="period"></or-translate></label>
94
- <div style="display: flex; gap: 8px;" class="layout horizontal">
99
+ ${h(y.some(e=>{var t;return null==(t=this._byRRuleParts)?void 0:t.includes(e)}),()=>s`
100
+ <label class="title" style="margin-top: var(--lumo-space-l)"><or-translate value="schedule.repeatOn"></or-translate></label>
101
+ <div>${this._getByRulePart("bymonth",v.CHECKBOX_LIST,Object.entries(g))}</div>
95
102
  <div>
96
- <or-mwc-input value="${p(t.start).format("YYYY-MM-DD")}" .type="${s.DATE}" @or-mwc-input-changed="${e=>this.setRRuleValue(e.detail.value,"start")}" .label="${o.t("from")}"></or-mwc-input>
97
- <or-mwc-input .disabled=${this.isAllDay} .value="${p(t.start).format("HH:mm")}" .type="${s.TIME}" @or-mwc-input-changed="${e=>this.setRRuleValue(e.detail.value,"start-time")}" .label="${o.t("from")}"></or-mwc-input>
103
+ ${this._getByRulePart("byweekno",v.SELECT,byWeekNoOptions)}
104
+ ${this._getByRulePart("byyearday",v.SELECT,byYearDayOptions)}
105
+ ${this._getByRulePart("bymonthday",v.SELECT,byMonthDayOptions)}
98
106
  </div>
107
+ <div>${this._getByRulePart("byweekday",v.CHECKBOX_LIST,Object.entries(S))}</div>
99
108
  <div>
100
- <or-mwc-input .value="${p(t.end).format("YYYY-MM-DD")}" .type="${s.DATE}" @or-mwc-input-changed="${e=>this.setRRuleValue(e.detail.value,"end")}" .label="${o.t("to")}"></or-mwc-input>
101
- <or-mwc-input .disabled=${this.isAllDay} .value="${p(t.end).format("HH:mm")}" .type="${s.TIME}" @or-mwc-input-changed="${e=>this.setRRuleValue(e.detail.value,"end-time")}" .label="${o.t("to")}"></or-mwc-input>
109
+ ${this._getByRulePart("byhour",v.SELECT,byHourOptions)}
110
+ ${this._getByRulePart("byminute",v.SELECT,byMinuteOrSecondsOptions)}
111
+ ${this._getByRulePart("bysecond",v.SELECT,byMinuteOrSecondsOptions)}
112
+ </div>
113
+ `)}
114
+ </div>`}_getByRulePart(e,i,a){var r,l,o,n;if(!(null==(r=this._byRRuleParts)?void 0:r.includes(e)))return;let d=null!=(n=null==(o=null==(l=this._rrule)?void 0:l.origOptions)?void 0:o[e])?n:[],u="byweekday"===e?null==d?void 0:d.map(String):Array.isArray(d)?d:[d];return i===v.CHECKBOX_LIST?s`
115
+ <or-vaadin-checkbox-group .value="${u}" @value-changed="${this._onPartChange(e,"detail",u)}">
116
+ ${a.map(([e,i])=>s`<vaadin-checkbox theme="button" value="${e}" label="${t.t(i).slice(0,3)}"></vaadin-checkbox>`)}
117
+ </or-vaadin-checkbox-group>
118
+ `:s`
119
+ <or-vaadin-multi-select-combo-box .selectedItems="${u}" .label="${t.t(`rrule.${e}`)}"
120
+ .items="${this.disableNegativeByPartValues?a.filter(e=>+e>0):a}"
121
+ @selected-items-changed="${this._onPartChange(e,"detail",u)}">
122
+ </or-vaadin-multi-select-combo-box>
123
+ `}_getPeriodTemplate(){let e=this._scheduleWithOffset;return s`
124
+ <div id="period" class="section">
125
+ <label class="title"><or-translate value="period"></or-translate></label>
126
+ <div style="display: flex; gap: 8px">
127
+ <div class="period">
128
+ <or-vaadin-date-picker style="text-transform: capitalize" ?combined="${!this.isAllDay}" .value="${D(e.start).format("YYYY-MM-DD")}"
129
+ @change="${this._onPartChange("start","value")}" label="${t.t("from")}" .max="${D(e.end).format("YYYY-MM-DD")}">
130
+ </or-vaadin-date-picker>
131
+ <or-vaadin-time-picker style="margin-top: auto" ?hidden=${this.isAllDay} .value="${D(e.start).format("HH:mm")}"
132
+ @change="${this._onPartChange("start-time","value")}"
133
+ .max="${D(e.end).isSameOrBefore(D(e.start),"day")&&D(e.end).format("HH:mm")}">
134
+ </or-vaadin-time-picker>
135
+ </div>
136
+ <div class="period">
137
+ <or-vaadin-date-picker style="text-transform: capitalize" ?combined="${!this.isAllDay}" .value="${D(e.end).format("YYYY-MM-DD")}"
138
+ @change="${this._onPartChange("end","value")}" label="${t.t("to")}" .min="${D(e.start).format("YYYY-MM-DD")}">
139
+ </or-vaadin-date-picker>
140
+ <or-vaadin-time-picker style="margin-top: auto" ?hidden=${this.isAllDay} .value="${D(e.end).format("HH:mm")}"
141
+ @change="${this._onPartChange("end-time","value")}"
142
+ .min="${D(e.end).isSameOrBefore(D(e.start),"day")&&D(e.start).format("HH:mm")}">
143
+ </or-vaadin-time-picker>
102
144
  </div>
103
145
  </div>
104
-
105
- <div class="layout horizontal">
106
- <or-mwc-input .value=${this.isAllDay} @or-mwc-input-changed="${e=>this.setRRuleValue(e.detail.value,"all-day")}" .type="${s.CHECKBOX}" .label="${o.t("allDay")}"></or-mwc-input>
107
- </div>
108
- </div>`}getEndsTemplate(){return e`
146
+ <or-vaadin-checkbox .checked=${this.isAllDay} @change="${this._onPartChange("all-day","checked")}" .label="${t.t("allDay")}"></or-vaadin-checkbox>
147
+ </div>`}_getEndsTemplate(){return s`
109
148
  <div id="recurrence-ends" class="section">
110
149
  <label class="title"><or-translate value="schedule._ends"></or-translate></label>
111
- <div style="display: flex; gap: 8px;" class="layout horizontal">
112
- <or-mwc-input style="padding-right: 10px" .type="${s.RADIO}"
113
- .value="${this._ends}"
114
- .options="${Object.entries(S).filter(([e])=>{var t;return!(null==(t=this.disabledRRuleParts)?void 0:t.includes(e))})}"
115
- @or-mwc-input-changed="${e=>this.setRRuleValue(e.detail.value,"recurrence-ends")}">
116
- </or-mwc-input>
117
- <div style="display: flex; flex-direction: column-reverse; flex: 1">
118
- ${b(!this.disabledRRuleParts.includes("count"),()=>e`
119
- <or-mwc-input ?disabled="${"count"!==this._ends}" min="1" .type="${s.NUMBER}"
150
+ <div style="display: flex; gap: 8px;">
151
+ <or-vaadin-radio-group style="padding-right: 10px; width: unset" .value="${this._ends}" theme="vertical"
152
+ @change="${this._onPartChange("recurrence-ends","value")}">
153
+ ${Object.entries($).filter(([e])=>{var t;return!(null==(t=this.disabledRRuleParts)?void 0:t.includes(e))}).map(([e,i])=>s`
154
+ <vaadin-radio-button style="margin: 6px 0" value="${e}" label="${t.t(i)}"></vaadin-radio-button>
155
+ `)}
156
+ </or-vaadin-radio-group>
157
+ <div style="display: flex; flex-direction: column; flex: 1; ">
158
+ ${h(!this.disabledRRuleParts.includes("until"),()=>s`
159
+ <or-vaadin-date-time-picker style="margin-top: auto; padding: var(--lumo-space-s) 0" ?disabled="${"until"!==this._ends}"
160
+ .value="${D(this._until).format("YYYY-MM-DDTHH:mm")}"
161
+ @change="${this._onPartChange("until","value")}">
162
+ </or-vaadin-date-time-picker>`)}
163
+ ${h(!this.disabledRRuleParts.includes("count"),()=>s`<div style="display: inline-flex">
164
+ <or-vaadin-number-field ?disabled="${"count"!==this._ends}" min="1" style="width: 120px"
165
+ step-buttons-visible
120
166
  .value="${this._count}"
121
- .label="${o.t("schedule.count",{count:this._count})}"
122
- @or-mwc-input-changed="${e=>this.setRRuleValue(e.detail.value,"count")}">
123
- </or-mwc-input>`)}
124
- ${b(!this.disabledRRuleParts.includes("until"),()=>e`
125
- <or-mwc-input ?disabled="${"until"!==this._ends}" .type="${s.DATETIME}"
126
- .value="${p(this._until).format("YYYY-MM-DD HH:mm")}"
127
- @or-mwc-input-changed="${e=>this.setRRuleValue(e.detail.value,"until")}">
128
- </or-mwc-input>`)}
167
+ @change="${this._onPartChange("count","value")}">
168
+ </or-vaadin-number-field><or-translate class="label" value="schedule.count"
169
+ ?disabled="${"count"!==this._ends}" .options="${{count:+this._count}}">
170
+ </or-translate>
171
+ </div>`)}
129
172
  </div>
130
173
  </div>
131
- </div>`}};__decorate([l({type:Object})],OrScheduler.prototype,"defaultSchedule",void 0),__decorate([l({type:String})],OrScheduler.prototype,"defaultEventTypeLabel",void 0),__decorate([l({type:Array})],OrScheduler.prototype,"disabledFrequencies",void 0),__decorate([l({type:Array})],OrScheduler.prototype,"disabledRRuleParts",void 0),__decorate([l({type:String})],OrScheduler.prototype,"header",void 0),__decorate([l({type:Boolean})],OrScheduler.prototype,"isAllDay",void 0),__decorate([l({type:Object})],OrScheduler.prototype,"schedule",void 0),__decorate([l()],OrScheduler.prototype,"timezoneOffset",void 0),__decorate([n()],OrScheduler.prototype,"_ends",void 0),__decorate([n()],OrScheduler.prototype,"_normalizedSchedule",void 0),__decorate([n()],OrScheduler.prototype,"_rrule",void 0),__decorate([r("#radial-modal")],OrScheduler.prototype,"dialog",void 0),OrScheduler=__decorate([i("or-scheduler")],OrScheduler);export{OrScheduler};
174
+ </div>`}};OrScheduler.styles=l`
175
+ .time-label {
176
+ display: flex;
177
+ &>:first-child {
178
+ display: inline-block;
179
+ overflow: hidden;
180
+ text-overflow: ellipsis;
181
+ white-space: nowrap;
182
+ &::first-letter { text-transform: uppercase; }
183
+ }
184
+ }
185
+ `,__decorate([d({type:Object})],OrScheduler.prototype,"defaultSchedule",void 0),__decorate([d({type:String})],OrScheduler.prototype,"defaultEventTypeLabel",void 0),__decorate([d({type:Boolean})],OrScheduler.prototype,"disableNegativeByPartValues",void 0),__decorate([d({type:Array})],OrScheduler.prototype,"disabledFrequencies",void 0),__decorate([d({type:Array})],OrScheduler.prototype,"disabledRRuleParts",void 0),__decorate([d({type:Object})],OrScheduler.prototype,"disabledByPartCombinations",void 0),__decorate([d({type:String})],OrScheduler.prototype,"header",void 0),__decorate([d({type:Boolean})],OrScheduler.prototype,"isAllDay",void 0),__decorate([d({type:Boolean})],OrScheduler.prototype,"open",void 0),__decorate([d({type:Boolean})],OrScheduler.prototype,"removable",void 0),__decorate([d({type:Object})],OrScheduler.prototype,"schedule",void 0),__decorate([d({type:Number})],OrScheduler.prototype,"timezoneOffset",void 0),__decorate([c()],OrScheduler.prototype,"_count",void 0),__decorate([c()],OrScheduler.prototype,"_ends",void 0),__decorate([c()],OrScheduler.prototype,"_eventType",void 0),__decorate([c()],OrScheduler.prototype,"_rrule",void 0),__decorate([u("#scheduler")],OrScheduler.prototype,"_dialog",void 0),OrScheduler=__decorate([n("or-scheduler")],OrScheduler);export{OrScheduler};