@sia.soul/sia-react-ui 0.1.76 → 0.1.77

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.
@@ -223,7 +223,7 @@ function DatePanelFooter({
223
223
  }) {
224
224
  return /* @__PURE__ */ jsxs("footer", { className: "sia-date-panel__footer", children: [
225
225
  /* @__PURE__ */ jsxs("span", { children: [
226
- showToday ? /* @__PURE__ */ jsx("button", { type: "button", onClick: onToday, children: "\u4ECA\u5929" }) : null,
226
+ showToday ? /* @__PURE__ */ jsx("button", { type: "button", onClick: onToday, children: "\u6B64\u523B" }) : null,
227
227
  extra
228
228
  ] }),
229
229
  needConfirm ? /* @__PURE__ */ jsx("button", { type: "button", className: "sia-date-panel__confirm", disabled: disabledConfirm, onClick: onConfirm, children: confirmText }) : null
@@ -348,17 +348,17 @@ function DatePicker({
348
348
  if (maximum && day > String(maximum).slice(0, 10)) return true;
349
349
  return disabledDate?.(day, { type: "date" }) ?? false;
350
350
  }
351
- function buildValue(day) {
351
+ function buildValue(day, time = draftTime) {
352
352
  const picked = formatPickerValue(day, picker);
353
- return showTime && picker === "date" ? withTime(picked, draftTime, showSecond) : picked;
353
+ return showTime && picker === "date" ? withTime(picked, time, showSecond) : picked;
354
354
  }
355
- function selectDate(day) {
355
+ function selectDate(day, time = draftTime, ensureSelected = false) {
356
356
  if (isDisabled(day)) return;
357
- const nextValue = buildValue(day);
357
+ const nextValue = buildValue(day, time);
358
358
  if (multiple) {
359
359
  const current = Array.isArray(draftValue) ? [...draftValue] : [];
360
360
  const exists = current.some((item) => dayFromValue(item) === day);
361
- const next = exists ? current.filter((item) => dayFromValue(item) !== day) : [...current, nextValue];
361
+ const next = exists ? ensureSelected ? current.map((item) => dayFromValue(item) === day ? nextValue : item) : current.filter((item) => dayFromValue(item) !== day) : [...current, nextValue];
362
362
  setDraftValue(next);
363
363
  if (!resolvedNeedConfirm) setCurrentValue(next);
364
364
  return;
@@ -450,7 +450,15 @@ function DatePicker({
450
450
  showToday,
451
451
  needConfirm: resolvedNeedConfirm,
452
452
  disabledConfirm: Array.isArray(draftValue) ? draftValue.length === 0 : !draftValue,
453
- onToday: () => selectDate(dateKey(/* @__PURE__ */ new Date())),
453
+ onToday: () => {
454
+ const now = /* @__PURE__ */ new Date();
455
+ const day = dateKey(now);
456
+ if (isDisabled(day)) return;
457
+ const time = [now.getHours(), now.getMinutes(), now.getSeconds()].map(pad).join(":");
458
+ if (showTime) setDraftTime(time);
459
+ setViewMonth(startOfMonth(now));
460
+ selectDate(day, time, true);
461
+ },
454
462
  onConfirm: commitDraft
455
463
  }
456
464
  )
@@ -611,10 +619,13 @@ function DateRangePicker({
611
619
  changeOpen(false);
612
620
  }
613
621
  }
614
- function selectDateTime(day, index) {
622
+ function selectDateTime(day, index, time = index === 1 ? "23:59:59" : times[index]) {
615
623
  if (isDisabled(day, index, true)) return;
624
+ const nextTimes = [...times];
625
+ nextTimes[index] = time;
626
+ setTimes(nextTimes);
616
627
  const nextValue = [...draftValue];
617
- nextValue[index] = buildRangeValue(day, index);
628
+ nextValue[index] = withTime(day, time, showSecond);
618
629
  updateDraft(nextValue);
619
630
  setHoverDate("");
620
631
  setActiveIndex(index);
@@ -830,7 +841,19 @@ function DateRangePicker({
830
841
  " \u5929"
831
842
  ] }) : null
832
843
  ] }),
833
- onToday: () => showTime ? selectDateTime(dateKey(/* @__PURE__ */ new Date()), activeIndex) : selectDate(dateKey(/* @__PURE__ */ new Date())),
844
+ onToday: () => {
845
+ const now = /* @__PURE__ */ new Date();
846
+ const day = dateKey(now);
847
+ if (isDisabled(day, activeIndex, Boolean(showTime))) return;
848
+ if (showTime) {
849
+ const time = [now.getHours(), now.getMinutes(), now.getSeconds()].map(pad).join(":");
850
+ (activeIndex === 0 ? setViewMonth : setEndViewMonth)(startOfMonth(now));
851
+ selectDateTime(day, activeIndex, time);
852
+ } else {
853
+ setViewMonth(startOfMonth(now));
854
+ selectDate(day);
855
+ }
856
+ },
834
857
  onConfirm: confirm
835
858
  }
836
859
  )
package/dist/index.cjs CHANGED
@@ -7413,7 +7413,7 @@ function DatePanelFooter({
7413
7413
  }) {
7414
7414
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("footer", { className: "sia-date-panel__footer", children: [
7415
7415
  /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("span", { children: [
7416
- showToday ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("button", { type: "button", onClick: onToday, children: "\u4ECA\u5929" }) : null,
7416
+ showToday ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("button", { type: "button", onClick: onToday, children: "\u6B64\u523B" }) : null,
7417
7417
  extra
7418
7418
  ] }),
7419
7419
  needConfirm ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("button", { type: "button", className: "sia-date-panel__confirm", disabled: disabledConfirm, onClick: onConfirm, children: confirmText }) : null
@@ -7538,17 +7538,17 @@ function DatePicker({
7538
7538
  if (maximum && day > String(maximum).slice(0, 10)) return true;
7539
7539
  return disabledDate?.(day, { type: "date" }) ?? false;
7540
7540
  }
7541
- function buildValue(day) {
7541
+ function buildValue(day, time = draftTime) {
7542
7542
  const picked = formatPickerValue(day, picker);
7543
- return showTime && picker === "date" ? withTime(picked, draftTime, showSecond) : picked;
7543
+ return showTime && picker === "date" ? withTime(picked, time, showSecond) : picked;
7544
7544
  }
7545
- function selectDate(day) {
7545
+ function selectDate(day, time = draftTime, ensureSelected = false) {
7546
7546
  if (isDisabled(day)) return;
7547
- const nextValue = buildValue(day);
7547
+ const nextValue = buildValue(day, time);
7548
7548
  if (multiple) {
7549
7549
  const current = Array.isArray(draftValue) ? [...draftValue] : [];
7550
7550
  const exists = current.some((item) => dayFromValue(item) === day);
7551
- const next = exists ? current.filter((item) => dayFromValue(item) !== day) : [...current, nextValue];
7551
+ const next = exists ? ensureSelected ? current.map((item) => dayFromValue(item) === day ? nextValue : item) : current.filter((item) => dayFromValue(item) !== day) : [...current, nextValue];
7552
7552
  setDraftValue(next);
7553
7553
  if (!resolvedNeedConfirm) setCurrentValue(next);
7554
7554
  return;
@@ -7640,7 +7640,15 @@ function DatePicker({
7640
7640
  showToday,
7641
7641
  needConfirm: resolvedNeedConfirm,
7642
7642
  disabledConfirm: Array.isArray(draftValue) ? draftValue.length === 0 : !draftValue,
7643
- onToday: () => selectDate(dateKey(/* @__PURE__ */ new Date())),
7643
+ onToday: () => {
7644
+ const now = /* @__PURE__ */ new Date();
7645
+ const day = dateKey(now);
7646
+ if (isDisabled(day)) return;
7647
+ const time = [now.getHours(), now.getMinutes(), now.getSeconds()].map(pad2).join(":");
7648
+ if (showTime) setDraftTime(time);
7649
+ setViewMonth(startOfMonth(now));
7650
+ selectDate(day, time, true);
7651
+ },
7644
7652
  onConfirm: commitDraft
7645
7653
  }
7646
7654
  )
@@ -7801,10 +7809,13 @@ function DateRangePicker({
7801
7809
  changeOpen(false);
7802
7810
  }
7803
7811
  }
7804
- function selectDateTime(day, index) {
7812
+ function selectDateTime(day, index, time = index === 1 ? "23:59:59" : times[index]) {
7805
7813
  if (isDisabled(day, index, true)) return;
7814
+ const nextTimes = [...times];
7815
+ nextTimes[index] = time;
7816
+ setTimes(nextTimes);
7806
7817
  const nextValue = [...draftValue];
7807
- nextValue[index] = buildRangeValue(day, index);
7818
+ nextValue[index] = withTime(day, time, showSecond);
7808
7819
  updateDraft(nextValue);
7809
7820
  setHoverDate("");
7810
7821
  setActiveIndex(index);
@@ -8020,7 +8031,19 @@ function DateRangePicker({
8020
8031
  " \u5929"
8021
8032
  ] }) : null
8022
8033
  ] }),
8023
- onToday: () => showTime ? selectDateTime(dateKey(/* @__PURE__ */ new Date()), activeIndex) : selectDate(dateKey(/* @__PURE__ */ new Date())),
8034
+ onToday: () => {
8035
+ const now = /* @__PURE__ */ new Date();
8036
+ const day = dateKey(now);
8037
+ if (isDisabled(day, activeIndex, Boolean(showTime))) return;
8038
+ if (showTime) {
8039
+ const time = [now.getHours(), now.getMinutes(), now.getSeconds()].map(pad2).join(":");
8040
+ (activeIndex === 0 ? setViewMonth : setEndViewMonth)(startOfMonth(now));
8041
+ selectDateTime(day, activeIndex, time);
8042
+ } else {
8043
+ setViewMonth(startOfMonth(now));
8044
+ selectDate(day);
8045
+ }
8046
+ },
8024
8047
  onConfirm: confirm
8025
8048
  }
8026
8049
  )
package/dist/index.d.cts CHANGED
@@ -5,7 +5,7 @@ import { HTMLAttributes, ReactNode, CSSProperties, ElementType, FormHTMLAttribut
5
5
  import { C as ControlSize, I as InputPlaceholderMode, a as ControlStatus } from './shared-Bx4B28Wh.cjs';
6
6
  import { O as OverlayContainer, a as OverlayApiHandle, M as ModalOpenConfig, S as SelectOption, b as SelectChangeValue, c as SelectProps, d as ModalActionResult, B as ButtonProps, e as ButtonSize } from './Select-Bv2AmXRD.cjs';
7
7
  export { f as Button, g as ButtonVariant, h as Modal, i as ModalProps, j as ModalType, k as Select, l as SelectMode, m as SelectValue } from './Select-Bv2AmXRD.cjs';
8
- 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-DN4eBuVx.cjs';
8
+ 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-CRWxqHFp.cjs';
9
9
  export { RichTextContent, RichTextContentFormat, RichTextContentProps, RichTextEditor, RichTextEditorProps, RichTextImagePasteHandler, RichTextToolbar } from './rich-text-editor.cjs';
10
10
  export { MarkdownEditor, MarkdownEditorMode, MarkdownEditorProps } from './markdown-editor.cjs';
11
11
  import * as Monaco from 'monaco-editor';
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ import { HTMLAttributes, ReactNode, CSSProperties, ElementType, FormHTMLAttribut
5
5
  import { C as ControlSize, I as InputPlaceholderMode, a as ControlStatus } from './shared-Bx4B28Wh.js';
6
6
  import { O as OverlayContainer, a as OverlayApiHandle, M as ModalOpenConfig, S as SelectOption, b as SelectChangeValue, c as SelectProps, d as ModalActionResult, B as ButtonProps, e as ButtonSize } from './Select-Cc1owuvN.js';
7
7
  export { f as Button, g as ButtonVariant, h as Modal, i as ModalProps, j as ModalType, k as Select, l as SelectMode, m as SelectValue } from './Select-Cc1owuvN.js';
8
- 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-YrK9kuKW.js';
8
+ 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-rtYL9egr.js';
9
9
  export { RichTextContent, RichTextContentFormat, RichTextContentProps, RichTextEditor, RichTextEditorProps, RichTextImagePasteHandler, RichTextToolbar } from './rich-text-editor.js';
10
10
  export { MarkdownEditor, MarkdownEditorMode, MarkdownEditorProps } from './markdown-editor.js';
11
11
  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-TG7ZYXA7.js";
98
+ } from "./chunk-K5OU5NOT.js";
99
99
  import {
100
100
  Checkbox,
101
101
  FloatingScrollbarProvider,
@@ -71,12 +71,12 @@ interface DatePickerProps extends SharedDatePickerProps {
71
71
  /** 选择后需要点击确定才提交;带时间的范围必须确认后保存;纯日期范围点选后立即保存合法值,此属性仅控制是否保留面板供确认关闭。 */
72
72
  needConfirm?: boolean;
73
73
  /**
74
- * 组合时间面板,可显示秒;范围选择始终显示单个面板,点击起止输入区域直接编辑对应端点;先确认当前端点,再切换到另一端点,两个端点确认后提交并关闭;锁定端点无需再次确认,快捷范围只需一次确认
74
+ * 组合时间面板,可显示秒;范围选择始终显示单个面板,点击起止输入区域直接编辑对应端点。日历点选结束日期时自动填入 23:59,开启 showSecond 时为 23:59:59,可随后手动调整;开始日期保留原时间,“此刻”使用当前时间,快捷范围保留预设时间。先确认当前端点,再切换到另一端点,两个端点确认后提交并关闭;锁定端点无需再次确认,快捷范围只需一次确认。
75
75
  * @defaultValue false
76
76
  */
77
77
  showTime?: DatePickerShowTime;
78
78
  /**
79
- * 是否显示返回今天的入口。
79
+ * 是否显示“此刻”入口。点击选择本机当前日期;开启 showTime 时同时填入当前时分,showSecond 为 true 时包含秒。沿用 needConfirm 的提交规则;范围选择仅更新当前编辑端点,禁用日期不可选择。
80
80
  * @defaultValue true
81
81
  */
82
82
  showToday?: boolean;
@@ -71,12 +71,12 @@ interface DatePickerProps extends SharedDatePickerProps {
71
71
  /** 选择后需要点击确定才提交;带时间的范围必须确认后保存;纯日期范围点选后立即保存合法值,此属性仅控制是否保留面板供确认关闭。 */
72
72
  needConfirm?: boolean;
73
73
  /**
74
- * 组合时间面板,可显示秒;范围选择始终显示单个面板,点击起止输入区域直接编辑对应端点;先确认当前端点,再切换到另一端点,两个端点确认后提交并关闭;锁定端点无需再次确认,快捷范围只需一次确认
74
+ * 组合时间面板,可显示秒;范围选择始终显示单个面板,点击起止输入区域直接编辑对应端点。日历点选结束日期时自动填入 23:59,开启 showSecond 时为 23:59:59,可随后手动调整;开始日期保留原时间,“此刻”使用当前时间,快捷范围保留预设时间。先确认当前端点,再切换到另一端点,两个端点确认后提交并关闭;锁定端点无需再次确认,快捷范围只需一次确认。
75
75
  * @defaultValue false
76
76
  */
77
77
  showTime?: DatePickerShowTime;
78
78
  /**
79
- * 是否显示返回今天的入口。
79
+ * 是否显示“此刻”入口。点击选择本机当前日期;开启 showTime 时同时填入当前时分,showSecond 为 true 时包含秒。沿用 needConfirm 的提交规则;范围选择仅更新当前编辑端点,禁用日期不可选择。
80
80
  * @defaultValue true
81
81
  */
82
82
  showToday?: boolean;
@@ -1734,7 +1734,7 @@ function DatePanelFooter({
1734
1734
  }) {
1735
1735
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("footer", { className: "sia-date-panel__footer", children: [
1736
1736
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
1737
- showToday ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", onClick: onToday, children: "\u4ECA\u5929" }) : null,
1737
+ showToday ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", onClick: onToday, children: "\u6B64\u523B" }) : null,
1738
1738
  extra
1739
1739
  ] }),
1740
1740
  needConfirm ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "sia-date-panel__confirm", disabled: disabledConfirm, onClick: onConfirm, children: confirmText }) : null
@@ -1859,17 +1859,17 @@ function DatePicker({
1859
1859
  if (maximum && day > String(maximum).slice(0, 10)) return true;
1860
1860
  return disabledDate?.(day, { type: "date" }) ?? false;
1861
1861
  }
1862
- function buildValue(day) {
1862
+ function buildValue(day, time = draftTime) {
1863
1863
  const picked = formatPickerValue(day, picker);
1864
- return showTime && picker === "date" ? withTime(picked, draftTime, showSecond) : picked;
1864
+ return showTime && picker === "date" ? withTime(picked, time, showSecond) : picked;
1865
1865
  }
1866
- function selectDate(day) {
1866
+ function selectDate(day, time = draftTime, ensureSelected = false) {
1867
1867
  if (isDisabled(day)) return;
1868
- const nextValue = buildValue(day);
1868
+ const nextValue = buildValue(day, time);
1869
1869
  if (multiple) {
1870
1870
  const current = Array.isArray(draftValue) ? [...draftValue] : [];
1871
1871
  const exists = current.some((item) => dayFromValue(item) === day);
1872
- const next = exists ? current.filter((item) => dayFromValue(item) !== day) : [...current, nextValue];
1872
+ const next = exists ? ensureSelected ? current.map((item) => dayFromValue(item) === day ? nextValue : item) : current.filter((item) => dayFromValue(item) !== day) : [...current, nextValue];
1873
1873
  setDraftValue(next);
1874
1874
  if (!resolvedNeedConfirm) setCurrentValue(next);
1875
1875
  return;
@@ -1961,7 +1961,15 @@ function DatePicker({
1961
1961
  showToday,
1962
1962
  needConfirm: resolvedNeedConfirm,
1963
1963
  disabledConfirm: Array.isArray(draftValue) ? draftValue.length === 0 : !draftValue,
1964
- onToday: () => selectDate(dateKey(/* @__PURE__ */ new Date())),
1964
+ onToday: () => {
1965
+ const now = /* @__PURE__ */ new Date();
1966
+ const day = dateKey(now);
1967
+ if (isDisabled(day)) return;
1968
+ const time = [now.getHours(), now.getMinutes(), now.getSeconds()].map(pad).join(":");
1969
+ if (showTime) setDraftTime(time);
1970
+ setViewMonth(startOfMonth(now));
1971
+ selectDate(day, time, true);
1972
+ },
1965
1973
  onConfirm: commitDraft
1966
1974
  }
1967
1975
  )
@@ -2122,10 +2130,13 @@ function DateRangePicker({
2122
2130
  changeOpen(false);
2123
2131
  }
2124
2132
  }
2125
- function selectDateTime(day, index) {
2133
+ function selectDateTime(day, index, time = index === 1 ? "23:59:59" : times[index]) {
2126
2134
  if (isDisabled(day, index, true)) return;
2135
+ const nextTimes = [...times];
2136
+ nextTimes[index] = time;
2137
+ setTimes(nextTimes);
2127
2138
  const nextValue = [...draftValue];
2128
- nextValue[index] = buildRangeValue(day, index);
2139
+ nextValue[index] = withTime(day, time, showSecond);
2129
2140
  updateDraft(nextValue);
2130
2141
  setHoverDate("");
2131
2142
  setActiveIndex(index);
@@ -2341,7 +2352,19 @@ function DateRangePicker({
2341
2352
  " \u5929"
2342
2353
  ] }) : null
2343
2354
  ] }),
2344
- onToday: () => showTime ? selectDateTime(dateKey(/* @__PURE__ */ new Date()), activeIndex) : selectDate(dateKey(/* @__PURE__ */ new Date())),
2355
+ onToday: () => {
2356
+ const now = /* @__PURE__ */ new Date();
2357
+ const day = dateKey(now);
2358
+ if (isDisabled(day, activeIndex, Boolean(showTime))) return;
2359
+ if (showTime) {
2360
+ const time = [now.getHours(), now.getMinutes(), now.getSeconds()].map(pad).join(":");
2361
+ (activeIndex === 0 ? setViewMonth : setEndViewMonth)(startOfMonth(now));
2362
+ selectDateTime(day, activeIndex, time);
2363
+ } else {
2364
+ setViewMonth(startOfMonth(now));
2365
+ selectDate(day);
2366
+ }
2367
+ },
2345
2368
  onConfirm: confirm
2346
2369
  }
2347
2370
  )
@@ -1,4 +1,4 @@
1
- export { S as SelectDateRange, i as SelectDateRangeProps, j as SelectDateRangeValue } from './select-date-range-DN4eBuVx.cjs';
1
+ export { S as SelectDateRange, i as SelectDateRangeProps, j as SelectDateRangeValue } from './select-date-range-CRWxqHFp.cjs';
2
2
  import 'react';
3
3
  import './shared-Bx4B28Wh.cjs';
4
4
  import './Select-Bv2AmXRD.cjs';
@@ -1,4 +1,4 @@
1
- export { S as SelectDateRange, i as SelectDateRangeProps, j as SelectDateRangeValue } from './select-date-range-YrK9kuKW.js';
1
+ export { S as SelectDateRange, i as SelectDateRangeProps, j as SelectDateRangeValue } from './select-date-range-rtYL9egr.js';
2
2
  import 'react';
3
3
  import './shared-Bx4B28Wh.js';
4
4
  import './Select-Cc1owuvN.js';
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SelectDateRange
3
- } from "./chunk-TG7ZYXA7.js";
3
+ } from "./chunk-K5OU5NOT.js";
4
4
  import "./chunk-TKCXP6RZ.js";
5
5
  import "./chunk-YMOOL62S.js";
6
6
  import "./chunk-IKAMZNCK.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sia.soul/sia-react-ui",
3
- "version": "0.1.76",
3
+ "version": "0.1.77",
4
4
  "description": "Sia Design components and tokens for React",
5
5
  "publishConfig": {
6
6
  "access": "public",