@sia.soul/sia-react-ui 0.1.24 → 0.1.26

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.
Files changed (37) hide show
  1. package/dist/{Select-O_yY51vc.d.ts → Select-CCrPqULn.d.ts} +1 -1
  2. package/dist/{Select-W_xpkpOW.d.cts → Select-YJbT-MF1.d.cts} +1 -1
  3. package/dist/chart.cjs +1 -1
  4. package/dist/chart.js +4 -4
  5. package/dist/{chunk-6R7JY7IY.js → chunk-5MW3NE2V.js} +227 -202
  6. package/dist/{chunk-T2QIW4OO.js → chunk-IQU4GGLM.js} +11 -5
  7. package/dist/{chunk-6WBABNAX.js → chunk-IYNS423D.js} +1 -1
  8. package/dist/{chunk-RGXVPS37.js → chunk-LK56NX5F.js} +3 -3
  9. package/dist/{chunk-LIYCU2GU.js → chunk-NAOV53NK.js} +5 -5
  10. package/dist/{chunk-LA7O3PN4.js → chunk-PXHBIRQW.js} +1 -1
  11. package/dist/{chunk-NSSPGXNM.js → chunk-RAO3JHDL.js} +1 -1
  12. package/dist/{chunk-GUXAWU63.js → chunk-TZROBD65.js} +3 -3
  13. package/dist/{chunk-LRPQ5FGE.js → chunk-YF2I6SDB.js} +3 -3
  14. package/dist/{chunk-OH6YILJW.js → chunk-YQDHCORW.js} +1 -1
  15. package/dist/{core-tbb9ZiBY.d.cts → core-BM-wnJRa.d.cts} +3 -3
  16. package/dist/{core-BOzLwiXG.d.ts → core-CLqv6btD.d.ts} +3 -3
  17. package/dist/core.cjs +270 -243
  18. package/dist/core.css +10 -5
  19. package/dist/core.d.cts +2 -2
  20. package/dist/core.d.ts +2 -2
  21. package/dist/core.js +6 -6
  22. package/dist/index.cjs +296 -252
  23. package/dist/index.css +10 -5
  24. package/dist/index.d.cts +20 -14
  25. package/dist/index.d.ts +20 -14
  26. package/dist/index.js +29 -15
  27. package/dist/markdown-editor.cjs +1 -1
  28. package/dist/markdown-editor.js +2 -2
  29. package/dist/rich-text-editor.cjs +2 -2
  30. package/dist/rich-text-editor.js +4 -4
  31. package/dist/{select-date-range-C9w8z3G8.d.cts → select-date-range-CtA-B8DB.d.cts} +1 -1
  32. package/dist/{select-date-range-BjqFUeU6.d.ts → select-date-range-D9W_mmMq.d.ts} +1 -1
  33. package/dist/select-date-range.cjs +706 -674
  34. package/dist/select-date-range.d.cts +2 -2
  35. package/dist/select-date-range.d.ts +2 -2
  36. package/dist/select-date-range.js +5 -5
  37. package/package.json +1 -1
package/dist/core.cjs CHANGED
@@ -245,7 +245,7 @@ function installTitleTooltips(doc) {
245
245
  else if (active.getAttribute("data-sia-title") !== doc.getElementById(tooltipId)?.textContent) render();
246
246
  });
247
247
  observer.observe(doc.body, { childList: true, subtree: true, attributes: true, attributeFilter: ["data-sia-title"] });
248
- }, 250);
248
+ }, 600);
249
249
  };
