@3mo/date-time-fields 0.10.0 → 0.10.2

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 (39) hide show
  1. package/dist/FieldDate.d.ts +1 -1
  2. package/dist/FieldDate.d.ts.map +1 -1
  3. package/dist/FieldDate.js +2 -8
  4. package/dist/FieldDateRange.d.ts +1 -1
  5. package/dist/FieldDateRange.d.ts.map +1 -1
  6. package/dist/FieldDateRange.js +2 -5
  7. package/dist/FieldDateTime.d.ts +2 -1
  8. package/dist/FieldDateTime.d.ts.map +1 -1
  9. package/dist/FieldDateTime.js +14 -5
  10. package/dist/FieldDateTimeBase.d.ts +1 -10
  11. package/dist/FieldDateTimeBase.d.ts.map +1 -1
  12. package/dist/FieldDateTimeBase.js +9 -54
  13. package/dist/FieldDateTimePrecision.d.ts +20 -0
  14. package/dist/FieldDateTimePrecision.d.ts.map +1 -0
  15. package/dist/FieldDateTimePrecision.js +47 -0
  16. package/dist/FieldDateTimeRange.d.ts +2 -1
  17. package/dist/FieldDateTimeRange.d.ts.map +1 -1
  18. package/dist/FieldDateTimeRange.js +12 -10
  19. package/dist/FieldToggleableDateTimeRange.d.ts +1 -1
  20. package/dist/FieldToggleableDateTimeRange.d.ts.map +1 -1
  21. package/dist/FieldToggleableDateTimeRange.js +2 -2
  22. package/dist/custom-elements.json +42 -108
  23. package/dist/index.d.ts +1 -0
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +1 -0
  26. package/dist/selection/calendar/Calendar.d.ts +9 -5
  27. package/dist/selection/calendar/Calendar.d.ts.map +1 -1
  28. package/dist/selection/calendar/Calendar.js +52 -37
  29. package/dist/selection/calendar/SelectableCalendar.d.ts +6 -5
  30. package/dist/selection/calendar/SelectableCalendar.d.ts.map +1 -1
  31. package/dist/selection/calendar/SelectableCalendar.js +52 -16
  32. package/dist/selection/calendar/index.d.ts +0 -1
  33. package/dist/selection/calendar/index.d.ts.map +1 -1
  34. package/dist/selection/calendar/index.js +0 -1
  35. package/dist/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +1 -1
  37. package/dist/selection/calendar/SelectableRangeCalendar.d.ts +0 -22
  38. package/dist/selection/calendar/SelectableRangeCalendar.d.ts.map +0 -1
  39. package/dist/selection/calendar/SelectableRangeCalendar.js +0 -70
@@ -27,7 +27,7 @@
27
27
  "name": "precision",
28
28
  "description": "The precision of the date picker. Defaults to 'minute'",
29
29
  "type": "FieldDateTimePrecision",
30
- "default": "\"day\""
30
+ "default": "\"Day\""
31
31
  },
32
32
  {
33
33
  "name": "selectOnFocus",
@@ -103,7 +103,7 @@
103
103
  "attribute": "precision",
104
104
  "description": "The precision of the date picker. Defaults to 'minute'",
105
105
  "type": "FieldDateTimePrecision",
106
- "default": "\"day\""
106
+ "default": "\"Day\""
107
107
  },
108
108
  {
109
109
  "name": "inputElement",
@@ -245,7 +245,7 @@
245
245
  "name": "precision",
246
246
  "description": "The precision of the date picker. Defaults to 'minute'",
247
247
  "type": "FieldDateTimePrecision",
248
- "default": "\"day\""
248
+ "default": "\"Day\""
249
249
  },
250
250
  {
251
251
  "name": "selectOnFocus",
@@ -328,7 +328,7 @@
328
328
  "attribute": "precision",
329
329
  "description": "The precision of the date picker. Defaults to 'minute'",
330
330
  "type": "FieldDateTimePrecision",
331
- "default": "\"day\""
331
+ "default": "\"Day\""
332
332
  },
333
333
  {
334
334
  "name": "inputElement",
@@ -470,7 +470,7 @@
470
470
  "name": "precision",
471
471
  "description": "The precision of the date picker. Defaults to 'minute'",
472
472
  "type": "FieldDateTimePrecision",
473
- "default": "\"day\""
473
+ "default": "\"Day\""
474
474
  },
