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

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/chart.js CHANGED
@@ -56,9 +56,8 @@ import {
56
56
  smoothSvgPath,
57
57
  svgArcPath,
58
58
  transferCompositeValue
59
- } from "./chunk-Q4FDV6KP.js";
60
- import "./chunk-SMCYEPBL.js";
61
- import "./chunk-IKAMZNCK.js";
59
+ } from "./chunk-BDS42FR3.js";
60
+ import "./chunk-JZWTTSOZ.js";
62
61
  import "./chunk-H7IAG72O.js";
63
62
  export {
64
63
  BarChart,
@@ -1,9 +1,7 @@
1
1
  import {
2
+ Button,
2
3
  TextArea
3
- } from "./chunk-SMCYEPBL.js";
4
- import {
5
- Button
6
- } from "./chunk-IKAMZNCK.js";
4
+ } from "./chunk-JZWTTSOZ.js";
7
5
  import {
8
6
  withTitleTooltip
9
7
  } from "./chunk-H7IAG72O.js";
@@ -2,10 +2,10 @@ import {
2
2
  Dropdown,
3
3
  Icon,
4
4
  Input
5
- } from "./chunk-YMOOL62S.js";
5
+ } from "./chunk-XHLIIDD2.js";
6
6
  import {
7
7
  Button
8
- } from "./chunk-IKAMZNCK.js";
8
+ } from "./chunk-JZWTTSOZ.js";
9
9
  import {
10
10
  useFloatingPlaceholder,
11
11
  withTitleTooltip
@@ -0,0 +1,131 @@
1
+ import {
2
+ useControlSize,
3
+ useFloatingPlaceholder,
4
+ withTitleTooltip
5
+ } from "./chunk-H7IAG72O.js";
6
+
7
+ // src/components/Button.tsx
8
+ import { forwardRef, useRef } from "react";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
10
+ var Button = forwardRef(function Button2({
11
+ variant = "default",
12
+ size: sizeProp,
13
+ loading = false,
14
+ block = false,
15
+ danger = false,
16
+ icon,
17
+ iconPosition = "start",
18
+ className = "",
19
+ children,
20
+ disabled,
21
+ onClick,
22
+ style,
23
+ ...props
24
+ }, forwardedRef) {
25
+ const size = useControlSize(sizeProp);
26
+ const localRef = useRef(null);
27
+ function setRef(node) {
28
+ localRef.current = node;
29
+ if (typeof forwardedRef === "function") forwardedRef(node);
30
+ else if (forwardedRef) forwardedRef.current = node;
31
+ }
32
+ function handleClick(event) {
33
+ const button = localRef.current;
34
+ if (button && variant === "primary") {
35
+ const rect = button.getBoundingClientRect();
36
+ button.style.setProperty("--sia-wave-x", `${event.clientX - rect.left}px`);
37
+ button.style.setProperty("--sia-wave-y", `${event.clientY - rect.top}px`);
38
+ button.dataset.wave = "active";
39
+ window.setTimeout(() => delete button.dataset.wave, 360);
40
+ }
41
+ onClick?.(event);
42
+ }
43
+ const mergedStyle = block ? { ...style, width: "100%" } : style ?? {};
44
+ return /* @__PURE__ */ jsxs(
45
+ "button",
46
+ {
47
+ ref: setRef,
48
+ type: "button",
49
+ className: `sia-button sia-button--${variant} sia-button--${size}${danger ? " sia-button--danger" : ""} ${className}`.trim(),
50
+ "aria-busy": loading || void 0,
51
+ disabled: disabled || loading,
52
+ onClick: handleClick,
53
+ style: mergedStyle,
54
+ ...withTitleTooltip(props),
55
+ children: [
56
+ loading ? /* @__PURE__ */ jsx("span", { className: "sia-button__spinner", "aria-hidden": "true" }) : icon && iconPosition === "start" ? /* @__PURE__ */ jsx("span", { className: "sia-button__icon", children: icon }) : null,
57
+ children !== void 0 && children !== null ? /* @__PURE__ */ jsx("span", { children }) : null,
58
+ !loading && icon && iconPosition === "end" ? /* @__PURE__ */ jsx("span", { className: "sia-button__icon", children: icon }) : null
59
+ ]
60
+ }
61
+ );
62
+ });
63
+
64
+ // src/components/TextArea.tsx
65
+ import { forwardRef as forwardRef2, useId, useState } from "react";
66
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
67
+ var TextArea = forwardRef2(function TextArea2({
68
+ label,
69
+ hint,
70
+ status = "default",
71
+ size: sizeProp,
72
+ showCount = false,
73
+ placeholder,
74
+ placeholderMode,
75
+ className = "",
76
+ id,
77
+ disabled,
78
+ value,
79
+ defaultValue,
80
+ maxLength,
81
+ onChange,
82
+ ...props
83
+ }, ref) {
84
+ const size = useControlSize(sizeProp);
85
+ const fallbackId = useId();
86
+ const textAreaId = id ?? fallbackId;
87
+ const [uncontrolledValue, setUncontrolledValue] = useState(() => defaultValue === void 0 ? "" : String(defaultValue));
88
+ const currentText = value !== void 0 ? String(value) : uncontrolledValue;
89
+ const floating = useFloatingPlaceholder({ mode: placeholderMode, placeholder, filled: currentText.length > 0 });
90
+ const hintId = `${textAreaId}-hint`;
91
+ const describedBy = [props["aria-describedby"], hint ? hintId : null].filter(Boolean).join(" ") || void 0;
92
+ function handleChange(event) {
93
+ setUncontrolledValue(event.target.value);
94
+ onChange?.(event);
95
+ }
96
+ const control = /* @__PURE__ */ jsxs2("span", { className: `sia-textarea-control sia-textarea-control--${size} sia-textarea-control--${status}${floating.className}${disabled ? " is-disabled" : ""}`, children: [
97
+ /* @__PURE__ */ jsx2(
98
+ "textarea",
99
+ {
100
+ ...withTitleTooltip(props),
101
+ ref,
102
+ id: textAreaId,
103
+ className: "sia-textarea",
104
+ disabled,
105
+ value,
106
+ defaultValue,
107
+ maxLength,
108
+ placeholder,
109
+ "aria-describedby": describedBy,
110
+ "aria-invalid": status === "error" || void 0,
111
+ onChange: handleChange
112
+ }
113
+ ),
114
+ floating.label,
115
+ showCount ? /* @__PURE__ */ jsxs2("span", { className: `sia-textarea-control__count${maxLength !== void 0 && currentText.length >= maxLength ? " is-limit" : ""}`, "aria-live": "polite", children: [
116
+ currentText.length,
117
+ maxLength !== void 0 ? `/${maxLength}` : null
118
+ ] }) : null
119
+ ] });
120
+ if (!label && !hint) return /* @__PURE__ */ jsx2("span", { className: `sia-field ${className}`.trim(), children: control });
121
+ return /* @__PURE__ */ jsxs2("span", { className: `sia-field ${className}`.trim(), children: [
122
+ label ? /* @__PURE__ */ jsx2("label", { className: "sia-field__label", htmlFor: textAreaId, children: label }) : null,
123
+ control,
124
+ hint ? /* @__PURE__ */ jsx2("span", { id: hintId, className: `sia-field__hint sia-field__hint--${status}`, children: hint }) : null
125
+ ] });
126
+ });
127
+
128
+ export {
129
+ Button,
130
+ TextArea
131
+ };