250
250
  doc.addEventListener("pointerover", (event) => {
251
251
  if (event.pointerType === "touch") return;
@@ -2742,7 +2742,7 @@ var Input = (0, import_react17.forwardRef)(function Input2({
2742
2742
  size: sizeProp,
2743
2743
  prefix,
2744
2744
  suffix,
2745
- allowClear = false,
2745
+ allowClear = true,
2746
2746
  onClear,
2747
2747
  showCount = false,
2748
2748
  placeholderMode,
@@ -2837,252 +2837,17 @@ var Input = (0, import_react17.forwardRef)(function Input2({
2837
2837
  });
2838
2838
 
2839
2839
  // src/components/SelectionPanel.tsx
2840
- var import_react18 = require("react");
2841
- var import_jsx_runtime19 = require("react/jsx-runtime");
2842
- function SelectionPanel({
2843
- options,
2844
- value,
2845
- onChange,
2846
- multiple = false,
2847
- allowDeselect = false,
2848
- disabled = false,
2849
- loading = false,
2850
- showSearch = true,
2851
- showActions = true,
2852
- includeUnknownValues = true,
2853
- searchValue,
2854
- onSearch,
2855
- selectedOnly = false,
2856
- showValue = false,
2857
- displayField = "label",
2858
- columns = 1,
2859
- maxHeight = 250,
2860
- autoFocusSearch = false
2861
- }) {
2862
- const [localSearch, setLocalSearch] = (0, import_react18.useState)("");
2863
- const search = searchValue ?? localSearch;
2864
- const [scrollTop, setScrollTop] = (0, import_react18.useState)(0);
2865
- const [active, setActive] = (0, import_react18.useState)();
2866
- const [keyboardActive, setKeyboardActive] = (0, import_react18.useState)(false);
2867
- const [deselectedHover, setDeselectedHover] = (0, import_react18.useState)();
2868
- const listRef = (0, import_react18.useRef)(null);
2869
- const id = (0, import_react18.useId)();
2870
- const selected = (0, import_react18.useMemo)(() => new Set(value), [value]);
2871
- const count = Math.max(1, Math.floor(columns));
2872
- const allOptions = (0, import_react18.useMemo)(() => {
2873
- if (!includeUnknownValues) return [...options];
2874
- const known = new Set(options.filter((option) => option.optionType !== "divider").map((option) => option.value));
2875
- return [...value.filter((item) => !known.has(item)).map((item) => ({ value: item, label: String(item), group: "\u81EA\u5B9A\u4E49\u503C" })), ...options];
2876
- }, [options, value, includeUnknownValues]);
2877
- const filtered = (0, import_react18.useMemo)(
2878
- () => allOptions.filter((option) => (!selectedOnly || selected.has(option.value)) && (!search || option.optionType !== "divider" && [option.label, option.value].some((text) => String(text ?? "").toLowerCase().includes(search.toLowerCase())))),
2879
- [allOptions, selectedOnly, selected, search]
2880
- );
2881
- const rows = (0, import_react18.useMemo)(() => {
2882
- const groups = /* @__PURE__ */ new Map();
2883
- filtered.forEach((option) => {
2884
- const items = groups.get(option.group) ?? [];
2885
- items.push(option);
2886
- groups.set(option.group, items);
2887
- });
2888
- const rows2 = [];
2889
- let top = 0;
2890
- for (const [group, items] of groups) {
2891
- if (group) {
2892
- rows2.push({ key: `group-${rows2.length}`, title: group, top, height: 30 });
2893
- top += 30;
2894
- }
2895
- for (let index = 0; index < items.length; index += count) {
2896
- const height = showValue ? 48 : 34;
2897
- rows2.push({ key: `row-${rows2.length}`, items: items.slice(index, index + count), top, height });
2898
- top += height;
2899
- }
2900
- }
2901
- return rows2;
2902
- }, [filtered, count, showValue]);
2903
- const totalHeight = rows.length ? rows[rows.length - 1].top + rows[rows.length - 1].height : 0;
2904
- const virtual = filtered.length > 100;
2905
- const renderedRows = virtual ? rows.filter((row) => row.top + row.height >= scrollTop - 100 && row.top <= scrollTop + maxHeight + 100) : rows;
2906
- const enabled = filtered.filter((option) => !option.disabled && option.optionType !== "divider");
2907
- (0, import_react18.useEffect)(() => {
2908
- setScrollTop(0);
2909
- if (listRef.current) listRef.current.scrollTop = 0;
2910
- setActive(void 0);
2911
- }, [search, selectedOnly, count]);
2912
- function toggle(option, keyboard = false) {
2913
- if (disabled || loading || option.disabled || option.optionType === "divider") return;
2914
- setActive(option.value);
2915
- setKeyboardActive(keyboard);
2916
- setDeselectedHover(!keyboard && !multiple && allowDeselect && selected.has(option.value) ? option.value : void 0);
2917
- onChange(multiple ? selected.has(option.value) ? value.filter((item) => item !== option.value) : [...value, option.value] : allowDeselect && selected.has(option.value) ? [] : [option.value]);
2918
- }
2919
- function batch(operation) {
2920
- if (disabled || loading) return;
2921
- if (operation === "clear") {
2922
- onChange([]);
2923
- return;
2924
- }
2925
- const editable = new Set(enabled.map((option) => option.value));
2926
- const retained = value.filter((item) => !editable.has(item));
2927
- const add = enabled.filter((option) => operation === "all" || !selected.has(option.value)).map((option) => option.value);
2928
- onChange([...retained, ...add]);
2929
- }
2930
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "sia-selection-panel", children: [
2931
- showSearch && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2932
- Input,
2933
- {
2934
- "aria-label": "\u641C\u7D22\u9009\u9879",
2935
- placeholder: "\u641C\u7D22",
2936
- autoFocus: autoFocusSearch,
2937
- value: search,
2938
- allowClear: true,
2939
- onChange: (event) => {
2940
- setLocalSearch(event.target.value);
2941
- onSearch?.(event.target.value);
2942
- }
2943
- }
2944
- ),
2945
- multiple && showActions && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "sia-selection-panel__actions", children: [
2946
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { variant: "link", size: "small", disabled: disabled || loading || !enabled.length, onClick: () => batch("all"), children: "\u5168\u9009" }),
2947
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { variant: "link", size: "small", disabled: disabled || loading || !enabled.length, onClick: () => batch("invert"), children: "\u53CD\u9009" }),
2948
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { variant: "link", size: "small", disabled: disabled || loading || !value.length, onClick: () => batch("clear"), children: "\u6E05\u7A7A" }),
2949
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { children: [
2950
- "\u5DF2\u9009 ",
2951
- value.length,
2952
- " \u9879"
2953
- ] })
2954
- ] }),
2955
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2956
- "div",
2957
- {
2958
- ref: listRef,
2959
- role: "listbox",
2960
- "aria-label": "\u9009\u9879\u5217\u8868",
2961
- "aria-multiselectable": multiple || void 0,
2962
- tabIndex: disabled ? -1 : 0,
2963
- className: "sia-selection-panel__list",
2964
- style: { maxHeight },
2965
- onScroll: (event) => setScrollTop(event.currentTarget.scrollTop),
2966
- onPointerDown: () => setKeyboardActive(false),
2967
- onBlur: (event) => {
2968
- if (!event.currentTarget.contains(event.relatedTarget)) setKeyboardActive(false);
2969
- },
2970
- "aria-activedescendant": active !== void 0 ? `${id}-${typeof active}-${active}` : void 0,
2971
- onKeyDown: (event) => {
2972
- if (event.target instanceof HTMLInputElement) return;
2973
- if (disabled || loading || !enabled.length) return;
2974
- const index = enabled.findIndex((option) => option.value === active);
2975
- if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) {
2976
- event.preventDefault();
2977
- setKeyboardActive(true);
2978
- setDeselectedHover(void 0);
2979
- 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)));
2980
- const option = enabled[next];
2981
- setActive(option.value);
2982
- const row = rows.find((row2) => row2.items?.includes(option));
2983
- if (row && listRef.current) {
2984
- listRef.current.scrollTop = Math.max(0, row.top - maxHeight / 2);
2985
- setScrollTop(listRef.current.scrollTop);
2986
- }
2987
- } else if ((event.key === "Enter" || event.key === " ") && index >= 0) {
2988
- event.preventDefault();
2989
- toggle(enabled[index], true);
2990
- }
2991
- },
2992
- children: loading ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { role: "status", children: "\u52A0\u8F7D\u4E2D\u2026" }) : !rows.length ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "sia-selection-panel__empty", children: "\u6682\u65E0\u5339\u914D\u9009\u9879" }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { style: { height: totalHeight, position: "relative" }, children: renderedRows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2993
- "div",
2994
- {
2995
- className: row.title !== void 0 ? "sia-selection-panel__group" : "sia-selection-panel__row",
2996
- style: { position: "absolute", top: row.top, height: row.height, width: "100%", gridTemplateColumns: `repeat(${count}, minmax(0, 1fr))` },
2997
- children: row.title ?? row.items?.map((option, index) => option.optionType === "divider" ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { role: "separator", className: "sia-selection-panel__divider" }, `divider-${index}`) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Tooltip, { title: option.disabled ? option.disabledTip : void 0, placement: "right", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2998
- "div",
2999
- {
3000
- role: "option",
3001
- id: `${id}-${typeof option.value}-${option.value}`,
3002
- tabIndex: -1,
3003
- "aria-selected": selected.has(option.value),
3004
- "aria-disabled": disabled || option.disabled || void 0,
3005
- className: `sia-selection-panel__option${keyboardActive && active === option.value ? " is-active" : ""}`,
3006
- "data-deselected-hover": deselectedHover === option.value || void 0,
3007
- onPointerLeave: () => {
3008
- if (deselectedHover === option.value) setDeselectedHover(void 0);
3009
- },
3010
- onClick: (event) => {
3011
- if (!event.target.closest(".sia-checkbox")) toggle(option);
3012
- },
3013
- children: multiple ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Checkbox2, { checked: selected.has(option.value), disabled: disabled || loading || option.disabled, tabIndex: -1, onChange: () => toggle(option), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "sia-selection-panel__text", children: [
3014
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "sia-selection-panel__label", children: showValue || displayField === "label" ? option.label : String(option.value) }),
3015
- showValue && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("small", { children: String(option.value) })
3016
- ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "sia-selection-panel__text", children: [
3017
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "sia-selection-panel__label", children: showValue || displayField === "label" ? option.label : String(option.value) }),
3018
- showValue && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("small", { children: String(option.value) })
3019
- ] })
3020
- }
3021
- ) }, `${typeof option.value}-${option.value}`))
3022
- },
3023
- row.key
3024
- )) })
3025
- }
3026
- )
3027
- ] });
3028
- }
3029
-
3030
- // src/components/OverflowTags.tsx
3031
- var import_react19 = require("react");
3032
- var import_jsx_runtime20 = require("react/jsx-runtime");
3033
- function OverflowTags({ items, maxCount: maxCount2, className = "", tagClassName, restClassName = "" }) {
3034
- const rootRef = (0, import_react19.useRef)(null);
3035
- const measureRef = (0, import_react19.useRef)(null);
3036
- const limit = Math.min(items.length, Math.max(0, Math.floor(maxCount2) || 0));
3037
- const [visibleCount, setVisibleCount] = (0, import_react19.useState)(0);
3038
- (0, import_react19.useLayoutEffect)(() => {
3039
- const root = rootRef.current;
3040
- const measure = measureRef.current;
3041
- if (!root || !measure) return;
3042
- const update = () => {
3043
- const gap = Number.parseFloat(getComputedStyle(root).columnGap) || 0;
3044
- const widths = Array.from(measure.children, (child) => child.getBoundingClientRect().width);
3045
- let used = 0;
3046
- let fitting = 0;
3047
- for (let count2 = 1; count2 <= limit; count2 += 1) {
3048
- used += widths[count2 - 1] + (count2 > 1 ? gap : 0);
3049
- const rest = count2 < items.length ? gap + widths[limit + count2] : 0;
3050
- if (used + rest <= root.clientWidth) fitting = count2;
3051
- }
3052
- setVisibleCount((previous) => previous === fitting ? previous : fitting);
3053
- };
3054
- update();
3055
- const observer = new ResizeObserver(update);
3056
- observer.observe(root);
3057
- for (const child of measure.children) observer.observe(child);
3058
- return () => observer.disconnect();
3059
- }, [items, limit]);
3060
- const count = Math.min(visibleCount, limit);
3061
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { ref: rootRef, className: `sia-overflow-tags ${className}`.trim(), children: [
3062
- items.slice(0, count).map((item) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: tagClassName, children: item.label }, item.key)),
3063
- items.length > count ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { className: `${tagClassName} sia-overflow-tags__rest ${restClassName}`.trim(), children: [
3064
- "+",
3065
- items.length - count
3066
- ] }) : null,
3067
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { ref: measureRef, className: "sia-overflow-tags__measure", "aria-hidden": "true", children: [
3068
- items.slice(0, limit).map((item) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: tagClassName, children: item.label }, item.key)),
3069
- Array.from({ length: limit + 1 }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { className: `${tagClassName} ${restClassName}`.trim(), children: [
3070
- "+",
3071
- items.length - index
3072
- ] }, `rest-${index}`))
3073
- ] })
3074
- ] });
3075
- }
2840
+ var import_react20 = require("react");
3076
2841
 
