@bitrise/bitkit-v2 0.3.540 → 0.3.542
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.
|
@@ -4,10 +4,6 @@ type CalendarYearSelectProps = {
|
|
|
4
4
|
min?: CalendarDate;
|
|
5
5
|
max?: CalendarDate;
|
|
6
6
|
monthOffset: number;
|
|
7
|
-
yearsRange?: {
|
|
8
|
-
from: number;
|
|
9
|
-
to: number;
|
|
10
|
-
};
|
|
11
7
|
};
|
|
12
|
-
declare const CalendarYearSelect: ({ device, monthOffset, max, min
|
|
8
|
+
declare const CalendarYearSelect: ({ device, monthOffset, max, min }: CalendarYearSelectProps) => import('react').JSX.Element;
|
|
13
9
|
export default CalendarYearSelect;
|
|
@@ -3,41 +3,35 @@ import { rem } from "../../../theme/themeUtils.js";
|
|
|
3
3
|
import CalendarSelect from "./CalendarSelect.js";
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { CalendarDate } from "@internationalized/date";
|
|
6
7
|
// lib/components/BitkitCalendar/components/CalendarYearSelect.tsx
|
|
7
|
-
var
|
|
8
|
+
var YEAR_WINDOW = 10;
|
|
9
|
+
var CalendarYearSelect = ({ device, monthOffset, max, min }) => {
|
|
8
10
|
const datePicker = useDatePickerContext();
|
|
9
11
|
const firstDayOfMonth = datePicker.getOffset({ months: monthOffset }).visibleRange.start;
|
|
12
|
+
const visibleYear = firstDayOfMonth.year;
|
|
10
13
|
const handleYearChange = (details) => {
|
|
11
14
|
const selectedYear = parseInt(details.value[0], 10);
|
|
12
|
-
datePicker.
|
|
15
|
+
datePicker.setFocusedValue(new CalendarDate(1990, 1, 1));
|
|
16
|
+
datePicker.setFocusedValue(firstDayOfMonth.set({ year: selectedYear }).subtract({ months: monthOffset }));
|
|
13
17
|
};
|
|
14
18
|
const years = useMemo(() => {
|
|
15
19
|
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
const from = min?.year ?? Math.min(visibleYear, currentYear) - YEAR_WINDOW;
|
|
21
|
+
const to = max?.year ?? Math.max(visibleYear, currentYear) + YEAR_WINDOW;
|
|
22
|
+
const first = Math.min(from, visibleYear);
|
|
23
|
+
const last = Math.max(to, visibleYear);
|
|
24
|
+
return Array.from({ length: last - first + 1 }, (_, index) => {
|
|
25
|
+
const year = (first + index).toString();
|
|
26
|
+
return {
|
|
27
|
+
label: year,
|
|
28
|
+
value: year
|
|
29
|
+
};
|
|
20
30
|
});
|
|
21
|
-
else yearOptions = [
|
|
22
|
-
currentYear - 1,
|
|
23
|
-
currentYear,
|
|
24
|
-
currentYear + 1
|
|
25
|
-
].map((year) => ({
|
|
26
|
-
label: year.toString(),
|
|
27
|
-
value: year.toString()
|
|
28
|
-
}));
|
|
29
|
-
if (min || max) return yearOptions.filter((year) => {
|
|
30
|
-
const yearNumber = parseInt(year.value, 10);
|
|
31
|
-
const isBeforeMin = min && yearNumber < min.year;
|
|
32
|
-
const isAfterMax = max && yearNumber > max.year;
|
|
33
|
-
return !isBeforeMin && !isAfterMax;
|
|
34
|
-
});
|
|
35
|
-
return yearOptions;
|
|
36
31
|
}, [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
max
|
|
32
|
+
min?.year,
|
|
33
|
+
max?.year,
|
|
34
|
+
visibleYear
|
|
41
35
|
]);
|
|
42
36
|
return /* @__PURE__ */ jsx(CalendarSelect, {
|
|
43
37
|
contentProps: {
|
|
@@ -49,7 +43,7 @@ var CalendarYearSelect = ({ device, monthOffset, max, min, yearsRange }) => {
|
|
|
49
43
|
defaultValue: [(/* @__PURE__ */ new Date()).getFullYear().toString()],
|
|
50
44
|
items: years,
|
|
51
45
|
onValueChange: handleYearChange,
|
|
52
|
-
value: [
|
|
46
|
+
value: [visibleYear.toString()]
|
|
53
47
|
});
|
|
54
48
|
};
|
|
55
49
|
export { CalendarYearSelect as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalendarYearSelect.js","names":[],"sources":["../../../../lib/components/BitkitCalendar/components/CalendarYearSelect.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"CalendarYearSelect.js","names":[],"sources":["../../../../lib/components/BitkitCalendar/components/CalendarYearSelect.tsx"],"sourcesContent":["import { CalendarDate } from '@internationalized/date';\nimport { useMemo } from 'react';\n\nimport { useDatePickerContext } from '../../../atoms/DatePicker/DatePicker';\nimport { rem } from '../../../theme/themeUtils';\nimport CalendarSelect from './CalendarSelect';\n\n// Years listed on each side when `min` / `max` doesn't bound the list.\nconst YEAR_WINDOW = 10;\n\ntype CalendarYearSelectProps = {\n device?: 'desktop' | 'mobile';\n min?: CalendarDate;\n max?: CalendarDate;\n monthOffset: number;\n};\n\nconst CalendarYearSelect = ({ device, monthOffset, max, min }: CalendarYearSelectProps) => {\n const datePicker = useDatePickerContext();\n\n const firstDayOfMonth = datePicker.getOffset({ months: monthOffset }).visibleRange.start;\n const visibleYear = firstDayOfMonth.year;\n\n const handleYearChange = (details: { value: string[] }) => {\n const selectedYear = parseInt(details.value[0], 10);\n\n // Same as CalendarMonthSelect: jump away first so the 2-month layout doesn't realign the view,\n // then focus the left month, so the select that changed shows the picked year.\n datePicker.setFocusedValue(new CalendarDate(1990, 1, 1));\n datePicker.setFocusedValue(firstDayOfMonth.set({ year: selectedYear }).subtract({ months: monthOffset }));\n };\n\n const years = useMemo(() => {\n const currentYear = new Date().getFullYear();\n const from = min?.year ?? Math.min(visibleYear, currentYear) - YEAR_WINDOW;\n const to = max?.year ?? Math.max(visibleYear, currentYear) + YEAR_WINDOW;\n // The visible year is always listed: the arrows can page past the window, and the 2-month view can run past `max`.\n const first = Math.min(from, visibleYear);\n const last = Math.max(to, visibleYear);\n\n return Array.from({ length: last - first + 1 }, (_, index) => {\n const year = (first + index).toString();\n\n return { label: year, value: year };\n });\n }, [min?.year, max?.year, visibleYear]);\n\n return (\n <CalendarSelect\n contentProps={{\n maxHeight: rem(312),\n width: rem(108),\n }}\n controlProps={{\n width: rem(device === 'mobile' ? 92 : 77),\n }}\n device={device}\n defaultValue={[new Date().getFullYear().toString()]}\n items={years}\n onValueChange={handleYearChange}\n value={[visibleYear.toString()]}\n />\n );\n};\n\nexport default CalendarYearSelect;\n"],"mappings":";;;;;;;AAQA,IAAM,cAAc;AASpB,IAAM,sBAAsB,EAAE,QAAQ,aAAa,KAAK,UAAmC;CACzF,MAAM,aAAa,qBAAqB;CAExC,MAAM,kBAAkB,WAAW,UAAU,EAAE,QAAQ,YAAY,CAAC,CAAC,CAAC,aAAa;CACnF,MAAM,cAAc,gBAAgB;CAEpC,MAAM,oBAAoB,YAAiC;EACzD,MAAM,eAAe,SAAS,QAAQ,MAAM,IAAI,EAAE;EAIlD,WAAW,gBAAgB,IAAI,aAAa,MAAM,GAAG,CAAC,CAAC;EACvD,WAAW,gBAAgB,gBAAgB,IAAI,EAAE,MAAM,aAAa,CAAC,CAAC,CAAC,SAAS,EAAE,QAAQ,YAAY,CAAC,CAAC;CAC1G;CAEA,MAAM,QAAQ,cAAc;EAC1B,MAAM,+BAAc,IAAI,KAAK,EAAA,CAAE,YAAY;EAC3C,MAAM,OAAO,KAAK,QAAQ,KAAK,IAAI,aAAa,WAAW,IAAI;EAC/D,MAAM,KAAK,KAAK,QAAQ,KAAK,IAAI,aAAa,WAAW,IAAI;EAE7D,MAAM,QAAQ,KAAK,IAAI,MAAM,WAAW;EACxC,MAAM,OAAO,KAAK,IAAI,IAAI,WAAW;EAErC,OAAO,MAAM,KAAK,EAAE,QAAQ,OAAO,QAAQ,EAAE,IAAI,GAAG,UAAU;GAC5D,MAAM,QAAQ,QAAQ,MAAA,CAAO,SAAS;GAEtC,OAAO;IAAE,OAAO;IAAM,OAAO;GAAK;EACpC,CAAC;CACH,GAAG;EAAC,KAAK;EAAM,KAAK;EAAM;CAAW,CAAC;CAEtC,OACE,oBAAC,gBAAD;EACE,cAAc;GACZ,WAAW,IAAI,GAAG;GAClB,OAAO,IAAI,GAAG;EAChB;EACA,cAAc,EACZ,OAAO,IAAI,WAAW,WAAW,KAAK,EAAE,EAC1C;EACQ;EACR,cAAc,kBAAC,IAAI,KAAK,EAAA,CAAE,YAAY,CAAC,CAAC,SAAS,CAAC;EAClD,OAAO;EACP,eAAe;EACf,OAAO,CAAC,YAAY,SAAS,CAAC;CAC/B,CAAA;AAEL"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitrise/bitkit-v2",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.542",
|
|
5
5
|
"description": "Bitrise Design System Components built with Chakra UI V3",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"react",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@figma-export/cli": "^6.4.1",
|
|
78
78
|
"@figma-export/output-components-as-svg": "^6.4.1",
|
|
79
79
|
"@figma-export/transform-svg-with-svgo": "^6.4.1",
|
|
80
|
-
"@google-cloud/storage": "^
|
|
80
|
+
"@google-cloud/storage": "^9.0.0",
|
|
81
81
|
"@storybook/addon-docs": "10.6.7",
|
|
82
82
|
"@storybook/addon-mcp": "10.6.7",
|
|
83
83
|
"@storybook/addon-themes": "10.6.7",
|
|
@@ -87,6 +87,7 @@
|
|
|
87
87
|
"@types/react": "^19.3.0",
|
|
88
88
|
"@types/react-dom": "^19.3.0",
|
|
89
89
|
"@vitejs/plugin-react": "^6.3.0",
|
|
90
|
+
"google-auth-library": "^11.3.4",
|
|
90
91
|
"react": "^19.3.1",
|
|
91
92
|
"react-dom": "^19.3.1",
|
|
92
93
|
"release-it": "^21.1.2",
|