@rockshin/tao-ui 0.0.16 → 0.0.17

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.
@@ -101,6 +101,57 @@ button[data-tao-button]:disabled {
101
101
  cursor: not-allowed;
102
102
  }
103
103
 
104
+ [data-tao-button-icon] {
105
+ flex: none;
106
+ justify-content: center;
107
+ align-items: center;
108
+ width: 1.25em;
109
+ height: 1.25em;
110
+ display: inline-flex;
111
+ position: relative;
112
+ }
113
+
114
+ [data-tao-button-icon-idle], [data-tao-button-icon-spin] {
115
+ transition: opacity var(--tao-motion-duration-fast) var(--tao-motion-ease-out);
116
+ justify-content: center;
117
+ align-items: center;
118
+ line-height: 0;
119
+ display: inline-flex;
120
+ position: absolute;
121
+ inset: 0;
122
+ }
123
+
124
+ [data-tao-button-icon-idle] > svg, [data-tao-button-spinner] {
125
+ width: 1.25em;
126
+ height: 1.25em;
127
+ }
128
+
129
+ [data-tao-button-icon]:not([data-tao-loading]) [data-tao-button-icon-spin] {
130
+ opacity: 0;
131
+ }
132
+
133
+ [data-tao-button-icon]:not([data-tao-loading]) [data-tao-button-icon-idle] {
134
+ opacity: 1;
135
+ }
136
+
137
+ [data-tao-button-icon][data-tao-loading] [data-tao-button-icon-idle] {
138
+ opacity: 0;
139
+ }
140
+
141
+ [data-tao-button-icon][data-tao-loading] [data-tao-button-icon-spin] {
142
+ opacity: 1;
143
+ }
144
+
145
+ [data-tao-button-spinner] {
146
+ animation: .8s linear infinite tao-button-spin;
147
+ }
148
+
149
+ @keyframes tao-button-spin {
150
+ to {
151
+ transform: rotate(360deg);
152
+ }
153
+ }
154
+
104
155
  button[data-tao-button]:focus-visible {
105
156
  box-shadow: 0 0 0 var(--tao-ring-width) var(--tao-control-outline);
106
157
  outline: none;
@@ -8,8 +8,12 @@ export interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement
8
8
  size?: TaoSize;
9
9
  disabled?: boolean;
10
10
  loading?: boolean;
11
+ /** Left-leading decorative icon (non-loading state). */
12
+ icon?: ReactNode;
13
+ /** Icon shown while loading. Defaults to a built-in spinner. */
14
+ loadingIcon?: ReactNode;
11
15
  children?: ReactNode;
12
16
  classNames?: SemanticClassNames<ButtonSemanticPart>;
13
17
  styles?: SemanticStyles<ButtonSemanticPart>;
14
18
  }
