@sia.soul/sia-react-ui 0.1.0 → 0.1.2

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.
package/dist/index.cjs CHANGED
@@ -86,6 +86,7 @@ __export(index_exports, {
86
86
  ImagePreview: () => ImagePreview,
87
87
  Input: () => Input,
88
88
  InputNumber: () => InputNumber,
89
+ InputSelect: () => InputSelect,
89
90
  KLineChart: () => KLineChart,
90
91
  LineChart: () => LineChart,
91
92
  LineShareChart: () => LineShareChart,
@@ -111,6 +112,7 @@ __export(index_exports, {
111
112
  Segmented: () => Segmented,
112
113
  Select: () => Select,
113
114
  SelectDateRange: () => SelectDateRange,
115
+ SelectionPanel: () => SelectionPanel,
114
116
  SiaChart: () => SiaChart,
115
117
  Slider: () => Slider,
116
118
  Space: () => Space,
@@ -145,6 +147,7 @@ __export(index_exports, {
145
147
  WordCloudChart: () => WordCloudChart,
146
148
  XYChart: () => XYChart,
147
149
  applySiaTheme: () => applySiaTheme,
150
+ buildFlatTree: () => buildFlatTree,
148
151
  chartColor: () => chartColor,
149
152
  chartTicks: () => chartTicks,
150
153
  createBaiduMapHost: () => createBaiduMapHost,
@@ -3128,10 +3131,10 @@ function Tree({
3128
3131
  },
3129
3132
  children: (() => {
3130
3133
  const content = /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "sia-tree__context-content", children: [
3131
- hasChildren ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: "sia-tree__switcher", style: { width: normalizedSwitcherWidth, flexBasis: normalizedSwitcherWidth }, disabled: node.disabled, onClick: (event) => {
3134
+ hasChildren ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: "sia-tree__switcher", "aria-label": open ? "\u6536\u8D77\u8282\u70B9" : "\u5C55\u5F00\u8282\u70B9", "aria-expanded": open, style: { width: normalizedSwitcherWidth, flexBasis: normalizedSwitcherWidth }, disabled: node.disabled, onClick: (event) => {
3132
3135
  event.stopPropagation();
3133
3136
  void toggleExpand(node);
3134
- }, children: nodeLoading ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: "loader", className: "sia-spin-icon", size: 13 }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: open ? "chevron-down" : "chevron-right", size: 13 }) }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "sia-tree__switcher", style: { width: normalizedSwitcherWidth, flexBasis: normalizedSwitcherWidth }, "aria-hidden": "true" }),
3137
+ }, children: nodeLoading ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: "loader", className: "sia-spin-icon", size: 13 }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: open ? "chevron-down" : "chevron-right", size: 13 }) }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "sia-tree__switcher", "aria-label": open ? "\u6536\u8D77\u8282\u70B9" : "\u5C55\u5F00\u8282\u70B9", "aria-expanded": open, style: { width: normalizedSwitcherWidth, flexBasis: normalizedSwitcherWidth }, "aria-hidden": "true" }),
3135
3138
  checkable || node.checkable ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { onClick: (event) => event.stopPropagation(), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Checkbox2, { checked: isChecked, disabled: node.disabled || node.disableCheckbox, onChange: () => check(node) }) }) : null,
3136
3139
  node.prefix ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "sia-tree__prefix", onClick: (event) => event.stopPropagation(), children: node.prefix }) : null,
3137
3140
  showIcon ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "sia-tree__icon", children: node.icon ?? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: hasChildren ? "folder" : "file", size: 15 }) }) : null,
