@dxos/react-ui-calendar 0.8.4-staging.ac66bdf99f → 0.9.0

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.
@@ -1 +1 @@
1
- {"inputs":{"src/translations.ts":{"bytes":1196,"imports":[],"format":"esm"},"src/components/Calendar/util.ts":{"bytes":2802,"imports":[],"format":"esm"},"src/components/Calendar/Calendar.tsx":{"bytes":29966,"imports":[{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"date-fns","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-resize-detector","kind":"import-statement","external":true},{"path":"react-virtualized","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true},{"path":"src/translations.ts","kind":"import-statement","original":"../../translations"},{"path":"src/components/Calendar/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"src/components/Calendar/index.ts":{"bytes":476,"imports":[{"path":"src/components/Calendar/Calendar.tsx","kind":"import-statement","original":"./Calendar"}],"format":"esm"},"src/components/index.ts":{"bytes":467,"imports":[{"path":"src/components/Calendar/index.ts","kind":"import-statement","original":"./Calendar"}],"format":"esm"},"src/index.ts":{"bytes":462,"imports":[{"path":"src/components/index.ts","kind":"import-statement","original":"./components"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18163},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"date-fns","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-resize-detector","kind":"import-statement","external":true},{"path":"react-virtualized","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true}],"exports":["Calendar"],"entryPoint":"src/index.ts","inputs":{"src/components/Calendar/Calendar.tsx":{"bytesInOutput":7386},"src/translations.ts":{"bytesInOutput":167},"src/components/Calendar/util.ts":{"bytesInOutput":517},"src/components/Calendar/index.ts":{"bytesInOutput":0},"src/components/index.ts":{"bytesInOutput":0},"src/index.ts":{"bytesInOutput":0}},"bytes":8362}}}
1
+ {"inputs":{"src/components/Calendar/util.ts":{"bytes":5384,"imports":[{"path":"date-fns","kind":"import-statement","external":true}],"format":"esm"},"src/components/Calendar/Calendar.tsx":{"bytes":73196,"imports":[{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"date-fns","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-resize-detector","kind":"import-statement","external":true},{"path":"react-virtualized","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true},{"path":"#translations","kind":"import-statement","external":true},{"path":"src/components/Calendar/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"src/components/Calendar/index.ts":{"bytes":376,"imports":[{"path":"src/components/Calendar/Calendar.tsx","kind":"import-statement","original":"./Calendar"}],"format":"esm"},"src/components/index.ts":{"bytes":376,"imports":[{"path":"src/components/Calendar/index.ts","kind":"import-statement","original":"./Calendar"}],"format":"esm"},"src/index.ts":{"bytes":382,"imports":[{"path":"src/components/index.ts","kind":"import-statement","original":"./components"}],"format":"esm"},"src/translations.ts":{"bytes":1105,"imports":[],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":40858},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"date-fns","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-resize-detector","kind":"import-statement","external":true},{"path":"react-virtualized","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true},{"path":"#translations","kind":"import-statement","external":true},{"path":"date-fns","kind":"import-statement","external":true}],"exports":["Calendar"],"entryPoint":"src/index.ts","inputs":{"src/components/Calendar/Calendar.tsx":{"bytesInOutput":15985},"src/components/Calendar/util.ts":{"bytesInOutput":918},"src/components/Calendar/index.ts":{"bytesInOutput":0},"src/components/index.ts":{"bytesInOutput":0},"src/index.ts":{"bytesInOutput":0}},"bytes":17171},"dist/lib/node-esm/translations.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":584},"dist/lib/node-esm/translations.mjs":{"imports":[],"exports":["translationKey","translations"],"entryPoint":"src/translations.ts","inputs":{"src/translations.ts":{"bytesInOutput":167}},"bytes":370}}}
@@ -0,0 +1,18 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+
3
+ // src/translations.ts
4
+ var translationKey = "@dxos/react-ui-calendar";
5
+ var translations = [
6
+ {
7
+ "en-US": {
8
+ [translationKey]: {
9
+ "today.button": "Today"
10
+ }
11
+ }
12
+ }
13
+ ];
14
+ export {
15
+ translationKey,
16
+ translations
17
+ };
18
+ //# sourceMappingURL=translations.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/translations.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Resource } from '@dxos/react-ui';\n\nexport const translationKey = '@dxos/react-ui-calendar';\n\nexport const translations = [\n {\n 'en-US': {\n [translationKey]: {\n 'today.button': 'Today',\n },\n },\n },\n] as const satisfies Resource[];\n"],
5
+ "mappings": ";;;AAMO,IAAMA,iBAAiB;AAEvB,IAAMC,eAAe;EAC1B;IACE,SAAS;MACP,CAACD,cAAAA,GAAiB;QAChB,gBAAgB;MAClB;IACF;EACF;;",
6
+ "names": ["translationKey", "translations"]
7
+ }
@@ -1,6 +1,14 @@
1
1
  import { type Day } from 'date-fns';
2
2
  import React, { type Dispatch, type PropsWithChildren, type SetStateAction } from 'react';
3
3
  import { Event } from '@dxos/async';
4
+ /**
5
+ * Inclusive date range. `from <= to`. Both endpoints are anchored at the
6
+ * start of their day; callers should not rely on time-of-day precision.
7
+ */
8
+ export type Range = {
9
+ from: Date;
10
+ to: Date;
11
+ };
4
12
  type CalendarEvent = {
5
13
  type: 'scroll';
6
14
  date: Date;
@@ -12,6 +20,12 @@ type CalendarContextValue = {
12
20
  setIndex: Dispatch<SetStateAction<number | undefined>>;
13
21
  selected: Date | undefined;
14
22
  setSelected: Dispatch<SetStateAction<Date | undefined>>;
23
+ /** Committed date range, set by the most recent drag or shift+arrow selection. */
24
+ range: Range | undefined;
25
+ setRange: Dispatch<SetStateAction<Range | undefined>>;
26
+ /** Live drag preview; non-undefined only while the user is dragging. */
27
+ pendingRange: Range | undefined;
28
+ setPendingRange: Dispatch<SetStateAction<Range | undefined>>;
15
29
  };
16
30
  type CalendarController = {
17
31
  scrollTo: (date: Date) => void;
@@ -22,9 +36,24 @@ type CalendarGridProps = {
22
36
  rows?: number;
23
37
  /** Dates to highlight on the grid. Each date that appears in this array receives a border indicator. */
24
38
  dates?: Date[];
39
+ /**
40
+ * Date the grid scrolls into view on mount, and whenever this value changes.
41
+ * Defaults to today. Pass a stable (memoized) Date so the grid does not
42
+ * re-scroll on every render.
43
+ */
44
+ initialDate?: Date;
45
+ /** Fired when a user selects a single date (click or arrow key). */
25
46
  onSelect?: (event: {
26
47
  date: Date;
27
48
  }) => void;
49
+ /**
50
+ * Fired when a user commits a multi-day range, either by a drag gesture or
51
+ * by shift+arrow extension. The range is normalized: `from <= to`, both at
52
+ * start-of-day. Not fired for single-day selections (use {@link onSelect}).
53
+ */
54
+ onSelectRange?: (event: {
55
+ range: Range;
56
+ }) => void;
28
57
  };
29
58
  export declare const Calendar: {
30
59
  Root: React.ForwardRefExoticComponent<Partial<Pick<CalendarContextValue, "weekStartsOn">> & {
@@ -1 +1 @@
1
- {"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../../../../../src/components/Calendar/Calendar.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,GAAG,EAA+D,MAAM,UAAU,CAAC;AACjG,OAAO,KAAK,EAAE,EACZ,KAAK,QAAQ,EACb,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAQpB,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAgBpC,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;CACZ,CAAC;AAEF,KAAK,oBAAoB,GAAG;IAC1B,YAAY,EAAE,GAAG,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAC5B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IACvD,QAAQ,EAAE,IAAI,GAAG,SAAS,CAAC;IAC3B,WAAW,EAAE,QAAQ,CAAC,cAAc,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC;CACzD,CAAC;AAQF,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CAChC,CAAC;AAMF,KAAK,iBAAiB,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;AAuChG,KAAK,oBAAoB,GAAG,EAAE,CAAC;AA+C/B,KAAK,iBAAiB,GAAG;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wGAAwG;IACxG,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,I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AAK,GAAG,SAAS,CAAC;IAChC,eAAe,EAAE,QAAQ,CAAC,cAAc,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC;CAC9D,CAAC;AAQF,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CAChC,CAAC;AAMF,KAAK,iBAAiB,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;AA6ChG,KAAK,oBAAoB,GAAG,EAAE,CAAC;AA6C/B,KAAK,iBAAiB,GAAG;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wGAAwG;IACxG,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf;;;;OAIG;IACH,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,KAAK,IAAI,CAAC;IAC3C;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE,KAAK,IAAI,CAAC;CACnD,CAAC;AAsbF,eAAO,MAAM,QAAQ;IACnB,IAAI;;;IACJ,OAAO;;;IACP,IAAI;;;CACL,CAAC;AAEF,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,CAAC"}
@@ -9,7 +9,7 @@ declare const meta: {
9
9
  translations: [{
10
10
  readonly 'en-US': {
11
11
  readonly "@dxos/react-ui-calendar": {
12
- readonly 'today.button': "Today";
12
+ readonly 'today.button': 'Today';
13
13
  };
14
14
  };
15
15
  }];
@@ -18,5 +18,6 @@ declare const meta: {
18
18
  export default meta;
19
19
  type Story = StoryObj<typeof meta>;
20
20
  export declare const Default: Story;
21
+ export declare const Range: Story;
21
22
  export declare const Column: Story;
22
23
  //# sourceMappingURL=Calendar.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Calendar.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Calendar/Calendar.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,QAAA,MAAM,IAAI;;;;;;;;;;;;;;CAM4B,CAAC;AAEvC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAQrB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAcpB,CAAC"}
1
+ {"version":3,"file":"Calendar.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Calendar/Calendar.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,KAAmB,MAAM,OAAO,CAAC;AASxC,QAAA,MAAM,IAAI;;;;;;;;;;;;;;CAM4B,CAAC;eAExB,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAQrB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAgBnB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAcpB,CAAC"}
@@ -1,4 +1,15 @@
1
1
  import { type Day } from 'date-fns';
2
2
  export declare const getDate: (start: Date, weekNumber: number, dayOfWeek: number, weekStartsOn: Day) => Date;
3
+ /**
4
+ * Inverse of {@link getDate}: returns the row index for a given date, matching
5
+ * the grid layout (which respects `weekStartsOn`).
6
+ *
7
+ * Uses `differenceInCalendarDays` (DST-safe) — naive ms subtraction silently
8
+ * loses an hour each DST transition, which accumulates over decades and
9
+ * eventually shifts the row boundary by one day. `differenceInWeeks` is also
10
+ * unsuitable because it computes raw 7-day chunks anchored at the start
11
+ * date's weekday rather than the grid's `weekStartsOn` column.
12
+ */
13
+ export declare const getRowIndex: (start: Date, date: Date, weekStartsOn: Day) => number;
3
14
  export declare const isSameDay: (date1: Date, date2: Date | undefined) => boolean;
4
15
  //# sourceMappingURL=util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../../src/components/Calendar/util.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC,eAAO,MAAM,OAAO,GAAI,OAAO,IAAI,EAAE,YAAY,MAAM,EAAE,WAAW,MAAM,EAAE,cAAc,GAAG,KAAG,IAM/F,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,OAAO,IAAI,EAAE,OAAO,IAAI,GAAG,SAAS,KAAG,OAOhE,CAAC"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../../src/components/Calendar/util.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,GAAG,EAA4B,MAAM,UAAU,CAAC;AAE9D,eAAO,MAAM,OAAO,UAAW,IAAI,cAAc,MAAM,aAAa,MAAM,gBAAgB,GAAG,KAAG,IAM/F,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,UAAW,IAAI,QAAQ,IAAI,gBAAgB,GAAG,KAAG,MAMxE,CAAC;AAEF,eAAO,MAAM,SAAS,UAAW,IAAI,SAAS,IAAI,GAAG,SAAS,KAAG,OAOhE,CAAC"}
@@ -2,7 +2,7 @@ export declare const translationKey = "@dxos/react-ui-calendar";
2
2
  export declare const translations: [{
3
3
  readonly 'en-US': {
4
4
  readonly "@dxos/react-ui-calendar": {
5
- readonly 'today.button': "Today";
5
+ readonly 'today.button': 'Today';
6
6
  };
7
7
  };
8
8
  }];
@@ -1 +1 @@
1
- {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,cAAc,4BAA4B,CAAC;AAExD,eAAO,MAAM,YAAY;;;;;;EAQM,CAAC"}
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,cAAc,4BAA4B,CAAC;AAExD,eAAO,MAAM,YAAY;;;qBAIjB,cAAc,EAAE,OAAO;;;EAIA,CAAC"}