3077
2842
  // src/components/FloatingScrollbarProvider.tsx
3078
- var import_react21 = require("react");
2843
+ var import_react19 = require("react");
3079
2844
 
3080
2845
  // src/components/useScrollbarProximity.ts
3081
- var import_react20 = require("react");
2846
+ var import_react18 = require("react");
3082
2847
  var users = 0;
3083
2848
  var cleanup;
3084
2849
  function useScrollbarProximity() {
3085
- (0, import_react20.useEffect)(() => {
2850
+ (0, import_react18.useEffect)(() => {
3086
2851
  if (users++ === 0) {
3087
2852
  let frame = 0;
3088
2853
  let x = -Infinity;
@@ -3203,7 +2968,7 @@ function createTrack(axis) {
3203
2968
  }
3204
2969
  function FloatingScrollbarProvider({ disabled = false, targetRef }) {
3205
2970
  useScrollbarProximity();
3206
- (0, import_react21.useEffect)(() => {
2971
+ (0, import_react19.useEffect)(() => {
3207
2972
  if (disabled) return;
3208
2973
  const layer = document.createElement("div");
3209
2974
  layer.className = "sia-floating-scrollbar-layer";
@@ -3449,6 +3214,244 @@ function FloatingScrollbarProvider({ disabled = false, targetRef }) {
3449
3214
  return null;
3450
3215
  }
3451
3216
 
3217
+ // src/components/SelectionPanel.tsx
3218
+ var import_jsx_runtime19 = require("react/jsx-runtime");
3219
+ function SelectionPanel({
3220
+ options,
3221
+ value,
3222
+ onChange,
3223
+ multiple = false,
3224
+ allowDeselect = false,
3225
+ disabled = false,
3226
+ loading = false,
3227
+ showSearch = true,
3228
+ showActions = true,
3229
+ includeUnknownValues = true,
3230
+ searchValue,
3231
+ onSearch,
3232
+ selectedOnly = false,
3233
+ showValue = false,
3234
+ displayField = "label",
3235
+ columns = 1,
3236
+ maxHeight = 250,
3237
+ autoFocusSearch = false
3238
+ }) {
3239
+ const [localSearch, setLocalSearch] = (0, import_react20.useState)("");
3240
+ const search = searchValue ?? localSearch;
3241
+ const [scrollTop, setScrollTop] = (0, import_react20.useState)(0);
3242
+ const [active, setActive] = (0, import_react20.useState)();
3243
+ const [keyboardActive, setKeyboardActive] = (0, import_react20.useState)(false);
3244
+ const [deselectedHover, setDeselectedHover] = (0, import_react20.useState)();
3245
+ const listRef = (0, import_react20.useRef)(null);
3246
+ const id = (0, import_react20.useId)();
3247
+ const selected = (0, import_react20.useMemo)(() => new Set(value), [value]);
3248
+ const count = Math.max(1, Math.floor(columns));
3249
+ const allOptions = (0, import_react20.useMemo)(() => {
3250
+ if (!includeUnknownValues) return [...options];
3251
+ const known = new Set(options.filter((option) => option.optionType !== "divider").map((option) => option.value));
3252
+ return [...value.filter((item) => !known.has(item)).map((item) => ({ value: item, label: String(item), group: "\u81EA\u5B9A\u4E49\u503C" })), ...options];
3253
+ }, [options, value, includeUnknownValues]);
3254
+ const filtered = (0, import_react20.useMemo)(
3255
+ () => allOptions.filter((option) => (!selectedOnly || selected.has(option.value)) && (!search || option.optionType !== "divider" && [option.label, option.value].some((text) => String(text ?? "").toLowerCase().includes(search.toLowerCase())))),
3256
+ [allOptions, selectedOnly, selected, search]
3257
+ );
3258
+ const rows = (0, import_react20.useMemo)(() => {
3259
+ const groups = /* @__PURE__ */ new Map();
3260
+ filtered.forEach((option) => {
3261
+ const items = groups.get(option.group) ?? [];
3262
+ items.push(option);
3263
+ groups.set(option.group, items);
3264
+ });
3265
+ const rows2 = [];
3266
+ let top = 0;
3267
+ for (const [group, items] of groups) {
3268
+ if (group) {
3269
+ rows2.push({ key: `group-${rows2.length}`, title: group, top, height: 30 });
3270
+ top += 30;
3271
+ }
3272
+ for (let index = 0; index < items.length; index += count) {
3273
+ const height = showValue ? 48 : 34;
3274
+ rows2.push({ key: `row-${rows2.length}`, items: items.slice(index, index + count), top, height });
3275
+ top += height;
3276
+ }
3277
+ }
3278
+ return rows2;
3279
+ }, [filtered, count, showValue]);
3280
+ const totalHeight = rows.length ? rows[rows.length - 1].top + rows[rows.length - 1].height : 0;
3281
+ const virtual = filtered.length > 100;
3282
+ const renderedRows = virtual ? rows.filter((row) => row.top + row.height >= scrollTop - 100 && row.top <= scrollTop + maxHeight + 100) : rows;
3283
+ const enabled = filtered.filter((option) => !option.disabled && option.optionType !== "divider");
3284
+ (0, import_react20.useEffect)(() => {
3285
+ setScrollTop(0);
3286
+ if (listRef.current) listRef.current.scrollTop = 0;
3287
+ setActive(void 0);
3288
+ }, [search, selectedOnly, count]);
3289
+ function toggle(option, keyboard = false) {
3290
+ if (disabled || loading || option.disabled || option.optionType === "divider") return;
3291
+ setActive(option.value);
3292
+ setKeyboardActive(keyboard);
3293
+ setDeselectedHover(!keyboard && !multiple && allowDeselect && selected.has(option.value) ? option.value : void 0);
3294
+ onChange(multiple ? selected.has(option.value) ? value.filter((item) => item !== option.value) : [...value, option.value] : allowDeselect && selected.has(option.value) ? [] : [option.value]);
3295
+ }
3296
+ function batch(operation) {
3297
+ if (disabled || loading) return;
3298
+ if (operation === "clear") {
3299
+ onChange([]);
3300
+ return;
3301
+ }
3302
+ const editable = new Set(enabled.map((option) => option.value));
3303
+ const retained = value.filter((item) => !editable.has(item));
3304
+ const add = enabled.filter((option) => operation === "all" || !selected.has(option.value)).map((option) => option.value);
3305
+ onChange([...retained, ...add]);
3306
+ }
3307
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "sia-selection-panel", children: [
3308
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(FloatingScrollbarProvider, { targetRef: listRef }),
3309
+ showSearch && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3310
+ Input,
3311
+ {
3312
+ "aria-label": "\u641C\u7D22\u9009\u9879",
3313
+ placeholder: "\u641C\u7D22",
3314
+ autoFocus: autoFocusSearch,
3315
+ value: search,
3316
+ allowClear: true,
3317
+ onChange: (event) => {
3318
+ setLocalSearch(event.target.value);
3319
+ onSearch?.(event.target.value);
3320
+ }
3321
+ }
3322
+ ),
3323
+ multiple && showActions && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "sia-selection-panel__actions", children: [
3324
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { variant: "link", size: "small", disabled: disabled || loading || !enabled.length, onClick: () => batch("all"), children: "\u5168\u9009" }),
3325
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { variant: "link", size: "small", disabled: disabled || loading || !enabled.length, onClick: () => batch("invert"), children: "\u53CD\u9009" }),
3326
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { variant: "link", size: "small", disabled: disabled || loading || !value.length, onClick: () => batch("clear"), children: "\u6E05\u7A7A" }),
3327
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { children: [
3328
+ "\u5DF2\u9009 ",
3329
+ value.length,
3330
+ " \u9879"
3331
+ ] })
3332
+ ] }),
3333
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3334
+ "div",
3335
+ {
3336
+ ref: listRef,
3337
+ role: "listbox",
3338
+ "aria-label": "\u9009\u9879\u5217\u8868",
3339
+ "aria-multiselectable": multiple || void 0,
3340
+ tabIndex: disabled ? -1 : 0,
3341
+ className: "sia-selection-panel__list",
3342
+ style: { maxHeight },
3343
+ onScroll: (event) => setScrollTop(event.currentTarget.scrollTop),
3344
+ onPointerDown: () => setKeyboardActive(false),
3345
+ onBlur: (event) => {
3346
+ if (!event.currentTarget.contains(event.relatedTarget)) setKeyboardActive(false);
3347
+ },
3348
+ "aria-activedescendant": active !== void 0 ? `${id}-${typeof active}-${active}` : void 0,
3349
+ onKeyDown: (event) => {
3350
+ if (event.target instanceof HTMLInputElement) return;
3351
+ if (disabled || loading || !enabled.length) return;
3352
+ const index = enabled.findIndex((option) => option.value === active);
3353
+ if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) {
3354
+ event.preventDefault();
3355
+ setKeyboardActive(true);
3356
+ setDeselectedHover(void 0);
3357
+ 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)));
3358
+ const option = enabled[next];
3359
+ setActive(option.value);
3360
+ const row = rows.find((row2) => row2.items?.includes(option));
3361
+ if (row && listRef.current) {
3362
+ listRef.current.scrollTop = Math.max(0, row.top - maxHeight / 2);
3363
+ setScrollTop(listRef.current.scrollTop);
3364
+ }
3365
+ } else if ((event.key === "Enter" || event.key === " ") && index >= 0) {
3366
+ event.preventDefault();
3367
+ toggle(enabled[index], true);
3368
+ }
3369
+ },
3370
+ children: loading ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { role: "status", children: "\u52A0\u8F7D\u4E2D\u2026" }) : !rows.length ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "sia-selection-panel__empty", children: "\u6682\u65E0\u5339\u914D\u9009\u9879" }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { style: { height: totalHeight, position: "relative" }, children: renderedRows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3371
+ "div",
3372
+ {
3373
+ className: row.title !== void 0 ? "sia-selection-panel__group" : "sia-selection-panel__row",
3374
+ style: { position: "absolute", top: row.top, height: row.height, width: "100%", gridTemplateColumns: `repeat(${count}, minmax(0, 1fr))` },
3375
+ children: row.title ?? row.items?.map((option, index) => option.optionType === "divider" ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { role: "separator", className: "sia-selection-panel__divider" }, `divider-${index}`) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Tooltip, { title: option.disabled ? option.disabledTip : void 0, placement: "right", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3376
+ "div",
3377
+ {
3378
+ role: "option",
3379
+ id: `${id}-${typeof option.value}-${option.value}`,
3380
+ tabIndex: -1,
3381
+ "aria-selected": selected.has(option.value),
3382
+ "aria-disabled": disabled || option.disabled || void 0,
3383
+ className: `sia-selection-panel__option${keyboardActive && active === option.value ? " is-active" : ""}`,
3384
+ "data-deselected-hover": deselectedHover === option.value || void 0,
3385
+ onPointerLeave: () => {
3386
+ if (deselectedHover === option.value) setDeselectedHover(void 0);
3387
+ },
3388
+ onClick: (event) => {
3389
+ if (!event.target.closest(".sia-checkbox")) toggle(option);
3390
+ },
3391
+ children: multiple ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Checkbox2, { checked: selected.has(option.value), disabled: disabled || loading || option.disabled, tabIndex: -1, onChange: () => toggle(option), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "sia-selection-panel__text", children: [
3392
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "sia-selection-panel__label", children: showValue || displayField === "label" ? option.label : String(option.value) }),
3393
+ showValue && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("small", { children: String(option.value) })
3394
+ ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "sia-selection-panel__text", children: [
3395
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "sia-selection-panel__label", children: showValue || displayField === "label" ? option.label : String(option.value) }),
3396
+ showValue && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("small", { children: String(option.value) })
3397
+ ] })
3398
+ }
3399
+ ) }, `${typeof option.value}-${option.value}`))
3400
+ },
3401
+ row.key
3402
+ )) })
3403
+ }
3404
+ )
3405
+ ] });
3406
+ }
3407
+
3408
+ // src/components/OverflowTags.tsx
3409
+ var import_react21 = require("react");
3410
+ var import_jsx_runtime20 = require("react/jsx-runtime");
3411
+ function OverflowTags({ items, maxCount: maxCount2, className = "", tagClassName, restClassName = "" }) {
3412
+ const rootRef = (0, import_react21.useRef)(null);
3413
+ const measureRef = (0, import_react21.useRef)(null);
3414
+ const limit = Math.min(items.length, Math.max(0, Math.floor(maxCount2) || 0));
3415
+ const [visibleCount, setVisibleCount] = (0, import_react21.useState)(0);
3416
+ (0, import_react21.useLayoutEffect)(() => {
3417
+ const root = rootRef.current;
3418
+ const measure = measureRef.current;
3419
+ if (!root || !measure) return;
3420
+ const update = () => {
3421
+ const gap = Number.parseFloat(getComputedStyle(root).columnGap) || 0;
3422
+ const widths = Array.from(measure.children, (child) => child.getBoundingClientRect().width);
3423
+ let used = 0;
3424
+ let fitting = 0;
3425
+ for (let count2 = 1; count2 <= limit; count2 += 1) {
3426
+ used += widths[count2 - 1] + (count2 > 1 ? gap : 0);
3427
+ const rest = count2 < items.length ? gap + widths[limit + count2] : 0;
3428
+ if (used + rest <= root.clientWidth) fitting = count2;
3429
+ }
3430
+ setVisibleCount((previous) => previous === fitting ? previous : fitting);
3431
+ };
3432
+ update();
3433
+ const observer = new ResizeObserver(update);
3434
+ observer.observe(root);
3435
+ for (const child of measure.children) observer.observe(child);
3436
+ return () => observer.disconnect();
3437
+ }, [items, limit]);
3438
+ const count = Math.min(visibleCount, limit);
3439
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { ref: rootRef, className: `sia-overflow-tags ${className}`.trim(), children: [
3440
+ items.slice(0, count).map((item) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: tagClassName, children: item.label }, item.key)),
3441
+ items.length > count ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { className: `${tagClassName} sia-overflow-tags__rest ${restClassName}`.trim(), children: [
3442
+ "+",
3443
+ items.length - count
3444
+ ] }) : null,
3445
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { ref: measureRef, className: "sia-overflow-tags__measure", "aria-hidden": "true", children: [
3446
+ items.slice(0, limit).map((item) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: tagClassName, children: item.label }, item.key)),
3447
+ Array.from({ length: limit + 1 }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { className: `${tagClassName} ${restClassName}`.trim(), children: [
3448
+ "+",
3449
+ items.length - index
3450
+ ] }, `rest-${index}`))
3451
+ ] })
3452
+ ] });
3453
+ }
3454
+
3452
3455
  // src/components/Select.tsx
