@sia.soul/sia-react-ui 0.1.154 → 0.1.155

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.
@@ -346,8 +346,9 @@ function DatePicker({
346
346
  function isDisabled(day) {
347
347
  const minimum = minDate ?? props.min;
348
348
  const maximum = maxDate ?? props.max;
349
- if (minimum && day < String(minimum).slice(0, 10)) return true;
350
- if (maximum && day > String(maximum).slice(0, 10)) return true;
349
+ const length = picker === "year" ? 4 : 10;
350
+ if (minimum && day.slice(0, length) < String(minimum).slice(0, length)) return true;
351
+ if (maximum && day.slice(0, length) > String(maximum).slice(0, length)) return true;
351
352
  return disabledDate?.(day, { type: "date" }) ?? false;
352
353
  }
353
354
  function buildValue(day, time = draftTime) {
@@ -427,7 +428,24 @@ function DatePicker({
427
428
  changeOpen(false);
428
429
  }
429
430
  }, children: preset.label }, index)) }) : null,
430
- /* @__PURE__ */ jsxs2("section", { className: "sia-date-panel__calendar", children: [
431
+ /* @__PURE__ */ jsx2("section", { className: "sia-date-panel__calendar", children: picker === "year" ? /* @__PURE__ */ jsxs2(Fragment, { children: [
432
+ /* @__PURE__ */ jsxs2("div", { className: "sia-date-panel__header", children: [
433
+ /* @__PURE__ */ jsx2("span", { className: "sia-date-panel__nav", children: /* @__PURE__ */ jsx2("button", { type: "button", "aria-label": "\u4E0A\u5341\u5E74", onClick: () => setViewMonth(addMonths(viewMonth, -120)), children: /* @__PURE__ */ jsx2(Icon, { name: "chevron-left", size: 15 }) }) }),
434
+ /* @__PURE__ */ jsxs2("strong", { children: [
435
+ Math.floor(viewMonth.getFullYear() / 10) * 10,
436
+ "\u5E74 \u2014 ",
437
+ Math.floor(viewMonth.getFullYear() / 10) * 10 + 9,
438
+ "\u5E74"
439
+ ] }),
440
+ /* @__PURE__ */ jsx2("span", { className: "sia-date-panel__nav", children: /* @__PURE__ */ jsx2("button", { type: "button", "aria-label": "\u4E0B\u5341\u5E74", onClick: () => setViewMonth(addMonths(viewMonth, 120)), children: /* @__PURE__ */ jsx2(Icon, { name: "chevron-right", size: 15 }) }) })
441
+ ] }),
442
+ /* @__PURE__ */ jsx2("div", { className: "sia-date-panel__years", children: Array.from({ length: 10 }, (_, index) => {
443
+ const year = String(Math.floor(viewMonth.getFullYear() / 10) * 10 + index);
444
+ const day = `${year}-01-01`;
445
+ const selected = selectedDates.some((value2) => value2.slice(0, 4) === year);
446
+ return /* @__PURE__ */ jsx2("span", { className: `sia-date-panel__cell${selected ? " is-selected" : ""}${year === String((/* @__PURE__ */ new Date()).getFullYear()) ? " is-today" : ""}`, children: /* @__PURE__ */ jsx2("button", { type: "button", "aria-label": `${year}\u5E74`, "aria-pressed": selected, disabled: isDisabled(day), onClick: () => selectDate(day), children: year }) }, year);
447
+ }) })
448
+ ] }) : /* @__PURE__ */ jsxs2(Fragment, { children: [
431
449
  /* @__PURE__ */ jsx2(
432
450
  CalendarHeader,
433
451
  {
@@ -439,7 +457,7 @@ function DatePicker({
439
457
  }
440
458
  ),
441
459
  /* @__PURE__ */ jsx2(CalendarMonth, { month: viewMonth, selectedDates, disabledDate: isDisabled, onSelect: selectDate })
442
- ] }),
460
+ ] }) }),
443
461
  showTime ? /* @__PURE__ */ jsx2(TimePanel, { value: draftTime, showSecond, onChange: (next) => {
444
462
  setDraftTime(next);
445
463
  if (typeof draftValue === "string" && draftValue) setDraftValue(withTime(dayFromValue(draftValue), next, showSecond));
package/dist/core.css CHANGED
@@ -11552,6 +11552,15 @@ button.sia-treemap__tile:focus-visible,
11552
11552
  flex-wrap: wrap;
11553
11553
  }
11554
11554
  }
11555
+ .sia-date-panel__years {
11556
+ display: grid;
11557
+ grid-template-columns: repeat(3, 1fr);
11558
+ gap: 12px 8px;
11559
+ padding: 16px 12px;
11560
+ }
11561
+ .sia-date-panel__years .sia-date-panel__cell button {
11562
+ width: 64px;
11563
+ }
11555
11564
 
11556
11565
  /* src/title-tooltip.css */
11557
11566
  body > .sia-title-tooltip[data-sia-popup-layer] {
package/dist/index.cjs CHANGED
@@ -9974,8 +9974,9 @@ function DatePicker({
9974
9974
  function isDisabled(day) {
9975
9975
  const minimum = minDate ?? props.min;
9976
9976
  const maximum = maxDate ?? props.max;
9977
- if (minimum && day < String(minimum).slice(0, 10)) return true;
9978
- if (maximum && day > String(maximum).slice(0, 10)) return true;
9977
+ const length = picker === "year" ? 4 : 10;
9978
+ if (minimum && day.slice(0, length) < String(minimum).slice(0, length)) return true;
9979
+ if (maximum && day.slice(0, length) > String(maximum).slice(0, length)) return true;
9979
9980
  return disabledDate?.(day, { type: "date" }) ?? false;
9980
9981
  }
9981
9982
  function buildValue(day, time = draftTime) {
@@ -10055,7 +10056,24 @@ function DatePicker({
10055
10056
  changeOpen(false);
10056
10057
  }
10057
10058
  }, children: preset2.label }, index)) }) : null,
10058
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("section", { className: "sia-date-panel__calendar", children: [
10059
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("section", { className: "sia-date-panel__calendar", children: picker === "year" ? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
10060
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-panel__header", children: [
10061
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "sia-date-panel__nav", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { type: "button", "aria-label": "\u4E0A\u5341\u5E74", onClick: () => setViewMonth(addMonths(viewMonth, -120)), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Icon, { name: "chevron-left", size: 15 }) }) }),
10062
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("strong", { children: [
10063
+ Math.floor(viewMonth.getFullYear() / 10) * 10,
10064
+ "\u5E74 \u2014 ",
10065
+ Math.floor(viewMonth.getFullYear() / 10) * 10 + 9,
10066
+ "\u5E74"
10067
+ ] }),
10068
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "sia-date-panel__nav", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { type: "button", "aria-label": "\u4E0B\u5341\u5E74", onClick: () => setViewMonth(addMonths(viewMonth, 120)), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Icon, { name: "chevron-right", size: 15 }) }) })
10069
+ ] }),
10070
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "sia-date-panel__years", children: Array.from({ length: 10 }, (_, index) => {
10071
+ const year = String(Math.floor(viewMonth.getFullYear() / 10) * 10 + index);
10072
+ const day = `${year}-01-01`;
10073
+ const selected = selectedDates.some((value2) => value2.slice(0, 4) === year);
10074
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: `sia-date-panel__cell${selected ? " is-selected" : ""}${year === String((/* @__PURE__ */ new Date()).getFullYear()) ? " is-today" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { type: "button", "aria-label": `${year}\u5E74`, "aria-pressed": selected, disabled: isDisabled(day), onClick: () => selectDate(day), children: year }) }, year);
10075
+ }) })
10076
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
10059
10077
  /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10060
10078
  CalendarHeader,
10061
10079
  {
@@ -10067,7 +10085,7 @@ function DatePicker({
10067
10085
  }
10068
10086
  ),
10069
10087
  /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CalendarMonth, { month: viewMonth, selectedDates, disabledDate: isDisabled, onSelect: selectDate })
10070
- ] }),
10088
+ ] }) }),
10071
10089
  showTime ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(TimePanel, { value: draftTime, showSecond, onChange: (next) => {
10072
10090
  setDraftTime(next);
10073
10091
  if (typeof draftValue === "string" && draftValue) setDraftValue(withTime(dayFromValue(draftValue), next, showSecond));
package/dist/index.css CHANGED
@@ -11552,6 +11552,15 @@ button.sia-treemap__tile:focus-visible,
11552
11552
  flex-wrap: wrap;
11553
11553
  }
11554
11554
  }
11555
+ .sia-date-panel__years {
11556
+ display: grid;
11557
+ grid-template-columns: repeat(3, 1fr);
11558
+ gap: 12px 8px;
11559
+ padding: 16px 12px;
11560
+ }
11561
+ .sia-date-panel__years .sia-date-panel__cell button {
11562
+ width: 64px;
11563
+ }
11555
11564
 
11556
11565
  /* src/title-tooltip.css */
11557
11566
  body > .sia-title-tooltip[data-sia-popup-layer] {
package/dist/index.d.cts CHANGED
@@ -7,7 +7,7 @@ import { B as ButtonProps, a as ButtonSize } from './Button-xLR4Yt57.cjs';
7
7
  export { b as Button, c as ButtonVariant } from './Button-xLR4Yt57.cjs';
8
8
  import { O as OverlayContainer, a as OverlayApiHandle, M as ModalOpenConfig, S as SelectOption, b as SelectChangeValue, c as SelectProps, d as ModalActionResult } from './Select-DKfT3fJR.cjs';
9
9
  export { e as Modal, f as ModalProps, g as ModalType, h as Select, i as SelectMode, j as SelectValue } from './Select-DKfT3fJR.cjs';
10
- export { D as DatePicker, a as DatePickerDisabledInfo, b as DatePickerPreset, c as DatePickerProps, d as DatePickerShowTime, e as DatePickerType, f as DatePickerValue, g as DateRangePickerPreset, h as DateRangePickerProps, S as SelectDateRange, i as SelectDateRangeProps, j as SelectDateRangeValue } from './select-date-range-C5bNGxaY.cjs';
10
+ export { D as DatePicker, a as DatePickerDisabledInfo, b as DatePickerPreset, c as DatePickerProps, d as DatePickerShowTime, e as DatePickerType, f as DatePickerValue, g as DateRangePickerPreset, h as DateRangePickerProps, S as SelectDateRange, i as SelectDateRangeProps, j as SelectDateRangeValue } from './select-date-range-BxjiD6zL.cjs';
11
11
  export { RichTextContent, RichTextContentFormat, RichTextContentProps, RichTextEditor, RichTextEditorProps, RichTextImagePasteHandler, RichTextToolbar } from './rich-text-editor.cjs';
12
12
  export { MarkdownEditor, MarkdownEditorMode, MarkdownEditorProps } from './markdown-editor.cjs';
13
13
  import * as Monaco from 'monaco-editor';
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import { B as ButtonProps, a as ButtonSize } from './Button-B59TIes7.js';
7
7
  export { b as Button, c as ButtonVariant } from './Button-B59TIes7.js';
8
8
  import { O as OverlayContainer, a as OverlayApiHandle, M as ModalOpenConfig, S as SelectOption, b as SelectChangeValue, c as SelectProps, d as ModalActionResult } from './Select-Wolx4zNc.js';
9
9
  export { e as Modal, f as ModalProps, g as ModalType, h as Select, i as SelectMode, j as SelectValue } from './Select-Wolx4zNc.js';
10
- export { D as DatePicker, a as DatePickerDisabledInfo, b as DatePickerPreset, c as DatePickerProps, d as DatePickerShowTime, e as DatePickerType, f as DatePickerValue, g as DateRangePickerPreset, h as DateRangePickerProps, S as SelectDateRange, i as SelectDateRangeProps, j as SelectDateRangeValue } from './select-date-range-DfhpX7vv.js';
10
+ export { D as DatePicker, a as DatePickerDisabledInfo, b as DatePickerPreset, c as DatePickerProps, d as DatePickerShowTime, e as DatePickerType, f as DatePickerValue, g as DateRangePickerPreset, h as DateRangePickerProps, S as SelectDateRange, i as SelectDateRangeProps, j as SelectDateRangeValue } from './select-date-range-D3-8mmAT.js';
11
11
  export { RichTextContent, RichTextContentFormat, RichTextContentProps, RichTextEditor, RichTextEditorProps, RichTextImagePasteHandler, RichTextToolbar } from './rich-text-editor.js';
12
12
  export { MarkdownEditor, MarkdownEditorMode, MarkdownEditorProps } from './markdown-editor.js';
13
13
  import * as Monaco from 'monaco-editor';
package/dist/index.js CHANGED
@@ -95,7 +95,7 @@ import {
95
95
  DatePicker,
96
96
  SelectDateRange,
97
97
  TimePanel
98
- } from "./chunk-PDYEIHUO.js";
98
+ } from "./chunk-SD3MG2PO.js";
99
99
  import {
100
100
  Checkbox,
101
101
  OverflowTags,
@@ -47,7 +47,7 @@ interface DatePickerProps extends SharedDatePickerProps {
47
47
  /** 非受控模式的初始值,仅在初始化时使用。 */
48
48
  defaultValue?: DatePickerValue;
49
49
  /**
50
- * 日期粒度
50
+ * 日期粒度;year 展示十年一页的年份网格,点击年份回传 YYYY,支持翻页、多选与确认。
51
51
  * @defaultValue "date"
52
52
  */
53
53
  picker?: DatePickerType;
@@ -47,7 +47,7 @@ interface DatePickerProps extends SharedDatePickerProps {
47
47
  /** 非受控模式的初始值,仅在初始化时使用。 */
48
48
  defaultValue?: DatePickerValue;
49
49
  /**
50
- * 日期粒度
50
+ * 日期粒度;year 展示十年一页的年份网格,点击年份回传 YYYY,支持翻页、多选与确认。
51
51
  * @defaultValue "date"
52
52
  */
53
53
  picker?: DatePickerType;
@@ -2558,8 +2558,9 @@ function DatePicker({
2558
2558
  function isDisabled(day) {
2559
2559
  const minimum = minDate ?? props.min;
2560
2560
  const maximum = maxDate ?? props.max;
2561
- if (minimum && day < String(minimum).slice(0, 10)) return true;
2562
- if (maximum && day > String(maximum).slice(0, 10)) return true;
2561
+ const length = picker === "year" ? 4 : 10;
2562
+ if (minimum && day.slice(0, length) < String(minimum).slice(0, length)) return true;
2563
+ if (maximum && day.slice(0, length) > String(maximum).slice(0, length)) return true;
2563
2564
  return disabledDate?.(day, { type: "date" }) ?? false;
2564
2565
  }
2565
2566
  function buildValue(day, time = draftTime) {
@@ -2639,7 +2640,24 @@ function DatePicker({
2639
2640
  changeOpen(false);
2640
2641
  }
2641
2642
  }, children: preset2.label }, index)) }) : null,
2642
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("section", { className: "sia-date-panel__calendar", children: [
2643
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("section", { className: "sia-date-panel__calendar", children: picker === "year" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
2644
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "sia-date-panel__header", children: [
2645
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "sia-date-panel__nav", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "aria-label": "\u4E0A\u5341\u5E74", onClick: () => setViewMonth(addMonths(viewMonth, -120)), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "chevron-left", size: 15 }) }) }),
2646
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("strong", { children: [
2647
+ Math.floor(viewMonth.getFullYear() / 10) * 10,
2648
+ "\u5E74 \u2014 ",
2649
+ Math.floor(viewMonth.getFullYear() / 10) * 10 + 9,
2650
+ "\u5E74"
2651
+ ] }),
2652
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "sia-date-panel__nav", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "aria-label": "\u4E0B\u5341\u5E74", onClick: () => setViewMonth(addMonths(viewMonth, 120)), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "chevron-right", size: 15 }) }) })
2653
+ ] }),
2654
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "sia-date-panel__years", children: Array.from({ length: 10 }, (_, index) => {
2655
+ const year = String(Math.floor(viewMonth.getFullYear() / 10) * 10 + index);
2656
+ const day = `${year}-01-01`;
2657
+ const selected = selectedDates.some((value2) => value2.slice(0, 4) === year);
2658
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: `sia-date-panel__cell${selected ? " is-selected" : ""}${year === String((/* @__PURE__ */ new Date()).getFullYear()) ? " is-today" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "aria-label": `${year}\u5E74`, "aria-pressed": selected, disabled: isDisabled(day), onClick: () => selectDate(day), children: year }) }, year);
2659
+ }) })
2660
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
2643
2661
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2644
2662
  CalendarHeader,