475
475
  {
476
476
  "name": "selectOnFocus",
@@ -553,7 +553,7 @@
553
553
  "attribute": "precision",
554
554
  "description": "The precision of the date picker. Defaults to 'minute'",
555
555
  "type": "FieldDateTimePrecision",
556
- "default": "\"day\""
556
+ "default": "\"Day\""
557
557
  },
558
558
  {
559
559
  "name": "inputElement",
@@ -689,7 +689,7 @@
689
689
  "name": "precision",
690
690
  "description": "The precision of the date picker. Defaults to 'minute'",
691
691
  "type": "FieldDateTimePrecision",
692
- "default": "\"minute\""
692
+ "default": "\"Minute\""
693
693
  },
694
694
  {
695
695
  "name": "selectOnFocus",
@@ -765,7 +765,7 @@
765
765
  "attribute": "precision",
766
766
  "description": "The precision of the date picker. Defaults to 'minute'",
767
767
  "type": "FieldDateTimePrecision",
768
- "default": "\"minute\""
768
+ "default": "\"Minute\""
769
769
  },
770
770
  {
771
771
  "name": "inputElement",
@@ -907,7 +907,7 @@
907
907
  "name": "precision",
908
908
  "description": "The precision of the date picker. Defaults to 'minute'",
909
909
  "type": "FieldDateTimePrecision",
910
- "default": "\"minute\""
910
+ "default": "\"Minute\""
911
911
  },
912
912
  {
913
913
  "name": "selectOnFocus",
@@ -990,7 +990,7 @@
990
990
  "attribute": "precision",
991
991
  "description": "The precision of the date picker. Defaults to 'minute'",
992
992
  "type": "FieldDateTimePrecision",
993
- "default": "\"minute\""
993
+ "default": "\"Minute\""
994
994
  },
995
995
  {
996
996
  "name": "inputElement",
@@ -1132,7 +1132,7 @@
1132
1132
  "name": "precision",
1133
1133
  "description": "The precision of the date picker. Defaults to 'minute'",
1134
1134
  "type": "FieldDateTimePrecision",
1135
- "default": "\"minute\""
1135
+ "default": "\"Minute\""
1136
1136
  },
1137
1137
  {
1138
1138
  "name": "selectOnFocus",
@@ -1215,7 +1215,7 @@
1215
1215
  "attribute": "precision",
1216
1216
  "description": "The precision of the date picker. Defaults to 'minute'",
1217
1217
  "type": "FieldDateTimePrecision",
1218
- "default": "\"minute\""
1218
+ "default": "\"Minute\""
1219
1219
  },
1220
1220
  {
1221
1221
  "name": "inputElement",
@@ -1552,7 +1552,7 @@
1552
1552
  "name": "precision",
1553
1553
  "description": "The precision of the date picker. Defaults to 'minute'",
1554
1554
  "type": "FieldDateTimePrecision",
1555
- "default": "\"day\""
1555
+ "default": "\"Day\""
1556
1556
  },
1557
1557
  {
1558
1558
  "name": "selectOnFocus",
@@ -1639,7 +1639,7 @@
1639
1639
  "attribute": "precision",
1640
1640
  "description": "The precision of the date picker. Defaults to 'minute'",
1641
1641
  "type": "FieldDateTimePrecision",
1642
- "default": "\"day\""
1642
+ "default": "\"Day\""
1643
1643
  },