15
- export declare function Button({ variant, size, disabled, loading, children, className, style, classNames, styles, ...rest }: ButtonProps): import("react/jsx-runtime").JSX.Element;
19
+ export declare function Button({ variant, size, disabled, loading, icon, loadingIcon, children, className, style, classNames, styles, ...rest }: ButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -1,73 +1,102 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { c } from "react/compiler-runtime";
3
3
  import { useTaoConfig } from "../../provider/tao-provider.js";
4
4
  import { cx } from "../../utils/semantic.js";
5
5
  import "./button.css";
6
6
  function Button(t0) {
7
- const $ = c(26);
7
+ const $ = c(34);
8
8
  let children;
9
9
  let className;
10
10
  let classNames;
11
11
  let disabled;
12
+ let icon;
12
13
  let loading;
14
+ let loadingIcon;
13
15
  let rest;
14
16
  let size;
15
17
  let style;
16
18
  let styles;
17
19
  let t1;
18
20
  if ($[0] !== t0) {
19
- ({ variant: t1, size, disabled, loading, children, className, style, classNames, styles, ...rest } = t0);
21
+ ({ variant: t1, size, disabled, loading, icon, loadingIcon, children, className, style, classNames, styles, ...rest } = t0);
20
22
  $[0] = t0;
21
23
  $[1] = children;
22
24
  $[2] = className;
23
25
  $[3] = classNames;
24
26
  $[4] = disabled;
25
- $[5] = loading;
26
- $[6] = rest;
27
- $[7] = size;
28
- $[8] = style;
29
- $[9] = styles;
30
- $[10] = t1;
27
+ $[5] = icon;
28
+ $[6] = loading;
29
+ $[7] = loadingIcon;
30
+ $[8] = rest;
31
+ $[9] = size;
32
+ $[10] = style;
33
+ $[11] = styles;
34
+ $[12] = t1;
31
35
  } else {
32
36
  children = $[1];
33
37
  className = $[2];
34
38
  classNames = $[3];
35
39
  disabled = $[4];
36
- loading = $[5];
37
- rest = $[6];
38
- size = $[7];
39
- style = $[8];
40
- styles = $[9];
41
- t1 = $[10];
40
+ icon = $[5];
41
+ loading = $[6];
42
+ loadingIcon = $[7];
43
+ rest = $[8];
44
+ size = $[9];
45
+ style = $[10];
46
+ styles = $[11];
47
+ t1 = $[12];
42
48
  }
43
49
  const variant = void 0 === t1 ? "primary" : t1;
44
50
  const ctx = useTaoConfig();
45
51
  const resolvedSize = size ?? ctx.size;
46
52
  const resolvedDisabled = disabled ?? ctx.disabled ?? false;
47
53
  const isDisabled = resolvedDisabled || loading;
54
+ const hasIconSlot = null != icon || loading;
48
55
  const t2 = classNames?.root;
49
56
  let t3;
50
- if ($[11] !== className || $[12] !== t2) {
57
+ if ($[13] !== className || $[14] !== t2) {
51
58
  t3 = cx(t2, className);
52
- $[11] = className;
53
- $[12] = t2;
54
- $[13] = t3;
55
- } else t3 = $[13];
59
+ $[13] = className;
60
+ $[14] = t2;
61
+ $[15] = t3;
62
+ } else t3 = $[15];
56
63
  const t4 = styles?.root;
57
64
  let t5;
58
- if ($[14] !== style || $[15] !== t4) {
65
+ if ($[16] !== style || $[17] !== t4) {
59
66
  t5 = {
60
67
  ...t4,
61
68
  ...style
62
69
  };
63
- $[14] = style;
64
- $[15] = t4;
65
- $[16] = t5;
66
- } else t5 = $[16];
70
+ $[16] = style;
71
+ $[17] = t4;
72
+ $[18] = t5;
73
+ } else t5 = $[18];
67
74
  const t6 = loading || void 0;
68
75
  let t7;
69
- if ($[17] !== children || $[18] !== isDisabled || $[19] !== resolvedSize || $[20] !== rest || $[21] !== t3 || $[22] !== t5 || $[23] !== t6 || $[24] !== variant) {
70
- t7 = /*#__PURE__*/ jsx("button", {
76
+ if ($[19] !== hasIconSlot || $[20] !== icon || $[21] !== loading || $[22] !== loadingIcon) {
77
+ t7 = hasIconSlot && /*#__PURE__*/ jsxs("span", {
78
+ "data-tao-button-icon": "",
79
+ "data-tao-loading": loading || void 0,
80
+ children: [
81
+ null != icon && /*#__PURE__*/ jsx("span", {
82
+ "data-tao-button-icon-idle": "",
83
+ children: icon
84
+ }),
85
+ /*#__PURE__*/ jsx("span", {
86
+ "data-tao-button-icon-spin": "",
87
+ children: loadingIcon ?? /*#__PURE__*/ jsx(LoadingSpinner, {})
88
+ })
89
+ ]
90
+ });
91
+ $[19] = hasIconSlot;
92
+ $[20] = icon;
93
+ $[21] = loading;
94
+ $[22] = loadingIcon;
95
+ $[23] = t7;
96
+ } else t7 = $[23];
97
+ let t8;
98
+ if ($[24] !== children || $[25] !== isDisabled || $[26] !== resolvedSize || $[27] !== rest || $[28] !== t3 || $[29] !== t5 || $[30] !== t6 || $[31] !== t7 || $[32] !== variant) {
99
+ t8 = /*#__PURE__*/ jsxs("button", {
71
100
  type: "button",
72
101
  ...rest,
73
102
  className: t3,
@@ -77,18 +106,46 @@ function Button(t0) {
77
106
  "data-tao-button": "",
78
107
  "data-tao-variant": variant,
79
108
  "data-tao-size": resolvedSize,
80
- children: children
109
+ children: [
110
+ t7,
111
+ children
112
+ ]
113
+ });
114
+ $[24] = children;
115
+ $[25] = isDisabled;
116
+ $[26] = resolvedSize;
117
+ $[27] = rest;
118
+ $[28] = t3;
119
+ $[29] = t5;
120
+ $[30] = t6;
121
+ $[31] = t7;
122
+ $[32] = variant;
123
+ $[33] = t8;
124
+ } else t8 = $[33];
125
+ return t8;
126
+ }
127
+ function LoadingSpinner() {
128
+ const $ = c(1);
129
+ let t0;
130
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
131
+ t0 = /*#__PURE__*/ jsx("svg", {
132
+ "data-tao-button-spinner": "",
133
+ viewBox: "0 0 50 50",
134
+ fill: "none",
135
+ "aria-hidden": "true",
136
+ focusable: "false",
137
+ children: /*#__PURE__*/ jsx("circle", {
138
+ cx: "25",
139
+ cy: "25",
140
+ r: "20",
141
+ stroke: "currentColor",
142
+ strokeWidth: "5",
143
+ strokeLinecap: "round",
144
+ strokeDasharray: "90 40"
145
+ })
81
146
  });
82
- $[17] = children;
83
- $[18] = isDisabled;
84
- $[19] = resolvedSize;
85
- $[20] = rest;
86
- $[21] = t3;
87
- $[22] = t5;
88
- $[23] = t6;
89
- $[24] = variant;
90
- $[25] = t7;
91
- } else t7 = $[25];
92
- return t7;
147
+ $[0] = t0;
148
+ } else t0 = $[0];
149
+ return t0;
93
150
  }
94
151
  export { Button };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rockshin/tao-ui",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "type": "module",
5
5
  "description": "A modern React 19 component library with semantic DOM customization and OKLCH-based theming.",
6
6
  "keywords": [