Skip to content

Commit dede3e4

Browse files
authored
Merge branch 'master' into rkaraivanov/fix-1710
2 parents 336c20a + 2f78deb commit dede3e4

74 files changed

Lines changed: 7471 additions & 255 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package-lock.json

Lines changed: 87 additions & 88 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
"build:meta": "node scripts/build-stories.mjs",
2626
"watch-meta": "node scripts/stories-watcher.js ",
2727
"watch-scss": "node scripts/styles-watcher.mjs",
28-
"check": "madge --circular --warning --no-spinner --ts-config ./tsconfig.json --extensions ts src/index.ts",
28+
"check-imports": "madge --circular --warning --no-spinner --ts-config ./tsconfig.json --extensions ts src/index.ts",
29+
"check-types": "tsc -p scripts/tsconfig-ci.json",
30+
"check": "npm run check-imports && npm run check-types",
2931
"clean": "npm run clean:dist && npm run clean:styles && npm run clean:docs",
3032
"clean:dist": "rimraf ./dist",
3133
"clean:styles": "rimraf --glob \"src/**/*.css.ts\"",
@@ -50,7 +52,7 @@
5052
"prepare": "husky"
5153
},
5254
"dependencies": {
53-
"@floating-ui/dom": "^1.7.0",
55+
"@floating-ui/dom": "^1.7.1",
5456
"@lit-labs/virtualizer": "^2.1.0",
5557
"@lit/context": "^1.1.5",
5658
"lit": "^3.3.0"
@@ -60,10 +62,10 @@
6062
"@custom-elements-manifest/analyzer": "^0.10.4",
6163
"@igniteui/material-icons-extended": "^3.1.0",
6264
"@open-wc/testing": "^4.0.0",
63-
"@storybook/addon-a11y": "^9.0.0",
64-
"@storybook/addon-docs": "^9.0.0",
65-
"@storybook/addon-links": "^9.0.0",
66-
"@storybook/web-components-vite": "^9.0.0",
65+
"@storybook/addon-a11y": "^9.0.4",
66+
"@storybook/addon-docs": "^9.0.4",
67+
"@storybook/addon-links": "^9.0.4",
68+
"@storybook/web-components-vite": "^9.0.4",
6769
"@types/mocha": "^10.0.10",
6870
"@web/dev-server-esbuild": "^1.0.4",
6971
"@web/test-runner": "^0.20.2",
@@ -77,7 +79,7 @@
7779
"globby": "^14.1.0",
7880
"husky": "^9.1.7",
7981
"ig-typedoc-theme": "^6.1.0",
80-
"igniteui-theming": "^18.0.2",
82+
"igniteui-theming": "^18.1.0",
8183
"keep-a-changelog": "^2.6.2",
8284
"lint-staged": "^16.1.0",
8385
"lit-analyzer": "^2.0.3",
@@ -89,8 +91,8 @@
8991
"rimraf": "^6.0.1",
9092
"sass-embedded": "~1.78.0",
9193
"sinon": "^20.0.0",
92-
"storybook": "^9.0.0",
93-
"stylelint": "^16.19.1",
94+
"storybook": "^9.0.4",
95+
"stylelint": "^16.20.0",
9496
"stylelint-config-standard-scss": "^15.0.1",
9597
"stylelint-prettier": "^5.0.3",
9698
"stylelint-scss": "^6.12.0",

scripts/tsconfig-ci.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"noEmit": true
5+
}
6+
}

src/components/calendar/calendar.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ import IgcYearsViewComponent from './years-view/years-view.js';
5656

5757
export const focusActiveDate = Symbol();
5858