1644
1644
  {
1645
1645
  "name": "inputElement",
@@ -3579,29 +3579,11 @@
3579
3579
  "path": ".\\packages\\DateTimeFields\\dist\\selection\\calendar\\Calendar.d.ts",
3580
3580
  "properties": [
3581
3581
  {
3582
- "name": "includeWeekNumbers",
3583
- "type": "boolean"
3584
- },
3585
- {
3586
- "name": "navigatingValue",
3587
- "type": "DateTime"
3588
- }
3589
- ]
3590
- },
3591
- {
3592
- "name": "mo-selectable-calendar",
3593
- "path": ".\\packages\\DateTimeFields\\dist\\selection\\calendar\\SelectableCalendar.d.ts",
3594
- "properties": [
3595
- {
3596
- "name": "change",
3582
+ "name": "dayClick",
3597
3583
  "type": "EventDispatcher<DateTime>"
3598
3584
  },
3599
3585
  {
3600
- "name": "value",
3601
- "type": "DateTime | undefined"
3602
- },
3603
- {
3604
- "name": "includeWeekNumbers",
3586
+ "name": "includeWeek",
3605
3587
  "type": "boolean"
3606
3588
  },
3607
3589
  {
@@ -3611,29 +3593,26 @@
3611
3593
  ],
3612
3594
  "events": [
3613
3595
  {
3614
- "name": "change",
3596
+ "name": "dayClick",
3597
+ "description": "Dispatched when a day is clicked, with the clicked date as detail.",
3615
3598
  "type": "CustomEvent<DateTime>"
3616
3599
  }
3617
3600
  ]
3618
3601
  },
3619
3602
  {
3620
- "name": "mo-selectable-range-calendar",
3621
- "path": ".\\packages\\DateTimeFields\\dist\\selection\\calendar\\SelectableRangeCalendar.d.ts",
3603
+ "name": "mo-selectable-calendar",
3604
+ "path": ".\\packages\\DateTimeFields\\dist\\selection\\calendar\\SelectableCalendar.d.ts",
3622
3605
  "properties": [
3623
3606
  {
3624
- "name": "dateRange",
3607
+ "name": "value",
3625
3608
  "type": "DateTimeRange | undefined"
3626
3609
  },
3627
3610
  {
3628
- "name": "change",
3611
+ "name": "dayClick",
3629
3612
  "type": "EventDispatcher<DateTime>"
3630
3613
  },
3631
3614
  {
3632
- "name": "value",
3633
- "type": "DateTime | undefined"
3634
- },
3635
- {
3636
- "name": "includeWeekNumbers",
3615
+ "name": "includeWeek",
3637
3616
  "type": "boolean"
3638
3617
  },
3639
3618
  {
@@ -3643,7 +3622,8 @@
3643
3622
  ],
3644
3623
  "events": [
3645
3624
  {
3646
- "name": "change",
3625
+ "name": "dayClick",
3626
+ "description": "Dispatched when a day is clicked, with the clicked date as detail.",
3647
3627
  "type": "CustomEvent<DateTime>"
3648
3628
  }
3649
3629
  ]
@@ -3893,41 +3873,7 @@
3893
3873
  "path": ".\\packages\\DateTimeFields\\selection\\calendar\\Calendar.ts",
3894
3874
  "attributes": [
3895
3875
  {
3896
- "name": "includeWeekNumbers",
3897
- "type": "boolean",
3898
- "default": "false"
3899
- },
3900
- {
3901
- "name": "navigatingValue",
3902
- "type": "DateTime",
3903
- "default": "\"new DateTime\""
3904
- }
3905
- ],
3906
- "properties": [
3907
- {
3908
- "name": "includeWeekNumbers",
3909
- "attribute": "includeWeekNumbers",
3910
- "type": "boolean",
3911
- "default": "false"
3912
- },
3913
- {
3914
- "name": "navigatingValue",
3915
- "attribute": "navigatingValue",
3916
- "type": "DateTime",
3917
- "default": "\"new DateTime\""
3918
- }
3919
- ]
3920
- },
3921
- {
3922
- "name": "mo-selectable-calendar",
3923
- "path": ".\\packages\\DateTimeFields\\selection\\calendar\\SelectableCalendar.ts",
3924
- "attributes": [
3925
- {
3926
- "name": "value",
3927
- "type": "DateTime | undefined"
3928
- },
3929
- {
3930
- "name": "includeWeekNumbers",
3876
+ "name": "includeWeek",
3931
3877
  "type": "boolean",
3932
3878
  "default": "false"
3933
3879
  },
@@ -3939,17 +3885,12 @@
3939
3885
  ],
3940
3886
  "properties": [
3941
3887
  {
3942
- "name": "change",
3888
+ "name": "dayClick",
3943
3889
  "type": "EventDispatcher<DateTime>"
3944
3890
  },
3945
3891
  {
3946
- "name": "value",
3947
- "attribute": "value",
3948
- "type": "DateTime | undefined"
3949
- },
3950
- {
3951
- "name": "includeWeekNumbers",
3952
- "attribute": "includeWeekNumbers",
3892
+ "name": "includeWeek",
3893
+ "attribute": "includeWeek",
3953
3894
  "type": "boolean",
3954
3895
  "default": "false"
3955
3896
  },
@@ -3962,25 +3903,22 @@
3962
3903
  ],
3963
3904
  "events": [
3964
3905
  {
3965
- "name": "change",
3906
+ "name": "dayClick",
3907
+ "description": "Dispatched when a day is clicked, with the clicked date as detail.",
3966
3908
  "type": "CustomEvent<DateTime>"
3967
3909
  }
3968
3910
  ]
3969
3911
  },
3970
3912
  {
3971
- "name": "mo-selectable-range-calendar",
3972
- "path": ".\\packages\\DateTimeFields\\selection\\calendar\\SelectableRangeCalendar.ts",
3913
+ "name": "mo-selectable-calendar",
3914
+ "path": ".\\packages\\DateTimeFields\\selection\\calendar\\SelectableCalendar.ts",
3973
3915
  "attributes": [
3974
- {
3975
- "name": "dateRange",
3976
- "type": "DateTimeRange | undefined"
3977
- },
3978
3916
  {
3979
3917
  "name": "value",
3980
- "type": "DateTime | undefined"
3918
+ "type": "DateTimeRange | undefined"
3981
3919
  },
3982
3920
  {
3983
- "name": "includeWeekNumbers",
3921
+ "name": "includeWeek",
3984
3922
  "type": "boolean",
3985
3923
  "default": "false"
3986
3924
  },
@@ -3992,22 +3930,17 @@
3992
3930
  ],
3993
3931
  "properties": [
3994
3932
  {
3995
- "name": "dateRange",
3996
- "attribute": "dateRange",
3933
+ "name": "value",
3934
+ "attribute": "value",
3997
3935
  "type": "DateTimeRange | undefined"
3998
3936
  },
3999
3937
  {
4000
- "name": "change",
3938
+ "name": "dayClick",
4001
3939
  "type": "EventDispatcher<DateTime>"
4002
3940
  },
4003
3941
  {
4004
- "name": "value",
4005
- "attribute": "value",
4006
- "type": "DateTime | undefined"
4007
- },
4008
- {
4009
- "name": "includeWeekNumbers",
4010
- "attribute": "includeWeekNumbers",
3942
+ "name": "includeWeek",
3943
+ "attribute": "includeWeek",
4011
3944
  "type": "boolean",
4012
3945
  "default": "false"
4013
3946
  },
@@ -4020,7 +3953,8 @@
4020
3953
  ],
4021
3954
  "events": [
4022
3955
  {
4023
- "name": "change",
3956
+ "name": "dayClick",
3957
+ "description": "Dispatched when a day is clicked, with the clicked date as detail.",
4024
3958
  "type": "CustomEvent<DateTime>"
4025
3959
  }
4026
3960
  ]
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ import '@3mo/scroller';
10
10
  import '@3mo/list';
11
11
  export * from './selection/index.js';
12
12
  export * from './FieldTime.js';
13
+ export * from './FieldDateTimePrecision.js';
13
14
  export * from './FieldDateTime.js';
14
15
  export * from './FieldDateTimeRange.js';
15
16
  export * from './FieldDateRange.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAA;AACvB,OAAO,WAAW,CAAA;AAClB,OAAO,kBAAkB,CAAA;AACzB,OAAO,cAAc,CAAA;AACrB,OAAO,WAAW,CAAA;AAClB,OAAO,WAAW,CAAA;AAClB,OAAO,YAAY,CAAA;AACnB,OAAO,UAAU,CAAA;AACjB,OAAO,eAAe,CAAA;AACtB,OAAO,WAAW,CAAA;AAClB,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mCAAmC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAA;AACvB,OAAO,WAAW,CAAA;AAClB,OAAO,kBAAkB,CAAA;AACzB,OAAO,cAAc,CAAA;AACrB,OAAO,WAAW,CAAA;AAClB,OAAO,WAAW,CAAA;AAClB,OAAO,YAAY,CAAA;AACnB,OAAO,UAAU,CAAA;AACjB,OAAO,eAAe,CAAA;AACtB,OAAO,WAAW,CAAA;AAClB,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,6BAA6B,CAAA;AAC3C,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mCAAmC,CAAA"}
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ import '@3mo/scroller';
10
10
  import '@3mo/list';
11
11
  export * from './selection/index.js';
12
12
  export * from './FieldTime.js';
13
+ export * from './FieldDateTimePrecision.js';
13
14
  export * from './FieldDateTime.js';
14
15
  export * from './FieldDateTimeRange.js';
15
16
  export * from './FieldDateRange.js';
@@ -1,16 +1,20 @@
1
1
  import { Component, type ClassInfo } from '@a11d/lit';
2
2
  import '@a11d/array.prototype.group';
3
+ /**
4
+ * @fires dayClick - Dispatched when a day is clicked, with the clicked date as detail.
5
+ */
3
6
  export declare class Calendar extends Component {
4
- includeWeekNumbers: boolean;
7
+ readonly dayClick: EventDispatcher<DateTime>;
8
+ private static rangeOf;
9
+ includeWeek: boolean;
5
10
  navigatingValue: import("@3mo/date-time/DateTime.js").DateTime;
6
11
  private days;
7
12
  static get styles(): import("@a11d/lit").CSSResult;
13
+ private get columns();
14
+ private getColumnName;
8
15
  protected get template(): import("lit-html").HTMLTemplateResult;
9
- private rangeOf;
10
- protected getDayTemplate(day: DateTime): import("lit-html").HTMLTemplateResult;
11
- protected handleDayClick(day: DateTime): void;
12
- private get today();
13
16
  protected getDayElementClasses(day: DateTime): ClassInfo;
17
+ private get today();
14
18
  }
15
19
  declare global {
16
20
  interface HTMLElementTagNameMap {
@@ -1 +1 @@
1
- {"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../../../selection/calendar/Calendar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA4C,KAAK,SAAS,EAAS,MAAM,WAAW,CAAA;AACtG,OAAO,6BAA6B,CAAA;AAGpC,qBACa,QAAS,SAAQ,SAAS;IACM,kBAAkB,UAAQ;IAUnE,eAAe,gDAAe;IAExB,OAAO,CAAC,IAAI,CAA2D;IAEhF,WAAoB,MAAM,kCAyDzB;IAED,cAAuB,QAAQ,0CAyB9B;IAED,OAAO,CAAG,OAAO;IAOjB,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,QAAQ;IAQtC,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,QAAQ;IAKtC,OAAO,KAAK,KAAK,GAAqC;IAEtD,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,QAAQ,GAAG,SAAS;CAOxD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,aAAa,EAAE,QAAQ,CAAA;KACvB;CACD"}
1
+ {"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../../../selection/calendar/Calendar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA4C,KAAK,SAAS,EAAgB,MAAM,WAAW,CAAA;AAC7G,OAAO,6BAA6B,CAAA;AAGpC;;GAEG;AACH,qBACa,QAAS,SAAQ,SAAS;IAC7B,QAAQ,CAAC,QAAQ,EAAG,eAAe,CAAC,QAAQ,CAAC,CAAA;IAEtD,OAAO,CAAC,MAAM,CAAE,OAAO;IAOqB,WAAW,UAAQ;IAQ5D,eAAe,gDAAe;IAExB,OAAO,CAAC,IAAI,CAAwB;IAE7C,WAAoB,MAAM,kCA2DzB;IAED,OAAO,KAAK,OAAO,GAMlB;IAED,OAAO,CAAC,aAAa;IAIrB,cAAuB,QAAQ,0CAkC9B;IAED,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,QAAQ,GAAG,SAAS;IASxD,OAAO,KAAK,KAAK,GAAqC;CACtD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,aAAa,EAAE,QAAQ,CAAA;KACvB;CACD"}
@@ -1,24 +1,32 @@
1
1
  import { __decorate } from "tslib";
2
- import { Component, css, component, html, property, classMap, state } from '@a11d/lit';
2
+ import { Component, css, component, html, property, classMap, state, event } from '@a11d/lit';
3
3
  import '@a11d/array.prototype.group';
4
4
  import { MemoizeExpiring as memoizeExpiring } from 'typescript-memoize';
5
+ /**
6
+ * @fires dayClick - Dispatched when a day is clicked, with the clicked date as detail.
7
+ */
5
8
  let Calendar = class Calendar extends Component {
6
9
  constructor() {
7
10
  super(...arguments);
8
- this.includeWeekNumbers = false;
11
+ this.includeWeek = false;
9
12
  this.navigatingValue = new DateTime;
10
13
  this.days = new Array();
11
14
  }
15
+ static *rangeOf(start, end) {
16
+ while (!start.isAfter(end)) {
17
+ yield start;
18
+ start = start.add({ days: 1 });
19
+ }
20
+ }
12
21
  static get styles() {
13
22
  return css `
14
23
  :host {
15
24
  --mo-calendar-day-size: 36px;
16
25
  --mo-calendar-week-number-width: var(--mo-calendar-day-size);
17
- padding-inline: 10px;
26
+ padding: 0.5rem;
18
27
  }
19
28
 
20
29
  .month {
21
- min-height: 270px;
22
30
  place-items: center;
23
31
 
24
32
  .heading {
@@ -28,11 +36,14 @@ let Calendar = class Calendar extends Component {
28
36
  place-self: stretch;
29
37
  display: flex;
30
38
  align-items: center;
31
- margin-inline-start: 6px;
39
+ padding-inline-start: 6px;
40
+ padding-block-end: 0.5rem;
32
41
  }
33
42
 
34
43
  .header {
44
+ text-align: center;
35
45
  color: var(--mo-color-gray);
46
+ padding-block: 0.25rem
36
47
  }
37
48
  }
38
49
 
@@ -67,49 +78,51 @@ let Calendar = class Calendar extends Component {
67
78
  }
68
79
  `;
69
80
  }
81
+ get columns() {
82
+ const daysInWeek = this.days[0]?.daysInWeek ?? 7;
83
+ return [
84
+ !this.includeWeek ? undefined : '[week] var(--mo-calendar-week-number-width)',
85
+ ...this.days.slice(0, daysInWeek).map(day => `[${this.getColumnName(day)}] var(--mo-calendar-day-size)`),
86
+ ].join(' ');
87
+ }
88
+ getColumnName(date) {
89
+ return `day-${date.dayOfWeek}`;
90
+ }
70
91
  get template() {
71
92
  return html `
72
93
  <mo-grid class='month'
73
94
  rows='repeat(auto-fill, var(--mo-calendar-day-size))'
74
- columns=${this.includeWeekNumbers ? 'var(--mo-calendar-week-number-width) repeat(7, var(--mo-calendar-day-size))' : 'repeat(7, var(--mo-calendar-day-size))'}
95
+ columns=${this.columns}
75
96
  >
76
97
  <div class='heading' style='grid-column: 1 / -1'>
77
98
  ${this.navigatingValue.format({ year: 'numeric' })}
78
99
  ${this.navigatingValue.format({ month: 'long' })}
79
100
  </div>
80
101
 
81
- ${this.includeWeekNumbers === false ? html.nothing : html `<div></div>`}
82
-
83
- ${this.navigatingValue.weekDayNames.map(dayName => html `
84
- <div class='header'>
85
- ${dayName.charAt(0).toUpperCase() + dayName.charAt(1)}
86
- </div>
87
- `)}
102
+ <mo-grid class='header' columns='subgrid' style='grid-column: 1 / -1'>
103
+ ${this.includeWeek === false ? html.nothing : html `<div></div>`}
104
+ ${this.days.slice(0, this.days[0]?.daysInWeek).map(day => html `
105
+ <span style='grid-column: ${this.getColumnName(day)}' title=${day.format({ weekday: 'long' })}>
106
+ ${day.format({ weekday: 'narrow' })}
107
+ </span>
108
+ `)}
109
+ </mo-grid>
88
110
 
89
- ${this.days.map(([weekNumber, days]) => html `
90
- ${this.includeWeekNumbers === false ? html.nothing : html `<div class='week'>${weekNumber}</div>`}
91
- ${days.map(day => this.getDayTemplate(day))}
111
+ ${this.days.map(day => html `
112
+ ${this.includeWeek === false || day.dayOfWeek !== 1 ? html.nothing : html `
113
+ <div class='week' style='grid-column: week'>${day.weekOfYear}</div>
114
+ `}
115
+ <mo-flex tabindex='0'
116
+ style='grid-column: ${this.getColumnName(day)}'
117
+ class=${classMap(this.getDayElementClasses(day))}
118
+ @click=${() => this.dayClick.dispatch(day)}
119
+ >
120
+ ${day.format({ day: 'numeric' })}
121
+ </mo-flex>
92
122
  `)}
93
123
  </mo-grid>
94
124
  `;
95
125
  }
96
- *rangeOf(start, end) {
97
- while (!start.isAfter(end)) {
98
- yield start;
99
- start = start.add({ days: 1 });
100
- }
101
- }
102
- getDayTemplate(day) {
103
- return html `
104
- <mo-flex tabindex='0' class=${classMap(this.getDayElementClasses(day))} @click=${() => this.handleDayClick(day)}>
105
- ${day.format({ day: 'numeric' })}
106
- </mo-flex>
107
- `;
108
- }
109
- handleDayClick(day) {
110
- day;
111
- }
112
- get today() { return new DateTime().dayStart; }
113
126
  getDayElementClasses(day) {
114
127
  return {
115
128
  day: true,
@@ -117,19 +130,21 @@ let Calendar = class Calendar extends Component {
117
130
  outsideMonth: day.month !== this.navigatingValue.month
118
131
  };
119
132
  }
133
+ get today() { return new DateTime().dayStart; }
120
134
  };
135
+ __decorate([
136
+ event()
137
+ ], Calendar.prototype, "dayClick", void 0);
121
138
  __decorate([
122
139
  property({ type: Boolean, reflect: true })
123
- ], Calendar.prototype, "includeWeekNumbers", void 0);
140
+ ], Calendar.prototype, "includeWeek", void 0);
124
141
  __decorate([
125
142
  property({
126
143
  type: Object,
127
144
  updated() {
128
145
  const start = this.navigatingValue.monthStart.weekStart;
129
146
  const end = this.navigatingValue.monthEnd.weekEnd;
130
- const range = [...this.rangeOf(start, end)];
131
- this.days = [...range.groupToMap(d => String(d.weekOfYear))]
132
- .sort(([, dates1], [, dates2]) => dates1[0]?.isBefore(dates2[0]) ? -1 : +1);
147
+ this.days = [...Calendar.rangeOf(start, end)];
133
148
  }
134
149
  })
135
150
  ], Calendar.prototype, "navigatingValue", void 0);
@@ -1,13 +1,14 @@
1
+ import { type PropertyValues } from '@a11d/lit';
1
2
  import { Calendar } from './Calendar.js';
2
3
  import { type DateTime } from '@3mo/date-time';
3
- /** @fires change */
4
4
  export declare class SelectableCalendar extends Calendar {
5
- readonly change: EventDispatcher<DateTime>;
6
- value?: DateTime;
5
+ value?: DateTimeRange;
6
+ private readonly monthElement;
7
+ protected updated(pops: PropertyValues<this>): void;
7
8
  static get styles(): import("@a11d/lit").CSSResult;
8
- protected static get calendarStyles(): import("@a11d/lit").CSSResult;
9
- protected handleDayClick(day: DateTime): void;
10
9
  protected getDayElementClasses(day: DateTime): {
10
+ start: boolean;
11
+ end: boolean;
11
12
  selected: boolean;
12
13
  };
13
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SelectableCalendar.d.ts","sourceRoot":"","sources":["../../../selection/calendar/SelectableCalendar.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE9C,oBAAoB;AACpB,qBACa,kBAAmB,SAAQ,QAAQ;IACtC,QAAQ,CAAC,MAAM,EAAG,eAAe,CAAC,QAAQ,CAAC,CAAA;IAExB,KAAK,CAAC,EAAE,QAAQ,CAAA;IAE5C,WAAoB,MAAM,kCAKzB;IAED,SAAS,CAAC,MAAM,KAAK,cAAc,kCAOlC;cAEkB,cAAc,CAAC,GAAG,EAAE,QAAQ;cAK5B,oBAAoB,CAAC,GAAG,EAAE,QAAQ;;;CAMrD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,wBAAwB,EAAE,kBAAkB,CAAA;KAC5C;CACD"}
1
+ {"version":3,"file":"SelectableCalendar.d.ts","sourceRoot":"","sources":["../../../selection/calendar/SelectableCalendar.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,KAAK,cAAc,EAAE,MAAM,WAAW,CAAA;AAC3F,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE9C,qBACa,kBAAmB,SAAQ,QAAQ;IACnB,KAAK,CAAC,EAAE,aAAa,CAAA;IAEhC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAc;cAEzC,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC;IASrD,WAAoB,MAAM,kCA0CzB;cAEkB,oBAAoB,CAAC,GAAG,EAAE,QAAQ;;;;;CAUrD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,wBAAwB,EAAE,kBAAkB,CAAA;KAC5C;CACD"}
@@ -1,39 +1,75 @@
1
1
  import { __decorate } from "tslib";
2
- import { component, css, event, property } from '@a11d/lit';
2
+ import { component, css, property, query, unsafeCSS } from '@a11d/lit';
3
3
  import { Calendar } from './Calendar.js';
4
- /** @fires change */
5
4
  let SelectableCalendar = class SelectableCalendar extends Calendar {
5
+ updated(pops) {
6
+ super.updated(pops);
7
+ this.monthElement.dataset.selection = this.dataset.selection;
8
+ this.monthElement.toggleAttribute('data-start-exists', !!this.value?.start);
9
+ this.monthElement.toggleAttribute('data-end-exists', !!this.value?.end);
10
+ this.monthElement.toggleAttribute('data-start-behind', this.value?.start?.isBefore(this.navigatingValue.monthEnd.weekEnd) ?? false);
11
+ this.monthElement.toggleAttribute('data-end-ahead', this.value?.end?.isAfter(this.navigatingValue.monthEnd.weekEnd) ?? false);
12
+ }
6
13
  static get styles() {
14
+ const getRangeStyles = ({ start, end }) => {
15
+ return css `
16
+ .day${unsafeCSS(start)}, .day${unsafeCSS(end)} {
17
+ background: var(--mo-color-accent-transparent) !important;
18
+ color: color-mix(in srgb, var(--mo-color-accent), var(--mo-color-foreground));
19
+ }
20
+
21
+ .day${unsafeCSS(start)} ~ :not(${unsafeCSS(end)}):not(${unsafeCSS(end)} ~ *), /* Start is visible, end is visible or not */
22
+ &[data-start-exists]:has(${unsafeCSS(end)}):not(:has(${unsafeCSS(start)})) .day:not(${unsafeCSS(end)}):not(${unsafeCSS(end)} ~ *), /* Start is not visible, end is visible */
23
+ &[data-start-before][data-end-ahead] .day /* Start is before, end is after */
24
+ {
25
+ background: color-mix(in srgb, var(--mo-color-accent), transparent 92%);
26
+ }
27
+ `;
28
+ };
7
29
  return css `
8
30
  ${super.styles}
9
- ${this.calendarStyles}
10
- `;
11
- }
12
- static get calendarStyles() {
13
- return css `
31
+
14
32
  .day.selected {
15
33
  background: var(--mo-color-accent-transparent);
16
- color: var(--mo-color-accent) !important;
34
+ color: color-mix(in srgb, var(--mo-color-accent), var(--mo-color-foreground)) !important;
35
+ }
36
+
37
+ .month {
38
+ &:not(:hover) {
39
+ ${getRangeStyles({ start: '.selected.start', end: '.selected.end' })};
40
+ }
41
+
42
+ &:hover {
43
+ /* After start is selected: */
44
+ &[data-selection=end] {
45
+ ${getRangeStyles({ start: '.selected.start', end: ':hover' })};
46
+ }
47
+
48
+ /* After end is selected: */
49
+ &[data-selection=start] {
50
+ ${getRangeStyles({ start: ':hover', end: '.selected.end' })};
51
+ }
52
+ }
17
53
  }
18
54
  `;
19
55
  }
20
- handleDayClick(day) {
21
- this.value = day;
22
- this.change.dispatch(day);
23
- }
24
56
  getDayElementClasses(day) {
57
+ const start = this.value?.start?.dayStart.equals(day.dayStart) ?? false;
58
+ const end = this.value?.end?.dayStart.equals(day.dayStart) ?? false;
25
59
  return {
26
60
  ...super.getDayElementClasses(day),
27
- selected: !!this.value && day.equals(this.value),
61
+ start,
62
+ end,
63
+ selected: start || end,
28
64
  };
29
65
  }
30
66
  };
31
- __decorate([
32
- event()
33
- ], SelectableCalendar.prototype, "change", void 0);
34
67
  __decorate([
35
68
  property({ type: Object })
36
69
  ], SelectableCalendar.prototype, "value", void 0);
70
+ __decorate([
71
+ query('.month')
72
+ ], SelectableCalendar.prototype, "monthElement", void 0);
37
73
  SelectableCalendar = __decorate([
38
74
  component('mo-selectable-calendar')
39
75
  ], SelectableCalendar);
@@ -1,4 +1,3 @@
1
1
  export * from './Calendar.js';
2
2
  export * from './SelectableCalendar.js';
3
- export * from './SelectableRangeCalendar.js';
4
3
  //# sourceMappingURL=index.d.ts.map