2645
2663
  {
@@ -2651,7 +2669,7 @@ function DatePicker({
2651
2669
  }
2652
2670
  ),
2653
2671
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CalendarMonth, { month: viewMonth, selectedDates, disabledDate: isDisabled, onSelect: selectDate })
2654
- ] }),
2672
+ ] }) }),
2655
2673
  showTime ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TimePanel, { value: draftTime, showSecond, onChange: (next) => {
2656
2674
  setDraftTime(next);
2657
2675
  if (typeof draftValue === "string" && draftValue) setDraftValue(withTime(dayFromValue(draftValue), next, showSecond));
@@ -1,4 +1,4 @@
1
- export { S as SelectDateRange, i as SelectDateRangeProps, j as SelectDateRangeValue } from './select-date-range-C5bNGxaY.cjs';
1
+ export { S as SelectDateRange, i as SelectDateRangeProps, j as SelectDateRangeValue } from './select-date-range-BxjiD6zL.cjs';
2
2
  import 'react';
3
3
  import './shared-Bx4B28Wh.cjs';
4
4
  import './Select-DKfT3fJR.cjs';
@@ -1,4 +1,4 @@
1
- export { S as SelectDateRange, i as SelectDateRangeProps, j as SelectDateRangeValue } from './select-date-range-DfhpX7vv.js';
1
+ export { S as SelectDateRange, i as SelectDateRangeProps, j as SelectDateRangeValue } from './select-date-range-D3-8mmAT.js';
2
2
  import 'react';
3
3
  import './shared-Bx4B28Wh.js';
4
4
  import './Select-Wolx4zNc.js';
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SelectDateRange
3
- } from "./chunk-PDYEIHUO.js";
3
+ } from "./chunk-SD3MG2PO.js";
4
4
  import "./chunk-5P274RXG.js";
5
5
  import "./chunk-J4R734AI.js";
6
6
  import "./chunk-NRLIOMXY.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sia.soul/sia-react-ui",
3
- "version": "0.1.154",
3
+ "version": "0.1.155",
4
4
  "description": "Sia Design components and tokens for React",
5
5
  "publishConfig": {
6
6
  "access": "public",