3453
3456
  var import_jsx_runtime21 = require("react/jsx-runtime");
3454
3457
  function defaultFilterOption(query, option) {
@@ -3511,6 +3514,8 @@ var Select = (0, import_react22.forwardRef)(function Select2({
3511
3514
  const [query, setQuery] = (0, import_react22.useState)("");
3512
3515
  const [activeIndex, setActiveIndex] = (0, import_react22.useState)(-1);
3513
3516
  const [scrollTop, setScrollTop] = (0, import_react22.useState)(0);
3517
+ const [dropdownFontSize, setDropdownFontSize] = (0, import_react22.useState)();
3518
+ const pendingSelectedScroll = (0, import_react22.useRef)(false);
3514
3519
  const deferredQuery = (0, import_react22.useDeferredValue)(query.trim());
3515
3520
  const initialValue = defaultValue === void 0 ? mode === "multiple" ? [] : null : defaultValue;
3516
3521
  const [currentValue, setCurrentValue] = useControllableState({
@@ -3568,10 +3573,31 @@ var Select = (0, import_react22.forwardRef)(function Select2({
3568
3573
  (0, import_react22.useEffect)(() => {
3569
3574
  if (disabled || loading) closeDropdown();
3570
3575
  }, [disabled, loading]);
3576
+ (0, import_react22.useEffect)(() => {
3577
+ if (!open || popupMode !== "dropdown" || !pendingSelectedScroll.current || query) return;
3578
+ const index = filteredOptions.findIndex((option) => selectedValueSet.has(option.value));
3579
+ if (index < 0) return;
3580
+ const frame = requestAnimationFrame(() => {
3581
+ const list = listRef.current;
3582
+ if (!list) return;
3583
+ const item = virtualEnabled ? null : list.querySelectorAll('[role="option"]')[index];
3584
+ const top = virtualEnabled ? index * optionHeight : item ? item.getBoundingClientRect().top - list.getBoundingClientRect().top + list.scrollTop : 0;
3585
+ list.scrollTop = Math.max(0, top - (list.clientHeight - (item?.offsetHeight ?? optionHeight)) / 2);
3586
+ setScrollTop(list.scrollTop);
3587
+ pendingSelectedScroll.current = false;
3588
+ });
3589
+ return () => cancelAnimationFrame(frame);
3590
+ }, [open, popupMode, filteredOptions, selectedValueSet, virtualEnabled, optionHeight, query]);
3591
+ (0, import_react22.useLayoutEffect)(() => {
3592
+ if (!open || popupMode !== "dropdown") return;
3593
+ const trigger = rootRef.current?.querySelector(".sia-select__trigger");
3594
+ if (trigger) setDropdownFontSize(getComputedStyle(trigger).fontSize);
3595
+ }, [open, popupMode, size]);
3571
3596
  function firstEnabledIndex() {
3572
3597
  return filteredOptions.findIndex((option) => !option.disabled);
3573
3598
  }
3574
3599
  function closeDropdown() {
3600
+ pendingSelectedScroll.current = false;
3575
3601
  setOpen(false);
3576
3602
  setQuery("");
3577
3603
  setScrollTop(0);
@@ -3596,6 +3622,7 @@ var Select = (0, import_react22.forwardRef)(function Select2({
3596
3622
  }
3597
3623
  function openDropdown() {
3598
3624
  if (disabled || loading) return;
3625
+ pendingSelectedScroll.current = true;
3599
3626
  setOpenedMode(automaticMode);
3600
3627
  const selectedIndex = filteredOptions.findIndex((option) => selectedValueSet.has(option.value) && !option.disabled);
3601
3628
  setActiveIndex(selectedIndex >= 0 ? selectedIndex : firstEnabledIndex());
@@ -3770,7 +3797,7 @@ var Select = (0, import_react22.forwardRef)(function Select2({
3770
3797
  }
3771
3798
  ),
3772
3799
  allowClear && hasValue && !disabled && !loading ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { className: "sia-select__clear", type: "button", "aria-label": "\u6E05\u7A7A\u9009\u62E9", onClick: clearValue, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Icon, { name: "circle-close", variant: "filled", size: 15 }) }) : null,
3773
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(PopupPortal, { ref: popupRef, anchorRef: rootRef, open: open && popupMode === "dropdown", className: `sia-select__dropdown${filteredOptions.length === 0 && !canSubmitInput ? " sia-select__dropdown--empty" : ""}`, children: [
3800
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(PopupPortal, { ref: popupRef, anchorRef: rootRef, open: open && popupMode === "dropdown", style: { fontSize: dropdownFontSize }, className: `sia-select__dropdown${filteredOptions.length === 0 && !canSubmitInput ? " sia-select__dropdown--empty" : ""}`, children: [
3774
3801
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(FloatingScrollbarProvider, { targetRef: listRef }),
3775
3802
  showSearch || allowInput ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "sia-select__search", children: [
3776
3803
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Icon, { name: "search", size: 15 }),
package/dist/core.css CHANGED
@@ -2393,6 +2393,7 @@ fieldset:disabled .sia-input-number__floating-placeholder {
2393
2393
  padding-inline: 16px;
2394
2394
  }
2395
2395
  .sia-message {
2396
+ font-size: calc(var(--sia-font-size, 16px) - 1px);
2396
2397
  display: flex;
2397
2398
  align-items: center;
2398
2399
  gap: 9px;
@@ -6223,7 +6224,7 @@ fieldset:disabled .sia-input-number__floating-placeholder {
6223
6224
  width: max-content;
6224
6225
  overflow: hidden;
6225
6226
  color: var(--sia-color-text);
6226
- font-size: var(--sia-font-size);
6227
+ font-size: calc(var(--sia-font-size) + 1px);
6227
6228
  background: var(--sia-color-surface);
6228
6229
  border: 1px solid var(--sia-color-border);
6229
6230
  border-radius: 10px;
@@ -6235,7 +6236,7 @@ fieldset:disabled .sia-input-number__floating-placeholder {
6235
6236
  }
6236
6237
  .sia-time-panel .sia-date-panel__time > strong {
6237
6238
  font-variant-numeric: tabular-nums;
6238
- font-size: 15px;
6239
+ font-size: 16px;
6239
6240
  }
6240
6241
  .sia-time-panel .sia-date-panel__time-columns {
6241
6242
  grid-auto-columns: 64px;
@@ -6398,6 +6399,7 @@ fieldset:disabled .sia-input-number__floating-placeholder {
6398
6399
  }
6399
6400
  }
6400
6401
  .sia-date-panel {
6402
+ font-size: calc(1em + 1px);
6401
6403
  width: 282px;
6402
6404
  max-width: calc(100vw - 16px);
6403
6405
  max-height: min(640px, calc(100vh - 16px));
@@ -6501,7 +6503,7 @@ fieldset:disabled .sia-input-number__floating-placeholder {
6501
6503
  color: var(--sia-color-primary-text);
6502
6504
  background: color-mix(in srgb, var(--sia-color-primary) 10%, transparent);
6503
6505
  border-radius: 4px;
6504
- font-size: 11px;
6506
+ font-size: 12px;
6505
6507
  font-weight: 600;
6506
6508
  }
6507
6509
  .sia-date-panel__nav {
@@ -6644,9 +6646,8 @@ fieldset:disabled .sia-input-number__floating-placeholder {
6644
6646
  }
6645
6647
  .sia-date-panel__time-columns > div {
6646
6648
  height: 100%;
6647
- overflow: var(--sia-scroll-overflow, auto);
6649
+ overflow: auto;
6648
6650
  padding: 4px;
6649
- scrollbar-width: thin;
6650
6651
  }
6651
6652
  .sia-date-panel__time-columns > div + div {
6652
6653
  border-inline-start: 1px solid var(--sia-color-border);
@@ -9682,6 +9683,10 @@ button.sia-treemap__tile:focus-visible,
9682
9683
  text-align: center;
9683
9684
  color: var(--sia-color-text-secondary, #777);
9684
9685
  }
9686
+ .sia-date-panel button,
9687
+ .sia-time-panel button {
9688
+ font: inherit;
9689
+ }
9685
9690
 
9686
9691
  /* src/title-tooltip.css */
9687
9692
  body > .sia-title-tooltip[data-sia-popup-layer] {
package/dist/core.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { d as Breadcrumb, e as BreadcrumbItem, f as BreadcrumbProps, h as Card, i as CardAccent, j as CardProps, n as Collapse, o as CollapseItem, p as CollapseKey, q as CollapseProps, x as FilledIconName, y as FloatButton, z as FloatButtonBackTopProps, A as FloatButtonGroupProps, E as FloatButtonProps, G as FloatButtonShape, K as Icon, L as IconName, M as IconProps, N as IconVariant, U as Input, V as InputProps, a0 as MessageConfig, a1 as MessageHandle, a2 as MessageKey, a3 as MessageType, ab as Progress, ac as ProgressProps, ad as ProgressStatus, ag as Segmented, ah as SegmentedOption, ai as SegmentedProps, aj as SegmentedValue, aq as TabItem, ar as Tabs, at as TabsOrientation, au as TabsPosition, av as TabsProps, aw as TabsType, ax as Tag, ay as TagProps, T as TagStatus, az as TagVariant, aD as Toolbar, aE as ToolbarItem, aF as ToolbarProps, aQ as Typography, aR as TypographyLinkProps, aS as TypographyProps, aT as TypographyTitleProps, aU as TypographyType, aV as Upload, aW as UploadChangeInfo, aX as UploadDraggerProps, aY as UploadFile, aZ as UploadFileStatus, a_ as UploadProps, a$ as UploadRequestOptions, b3 as message } from './core-tbb9ZiBY.cjs';
2
- export { f as Button, B as ButtonProps, e as ButtonSize, g as ButtonVariant, h as Modal, d as ModalActionResult, M as ModalOpenConfig, i as ModalProps, j as ModalType, a as OverlayApiHandle, k as Select, S as SelectOption, c as SelectProps, m as SelectValue } from './Select-W_xpkpOW.cjs';
1
+ export { d as Breadcrumb, e as BreadcrumbItem, f as BreadcrumbProps, h as Card, i as CardAccent, j as CardProps, n as Collapse, o as CollapseItem, p as CollapseKey, q as CollapseProps, x as FilledIconName, y as FloatButton, z as FloatButtonBackTopProps, A as FloatButtonGroupProps, E as FloatButtonProps, G as FloatButtonShape, K as Icon, L as IconName, M as IconProps, N as IconVariant, U as Input, V as InputProps, a0 as MessageConfig, a1 as MessageHandle, a2 as MessageKey, a3 as MessageType, ab as Progress, ac as ProgressProps, ad as ProgressStatus, ag as Segmented, ah as SegmentedOption, ai as SegmentedProps, aj as SegmentedValue, aq as TabItem, ar as Tabs, at as TabsOrientation, au as TabsPosition, av as TabsProps, aw as TabsType, ax as Tag, ay as TagProps, T as TagStatus, az as TagVariant, aD as Toolbar, aE as ToolbarItem, aF as ToolbarProps, aQ as Typography, aR as TypographyLinkProps, aS as TypographyProps, aT as TypographyTitleProps, aU as TypographyType, aV as Upload, aW as UploadChangeInfo, aX as UploadDraggerProps, aY as UploadFile, aZ as UploadFileStatus, a_ as UploadProps, a$ as UploadRequestOptions, b3 as message } from './core-BM-wnJRa.cjs';
2
+ export { f as Button, B as ButtonProps, e as ButtonSize, g as ButtonVariant, h as Modal, d as ModalActionResult, M as ModalOpenConfig, i as ModalProps, j as ModalType, a as OverlayApiHandle, k as Select, S as SelectOption, c as SelectProps, m as SelectValue } from './Select-YJbT-MF1.cjs';
3
3
  import 'react';
4
4
  import './shared-Bx4B28Wh.cjs';