@@ -4383,6 +4386,21 @@ function setValue(source, path, value) {
4383
4386
  function isEmpty(value) {
4384
4387
  return value === void 0 || value === null || value === "" || Array.isArray(value) && value.length === 0;
4385
4388
  }
4389
+ function cloneFormValue(value, seen = /* @__PURE__ */ new WeakMap()) {
4390
+ if (!value || typeof value !== "object") return value;
4391
+ if (seen.has(value)) return seen.get(value);
4392
+ if (value instanceof Date) return new Date(value.getTime());
4393
+ if (value instanceof RegExp) return new RegExp(value.source, value.flags);
4394
+ const cloneable = value;
4395
+ if (typeof cloneable.clone === "function") return cloneable.clone();
4396
+ if (!Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) return value;
4397
+ const next = Array.isArray(value) ? [] : {};
4398
+ seen.set(value, next);
4399
+ Object.keys(value).forEach((key) => {
4400
+ next[key] = cloneFormValue(value[key], seen);
4401
+ });
4402
+ return next;
4403
+ }
4386
4404
  var FormStore = class {
4387
4405
  values = {};
4388
4406
  initialValues = {};
@@ -4391,11 +4409,13 @@ var FormStore = class {
4391
4409
  listeners = /* @__PURE__ */ new Set();
4392
4410
  callbacks = {};
4393
4411
  version = 0;
4412
+ initialized = false;
4394
4413
  configure(initialValues, callbacks) {
4395
4414
  this.callbacks = callbacks;
4396
- if (initialValues && Object.keys(this.initialValues).length === 0) {
4397
- this.initialValues = structuredClone(initialValues);
4398
- this.values = structuredClone(initialValues);
4415
+ if (!this.initialized) {
4416
+ this.initialized = true;
4417
+ this.initialValues = cloneFormValue(initialValues ?? {});
4418
+ this.values = cloneFormValue(initialValues ?? {});
4399
4419
  }
4400
4420
  }
4401
4421
  subscribe = (listener) => {
@@ -4417,7 +4437,7 @@ var FormStore = class {
4417
4437
  };
4418
4438
  }
4419
4439
  getFieldValue = (name) => getValue(this.values, pathArray(name));
4420
- getFieldsValue = () => structuredClone(this.values);
4440
+ getFieldsValue = () => cloneFormValue(this.values);
4421
4441
  getFieldError = (name) => this.errors.get(pathKey2(name)) ?? [];
4422
4442
  setFieldValue = (name, value) => {
4423
4443
  const path = pathArray(name);
@@ -4435,7 +4455,7 @@ var FormStore = class {
4435
4455
  };
4436
4456
  resetFields = (names) => {
4437
4457
  if (!names) {
4438
- this.values = structuredClone(this.initialValues);
4458
+ this.values = cloneFormValue(this.initialValues);
4439
4459
  this.errors.clear();
4440
4460
  } else {
4441
4461
  names.forEach((name) => {
@@ -4624,7 +4644,7 @@ function FormItem({
4624
4644
  content = children;
4625
4645
  }
4626
4646
  }
4627
- if (noStyle) return content;
4647
+ if (noStyle) return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: content });
4628
4648
  const inputWrap = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "sia-form-item__input-wrap", children: content });
4629
4649
  const hasError = status === "error" && Boolean(helpContent);
4630
4650
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { ref: itemRef, className: `sia-form-item${status ? ` sia-form-item--${status}` : ""} ${className}`.trim(), "data-sia-form-field": key || void 0, children: [
@@ -5237,14 +5257,15 @@ function withTime(date, time, showSecond = false) {
5237
5257
  const [hour = "00", minute = "00", second = "00"] = time.split(":");
5238
5258
  return `${date} ${hour}:${minute}${showSecond ? `:${second}` : ""}`;
5239
5259
  }
5240
- function normalizeDateValue(value, showTime) {
5260
+ function normalizeDateValue(value, showTime, index = 0) {
5241
5261
  if (!value) return "";
5242
5262
  const date = parseDate2(value);
5243
5263
  if (!date) return value;
5244
5264
  const day = dateKey(date);
5245
5265
  if (!showTime) return day;
5246
5266
  const config = typeof showTime === "object" ? showTime : {};
5247
- return withTime(day, timePart(value, config.defaultValue ?? "00:00:00"), Boolean(config.showSecond));
5267
+ const fallback = typeof config.defaultValue === "string" ? config.defaultValue : config.defaultValue?.[index] ?? "00:00:00";
5268
+ return withTime(day, timePart(value, fallback), Boolean(config.showSecond));
5248
5269
  }
5249
5270
  var WEEKDAYS = ["\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D", "\u65E5"];
5250
5271
  function CalendarMonth({
@@ -5444,8 +5465,9 @@ function placeholderFor(picker, showTime, multiple) {
5444
5465
  function showSecondFrom(showTime) {
5445
5466
  return Boolean(typeof showTime === "object" && showTime.showSecond);
5446
5467
  }
5447
- function defaultTimeFrom(showTime) {
5448
- return typeof showTime === "object" ? showTime.defaultValue ?? "00:00:00" : "00:00:00";
5468
+ function defaultTimeFrom(showTime, index = 0) {
5469
+ const value = typeof showTime === "object" ? showTime.defaultValue : void 0;
5470
+ return typeof value === "string" ? value : value?.[index] ?? "00:00:00";
5449
5471
  }
5450
5472
  function resolvePreset(value) {
5451
5473
  return typeof value === "function" ? value() : value;
@@ -5476,6 +5498,8 @@ function DatePicker({
5476
5498
  onChange,
5477
5499
  onOpenChange,
5478
5500
  placeholder,
5501
+ formatValue: formatValue2 = (value2) => value2,
5502
+ renderExtraFooter,
5479
5503
  ...props
5480
5504
  }) {
5481
5505
  const id = (0, import_react26.useId)();
@@ -5541,6 +5565,8 @@ function DatePicker({
5541
5565
  }
5542
5566
  }
5543
5567
  function commitDraft() {
5568
+ const values = Array.isArray(draftValue) ? draftValue : [draftValue];
5569
+ if (values.some((value2) => !value2 || isDisabled(dayFromValue(value2)))) return;
5544
5570
  setCurrentValue(draftValue);
5545
5571
  changeOpen(false);
5546
5572
  }
@@ -5550,7 +5576,7 @@ function DatePicker({
5550
5576
  setDraftValue(empty);
5551
5577
  setCurrentValue(empty);
5552
5578
  }
5553
- const display = Array.isArray(currentValue) ? currentValue.join("\u3001") : currentValue;
5579
+ const display = Array.isArray(currentValue) ? currentValue.map(formatValue2).join("\u3001") : currentValue ? formatValue2(currentValue) : "";
5554
5580
  const triggerLabel = props["aria-label"] ?? (typeof placeholder === "string" ? placeholder : "\u65E5\u671F\u9009\u62E9\u5668");
5555
5581
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("span", { ref: rootRef, className: `sia-picker sia-picker--${size} sia-picker--${status}${visible ? " is-open" : ""}${disabled ? " is-disabled" : ""} ${className}`.trim(), children: [
5556
5582
  /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
@@ -5576,15 +5602,16 @@ function DatePicker({
5576
5602
  },
5577
5603
  children: [
5578
5604
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: `sia-picker__value${display ? "" : " is-placeholder"}`, children: display || placeholder || placeholderFor(picker, showTime, multiple) }),
5579
- allowClear && display && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { role: "button", className: "sia-picker__clear", "aria-label": "\u6E05\u9664\u65E5\u671F", onClick: clearValue, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Icon, { name: "circle-close", variant: "filled", size: 15 }) }) : null,
5580
5605
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "sia-picker__icon", "aria-hidden": "true", children: suffixIcon ?? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Icon, { name: "calendar", size: 16 }) })
5581
5606
  ]
5582
5607
  }
5583
5608
  ),
5609
+ allowClear && display && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("button", { type: "button", className: "sia-picker__clear", "aria-label": "\u6E05\u9664\u65E5\u671F", onClick: clearValue, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Icon, { name: "circle-close", variant: "filled", size: 15 }) }) : null,
5584
5610
  /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(PopupPortal, { ref: popupRef, anchorRef: rootRef, open: visible, className: `sia-date-panel${showTime ? " sia-date-panel--with-time" : ""}${presets?.length ? " sia-date-panel--with-presets" : ""}`, role: "dialog", "aria-label": "\u65E5\u671F\u9009\u62E9\u9762\u677F", children: [
5585
5611
  /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "sia-date-panel__body", children: [
5586
5612
  presets?.length ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("aside", { className: "sia-date-panel__presets", children: presets.map((preset2, index) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("button", { type: "button", onClick: () => {
5587
5613
  const next = resolvePreset(preset2.value);
5614
+ if (!next || isDisabled(dayFromValue(next))) return;
5588
5615
  setDraftValue(next);
5589
5616
  if (!resolvedNeedConfirm) {
5590
5617
  setCurrentValue(next);
@@ -5612,6 +5639,7 @@ function DatePicker({
5612
5639
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
5613
5640
  DatePanelFooter,
5614
5641
  {
5642
+ extra: renderExtraFooter?.(),
5615
5643
  showToday,
5616
5644
  needConfirm: resolvedNeedConfirm,
5617
5645
  disabledConfirm: Array.isArray(draftValue) ? draftValue.length === 0 : !draftValue,
@@ -5629,6 +5657,8 @@ function DateRangePicker({
5629
5657
  separator = "\u2192",
5630
5658
  presets,
5631
5659
  maxRangeDays,
5660
+ allowEmpty = [false, false],
5661
+ endpointDisabled = [false, false],
5632
5662
  size = "medium",
5633
5663
  status = "default",
5634
5664
  allowClear = true,
@@ -5646,6 +5676,8 @@ function DateRangePicker({
5646
5676
  onCalendarChange,
5647
5677
  onChange,
5648
5678
  onOpenChange,
5679
+ formatValue: formatValue2 = (value2) => value2,
5680
+ renderExtraFooter,
5649
5681
  ...props
5650
5682
  }) {
5651
5683
  const id = (0, import_react26.useId)();
@@ -5661,9 +5693,10 @@ function DateRangePicker({
5661
5693
  const [compactDateTime, setCompactDateTime] = (0, import_react26.useState)(false);
5662
5694
  const showSecond = showSecondFrom(showTime);
5663
5695
  const defaultTime = defaultTimeFrom(showTime);
5696
+ const defaultEndTime = defaultTimeFrom(showTime, 1);
5664
5697
  const [times, setTimes] = (0, import_react26.useState)([
5665
5698
  timePart(currentValue[0], defaultTime),
5666
- timePart(currentValue[1], defaultTime)
5699
+ timePart(currentValue[1], defaultEndTime)
5667
5700
  ]);
5668
5701
  const resolvedNeedConfirm = needConfirm ?? Boolean(showTime);
5669
5702
  const rangeDates = [dayFromValue(draftValue[0]), dayFromValue(draftValue[1])];
@@ -5693,8 +5726,8 @@ function DateRangePicker({
5693
5726
  function changeOpen(next) {
5694
5727
  if (next) {
5695
5728
  setDraftValue(currentValue);
5696
- setTimes([timePart(currentValue[0], defaultTime), timePart(currentValue[1], defaultTime)]);
5697
- setActiveIndex(currentValue[0] && !currentValue[1] ? 1 : 0);
5729
+ setTimes([timePart(currentValue[0], defaultTime), timePart(currentValue[1], defaultEndTime)]);
5730
+ setActiveIndex(endpointDisabled[0] ? 1 : endpointDisabled[1] ? 0 : currentValue[0] && !currentValue[1] ? 1 : 0);
5698
5731
  const nextStartMonth = startOfMonth(parseDate2(dayFromValue(currentValue[0] || currentValue[1])) ?? /* @__PURE__ */ new Date());
5699
5732
  setViewMonth(nextStartMonth);
5700
5733
  setEndViewMonth(startOfMonth(parseDate2(dayFromValue(currentValue[1])) ?? addMonths(nextStartMonth, 1)));
@@ -5702,6 +5735,7 @@ function DateRangePicker({
5702
5735
  setVisible(next);
5703
5736
  }
5704
5737
  function isDisabled(day, index = activeIndex, pairedDateTime = false) {
5738
+ if (endpointDisabled[index]) return true;
5705
5739
  const minimum = minDate ?? props.min;
5706
5740
  const maximum = maxDate ?? props.max;
5707
5741
  if (minimum && day < String(minimum).slice(0, 10)) return true;
@@ -5724,6 +5758,17 @@ function DateRangePicker({
5724
5758
  }
5725
5759
  function selectDate(day) {
5726
5760
  if (isDisabled(day)) return;
5761
+ if (endpointDisabled.some(Boolean)) {
5762
+ const index = endpointDisabled[0] ? 1 : 0;
5763
+ const next = [...draftValue];
5764
+ next[index] = buildRangeValue(day, index);
5765
+ updateDraft(next);
5766
+ if (!resolvedNeedConfirm && isValidRange(next)) {
5767
+ setCurrentValue(next);
5768
+ changeOpen(false);
5769
+ }
5770
+ return;
5771
+ }
5727
5772
  if (activeIndex === 0 || !rangeDates[0] || rangeDates[1]) {
5728
5773
  const next = [buildRangeValue(day, 0), ""];
5729
5774
  updateDraft(next);
@@ -5759,6 +5804,7 @@ function DateRangePicker({
5759
5804
  }
5760
5805
  }
5761
5806
  function changeTime(index, nextTime) {
5807
+ if (endpointDisabled[index]) return;
5762
5808
  const nextTimes = [...times];
5763
5809
  nextTimes[index] = nextTime;
5764
5810
  setTimes(nextTimes);
@@ -5769,6 +5815,28 @@ function DateRangePicker({
5769
5815
  updateDraft(nextValue);
5770
5816
  }
5771
5817
  }
5818
+ function isValidRange(next) {
5819
+ if (!next.some(Boolean)) return false;
5820
+ for (const index of [0, 1]) {
5821
+ if (!next[index]) {
5822
+ if (!allowEmpty[index]) return false;
5823
+ else continue;
5824
+ }
5825
+ if (endpointDisabled[index]) {
5826
+ if (next[index] !== currentValue[index]) return false;
5827
+ else continue;
5828
+ }
5829
+ const day = dayFromValue(next[index]);
5830
+ if (!day) return false;
5831
+ if (minDate && day < minDate.slice(0, 10) || maxDate && day > maxDate.slice(0, 10)) return false;
5832
+ if (disabledDate?.(day, { from: index === 1 ? dayFromValue(next[0]) || void 0 : void 0, type: "date" })) return false;
5833
+ }
5834
+ if (next[0] && next[1]) {
5835
+ if (next[0] > next[1]) return false;
5836
+ if (maxRangeDays && Math.abs(daysBetween(dayFromValue(next[0]), dayFromValue(next[1]))) >= maxRangeDays) return false;
5837
+ }
5838
+ return true;
5839
+ }
5772
5840
  function confirm() {
5773
5841
  if (compactDateTime && showTime && activeIndex === 0) {
5774
5842
  if (!draftValue[0]) return;
@@ -5777,7 +5845,7 @@ function DateRangePicker({
5777
5845
  setHoverDate("");
5778
5846
  return;
5779
5847
  }
5780
- if (!draftValue[0] || !draftValue[1] || invalidDateTimeRange) return;
5848
+ if (!isValidRange(draftValue)) return;
5781
5849
  setCurrentValue(draftValue);
5782
5850
  changeOpen(false);
5783
5851
  }
@@ -5785,10 +5853,11 @@ function DateRangePicker({
5785
5853
  const raw = resolveRangePreset(preset2.value);
5786
5854
  const next = [
5787
5855
  normalizeDateValue(raw[0], showTime),
5788
- normalizeDateValue(raw[1], showTime)
5856
+ normalizeDateValue(raw[1], showTime, 1)
5789
5857
  ];
5858
+ if (!isValidRange(next)) return;
5790
5859
  updateDraft(next);
5791
- setTimes([timePart(next[0], defaultTime), timePart(next[1], defaultTime)]);
5860
+ setTimes([timePart(next[0], defaultTime), timePart(next[1], defaultEndTime)]);
5792
5861
  const nextStartMonth = startOfMonth(parseDate2(dayFromValue(next[0] || next[1])) ?? /* @__PURE__ */ new Date());
5793
5862
  setViewMonth(nextStartMonth);
5794
5863
  setEndViewMonth(startOfMonth(parseDate2(dayFromValue(next[1])) ?? addMonths(nextStartMonth, 1)));
@@ -5799,7 +5868,7 @@ function DateRangePicker({
5799
5868
  }
5800
5869
  function clearValue(event) {
5801
5870
  event.stopPropagation();
5802
- const empty = ["", ""];
5871
+ const empty = [endpointDisabled[0] ? currentValue[0] : "", endpointDisabled[1] ? currentValue[1] : ""];
5803
5872
  updateDraft(empty);
5804
5873
  setCurrentValue(empty);
5805
5874
  setActiveIndex(0);
@@ -5868,14 +5937,14 @@ function DateRangePicker({
5868
5937
  disabled,
5869
5938
  onClick: () => changeOpen(!visible),
5870
5939
  children: [
5871
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: `sia-picker-range-control__value${currentValue[0] ? "" : " is-placeholder"}`, children: currentValue[0] || placeholder[0] }),
5940
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: `sia-picker-range-control__value${currentValue[0] ? "" : " is-placeholder"}`, children: currentValue[0] ? formatValue2(currentValue[0]) : placeholder[0] }),
5872
5941
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "sia-picker-range-control__separator", children: separator }),
5873
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: `sia-picker-range-control__value${currentValue[1] ? "" : " is-placeholder"}`, children: currentValue[1] || placeholder[1] }),
5874
- allowClear && (currentValue[0] || currentValue[1]) && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { role: "button", className: "sia-picker__clear", "aria-label": "\u6E05\u9664\u65E5\u671F\u8303\u56F4", onClick: clearValue, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Icon, { name: "circle-close", variant: "filled", size: 15 }) }) : null,
5942
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: `sia-picker-range-control__value${currentValue[1] ? "" : " is-placeholder"}`, children: currentValue[1] ? formatValue2(currentValue[1]) : placeholder[1] }),
5875
5943
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "sia-picker__icon", "aria-hidden": "true", children: suffixIcon ?? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Icon, { name: "calendar", size: 16 }) })
5876
5944
  ]
5877
5945
  }
5878
5946
  ),
5947
+ allowClear && (currentValue[0] || currentValue[1]) && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("button", { type: "button", className: "sia-picker__clear", "aria-label": "\u6E05\u9664\u65E5\u671F\u8303\u56F4", onClick: clearValue, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Icon, { name: "circle-close", variant: "filled", size: 15 }) }) : null,
5879
5948
  /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(PopupPortal, { ref: popupRef, anchorRef: rootRef, open: visible, className: `sia-date-panel sia-date-panel--range${showTime ? ` sia-date-panel--with-time sia-date-panel--range-time-${compactDateTime ? "compact" : "paired"}` : ""}${presets?.length ? " sia-date-panel--with-presets" : ""}`, role: "dialog", "aria-label": "\u65E5\u671F\u8303\u56F4\u9009\u62E9\u9762\u677F", children: [
5880
5949
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "sia-date-panel__body", children: showTime ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "sia-date-panel__range-date-time", children: compactDateTime ? renderDateTimeGroup(activeIndex) : /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
5881
5950
  renderDateTimeGroup(0),
@@ -5910,10 +5979,11 @@ function DateRangePicker({
5910
5979
  DatePanelFooter,
5911
5980
  {
5912
5981
  showToday: showToday && !presets?.length,
5913
- needConfirm: resolvedNeedConfirm,
5914
- disabledConfirm: compactDateTime && showTime && activeIndex === 0 ? !draftValue[0] : !draftValue[0] || !draftValue[1] || invalidDateTimeRange,
5982
+ needConfirm: resolvedNeedConfirm || allowEmpty.some(Boolean),
5983
+ disabledConfirm: compactDateTime && showTime && activeIndex === 0 ? !draftValue[0] : !isValidRange(draftValue),
5915
5984
  confirmText: compactDateTime && showTime && activeIndex === 0 ? "\u4E0B\u4E00\u6B65" : "\u786E\u5B9A",
5916
5985
  extra: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
5986
+ renderExtraFooter?.(),
5917
5987
  presets?.map((preset2, index) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("button", { type: "button", onClick: () => applyPreset(preset2), children: preset2.label }, index)),
5918
5988
  compactDateTime && showTime && activeIndex === 1 ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("button", { type: "button", onClick: () => {
5919
5989
  setActiveIndex(0);
@@ -6165,14 +6235,14 @@ function TimeRangePicker({ value, defaultValue = ["", ""], placeholder = ["\u5F0
6165
6235
  // src/components/TreeSelect.tsx
6166
6236
  var import_react28 = require("react");
6167
6237
  var import_jsx_runtime29 = require("react/jsx-runtime");
6168
- function flattenTree(nodes, expanded, search, depth = 0, parents = []) {
6238
+ function flattenTree(nodes, expanded, search, filter, depth = 0, parents = [], ancestorMatched = false) {
6169
6239
  const result = [];
6170
6240
  for (const node of nodes) {
6171
- const matches = !search || String(node.title).toLowerCase().includes(search.toLowerCase());
6172
- const childMatches = search && node.children ? flattenTree(node.children, new Set(node.children.map((child) => child.value)), search, depth + 1, [...parents, node.value]) : [];
6241
+ const matches = !search || ancestorMatched || filter === false || (filter ? filter(search, node) : String(node.title).toLowerCase().includes(search.toLowerCase()));
6242
+ const childMatches = search && node.children ? flattenTree(node.children, expanded, search, filter, depth + 1, [...parents, node.value], matches) : [];
6173
6243
  if (matches || childMatches.length) result.push({ ...node, depth, parentValues: parents });
6174
- if (node.children && (expanded.has(node.value) || search)) {
6175
- result.push(...search ? childMatches : flattenTree(node.children, expanded, search, depth + 1, [...parents, node.value]));
6244
+ if (node.children && (expanded.has(node.key ?? node.value) || search)) {
6245
+ result.push(...search ? childMatches : flattenTree(node.children, expanded, search, filter, depth + 1, [...parents, node.value]));
6176
6246
  }
6177
6247
  }
6178
6248
  return result;
@@ -6203,25 +6273,54 @@ function TreeSelect({
6203
6273
  onChange,
6204
6274
  onSearch,
6205
6275
  onDropdownVisibleChange,
6276
+ open: controlledOpen,
6277
+ defaultOpen = false,
6278
+ searchValue,
6279
+ treeExpandedKeys,
6280
+ treeDefaultExpandedKeys = [],
6281
+ onTreeExpand,
6282
+ filterTreeNode,
6283
+ treeCheckStrictly = true,
6284
+ showCheckedStrategy = "all",
6285
+ loading = false,
6286
+ listHeight = 300,
6287
+ popupClassName = "",
6288
+ popupStyle,
6289
+ dropdownFooter,
6290
+ displayRender,
6291
+ renderTrigger,
6292
+ onClear,
6293
+ onSelect,
6294
+ onDeselect,
6206
6295
  ...props
6207
6296
  }) {
6208
6297
  const rootRef = (0, import_react28.useRef)(null);
6209
6298
  const popupRef = (0, import_react28.useRef)(null);
6299
+ const nodeIndex = (0, import_react28.useMemo)(() => {
6300
+ const index = /* @__PURE__ */ new Map();
6301
+ const visit = (nodes) => nodes.forEach((node) => {
6302
+ index.set(node.value, node);
6303
+ if (node.children) visit(node.children);
6304
+ });
6305
+ visit(treeData);
6306
+ return index;
6307
+ }, [treeData]);
6308
+ const resolveNodes = (values) => values.map((value2) => nodeIndex.get(value2) ?? { value: value2, title: String(value2) });
6210
6309
  const multi = multiple || treeCheckable;
6211
6310
  const initial3 = defaultValue ?? (multi ? [] : void 0);
6212
6311
  const [currentValue, setCurrentValue] = useControllableState({
6213
- value,
6312
+ value: value === null ? [] : value,
6214
6313
  defaultValue: initial3,
6215
- onChange: (next) => onChange?.(next, findNodes(treeData, Array.isArray(next) ? [...next] : next === void 0 ? [] : [next]))
6314
+ onChange: (next) => onChange?.(next, resolveNodes(Array.isArray(next) ? [...next] : next === void 0 ? [] : [next]))
6216
6315
  });
6217
- const [open, setOpen] = (0, import_react28.useState)(false);
6218
- const [search, setSearch] = (0, import_react28.useState)("");
6316
+ const [open, setOpen] = useControllableState({ value: controlledOpen, defaultValue: defaultOpen, onChange: onDropdownVisibleChange });
6317
+ const [search, setSearch] = useControllableState({ value: searchValue, defaultValue: "", onChange: onSearch });
6219
6318
  const [expanded, setExpanded] = (0, import_react28.useState)(() => {
6220
- if (!treeDefaultExpandAll) return /* @__PURE__ */ new Set();
6319
+ if (!treeDefaultExpandAll) return new Set(treeDefaultExpandedKeys);
6221
6320
  const values = [];
6222
6321
  const collect = (nodes) => nodes.forEach((node) => {
6223
6322
  if (node.children?.length) {
6224
- values.push(node.value);
6323
+ values.push(node.key ?? node.value);
6225
6324
  collect(node.children);
6226
6325
  }
6227
6326
  });
@@ -6229,99 +6328,229 @@ function TreeSelect({
6229
6328
  return new Set(values);
6230
6329
  });
6231
6330
  const selectedValues = Array.isArray(currentValue) ? [...currentValue] : currentValue === void 0 ? [] : [currentValue];
6232
- const selectedNodes = (0, import_react28.useMemo)(() => findNodes(treeData, selectedValues), [treeData, selectedValues.join("|")]);
6233
- const visibleNodes = (0, import_react28.useMemo)(() => flattenTree(treeData, expanded, search), [expanded, search, treeData]);
6331
+ const expandedSet = treeExpandedKeys ? new Set(treeExpandedKeys) : expanded;
6332
+ const selectedNodes = resolveNodes(selectedValues);
6333
+ const visibleNodes = flattenTree(treeData, expandedSet, search, filterTreeNode);
6334
+ (0, import_react28.useEffect)(() => {
6335
+ if (!open || treeExpandedKeys) return;
6336
+ const keys = new Set(expanded);
6337
+ const walk = (nodes, parents) => nodes.forEach((node) => {
6338
+ if (selectedValues.includes(node.value)) parents.forEach((key) => keys.add(key));
6339
+ if (node.children) walk(node.children, [...parents, node.key ?? node.value]);
6340
+ });
6341
+ walk(treeData, []);
6342
+ if (keys.size !== expanded.size) setExpanded(keys);
6343
+ const frame = requestAnimationFrame(() => popupRef.current?.querySelector('[aria-selected="true"]')?.scrollIntoView({ block: "nearest" }));
6344
+ return () => cancelAnimationFrame(frame);
6345
+ }, [open, treeData, currentValue, treeExpandedKeys]);
6346
+ function toggleNode(node) {
6347
+ const key = node.key ?? node.value;
6348
+ const next = new Set(expandedSet);
6349
+ if (next.has(key)) next.delete(key);
6350
+ else next.add(key);
6351
+ if (!treeExpandedKeys) setExpanded(next);
6352
+ onTreeExpand?.([...next]);
6353
+ }
6354
+ const cascade = treeCheckable && !treeCheckStrictly;
6355
+ function checkState(values) {
6356
+ const checked2 = new Set(values);
6357
+ const affected2 = (node) => node.disabled || node.disableCheckbox ? [] : [
6358
+ ...node.checkable === false ? [] : [node.value],
6359
+ ...node.children?.flatMap(affected2) ?? []
6360
+ ];
6361
+ if (cascade) {
6362
+ findNodes(treeData, values).forEach((node) => affected2(node).forEach((value2) => checked2.add(value2)));
6363
+ const fold = (nodes) => nodes.forEach((node) => {
6364
+ if (node.disabled || node.disableCheckbox) return;
6365
+ if (node.children) fold(node.children);
6366
+ const children = node.children?.filter((child) => !child.disabled && !child.disableCheckbox && child.checkable !== false) ?? [];
6367
+ if (children.length && node.checkable !== false) {
6368
+ if (children.every((child) => checked2.has(child.value))) checked2.add(node.value);
6369
+ else checked2.delete(node.value);
6370
+ }
6371
+ });
6372
+ fold(treeData);
6373
+ }
6374
+ return { checked: checked2, affected: affected2 };
6375
+ }
6376
+ const { checked, affected } = checkState(selectedValues);
6377
+ function outputValues(values) {
6378
+ if (!cascade || showCheckedStrategy === "all") return [...values];
6379
+ const output = [...values].filter((value2) => !nodeIndex.has(value2));
6380
+ const walk = (nodes, parentChecked = false) => nodes.forEach((node) => {
6381
+ const selected = values.has(node.value);
6382
+ const enabledChildren = node.children?.filter((child) => !child.disabled && !child.disableCheckbox) ?? [];
6383
+ if (selected && (showCheckedStrategy === "parent" ? !parentChecked : !enabledChildren.length)) output.push(node.value);
6384
+ if (node.children) walk(node.children, selected && !node.disabled && !node.disableCheckbox);
6385
+ });
6386
+ walk(treeData);
6387
+ return output;
6388
+ }
6389
+ function clear() {
6390
+ if (disabled || loading) return;
6391
+ setCurrentValue(multi ? [] : void 0);
6392
+ onClear?.();
6393
+ }
6234
6394
  (0, import_react28.useEffect)(() => {
6235
6395
  if (!open) return void 0;
6236
6396
  const close = (event) => {
6237
6397
  const target = event.target;
6238
6398
  if (!rootRef.current?.contains(target) && !popupRef.current?.contains(target)) {
6239
6399
  setOpen(false);
6240
- onDropdownVisibleChange?.(false);
6400
+ setSearch("");
6241
6401
  }
6242
6402
  };
6243
6403
  document.addEventListener("pointerdown", close);
6244
6404
  return () => document.removeEventListener("pointerdown", close);
6245
6405
  }, [onDropdownVisibleChange, open]);
6246
6406
  function changeOpen(next) {
6407
+ if (disabled) return;
6247
6408
  setOpen(next);
6248
- onDropdownVisibleChange?.(next);
6409
+ if (!next) setSearch("");
6249
6410
  }
6250
6411
  function select(node) {
6251
- if (node.disabled || node.selectable === false) return;
6412
+ if (disabled || loading || node.disabled) return;
6413
+ if (treeCheckable ? node.disableCheckbox || node.checkable === false : node.selectable === false) {
6414
+ if (node.children?.length) toggleNode(node);
6415
+ return;
6416
+ }
6252
6417
  if (multi) {
6253
- const next = selectedValues.includes(node.value) ? selectedValues.filter((item) => item !== node.value) : [...selectedValues, node.value];
6254
- setCurrentValue(next);
6418
+ const exists = checked.has(node.value);
6419
+ const next = new Set(checked);
6420
+ (cascade ? affected(node) : [node.value]).forEach((value2) => {
6421
+ if (exists) next.delete(value2);
6422
+ else next.add(value2);
6423
+ });
6424
+ if (cascade && exists) {
6425
+ const removeParents = (nodes) => {
6426
+ let found = false;
6427
+ nodes.forEach((item) => {
6428
+ const childFound = item.children ? removeParents(item.children) : false;
6429
+ if (childFound) next.delete(item.value);
6430
+ if (item.value === node.value || childFound) found = true;
6431
+ });
6432
+ return found;
6433
+ };
6434
+ removeParents(treeData);
6435
+ }
6436
+ setCurrentValue(outputValues(checkState([...next]).checked));
6437
+ if (exists) onDeselect?.(node.value, node);
6438
+ else onSelect?.(node.value, node);
6255
6439
  } else {
6256
6440
  setCurrentValue(node.value);
6441
+ onSelect?.(node.value, node);
6257
6442
  changeOpen(false);
6258
6443
  }
6259
6444
  }
6260
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { ref: rootRef, className: `sia-tree-select sia-tree-select--${size} sia-tree-select--${status}${open ? " is-open" : ""}${disabled ? " is-disabled" : ""} ${className}`.trim(), ...props, children: [
6261
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
6262
- "button",
6263
- {
6264
- type: "button",
6265
- className: "sia-tree-select__trigger",
6266
- disabled,
6267
- "aria-haspopup": "tree",
6268
- "aria-expanded": open,
6269
- onClick: () => changeOpen(!open),
6270
- onKeyDown: (event) => {
6271
- if (event.key === "ArrowDown") changeOpen(true);
6272
- if (event.key === "Escape") changeOpen(false);
6273
- },
6274
- children: [
6275
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "sia-tree-select__value", children: selectedNodes.length ? multi ? /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
6276
- selectedNodes.slice(0, maxTagCount).map((node) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "sia-tree-select__tag", children: node.title }, node.value)),
6277
- selectedNodes.length > maxTagCount ? /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("span", { className: "sia-tree-select__tag", children: [
6278
- "+",
6279
- selectedNodes.length - maxTagCount
6280
- ] }) : null
6281
- ] }) : selectedNodes[0]?.title : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "sia-tree-select__placeholder", children: placeholder }) }),
6282
- allowClear && selectedValues.length && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { role: "button", tabIndex: -1, className: "sia-tree-select__clear", "aria-label": "\u6E05\u9664\u9009\u62E9", onClick: (event) => {
6283
- event.stopPropagation();
6284
- setCurrentValue(multi ? [] : void 0);
6285
- }, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Icon, { name: "circle-close", variant: "filled", size: 15 }) }) : null,
6286
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Icon, { name: open ? "chevron-up" : "chevron-down", size: 14 })
6287
- ]
6445
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
6446
+ "div",
6447
+ {
6448
+ ref: rootRef,
6449
+ className: `sia-tree-select sia-tree-select--${size} sia-tree-select--${status}${open ? " is-open" : ""}${disabled ? " is-disabled" : ""} ${className}`.trim(),
6450
+ ...props,
6451
+ onKeyDown: (event) => {
6452
+ props.onKeyDown?.(event);
6453
+ if (event.key === "Escape") {
6454
+ event.stopPropagation();
6455
+ changeOpen(false);
6456
+ }
6457
+ },
6458
+ children: [
6459
+ renderTrigger ? renderTrigger({ open, toggle: () => changeOpen(!open), clear }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
6460
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
6461
+ "button",
6462
+ {
6463
+ type: "button",
6464
+ className: "sia-tree-select__trigger",
6465
+ disabled,
6466
+ "aria-haspopup": "tree",
6467
+ "aria-expanded": open,
6468
+ "aria-label": props["aria-label"],
6469
+ onClick: () => changeOpen(!open),
6470
+ onKeyDown: (event) => {
6471
+ if (event.key === "ArrowDown") {
6472
+ event.preventDefault();
6473
+ changeOpen(true);
6474
+ }
6475
+ if (event.key === "Escape") changeOpen(false);
6476
+ },
6477
+ children: [
6478
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "sia-tree-select__value", children: selectedNodes.length ? displayRender ? displayRender(selectedNodes) : multi ? /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
6479
+ selectedNodes.slice(0, maxTagCount).map((node) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "sia-tree-select__tag", children: node.title }, node.value)),
6480
+ selectedNodes.length > maxTagCount ? /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("span", { className: "sia-tree-select__tag", children: [
6481
+ "+",
6482
+ selectedNodes.length - maxTagCount
6483
+ ] }) : null
6484
+ ] }) : selectedNodes[0]?.title : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "sia-tree-select__placeholder", children: placeholder }) }),
6485
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Icon, { name: open ? "chevron-up" : "chevron-down", size: 14 })
6486
+ ]
6487
+ }
6488
+ ),
6489
+ allowClear && selectedValues.length > 0 && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("button", { type: "button", className: "sia-tree-select__clear", "aria-label": "\u6E05\u9664\u9009\u62E9", onClick: clear, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Icon, { name: "circle-close", variant: "filled", size: 15 }) }) : null
6490
+ ] }),
6491
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(PopupPortal, { ref: popupRef, anchorRef: rootRef, open: open && !disabled, className: `sia-tree-select__dropdown ${popupClassName}`, style: popupStyle, children: [
6492
+ showSearch ? /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("label", { className: "sia-tree-select__search", children: [
6493
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Icon, { name: "search", size: 15 }),
6494
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("input", { "aria-label": searchPlaceholder, autoFocus: true, value: search, placeholder: searchPlaceholder, onChange: (event) => setSearch(event.currentTarget.value) })
6495
+ ] }) : null,
6496
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "sia-tree-select__tree", role: "tree", "aria-multiselectable": multi || void 0, style: { maxHeight: listHeight }, children: loading ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { role: "status", className: "sia-tree-select__empty", children: "\u52A0\u8F7D\u4E2D\u2026" }) : visibleNodes.length ? visibleNodes.map((node) => {
6497
+ const hasChildren = Boolean(node.children?.length);
6498
+ const selected = checked.has(node.value);
6499
+ const partial = cascade && !selected && affected(node).some((value2) => checked.has(value2));
6500
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
6501
+ "div",
6502
+ {
6503
+ className: `sia-tree-select__node${selected ? " is-selected" : ""}${node.disabled ? " is-disabled" : ""}`,
6504
+ style: { paddingInlineStart: 8 + node.depth * 20 },
6505
+ role: "treeitem",
6506
+ "aria-level": node.depth + 1,
6507
+ "aria-disabled": node.disabled || void 0,
6508
+ "aria-selected": selected,
6509
+ "aria-expanded": hasChildren ? !!search || expandedSet.has(node.key ?? node.value) : void 0,
6510
+ "aria-checked": treeCheckable ? partial ? "mixed" : selected : void 0,
6511
+ children: [
6512
+ hasChildren ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("button", { type: "button", className: "sia-tree-select__expand", "aria-label": expandedSet.has(node.key ?? node.value) ? "\u6536\u8D77\u8282\u70B9" : "\u5C55\u5F00\u8282\u70B9", disabled: node.disabled, onClick: () => toggleNode(node), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Icon, { name: expandedSet.has(node.key ?? node.value) ? "chevron-down" : "chevron-right", size: 13 }) }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "sia-tree-select__indent" }),
6513
+ treeCheckable && node.checkable !== false ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Checkbox2, { "aria-label": typeof node.title === "string" ? node.title : void 0, checked: selected, indeterminate: partial, disabled: node.disabled || node.disableCheckbox, onChange: () => select(node) }) : null,
6514
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("button", { type: "button", className: "sia-tree-select__title", disabled: node.disabled, onClick: () => select(node), children: node.title })
6515
+ ]
6516
+ },
6517
+ node.key ?? node.value
6518
+ );
6519
+ }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "sia-tree-select__empty", children: "\u6682\u65E0\u5339\u914D\u8282\u70B9" }) }),
6520
+ dropdownFooter
6521
+ ] })
6522
+ ]
6523
+ }
6524
+ );
6525
+ }
6526
+
6527
+ // src/components/flatTree.ts
6528
+ function buildFlatTree(items, options = {}) {
6529
+ const { idField = "id", parentIdField = "pId", rootParentId } = options;
6530
+ const keyOf = (value) => String(value ?? "");
6531
+ const nodes = new Map(items.map((item) => [keyOf(item[idField]), { ...item, children: [] }]));
6532
+ const roots = [];
6533
+ const isRoot = (parent) => rootParentId !== void 0 ? keyOf(parent) === keyOf(rootParentId) : parent === null || parent === void 0 || parent === "" || parent === 0;
6534
+ for (const node of nodes.values()) {
6535
+ const parentKey = keyOf(node[parentIdField]);
6536
+ const parent = nodes.get(parentKey);
6537
+ let cyclic = false;
6538
+ const visited = /* @__PURE__ */ new Set([keyOf(node[idField])]);
6539
+ let ancestor = parent;
6540
+ while (ancestor) {
6541
+ const key = keyOf(ancestor[idField]);
6542
+ if (visited.has(key)) {
6543
+ cyclic = true;
6544
+ break;
6288
6545
  }
6289
- ),
6290
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(PopupPortal, { ref: popupRef, anchorRef: rootRef, open, className: "sia-tree-select__dropdown", children: [
6291
- showSearch ? /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("label", { className: "sia-tree-select__search", children: [
6292
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Icon, { name: "search", size: 15 }),
6293
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("input", { value: search, placeholder: searchPlaceholder, onChange: (event) => {
6294
- setSearch(event.currentTarget.value);
6295
- onSearch?.(event.currentTarget.value);
6296
- } })
6297
- ] }) : null,
6298
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "sia-tree-select__tree", role: "tree", "aria-multiselectable": multi || void 0, children: visibleNodes.length ? visibleNodes.map((node) => {
6299
- const hasChildren = Boolean(node.children?.length);
6300
- const selected = selectedValues.includes(node.value);
6301
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
6302
- "div",
6303
- {
6304
- className: `sia-tree-select__node${selected ? " is-selected" : ""}${node.disabled ? " is-disabled" : ""}`,
6305
- style: { paddingInlineStart: 8 + node.depth * 20 },
6306
- role: "treeitem",
6307
- "aria-selected": selected,
6308
- "aria-expanded": hasChildren ? expanded.has(node.value) : void 0,
6309
- children: [
6310
- hasChildren ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("button", { type: "button", className: "sia-tree-select__expand", "aria-label": expanded.has(node.value) ? "\u6536\u8D77\u8282\u70B9" : "\u5C55\u5F00\u8282\u70B9", onClick: () => setExpanded((current) => {
6311
- const next = new Set(current);
6312
- if (next.has(node.value)) next.delete(node.value);
6313
- else next.add(node.value);
6314
- return next;
6315
- }), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Icon, { name: expanded.has(node.value) ? "chevron-down" : "chevron-right", size: 13 }) }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "sia-tree-select__indent" }),
6316
- treeCheckable ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Checkbox2, { checked: selected, disabled: node.disabled, onChange: () => select(node) }) : null,
6317
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("button", { type: "button", className: "sia-tree-select__title", disabled: node.disabled, onClick: () => select(node), children: node.title })
6318
- ]
6319
- },
6320
- node.key ?? node.value
6321
- );
6322
- }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "sia-tree-select__empty", children: "\u6682\u65E0\u5339\u914D\u8282\u70B9" }) })
6323
- ] })
6324
- ] });
6546
+ visited.add(key);
6547
+ if (isRoot(ancestor[parentIdField])) break;
6548
+ ancestor = nodes.get(keyOf(ancestor[parentIdField]));
6549
+ }
6550
+ if (isRoot(node[parentIdField]) || !parent || cyclic) roots.push(node);
6551
+ else parent.children.push(node);
6552
+ }
6553
+ return roots;
6325
6554
  }