59+
/* blazorIndirectRender */
60+
/* blazorSupportsVisualChildren */
5961
/**
6062
* Represents a calendar that lets users
6163
* to select a date value in a variety of different ways.

src/components/calendar/helpers.ts

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
last,
77
modulo,
88
} from '../common/util.js';
9+
import type { DateRangeValue } from '../date-range-picker/date-range-picker.js';
910
import {
1011
CalendarDay,
1112
type CalendarRangeParams,
@@ -71,6 +72,33 @@ export function convertToDate(value?: Date | string | null): Date | null {
7172
return isString(value) ? parseISODate(value) : isValidDate(value);
7273
}
7374

75+
/**
76+
* Converts the given value to a DateRangeValue object.
77+
*
78+
* If the value is already a valid DateRangeValue object, it is returned directly.
79+
* If the value is a string, it is parsed to object and returned if it fields are valid dates.
80+
* If the value is null or undefined, null is returned.
81+
* If the parsing fails, null is returned.
82+
*/
83+
export function convertToDateRange(
84+
value?: DateRangeValue | string | null
85+
): DateRangeValue | null {
86+
if (!value) {
87+
return null;
88+
}
89+
90+
if (isString(value)) {
91+
const obj = JSON.parse(value);
92+
const start = convertToDate(obj.start);
93+
const end = convertToDate(obj.end);
94+
return {
95+
start: start ? CalendarDay.from(start).native : null,
96+
end: end ? CalendarDay.from(end).native : null,
97+
};
98+
}
99+
return value;
100+
}
101+
74102
/**
75103
* Converts a Date object to an ISO 8601 string.
76104
*
@@ -136,26 +164,41 @@ export function isPreviousMonth(target: DayParameter, origin: DayParameter) {
136164
}
137165

138166
/**
139-
* Returns a generator yielding day values between `start` and `end` (non-inclusive)
167+
* Returns a generator yielding day values between `start` and `end` (non-inclusive by default)
140168
* by a given `unit` as a step.
169+
* To include the end date set the `inclusive` option to true.
141170
*
142171
* @remarks
143172
* By default, `unit` is set to 'day'.
144173
*/
145-
export function* calendarRange(options: CalendarRangeParams) {
146-
let low = toCalendarDay(options.start);
147-
const unit = options.unit ?? 'day';
148-
const high =
149-
typeof options.end === 'number'
150-
? low.add(unit, options.end)
151-
: toCalendarDay(options.end);
152-
153-
const reverse = high.lessThan(low);
154-
const step = reverse ? -1 : 1;
155-
156-
while (!reverse ? low.lessThan(high) : low.greaterThan(high)) {
157-
yield low;
158-
low = low.add(unit, step);
174+
export function* calendarRange(
175+
options: CalendarRangeParams
176+
): Generator<CalendarDay, void, unknown> {
177+
const { start, end, unit = 'day', inclusive = false } = options;
178+
179+
let currentDate = toCalendarDay(start);
180+
const endDate =
181+
typeof end === 'number'
182+
? toCalendarDay(start).add(unit, end)
183+
: toCalendarDay(end);
184+
185+
const isReversed = endDate.lessThan(currentDate);
186+
const step = isReversed ? -1 : 1;
187+
188+
const shouldContinue = () => {
189+
if (inclusive) {
190+
return isReversed
191+
? currentDate.greaterThanOrEqual(endDate)
192+
: currentDate.lessThanOrEqual(endDate);
193+
}
194+
return isReversed
195+
? currentDate.greaterThan(endDate)
196+
: currentDate.lessThan(endDate);
197+
};
198+
199+
while (shouldContinue()) {
200+
yield currentDate;
201+
currentDate = currentDate.add(unit, step);
159202
}
160203
}
161204

src/components/calendar/model.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export type CalendarRangeParams = {
44
start: DayParameter;
55
end: DayParameter | number;
66
unit?: DayInterval;
7+
inclusive?: boolean;
78
};
89

910
type DayInterval = 'year' | 'quarter' | 'month' | 'week' | 'day';
@@ -43,6 +44,26 @@ export class CalendarDay {
4344
});
4445
}
4546

