@sia.soul/sia-react-ui 0.1.107 → 0.1.109

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.
@@ -104,6 +104,7 @@ function Card({
104
104
  defaultSelected = false,
105
105
  disabled = false,
106
106
  onSelectedChange,
107
+ onAction,
107
108
  hoverActions,
108
109
  accent,
109
110
  accentColor,
@@ -112,6 +113,7 @@ function Card({
112
113
  defaultCollapsed = false,
113
114
  onCollapsedChange,
114
115
  bodyHeight,
116
+ fill = false,
115
117
  bodyClassName = "",
116
118
  bodyStyle,
117
119
  className = "",
@@ -124,6 +126,7 @@ function Card({
124
126
  const [internalCollapsed, setInternalCollapsed] = useState2(defaultCollapsed);
125
127
  const [internalSelected, setInternalSelected] = useState2(defaultSelected);
126
128
  const isSelected = selected ?? internalSelected;
129
+ const actionable = Boolean(onAction) && !selectable;
127
130
  function toggleSelected() {
128
131
  if (!selectable || disabled) return;
129
132
  const next = !isSelected;
@@ -146,24 +149,28 @@ function Card({
146
149
  return /* @__PURE__ */ jsxs2(
147
150
  "section",
148
151
  {
149
- className: `sia-card${!bordered ? " sia-card--borderless" : ""}${isCollapsed ? " sia-card--collapsed" : ""}${selectable ? " sia-card--selectable" : ""}${selectable && isSelected ? " sia-card--selected" : ""}${hoverActions ? " sia-card--hover-actions" : ""} ${className}`.trim(),
152
+ className: `sia-card${fill ? " sia-card--fill" : ""}${fill && bodyHeight !== void 0 ? " sia-card--body-height" : ""}${!bordered ? " sia-card--borderless" : ""}${isCollapsed ? " sia-card--collapsed" : ""}${selectable ? " sia-card--selectable" : ""}${actionable ? " sia-card--actionable" : ""}${selectable && isSelected ? " sia-card--selected" : ""}${hoverActions ? " sia-card--hover-actions" : ""} ${className}`.trim(),
150
153
  style: mergedStyle,
151
- role: selectable ? "checkbox" : void 0,
154
+ role: selectable ? "checkbox" : actionable ? "button" : void 0,
152
155
  "aria-checked": selectable ? isSelected : void 0,
153
- "aria-disabled": selectable ? disabled : void 0,
154
- tabIndex: selectable && !disabled ? 0 : void 0,
156
+ "aria-disabled": selectable || actionable ? disabled : void 0,
157
+ tabIndex: (selectable || actionable) && !disabled ? 0 : void 0,
155
158
  ...withTitleTooltip(props),
156
159
  onClick: (event) => {
157
160
  onClick?.(event);
158
161
  const target = event.target;
159
162
  const interactive = target.closest('button, a, input, select, textarea, label, [role="button"], [role="checkbox"], [role="radio"], [role="switch"], [contenteditable="true"], [tabindex]');
160
- if (!event.defaultPrevented && (!interactive || interactive === event.currentTarget)) toggleSelected();
163
+ if (!event.defaultPrevented && (!interactive || interactive === event.currentTarget)) {
164
+ toggleSelected();
165
+ if (actionable && !disabled) onAction?.();
166
+ }
161
167
  },
162
168
  onKeyDown: (event) => {
163
169
  onKeyDown?.(event);
164
- if (!event.defaultPrevented && event.target === event.currentTarget && selectable && (event.key === "Enter" || event.key === " ")) {
170
+ if (!event.defaultPrevented && event.target === event.currentTarget && (selectable || actionable) && (event.key === "Enter" || event.key === " ")) {
165
171
  event.preventDefault();
166
172
  toggleSelected();
173
+ if (actionable && !disabled) onAction?.();
167
174
  }
168
175
  },
169
176
  children: [
@@ -77,12 +77,14 @@ interface CardProps extends Omit<HTMLAttributes<HTMLElement>, "title"> {
77
77
  */
78
78
  defaultSelected?: boolean;
79
79
  /**
80
- * 禁止切换选中,不禁用卡片内独立操作。
80
+ * 禁止切换选中或触发 onAction,不禁用卡片内独立操作。
81
81
  * @defaultValue false
82
82
  */
83
83
  disabled?: boolean;
84
84
  /** 用户切换选中时通知新的布尔状态;禁用时不触发。 */
85
85
  onSelectedChange?: (selected: boolean) => void;
86
+ /** 点击卡片非交互区域或聚焦卡片后按 Enter/空格时执行;提供后使用按钮语义和框架交互样式。disabled 为 true 或 selectable 为 true 时不触发,内部按钮、链接及表单控件保持独立操作。 */
87
+ onAction?: () => void;
86
88
  /** 鼠标移入或键盘聚焦卡片时从底部滑入的操作区;触屏设备始终显示。 */
87
89
  hoverActions?: ReactNode;
88
90
  /** 强调装饰样式。 */
@@ -105,6 +107,8 @@ interface CardProps extends Omit<HTMLAttributes<HTMLElement>, "title"> {
105
107
  onCollapsedChange?: (collapsed: boolean) => void;
106
108
  /** 固定内容区高度并开启内部滚动 */
107
109
  bodyHeight?: number | string;
110
+ /** 填充父容器分配的高度,标题固定、正文占用剩余空间;父容器必须提供确定高度或弹性分配。bodyHeight 显式指定时优先使用该正文高度。默认 false。 */
111
+ fill?: boolean;
108
112
  /**
109
113
  * 内容区域的 CSS 类名。
110
114
  * @defaultValue ""
@@ -114,7 +118,7 @@ interface CardProps extends Omit<HTMLAttributes<HTMLElement>, "title"> {
114
118
  bodyStyle?: CSSProperties;
115
119
  }
116
120
  /** 卡片组件。 */
117
- declare function Card({ bordered, title, description, extra, selectable, selected, showSelectedIndicator, defaultSelected, disabled, onSelectedChange, hoverActions, accent, accentColor, collapsible, collapsed, defaultCollapsed, onCollapsedChange, bodyHeight, bodyClassName, bodyStyle, className, style, children, onClick, onKeyDown, ...props }: CardProps): react.JSX.Element;
121
+ declare function Card({ bordered, title, description, extra, selectable, selected, showSelectedIndicator, defaultSelected, disabled, onSelectedChange, onAction, hoverActions, accent, accentColor, collapsible, collapsed, defaultCollapsed, onCollapsedChange, bodyHeight, fill, bodyClassName, bodyStyle, className, style, children, onClick, onKeyDown, ...props }: CardProps): react.JSX.Element;
118
122
 
119
123
  declare const iconPaths: {
120
124
  "notepad-file": react.JSX.Element;
@@ -77,12 +77,14 @@ interface CardProps extends Omit<HTMLAttributes<HTMLElement>, "title"> {
77
77
  */
78
78
  defaultSelected?: boolean;
79
79
  /**
80
- * 禁止切换选中,不禁用卡片内独立操作。
80
+ * 禁止切换选中或触发 onAction,不禁用卡片内独立操作。
81
81
  * @defaultValue false
82
82
  */
83
83
  disabled?: boolean;
84
84
  /** 用户切换选中时通知新的布尔状态;禁用时不触发。 */
85
85
  onSelectedChange?: (selected: boolean) => void;
86
+ /** 点击卡片非交互区域或聚焦卡片后按 Enter/空格时执行;提供后使用按钮语义和框架交互样式。disabled 为 true 或 selectable 为 true 时不触发,内部按钮、链接及表单控件保持独立操作。 */
87
+ onAction?: () => void;
86
88
  /** 鼠标移入或键盘聚焦卡片时从底部滑入的操作区;触屏设备始终显示。 */
87
89
  hoverActions?: ReactNode;
88
90
  /** 强调装饰样式。 */
@@ -105,6 +107,8 @@ interface CardProps extends Omit<HTMLAttributes<HTMLElement>, "title"> {
105
107
  onCollapsedChange?: (collapsed: boolean) => void;
106
108
  /** 固定内容区高度并开启内部滚动 */
107
109
  bodyHeight?: number | string;
110
+ /** 填充父容器分配的高度,标题固定、正文占用剩余空间;父容器必须提供确定高度或弹性分配。bodyHeight 显式指定时优先使用该正文高度。默认 false。 */
111
+ fill?: boolean;
108
112
  /**
109
113
  * 内容区域的 CSS 类名。
110
114
  * @defaultValue ""
@@ -114,7 +118,7 @@ interface CardProps extends Omit<HTMLAttributes<HTMLElement>, "title"> {
114
118
  bodyStyle?: CSSProperties;
115
119
  }
116
120
  /** 卡片组件。 */
117
- declare function Card({ bordered, title, description, extra, selectable, selected, showSelectedIndicator, defaultSelected, disabled, onSelectedChange, hoverActions, accent, accentColor, collapsible, collapsed, defaultCollapsed, onCollapsedChange, bodyHeight, bodyClassName, bodyStyle, className, style, children, onClick, onKeyDown, ...props }: CardProps): react.JSX.Element;
121
+ declare function Card({ bordered, title, description, extra, selectable, selected, showSelectedIndicator, defaultSelected, disabled, onSelectedChange, onAction, hoverActions, accent, accentColor, collapsible, collapsed, defaultCollapsed, onCollapsedChange, bodyHeight, fill, bodyClassName, bodyStyle, className, style, children, onClick, onKeyDown, ...props }: CardProps): react.JSX.Element;
118
122
 
119
123
  declare const iconPaths: {
120
124
  "notepad-file": react.JSX.Element;
package/dist/core.cjs CHANGED
@@ -2063,6 +2063,7 @@ function Card({
2063
2063
  defaultSelected = false,
2064
2064
  disabled = false,
2065
2065
  onSelectedChange,
2066
+ onAction,
2066
2067
  hoverActions,
2067
2068
  accent,
2068
2069
  accentColor,
@@ -2071,6 +2072,7 @@ function Card({
2071
2072
  defaultCollapsed = false,
2072
2073
  onCollapsedChange,
2073
2074
  bodyHeight,
2075
+ fill = false,
2074
2076
  bodyClassName = "",
2075
2077
  bodyStyle,
2076
2078
  className = "",
@@ -2083,6 +2085,7 @@ function Card({
2083
2085
  const [internalCollapsed, setInternalCollapsed] = (0, import_react10.useState)(defaultCollapsed);
2084
2086
  const [internalSelected, setInternalSelected] = (0, import_react10.useState)(defaultSelected);
2085
2087
  const isSelected = selected ?? internalSelected;
2088
+ const actionable = Boolean(onAction) && !selectable;
2086
2089
  function toggleSelected() {
2087
2090
  if (!selectable || disabled) return;
2088
2091
  const next = !isSelected;
@@ -2105,24 +2108,28 @@ function Card({
2105
2108
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
2106
2109
  "section",
2107
2110
  {
2108
- className: `sia-card${!bordered ? " sia-card--borderless" : ""}${isCollapsed ? " sia-card--collapsed" : ""}${selectable ? " sia-card--selectable" : ""}${selectable && isSelected ? " sia-card--selected" : ""}${hoverActions ? " sia-card--hover-actions" : ""} ${className}`.trim(),
2111
+ className: `sia-card${fill ? " sia-card--fill" : ""}${fill && bodyHeight !== void 0 ? " sia-card--body-height" : ""}${!bordered ? " sia-card--borderless" : ""}${isCollapsed ? " sia-card--collapsed" : ""}${selectable ? " sia-card--selectable" : ""}${actionable ? " sia-card--actionable" : ""}${selectable && isSelected ? " sia-card--selected" : ""}${hoverActions ? " sia-card--hover-actions" : ""} ${className}`.trim(),
2109
2112
  style: mergedStyle,
2110
- role: selectable ? "checkbox" : void 0,
2113
+ role: selectable ? "checkbox" : actionable ? "button" : void 0,
2111
2114
  "aria-checked": selectable ? isSelected : void 0,
2112
- "aria-disabled": selectable ? disabled : void 0,
2113
- tabIndex: selectable && !disabled ? 0 : void 0,
2115
+ "aria-disabled": selectable || actionable ? disabled : void 0,
2116
+ tabIndex: (selectable || actionable) && !disabled ? 0 : void 0,
2114
2117
  ...withTitleTooltip(props),
2115
2118
  onClick: (event) => {
2116
2119
  onClick?.(event);
2117
2120
  const target = event.target;
2118
2121
  const interactive = target.closest('button, a, input, select, textarea, label, [role="button"], [role="checkbox"], [role="radio"], [role="switch"], [contenteditable="true"], [tabindex]');
2119
- if (!event.defaultPrevented && (!interactive || interactive === event.currentTarget)) toggleSelected();
2122
+ if (!event.defaultPrevented && (!interactive || interactive === event.currentTarget)) {
2123
+ toggleSelected();
2124
+ if (actionable && !disabled) onAction?.();
2125
+ }
2120
2126
  },
2121
2127
  onKeyDown: (event) => {
2122
2128
  onKeyDown?.(event);
2123
- if (!event.defaultPrevented && event.target === event.currentTarget && selectable && (event.key === "Enter" || event.key === " ")) {
2129
+ if (!event.defaultPrevented && event.target === event.currentTarget && (selectable || actionable) && (event.key === "Enter" || event.key === " ")) {
2124
2130
  event.preventDefault();
2125
2131
  toggleSelected();
2132
+ if (actionable && !disabled) onAction?.();
2126
2133
  }
2127
2134
  },
2128
2135
  children: [
package/dist/core.css CHANGED
@@ -2597,6 +2597,35 @@ fieldset:disabled .sia-input-number__floating-placeholder {
2597
2597
  position: relative;
2598
2598
  cursor: pointer;
2599
2599
  }
2600
+ .sia-card--actionable {
2601
+ cursor: pointer;
2602
+ }
2603
+ .sia-card--actionable[aria-disabled=true] {
2604
+ cursor: default;
2605
+ }
2606
+ .sia-card--actionable:focus-visible {
2607
+ outline: 2px solid var(--sia-color-primary);
2608
+ outline-offset: 2px;
2609
+ }
2610
+ .sia-card--fill {
2611
+ height: 100%;
2612
+ min-height: 0;
2613
+ min-width: 0;
2614
+ display: flex;
2615
+ flex-direction: column;
2616
+ }
2617
+ .sia-card--fill > .sia-card__header,
2618
+ .sia-card--fill > .sia-card__description {
2619
+ flex-shrink: 0;
2620
+ }
2621
+ .sia-card--fill > .sia-card__body {
2622
+ flex: 1;
2623
+ min-height: 0;
2624
+ min-width: 0;
2625
+ }
2626
+ .sia-card--fill.sia-card--body-height > .sia-card__body {
2627
+ flex: 0 0 auto;
2628
+ }
2600
2629
  .sia-card__selected-corner {
2601
2630
  position: absolute;
2602
2631
  top: 0;
@@ -6067,6 +6096,7 @@ body:has(.sia-window-frame[data-sia-text-selectable=false]) img {
6067
6096
  }
6068
6097
  .sia-checkbox,
6069
6098
  .sia-radio {
6099
+ position: relative;
6070
6100
  display: inline-flex;
6071
6101
  align-items: center;
6072
6102
  gap: 8px;
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 Result, ah as ResultProps, ai as ResultStatus, aj as Segmented, ak as SegmentedOption, al as SegmentedProps, am as SegmentedValue, at as TabItem, au as Tabs, aw as TabsOrientation, ax as TabsPosition, ay as TabsProps, az as TabsType, aA as Tag, aB as TagProps, aC as TagSize, T as TagStatus, aD as TagVariant, aH as Toolbar, aI as ToolbarItem, aJ as ToolbarProps, aU as Typography, aV as TypographyLinkProps, aW as TypographyProps, aX as TypographyTitleProps, aY as TypographyType, aZ as Upload, a_ as UploadChangeInfo, a$ as UploadDraggerProps, b0 as UploadFile, b1 as UploadFileStatus, b4 as UploadProps, b8 as UploadRequestOptions, bc as message } from './core-zpQkbNf_.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 Result, ah as ResultProps, ai as ResultStatus, aj as Segmented, ak as SegmentedOption, al as SegmentedProps, am as SegmentedValue, at as TabItem, au as Tabs, aw as TabsOrientation, ax as TabsPosition, ay as TabsProps, az as TabsType, aA as Tag, aB as TagProps, aC as TagSize, T as TagStatus, aD as TagVariant, aH as Toolbar, aI as ToolbarItem, aJ as ToolbarProps, aU as Typography, aV as TypographyLinkProps, aW as TypographyProps, aX as TypographyTitleProps, aY as TypographyType, aZ as Upload, a_ as UploadChangeInfo, a$ as UploadDraggerProps, b0 as UploadFile, b1 as UploadFileStatus, b4 as UploadProps, b8 as UploadRequestOptions, bc as message } from './core-lGT-8jSj.cjs';
2
2
  export { b as Button, B as ButtonProps, a as ButtonSize, c as ButtonVariant } from './Button-O_pNB3SQ.cjs';
3
3
  export { e as Modal, d as ModalActionResult, M as ModalOpenConfig, f as ModalProps, g as ModalType, a as OverlayApiHandle, h as Select, S as SelectOption, c as SelectProps, j as SelectValue } from './Select-Cf0xz1Tg.cjs';
4
4
  import 'react';
package/dist/core.d.ts 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 Result, ah as ResultProps, ai as ResultStatus, aj as Segmented, ak as SegmentedOption, al as SegmentedProps, am as SegmentedValue, at as TabItem, au as Tabs, aw as TabsOrientation, ax as TabsPosition, ay as TabsProps, az as TabsType, aA as Tag, aB as TagProps, aC as TagSize, T as TagStatus, aD as TagVariant, aH as Toolbar, aI as ToolbarItem, aJ as ToolbarProps, aU as Typography, aV as TypographyLinkProps, aW as TypographyProps, aX as TypographyTitleProps, aY as TypographyType, aZ as Upload, a_ as UploadChangeInfo, a$ as UploadDraggerProps, b0 as UploadFile, b1 as UploadFileStatus, b4 as UploadProps, b8 as UploadRequestOptions, bc as message } from './core-Bm-1bOjF.js';
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 Result, ah as ResultProps, ai as ResultStatus, aj as Segmented, ak as SegmentedOption, al as SegmentedProps, am as SegmentedValue, at as TabItem, au as Tabs, aw as TabsOrientation, ax as TabsPosition, ay as TabsProps, az as TabsType, aA as Tag, aB as TagProps, aC as TagSize, T as TagStatus, aD as TagVariant, aH as Toolbar, aI as ToolbarItem, aJ as ToolbarProps, aU as Typography, aV as TypographyLinkProps, aW as TypographyProps, aX as TypographyTitleProps, aY as TypographyType, aZ as Upload, a_ as UploadChangeInfo, a$ as UploadDraggerProps, b0 as UploadFile, b1 as UploadFileStatus, b4 as UploadProps, b8 as UploadRequestOptions, bc as message } from './core-gI4QB_Nz.js';
2
2
  export { b as Button, B as ButtonProps, a as ButtonSize, c as ButtonVariant } from './Button-BiL3Wjsd.js';
3
3
  export { e as Modal, d as ModalActionResult, M as ModalOpenConfig, f as ModalProps, g as ModalType, a as OverlayApiHandle, h as Select, S as SelectOption, c as SelectProps, j as SelectValue } from './Select-BddM4uXC.js';
4
4
  import 'react';
package/dist/core.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  Typography,
12
12
  Upload,
13
13
  message
14
- } from "./chunk-JEDJQ257.js";
14
+ } from "./chunk-XRHL56EV.js";
15
15
  import "./chunk-RX242MUO.js";
16
16
  import {
17
17
  Select