6326
6555
 
6327
6556
  // src/components/Upload.tsx
@@ -8651,6 +8880,7 @@ var ModalRoot = (0, import_react37.forwardRef)(function Modal({
8651
8880
  onOk,
8652
8881
  onCancel,
8653
8882
  onOpenChange,
8883
+ afterOpenChange,
8654
8884
  className = "",
8655
8885
  style,
8656
8886
  ...props
@@ -8660,6 +8890,14 @@ var ModalRoot = (0, import_react37.forwardRef)(function Modal({
8660
8890
  const [submitting, setSubmitting] = (0, import_react37.useState)(false);
8661
8891
  const [rendered, setRendered] = (0, import_react37.useState)(open);
8662
8892
  const [closing, setClosing] = (0, import_react37.useState)(false);
8893
+ const afterOpenChangeRef = (0, import_react37.useRef)(afterOpenChange);
8894
+ afterOpenChangeRef.current = afterOpenChange;
8895
+ const submitLock = (0, import_react37.useRef)(false);
8896
+ (0, import_react37.useEffect)(() => {
8897
+ if (!open || !rendered) return void 0;
8898
+ const timer = window.setTimeout(() => afterOpenChangeRef.current?.(true), MODAL_MOTION_DURATION);
8899
+ return () => window.clearTimeout(timer);
8900
+ }, [open, rendered]);
8663
8901
  (0, import_react37.useEffect)(() => {
8664
8902
  if (open) {
8665
8903
  setRendered(true);
@@ -8671,6 +8909,7 @@ var ModalRoot = (0, import_react37.forwardRef)(function Modal({
8671
8909
  const timer = window.setTimeout(() => {
8672
8910
  setRendered(false);
8673
8911
  setClosing(false);
8912
+ afterOpenChangeRef.current?.(false);
8674
8913
  }, MODAL_MOTION_DURATION);
8675
8914
  return () => window.clearTimeout(timer);
8676
8915
  }, [open, rendered]);
@@ -8685,8 +8924,11 @@ var ModalRoot = (0, import_react37.forwardRef)(function Modal({
8685
8924
  onOpenChange?.(false);
8686
8925
  }
8687
8926
  async function handleOk() {
8927
+ if (submitLock.current || confirmLoading) return;
8928
+ submitLock.current = true;
8688
8929
  if (!onOk) {
8689
8930
  onOpenChange?.(false);
8931
+ submitLock.current = false;
8690
8932
  return;
8691
8933
  }
8692
8934
  try {
@@ -8701,6 +8943,7 @@ var ModalRoot = (0, import_react37.forwardRef)(function Modal({
8701
8943
  } catch {
8702
8944
  return;
8703
8945
  } finally {
8946
+ submitLock.current = false;
8704
8947
  setSubmitting(false);
8705
8948
  }
8706
8949
  }
@@ -19504,6 +19747,378 @@ function createBaiduMapHost(element, sdk, options) {
19504
19747
  destroy
19505
19748
  };
19506
19749
  }
19750
+
19751
+ // src/components/SelectionPanel.tsx
19752
+ var import_react82 = require("react");
19753
+ var import_jsx_runtime82 = require("react/jsx-runtime");
19754
+ function SelectionPanel({
19755
+ options,
19756
+ value,
19757
+ onChange,
19758
+ multiple = false,
19759
+ disabled = false,
19760
+ loading = false,
19761
+ showSearch = true,
19762
+ searchValue,
19763
+ onSearch,
19764
+ selectedOnly = false,
19765
+ showValue = false,
19766
+ displayField = "label",
19767
+ columns = 1,
19768
+ maxHeight = 250,
19769
+ autoFocusSearch = false
19770
+ }) {
19771
+ const [localSearch, setLocalSearch] = (0, import_react82.useState)("");
19772
+ const search = searchValue ?? localSearch;
19773
+ const [scrollTop, setScrollTop] = (0, import_react82.useState)(0);
19774
+ const [active, setActive] = (0, import_react82.useState)();
19775
+ const listRef = (0, import_react82.useRef)(null);
19776
+ const id = (0, import_react82.useId)();
19777
+ const selected = (0, import_react82.useMemo)(() => new Set(value), [value]);
19778
+ const count = Math.max(1, Math.floor(columns));
19779
+ const allOptions = (0, import_react82.useMemo)(() => {
19780
+ const known = new Set(options.filter((option) => option.optionType !== "divider").map((option) => option.value));
19781
+ return [...value.filter((item) => !known.has(item)).map((item) => ({ value: item, label: String(item), group: "\u81EA\u5B9A\u4E49\u503C" })), ...options];
19782
+ }, [options, value]);
19783
+ const filtered = (0, import_react82.useMemo)(
19784
+ () => allOptions.filter((option) => (!selectedOnly || selected.has(option.value)) && (!search || option.optionType !== "divider" && [option.label, option.value].some((text) => String(text ?? "").toLowerCase().includes(search.toLowerCase())))),
19785
+ [allOptions, selectedOnly, selected, search]
19786
+ );
19787
+ const rows = (0, import_react82.useMemo)(() => {
19788
+ const groups = /* @__PURE__ */ new Map();
19789
+ filtered.forEach((option) => {
19790
+ const items = groups.get(option.group) ?? [];
19791
+ items.push(option);
19792
+ groups.set(option.group, items);
19793
+ });
19794
+ const rows2 = [];
19795
+ let top = 0;
19796
+ for (const [group, items] of groups) {
19797
+ if (group) {
19798
+ rows2.push({ key: `group-${rows2.length}`, title: group, top, height: 30 });
19799
+ top += 30;
19800
+ }
19801
+ for (let index = 0; index < items.length; index += count) {
19802
+ const height = showValue ? 48 : 34;
19803
+ rows2.push({ key: `row-${rows2.length}`, items: items.slice(index, index + count), top, height });
19804
+ top += height;
19805
+ }
19806
+ }
19807
+ return rows2;
19808
+ }, [filtered, count, showValue]);
19809
+ const totalHeight = rows.length ? rows[rows.length - 1].top + rows[rows.length - 1].height : 0;
19810
+ const virtual = filtered.length > 100;
19811
+ const renderedRows = virtual ? rows.filter((row) => row.top + row.height >= scrollTop - 100 && row.top <= scrollTop + maxHeight + 100) : rows;
19812
+ const enabled = filtered.filter((option) => !option.disabled && option.optionType !== "divider");
19813
+ (0, import_react82.useEffect)(() => {
19814
+ setScrollTop(0);
19815
+ if (listRef.current) listRef.current.scrollTop = 0;
19816
+ setActive(void 0);
19817
+ }, [search, selectedOnly, count]);
19818
+ function toggle(option) {
19819
+ if (disabled || loading || option.disabled || option.optionType === "divider") return;
19820
+ setActive(option.value);
19821
+ onChange(multiple ? selected.has(option.value) ? value.filter((item) => item !== option.value) : [...value, option.value] : [option.value]);
19822
+ }
19823
+ function batch(operation) {
19824
+ if (disabled || loading) return;
19825
+ if (operation === "clear") {
19826
+ onChange([]);
19827
+ return;
19828
+ }
19829
+ const editable = new Set(enabled.map((option) => option.value));
19830
+ const retained = value.filter((item) => !editable.has(item));
19831
+ const add = enabled.filter((option) => operation === "all" || !selected.has(option.value)).map((option) => option.value);
19832
+ onChange([...retained, ...add]);
19833
+ }
19834
+ return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "sia-selection-panel", children: [
19835
+ showSearch && /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
19836
+ Input,
19837
+ {
19838
+ "aria-label": "\u641C\u7D22\u9009\u9879",
19839
+ placeholder: "\u641C\u7D22",
19840
+ autoFocus: autoFocusSearch,
19841
+ value: search,
19842
+ allowClear: true,
19843
+ onChange: (event) => {
19844
+ setLocalSearch(event.target.value);
19845
+ onSearch?.(event.target.value);
19846
+ }
19847
+ }
19848
+ ),
19849
+ multiple && /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "sia-selection-panel__actions", children: [
19850
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Button, { variant: "link", size: "small", disabled: disabled || loading || !enabled.length, onClick: () => batch("all"), children: "\u5168\u9009" }),
19851
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Button, { variant: "link", size: "small", disabled: disabled || loading || !enabled.length, onClick: () => batch("invert"), children: "\u53CD\u9009" }),
19852
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Button, { variant: "link", size: "small", disabled: disabled || loading || !value.length, onClick: () => batch("clear"), children: "\u6E05\u7A7A" }),
19853
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("span", { children: [
19854
+ "\u5DF2\u9009 ",
19855
+ value.length,
19856
+ " \u9879"
19857
+ ] })
19858
+ ] }),
19859
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
19860
+ "div",
19861
+ {
19862
+ ref: listRef,
19863
+ role: "listbox",
19864
+ "aria-label": "\u9009\u9879\u5217\u8868",
19865
+ "aria-multiselectable": multiple || void 0,
19866
+ tabIndex: disabled ? -1 : 0,
19867
+ className: "sia-selection-panel__list",
19868
+ style: { maxHeight },
19869
+ onScroll: (event) => setScrollTop(event.currentTarget.scrollTop),
19870
+ "aria-activedescendant": active !== void 0 ? `${id}-${typeof active}-${active}` : void 0,
19871
+ onKeyDown: (event) => {
19872
+ if (disabled || loading || !enabled.length) return;
19873
+ const index = enabled.findIndex((option) => option.value === active);
19874
+ if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) {
19875
+ event.preventDefault();
19876
+ const next = event.key === "Home" ? 0 : event.key === "End" ? enabled.length - 1 : Math.max(0, Math.min(enabled.length - 1, index + (event.key === "ArrowDown" ? 1 : -1)));
19877
+ const option = enabled[next];
19878
+ setActive(option.value);
19879
+ const row = rows.find((row2) => row2.items?.includes(option));
19880
+ if (row && listRef.current) {
19881
+ listRef.current.scrollTop = Math.max(0, row.top - maxHeight / 2);
19882
+ setScrollTop(listRef.current.scrollTop);
19883
+ }
19884
+ } else if ((event.key === "Enter" || event.key === " ") && index >= 0) {
19885
+ event.preventDefault();
19886
+ toggle(enabled[index]);
19887
+ }
19888
+ },
19889
+ children: loading ? /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { role: "status", children: "\u52A0\u8F7D\u4E2D\u2026" }) : !rows.length ? /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className: "sia-selection-panel__empty", children: "\u6682\u65E0\u5339\u914D\u9009\u9879" }) : /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { style: { height: totalHeight, position: "relative" }, children: renderedRows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
19890
+ "div",
19891
+ {
19892
+ className: row.title !== void 0 ? "sia-selection-panel__group" : "sia-selection-panel__row",
19893
+ style: { position: "absolute", top: row.top, height: row.height, width: "100%", gridTemplateColumns: `repeat(${count}, minmax(0, 1fr))` },
19894
+ children: row.title ?? row.items?.map((option, index) => option.optionType === "divider" ? /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { role: "separator", className: "sia-selection-panel__divider" }, `divider-${index}`) : /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Tooltip, { title: option.disabled ? option.disabledTip : void 0, placement: "right", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(
19895
+ "button",
19896
+ {
19897
+ type: "button",
19898
+ role: "option",
19899
+ id: `${id}-${typeof option.value}-${option.value}`,
19900
+ tabIndex: -1,
19901
+ "aria-selected": selected.has(option.value),
19902
+ "aria-disabled": disabled || option.disabled || void 0,
19903
+ className: `sia-selection-panel__option${active === option.value ? " is-active" : ""}`,
19904
+ onClick: () => toggle(option),
19905
+ children: [
19906
+ multiple && /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { "aria-hidden": "true", className: "sia-selection-panel__check", children: selected.has(option.value) ? "\u2713" : "" }),
19907
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("span", { className: "sia-selection-panel__text", children: [
19908
+ showValue || displayField === "label" ? option.label : String(option.value),
19909
+ showValue && /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("small", { children: String(option.value) })
19910
+ ] })
19911
+ ]
19912
+ }
19913
+ ) }, `${typeof option.value}-${option.value}`))
19914
+ },
19915
+ row.key
19916
+ )) })
19917
+ }
19918
+ )
19919
+ ] });
19920
+ }
19921
+
19922
+ // src/components/InputSelect.tsx
19923
+ var import_react83 = require("react");
19924
+ var import_jsx_runtime83 = require("react/jsx-runtime");
19925
+ var InputSelect = (0, import_react83.forwardRef)(function InputSelect2({
19926
+ options,
19927
+ value,
19928
+ defaultValue,
19929
+ onChange,
19930
+ multiple = false,
19931
+ displayField = "label",
19932
+ showValue = false,
19933
+ placeholder = "\u8BF7\u9009\u62E9",
19934
+ size = "medium",
19935
+ status,
19936
+ disabled = false,
19937
+ loading = false,
19938
+ allowClear = true,
19939
+ hideSearch,
19940
+ inputMaxLength,
19941
+ parseInput,
19942
+ enableModal,
19943
+ suffix,
19944
+ style,
19945
+ className = "",
19946
+ onOpenChange,
19947
+ ...inputProps
19948
+ }, forwardedRef) {
19949
+ const [internal, setInternal] = (0, import_react83.useState)(defaultValue);
19950
+ const current = value !== void 0 ? value : internal;
19951
+ const values = current == null ? [] : Array.isArray(current) ? current : [current];
19952
+ const text = values.map((item) => displayField === "label" ? String(options.find((option) => option.optionType !== "divider" && option.value === item)?.label ?? item) : String(item)).join(",");
19953
+ const [draft, setDraft] = (0, import_react83.useState)(text);
19954
+ (0, import_react83.useEffect)(() => {
19955
+ setDraft(text);
19956
+ }, [text, current]);
19957
+ const [open, setOpen] = (0, import_react83.useState)(false);
19958
+ const [search, setSearch] = (0, import_react83.useState)("");
19959
+ const [modalOpen, setModalOpen] = (0, import_react83.useState)(false);
19960
+ const [modalValues, setModalValues] = (0, import_react83.useState)([]);
19961
+ const [selectedOnly, setSelectedOnly] = (0, import_react83.useState)(false);
19962
+ const rootRef = (0, import_react83.useRef)(null);
19963
+ const popupRef = (0, import_react83.useRef)(null);
19964
+ const inputRef = (0, import_react83.useRef)(null);
19965
+ const config = typeof enableModal === "object" ? enableModal : {};
19966
+ function changeOpen(next) {
19967
+ if (next && (disabled || loading)) return;
19968
+ setOpen(next);
19969
+ if (next !== open) onOpenChange?.(next);
19970
+ if (!next) setSearch("");
19971
+ }
19972
+ function emit(next) {
19973
+ if (disabled || loading) return;
19974
+ if (value === void 0) setInternal(next);
19975
+ onChange?.(next);
19976
+ }
19977
+ function select(next) {
19978
+ emit(multiple ? next : next[0]);
19979
+ if (!multiple) {
19980
+ changeOpen(false);
19981
+ inputRef.current?.focus();
19982
+ }
19983
+ }
19984
+ (0, import_react83.useEffect)(() => {
19985
+ if (!open) return;
19986
+ const outside = (event) => {
19987
+ if (!rootRef.current?.contains(event.target) && !popupRef.current?.contains(event.target)) changeOpen(false);
19988
+ };
19989
+ document.addEventListener("pointerdown", outside);
19990
+ return () => document.removeEventListener("pointerdown", outside);
19991
+ }, [open, onOpenChange]);
19992
+ (0, import_react83.useEffect)(() => {
19993
+ if (disabled || loading) {
19994
+ changeOpen(false);
19995
+ setModalOpen(false);
19996
+ }
19997
+ }, [disabled, loading]);
19998
+ function openModal2() {
19999
+ if (disabled || loading) return;
20000
+ changeOpen(false);
20001
+ setModalValues([...values]);
20002
+ setSelectedOnly(false);
20003
+ setModalOpen(true);
20004
+ }
20005
+ return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { ref: rootRef, style, className: `sia-input-select ${className}`, onKeyDown: (event) => {
20006
+ if (event.key === "Escape" && open) {
20007
+ event.stopPropagation();
20008
+ changeOpen(false);
20009
+ inputRef.current?.focus();
20010
+ }
20011
+ }, children: [
20012
+ /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
20013
+ Input,
20014
+ {
20015
+ ...inputProps,
20016
+ ref: (node) => {
20017
+ inputRef.current = node;
20018
+ if (typeof forwardedRef === "function") forwardedRef(node);
20019
+ else if (forwardedRef) forwardedRef.current = node;
20020
+ },
20021
+ role: "combobox",
20022
+ "aria-label": inputProps["aria-label"] ?? placeholder,
20023
+ "aria-expanded": open,
20024
+ "aria-haspopup": "listbox",
20025
+ size,
20026
+ status,
20027
+ disabled,
20028
+ readOnly: displayField === "label" || loading,
20029
+ placeholder,
20030
+ value: draft,
20031
+ maxLength: inputMaxLength && inputMaxLength > 0 ? inputMaxLength : void 0,
20032
+ showCount: !!inputMaxLength && inputMaxLength > 0,
20033
+ onClick: () => changeOpen(!open),
20034
+ autoComplete: "off",
20035
+ onKeyDown: (event) => {
20036
+ if (event.key === "ArrowDown" || event.key === "Enter" && displayField === "label") {
20037
+ event.preventDefault();
20038
+ if (open) popupRef.current?.querySelector('[role="listbox"]')?.focus();
20039
+ else changeOpen(true);
20040
+ }
20041
+ },
20042
+ onChange: (event) => {
20043
+ const next = event.target.value;
20044
+ setDraft(next);
20045
+ emit(parseInput ? parseInput(next) : multiple ? next.split(",").map((item) => item.trim()).filter(Boolean) : next);
20046
+ changeOpen(true);
20047
+ },
20048
+ suffix: /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("span", { className: "sia-input-select__suffix", children: [
20049
+ allowClear && draft && !disabled && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Button, { variant: "text", size: "small", disabled: loading, "aria-label": "\u6E05\u9664\u8F93\u5165\u9009\u62E9", onClick: (event) => {
20050
+ event.stopPropagation();
20051
+ setDraft("");
20052
+ emit(multiple ? [] : void 0);
20053
+ inputRef.current?.focus();
20054
+ }, children: "\xD7" }),
20055
+ suffix,
20056
+ enableModal && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Button, { variant: "text", size: "small", disabled: disabled || loading, "aria-label": "\u6253\u5F00\u9009\u62E9\u5F39\u7A97", onClick: (event) => {
20057
+ event.stopPropagation();
20058
+ openModal2();
20059
+ }, children: "\u2026" }),
20060
+ /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Button, { variant: "text", size: "small", disabled: disabled || loading, "aria-label": "\u5C55\u5F00\u9009\u9879", onClick: (event) => {
20061
+ event.stopPropagation();
20062
+ changeOpen(!open);
20063
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Icon, { name: loading ? "refresh" : open ? "chevron-up" : "chevron-down", size: 13 }) })
20064
+ ] })
20065
+ }
20066
+ ),
20067
+ /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(PopupPortal, { ref: popupRef, anchorRef: rootRef, open: open && !disabled && !loading, className: "sia-input-select__popup", children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
20068
+ SelectionPanel,
20069
+ {
20070
+ options,
20071
+ value: values,
20072
+ multiple,
20073
+ onChange: select,
20074
+ showValue,
20075
+ displayField,
20076
+ showSearch: !(hideSearch ?? (!multiple && displayField === "value")),
20077
+ autoFocusSearch: displayField === "label",
20078
+ searchValue: search || (!multiple && displayField === "value" ? draft : ""),
20079
+ onSearch: setSearch
20080
+ }
20081
+ ) }),
20082
+ enableModal && /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
20083
+ Modal2,
20084
+ {
20085
+ open: modalOpen,
20086
+ title: config.title ?? "\u9009\u62E9",
20087
+ width: config.width ?? 900,
20088
+ onCancel: () => setModalOpen(false),
20089
+ onOpenChange: setModalOpen,
20090
+ onOk: () => {
20091
+ emit(multiple ? modalValues : modalValues[0]);
20092
+ setModalOpen(false);
20093
+ },
20094
+ children: [
20095
+ /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { className: "sia-selection-panel__actions", role: "tablist", "aria-label": "\u9009\u9879\u8303\u56F4", children: [
20096
+ /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Button, { role: "tab", "aria-selected": !selectedOnly, variant: !selectedOnly ? "primary" : "text", onClick: () => setSelectedOnly(false), children: "\u5168\u90E8" }),
20097
+ /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(Button, { role: "tab", "aria-selected": selectedOnly, variant: selectedOnly ? "primary" : "text", onClick: () => setSelectedOnly(true), children: [
20098
+ "\u5DF2\u9009\u9879(",
20099
+ modalValues.length,
20100
+ ")"
20101
+ ] })
20102
+ ] }),
20103
+ modalOpen && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
20104
+ SelectionPanel,
20105
+ {
20106
+ options,
20107
+ value: modalValues,
20108
+ multiple,
20109
+ onChange: setModalValues,
20110
+ selectedOnly,
20111
+ columns: config.columns ?? 3,
20112
+ maxHeight: config.maxHeight ?? 450,
20113
+ showValue,
20114
+ displayField
20115
+ }
20116
+ )
20117
+ ]
20118
+ }
20119
+ )
20120
+ ] });
20121
+ });
19507
20122
  // Annotate the CommonJS export names for ESM import in node:
19508
20123
  0 && (module.exports = {
19509
20124
  Alert,
@@ -19562,6 +20177,7 @@ function createBaiduMapHost(element, sdk, options) {
19562
20177
  ImagePreview,
19563
20178
  Input,
19564
20179
  InputNumber,
20180
+ InputSelect,
19565
20181
  KLineChart,
19566
20182
  LineChart,
19567
20183
  LineShareChart,
@@ -19587,6 +20203,7 @@ function createBaiduMapHost(element, sdk, options) {
19587
20203
  Segmented,
19588
20204
  Select,
19589
20205
  SelectDateRange,
20206
+ SelectionPanel,
19590
20207
  SiaChart,
19591
20208
  Slider,
19592
20209
  Space,
@@ -19621,6 +20238,7 @@ function createBaiduMapHost(element, sdk, options) {
19621
20238
  WordCloudChart,
19622
20239
  XYChart,
19623
20240
  applySiaTheme,
20241
+ buildFlatTree,
19624
20242
  chartColor,
19625
20243
  chartTicks,
19626
20244
  createBaiduMapHost,