47+
/**
48+
* Compares the date portion of two date objects.
49+
*
50+
* @returns
51+
* ```
52+
* first === second // 0
53+
* first > second // 1
54+
* first < second // -1
55+
* ```
56+
*/
57+
public static compare(first: DayParameter, second: DayParameter) {
58+
const a = toCalendarDay(first);
59+
const b = toCalendarDay(second);
60+
61+
if (a.equalTo(b)) {
62+
return 0;
63+
}
64+
return a.greaterThan(b) ? 1 : -1;
65+
}
66+
4667
constructor(args: CalendarDayParams) {
4768
this._date = new Date(args.year, args.month, args.date ?? 1);
4869
}
@@ -152,10 +173,18 @@ export class CalendarDay {
152173
return this.timestamp > toCalendarDay(value).timestamp;
153174
}
154175

176+
public greaterThanOrEqual(value: DayParameter) {
177+
return this.timestamp >= toCalendarDay(value).timestamp;
178+
}
179+
155180
public lessThan(value: DayParameter) {
156181
return this.timestamp < toCalendarDay(value).timestamp;
157182
}
158183

184+
public lessThanOrEqual(value: DayParameter) {
185+
return this.timestamp <= toCalendarDay(value).timestamp;
186+
}
187+
159188
public toString() {
160189
return `${this.native}`;
161190
}

src/components/combo/themes/combo.base.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@
5757
--ig-theme: material;
5858
}
5959

60+
[part~='case-icon'] {
61+
color: color(gray, 600);
62+
}
63+
6064
[part='case-icon active'] {
6165
color: color(primary, 500);
6266
}

src/components/common/definitions/defineAllComponents.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import IgcSwitchComponent from '../../checkbox/switch.js';
2020
import IgcChipComponent from '../../chip/chip.js';
2121
import IgcComboComponent from '../../combo/combo.js';
2222
import IgcDatePickerComponent from '../../date-picker/date-picker.js';
23+
import IgcDateRangePickerComponent from '../../date-range-picker/date-range-picker.js';
2324
import IgcDateTimeInputComponent from '../../date-time-input/date-time-input.js';
2425
import IgcDialogComponent from '../../dialog/dialog.js';
2526
import IgcDividerComponent from '../../divider/divider.js';
@@ -90,6 +91,7 @@ const allComponents: IgniteComponent[] = [
9091
IgcChipComponent,
9192
IgcComboComponent,
9293
IgcDatePickerComponent,
94+
IgcDateRangePickerComponent,
9395
IgcDropdownComponent,
9496
IgcDropdownGroupComponent,
9597
IgcDropdownHeaderComponent,
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import {
2+
IgcCalendarResourceStringEN,
3+
type IgcCalendarResourceStrings,
4+
} from './calendar.resources.js';
5+
6+
/* blazorSuppress */
7+
export interface IgcDateRangePickerResourceStrings
8+
extends IgcCalendarResourceStrings {
9+
separator: string;
10+
done: string;
11+
cancel: string;
12+
last7Days: string;
13+
last30Days: string;
14+
currentMonth: string;
15+
yearToDate: string;
16+
}
17+
18+
export const IgcDateRangePickerResourceStringsEN: IgcDateRangePickerResourceStrings =
19+
{
20+
separator: 'to',
21+
done: 'Done',
22+
cancel: 'Cancel',
23+
last7Days: 'Last 7 days',
24+
last30Days: 'Last 30 days',
25+
currentMonth: 'Current month',
26+
yearToDate: 'Year to date',
27+
...IgcCalendarResourceStringEN,
28+
};

src/components/common/mixins/combo-box.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface IgcBaseComboBoxEventMap {
1212
igcClosed: CustomEvent<void>;
1313
}
1414

15+
/* blazorIndirectRender */
1516
export abstract class IgcBaseComboBoxLikeComponent extends LitElement {
1617
declare public emitEvent: <
1718
K extends keyof IgcBaseComboBoxEventMap,

0 commit comments

Comments
 (0)