@skygraph/react 0.5.2 → 0.5.4
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/README.md +70 -70
- package/dist/{Table-BmesoMje.d.ts → Table-CAay8MmA.d.ts} +8 -1
- package/dist/{Table-CpKMOH2x.d.cts → Table-CMKo6Pc3.d.cts} +8 -1
- package/dist/{chunk-ZJF6SJLP.js → chunk-45YW5VSP.js} +44 -10
- package/dist/chunk-45YW5VSP.js.map +1 -0
- package/dist/{chunk-NXB3VAVF.js → chunk-7AA2JPZB.js} +148 -61
- package/dist/chunk-7AA2JPZB.js.map +1 -0
- package/dist/{chunk-Z5UGF7EO.js → chunk-EFDB2ENB.js} +87 -25
- package/dist/chunk-EFDB2ENB.js.map +1 -0
- package/dist/{chunk-UO6VJC3C.js → chunk-KGFFQGCM.js} +3 -3
- package/dist/{chunk-FSV73JI4.js → chunk-PEX2UTNG.js} +2 -2
- package/dist/chunk-VLRLCHEL.js +184 -0
- package/dist/chunk-VLRLCHEL.js.map +1 -0
- package/dist/{chunk-MLEBVELO.js → chunk-Y6XZ5TLD.js} +93 -47
- package/dist/chunk-Y6XZ5TLD.js.map +1 -0
- package/dist/{chunk-GJDDPZH7.js → chunk-ZJC2QUWA.js} +12 -12
- package/dist/chunk-ZJC2QUWA.js.map +1 -0
- package/dist/datagrid.cjs +76 -21
- package/dist/datagrid.cjs.map +1 -1
- package/dist/datagrid.js +3 -3
- package/dist/devtools.cjs +11 -11
- package/dist/devtools.cjs.map +1 -1
- package/dist/devtools.js +1 -1
- package/dist/form.cjs +168 -86
- package/dist/form.cjs.map +1 -1
- package/dist/form.d.cts +1 -1
- package/dist/form.d.ts +1 -1
- package/dist/form.js +3 -3
- package/dist/index.cjs +1549 -1021
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +157 -7
- package/dist/index.d.ts +157 -7
- package/dist/index.js +444 -231
- package/dist/index.js.map +1 -1
- package/dist/table.cjs +344 -221
- package/dist/table.cjs.map +1 -1
- package/dist/table.d.cts +1 -1
- package/dist/table.d.ts +1 -1
- package/dist/table.js +4 -4
- package/dist/tree.cjs.map +1 -1
- package/dist/tree.js +3 -3
- package/package.json +2 -2
- package/dist/chunk-2OCEO636.js +0 -91
- package/dist/chunk-2OCEO636.js.map +0 -1
- package/dist/chunk-GJDDPZH7.js.map +0 -1
- package/dist/chunk-MLEBVELO.js.map +0 -1
- package/dist/chunk-NXB3VAVF.js.map +0 -1
- package/dist/chunk-Z5UGF7EO.js.map +0 -1
- package/dist/chunk-ZJF6SJLP.js.map +0 -1
- /package/dist/{chunk-UO6VJC3C.js.map → chunk-KGFFQGCM.js.map} +0 -0
- /package/dist/{chunk-FSV73JI4.js.map → chunk-PEX2UTNG.js.map} +0 -0
package/README.md
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
# @skygraph/react
|
|
2
|
-
|
|
3
|
-
React adapter for [SkyGraph](https://skygraph.ruslansinkevich.ru/) —
|
|
4
|
-
|
|
5
|
-
> **Easier path — the meta-package:**
|
|
6
|
-
>
|
|
7
|
-
> ```bash
|
|
8
|
-
> npm install skygraph-react
|
|
9
|
-
> ```
|
|
10
|
-
>
|
|
11
|
-
> The meta-package re-exports everything below and auto-loads the CSS as a side effect. No separate `@skygraph/core` install, no manual `import '@skygraph/styles'`. Use this package directly only when you need fine-grained control over the install set.
|
|
12
|
-
|
|
13
|
-
## Install (direct)
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm install @skygraph/react @skygraph/core
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
```ts
|
|
20
|
-
import '@skygraph/styles'
|
|
21
|
-
import { Form, Field, SubmitButton } from '@skygraph/react'
|
|
22
|
-
|
|
23
|
-
export function App() {
|
|
24
|
-
return (
|
|
25
|
-
<Form
|
|
26
|
-
defaultValues={{ email: '' }}
|
|
27
|
-
onSubmit={(values) => console.log(values)}
|
|
28
|
-
>
|
|
29
|
-
<Field name="email" label="Email" rules={[{ type: 'email' }]} />
|
|
30
|
-
<SubmitButton>Submit</SubmitButton>
|
|
31
|
-
</Form>
|
|
32
|
-
)
|
|
33
|
-
}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Components
|
|
37
|
-
|
|
38
|
-
**Data entry:** Button, Input, InputNumber, Textarea, Select, Checkbox, Radio, Switch, Slider, DatePicker, TimePicker, AutoComplete, Rate, Upload, ColorPicker, Cascader, TreeSelect, Mentions
|
|
39
|
-
|
|
40
|
-
**Data display:** Table, DataGrid, Tree, List, Tabs, Collapse, Descriptions, Badge, Tag, Avatar, Calendar, Carousel, Timeline, Steps, Segmented, Skeleton, Diagram
|
|
41
|
-
|
|
42
|
-
**Visualization:** LineChart, BarChart, AreaChart, PieChart, Dashboard, DashboardEditor, Gantt, EventTimeline, ResourceCalendar
|
|
43
|
-
|
|
44
|
-
**Feedback:** Modal, Drawer, Notification, Popconfirm, Tooltip, Progress, Spin, Result, Empty
|
|
45
|
-
|
|
46
|
-
**Navigation:** Menu, Breadcrumb, Dropdown, Pagination, Transfer
|
|
47
|
-
|
|
48
|
-
**Form:** Form, Field, FormList, FormProvider, SchemaForm, SchemaFormEditor, AutoField, SubmitButton
|
|
49
|
-
|
|
50
|
-
**Utility:** Transition (CSS-class-based animations)
|
|
51
|
-
|
|
52
|
-
## Subpath exports
|
|
53
|
-
|
|
54
|
-
| Subpath | Use |
|
|
55
|
-
|---|---|
|
|
56
|
-
| `@skygraph/react` | Full bundle |
|
|
57
|
-
| `@skygraph/react/form` | Form primitives only |
|
|
58
|
-
| `@skygraph/react/table` | Table primitives only |
|
|
59
|
-
| `@skygraph/react/tree` | Tree primitives only |
|
|
60
|
-
| `@skygraph/react/virtual` | Virtual-scroll helpers |
|
|
61
|
-
| `@skygraph/react/datagrid` | DataGrid |
|
|
62
|
-
| `@skygraph/react/devtools` | Optional devtools panel |
|
|
63
|
-
|
|
64
|
-
## Repository
|
|
65
|
-
|
|
66
|
-
[github.com/RuslanSinkevich/skygraph-public](https://github.com/RuslanSinkevich/skygraph-public)
|
|
67
|
-
|
|
68
|
-
## License
|
|
69
|
-
|
|
70
|
-
MIT
|
|
1
|
+
# @skygraph/react
|
|
2
|
+
|
|
3
|
+
React adapter for [SkyGraph](https://skygraph.ruslansinkevich.ru/) — components, hooks and `ConfigProvider` built on the framework-agnostic [`@skygraph/core`](../core) engine. Shares the `.sg-*` CSS contract with the Vue and Angular adapters via [`@skygraph/styles`](../styles).
|
|
4
|
+
|
|
5
|
+
> **Easier path — the meta-package:**
|
|
6
|
+
>
|
|
7
|
+
> ```bash
|
|
8
|
+
> npm install skygraph-react
|
|
9
|
+
> ```
|
|
10
|
+
>
|
|
11
|
+
> The meta-package re-exports everything below and auto-loads the CSS as a side effect. No separate `@skygraph/core` install, no manual `import '@skygraph/styles'`. Use this package directly only when you need fine-grained control over the install set.
|
|
12
|
+
|
|
13
|
+
## Install (direct)
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @skygraph/react @skygraph/core
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import '@skygraph/styles'
|
|
21
|
+
import { Form, Field, SubmitButton } from '@skygraph/react'
|
|
22
|
+
|
|
23
|
+
export function App() {
|
|
24
|
+
return (
|
|
25
|
+
<Form
|
|
26
|
+
defaultValues={{ email: '' }}
|
|
27
|
+
onSubmit={(values) => console.log(values)}
|
|
28
|
+
>
|
|
29
|
+
<Field name="email" label="Email" rules={[{ type: 'email' }]} />
|
|
30
|
+
<SubmitButton>Submit</SubmitButton>
|
|
31
|
+
</Form>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Components
|
|
37
|
+
|
|
38
|
+
**Data entry:** Button, Input, InputNumber, Textarea, Select, Checkbox, Radio, Switch, Slider, DatePicker, TimePicker, AutoComplete, Rate, Upload, ColorPicker, Cascader, TreeSelect, Mentions
|
|
39
|
+
|
|
40
|
+
**Data display:** Table, DataGrid, Tree, List, Tabs, Collapse, Descriptions, Badge, Tag, Avatar, Calendar, Carousel, Timeline, Steps, Segmented, Skeleton, Diagram
|
|
41
|
+
|
|
42
|
+
**Visualization:** LineChart, BarChart, AreaChart, PieChart, Dashboard, DashboardEditor, Gantt, EventTimeline, ResourceCalendar
|
|
43
|
+
|
|
44
|
+
**Feedback:** Modal, Drawer, Notification, Popconfirm, Tooltip, Progress, Spin, Result, Empty
|
|
45
|
+
|
|
46
|
+
**Navigation:** Menu, Breadcrumb, Dropdown, Pagination, Transfer
|
|
47
|
+
|
|
48
|
+
**Form:** Form, Field, FormList, FormProvider, SchemaForm, SchemaFormEditor, AutoField, SubmitButton
|
|
49
|
+
|
|
50
|
+
**Utility:** Transition (CSS-class-based animations)
|
|
51
|
+
|
|
52
|
+
## Subpath exports
|
|
53
|
+
|
|
54
|
+
| Subpath | Use |
|
|
55
|
+
|---|---|
|
|
56
|
+
| `@skygraph/react` | Full bundle |
|
|
57
|
+
| `@skygraph/react/form` | Form primitives only |
|
|
58
|
+
| `@skygraph/react/table` | Table primitives only |
|
|
59
|
+
| `@skygraph/react/tree` | Tree primitives only |
|
|
60
|
+
| `@skygraph/react/virtual` | Virtual-scroll helpers |
|
|
61
|
+
| `@skygraph/react/datagrid` | DataGrid |
|
|
62
|
+
| `@skygraph/react/devtools` | Optional devtools panel |
|
|
63
|
+
|
|
64
|
+
## Repository
|
|
65
|
+
|
|
66
|
+
[github.com/RuslanSinkevich/skygraph-public](https://github.com/RuslanSinkevich/skygraph-public)
|
|
67
|
+
|
|
68
|
+
## License
|
|
69
|
+
|
|
70
|
+
MIT
|
|
@@ -224,6 +224,11 @@ interface CalendarLocale {
|
|
|
224
224
|
/** Tooltip on the "next month" navigation button. */
|
|
225
225
|
nextMonth?: string;
|
|
226
226
|
}
|
|
227
|
+
/** Locale strings shared by Input-family `clear` (×) buttons. */
|
|
228
|
+
interface InputLocale {
|
|
229
|
+
/** Accessible label for the clear (×) button. */
|
|
230
|
+
clear?: string;
|
|
231
|
+
}
|
|
227
232
|
/** Locale strings for the InputPassword component. */
|
|
228
233
|
interface InputPasswordLocale {
|
|
229
234
|
/** Accessible label for the visibility toggle when password is hidden. */
|
|
@@ -416,6 +421,8 @@ interface SgLocale {
|
|
|
416
421
|
transfer?: TransferLocale;
|
|
417
422
|
/** Calendar locale overrides. */
|
|
418
423
|
calendar?: CalendarLocale;
|
|
424
|
+
/** Input locale overrides (clear button label). */
|
|
425
|
+
input?: InputLocale;
|
|
419
426
|
/** InputPassword locale overrides. */
|
|
420
427
|
inputPassword?: InputPasswordLocale;
|
|
421
428
|
/** SearchInput locale overrides. */
|
|
@@ -1014,4 +1021,4 @@ interface TableRef {
|
|
|
1014
1021
|
*/
|
|
1015
1022
|
declare const Table: React__default.ForwardRefExoticComponent<TableProps & React__default.RefAttributes<TableRef>>;
|
|
1016
1023
|
|
|
1017
|
-
export { type
|
|
1024
|
+
export { type TransferLocale as $, type AggregateType as A, type BreadcrumbLocale as B, type CellSpan as C, type DashboardLocale as D, type ExpandableConfig as E, type FilterDropdownProps as F, type GroupRow as G, type HeaderCell as H, type InlineEditLocale as I, type PopconfirmLocale as J, type RateLocale as K, type ResourceCalendarLocale as L, type ModalLocale as M, type NotificationLocale as N, type SchemaFormEditorLocale as O, type PinnedRowsConfig as P, type SearchInputLocale as Q, type RowNumberConfig as R, type SelectionSummaryAction as S, Table as T, type UseTableOptions as U, type SkeletonLocale as V, type SpinLocale as W, type TableRef as X, type TagInputLocale as Y, type TagLocale as Z, type TimelineLocale as _, type FlatRow as a, type TreeSelectLocale as a0, type UploadLocale as a1, type RowSelectionConfig as b, type SummaryCell as c, type TableColumn as d, type TableLocale as e, type TableProps as f, type TreeConfig as g, type UseTableReturn as h, type SgLocale as i, type PrintOptions as j, type CalendarLocale as k, type PrintableProp as l, type SlotClassNames as m, type SlotStyles as n, type CarouselLocale as o, type CascaderLocale as p, type ChartsLocale as q, type DatePickerLocale as r, type DrawerLocale as s, type EmptyLocale as t, useTable as u, type FormLocale as v, type GanttLocale as w, type InputLocale as x, type InputPasswordLocale as y, type PaginationLocale as z };
|
|
@@ -224,6 +224,11 @@ interface CalendarLocale {
|
|
|
224
224
|
/** Tooltip on the "next month" navigation button. */
|
|
225
225
|
nextMonth?: string;
|
|
226
226
|
}
|
|
227
|
+
/** Locale strings shared by Input-family `clear` (×) buttons. */
|
|
228
|
+
interface InputLocale {
|
|
229
|
+
/** Accessible label for the clear (×) button. */
|
|
230
|
+
clear?: string;
|
|
231
|
+
}
|
|
227
232
|
/** Locale strings for the InputPassword component. */
|
|
228
233
|
interface InputPasswordLocale {
|
|
229
234
|
/** Accessible label for the visibility toggle when password is hidden. */
|
|
@@ -416,6 +421,8 @@ interface SgLocale {
|
|
|
416
421
|
transfer?: TransferLocale;
|
|
417
422
|
/** Calendar locale overrides. */
|
|
418
423
|
calendar?: CalendarLocale;
|
|
424
|
+
/** Input locale overrides (clear button label). */
|
|
425
|
+
input?: InputLocale;
|
|
419
426
|
/** InputPassword locale overrides. */
|
|
420
427
|
inputPassword?: InputPasswordLocale;
|
|
421
428
|
/** SearchInput locale overrides. */
|
|
@@ -1014,4 +1021,4 @@ interface TableRef {
|
|
|
1014
1021
|
*/
|
|
1015
1022
|
declare const Table: React__default.ForwardRefExoticComponent<TableProps & React__default.RefAttributes<TableRef>>;
|
|
1016
1023
|
|
|
1017
|
-
export { type
|
|
1024
|
+
export { type TransferLocale as $, type AggregateType as A, type BreadcrumbLocale as B, type CellSpan as C, type DashboardLocale as D, type ExpandableConfig as E, type FilterDropdownProps as F, type GroupRow as G, type HeaderCell as H, type InlineEditLocale as I, type PopconfirmLocale as J, type RateLocale as K, type ResourceCalendarLocale as L, type ModalLocale as M, type NotificationLocale as N, type SchemaFormEditorLocale as O, type PinnedRowsConfig as P, type SearchInputLocale as Q, type RowNumberConfig as R, type SelectionSummaryAction as S, Table as T, type UseTableOptions as U, type SkeletonLocale as V, type SpinLocale as W, type TableRef as X, type TagInputLocale as Y, type TagLocale as Z, type TimelineLocale as _, type FlatRow as a, type TreeSelectLocale as a0, type UploadLocale as a1, type RowSelectionConfig as b, type SummaryCell as c, type TableColumn as d, type TableLocale as e, type TableProps as f, type TreeConfig as g, type UseTableReturn as h, type SgLocale as i, type PrintOptions as j, type CalendarLocale as k, type PrintableProp as l, type SlotClassNames as m, type SlotStyles as n, type CarouselLocale as o, type CascaderLocale as p, type ChartsLocale as q, type DatePickerLocale as r, type DrawerLocale as s, type EmptyLocale as t, useTable as u, type FormLocale as v, type GanttLocale as w, type InputLocale as x, type InputPasswordLocale as y, type PaginationLocale as z };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Spin,
|
|
3
3
|
useConfig
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-VLRLCHEL.js";
|
|
5
5
|
|
|
6
6
|
// src/components/ui/Input.tsx
|
|
7
|
+
import React from "react";
|
|
7
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
9
|
function Input({
|
|
9
10
|
value,
|
|
@@ -14,9 +15,14 @@ function Input({
|
|
|
14
15
|
size: sizeProp,
|
|
15
16
|
disabled: disabledProp,
|
|
16
17
|
loading,
|
|
18
|
+
allowClear = false,
|
|
19
|
+
status,
|
|
20
|
+
prefix,
|
|
21
|
+
suffix,
|
|
17
22
|
onChange,
|
|
18
23
|
onBlur,
|
|
19
24
|
onFocus,
|
|
25
|
+
onClear,
|
|
20
26
|
"aria-invalid": ariaInvalid,
|
|
21
27
|
"aria-required": ariaRequired,
|
|
22
28
|
"aria-describedby": ariaDescribedBy,
|
|
@@ -28,45 +34,73 @@ function Input({
|
|
|
28
34
|
const config = useConfig();
|
|
29
35
|
const size = sizeProp ?? config.size ?? "middle";
|
|
30
36
|
const disabled = disabledProp ?? config.disabled ?? false;
|
|
37
|
+
const [internalValue, setInternalValue] = React.useState(defaultValue ?? "");
|
|
38
|
+
const currentValue = value ?? internalValue;
|
|
39
|
+
const isControlled = value !== void 0;
|
|
31
40
|
const wrapperClasses = unstyled ? className ?? "" : [
|
|
32
41
|
"sg-input-wrapper",
|
|
33
42
|
`sg-input-wrapper-${size}`,
|
|
34
43
|
loading ? "sg-input-wrapper-loading" : "",
|
|
35
44
|
readOnly ? "sg-input-wrapper-readonly" : "",
|
|
45
|
+
status ? `sg-input-wrapper-status-${status}` : "",
|
|
36
46
|
className
|
|
37
47
|
].filter(Boolean).join(" ");
|
|
38
48
|
const inputClasses = unstyled ? "" : [
|
|
39
49
|
"sg-input",
|
|
40
50
|
`sg-input-${size}`,
|
|
41
|
-
readOnly ? "sg-input-readonly" : ""
|
|
51
|
+
readOnly ? "sg-input-readonly" : "",
|
|
52
|
+
status ? `sg-input-status-${status}` : ""
|
|
42
53
|
].filter(Boolean).join(" ");
|
|
54
|
+
const clearLabel = config.locale?.input?.clear ?? "Clear";
|
|
55
|
+
const showClear = allowClear && !disabled && !readOnly && !loading && currentValue !== "";
|
|
56
|
+
const handleChange = (e) => {
|
|
57
|
+
if (!isControlled) setInternalValue(e.target.value);
|
|
58
|
+
onChange?.(e.target.value);
|
|
59
|
+
};
|
|
60
|
+
const handleClear = () => {
|
|
61
|
+
if (!isControlled) setInternalValue("");
|
|
62
|
+
onChange?.("");
|
|
63
|
+
onClear?.();
|
|
64
|
+
};
|
|
65
|
+
const resolvedAriaInvalid = ariaInvalid ?? (status === "error" ? true : void 0);
|
|
43
66
|
return /* @__PURE__ */ jsxs("span", { className: wrapperClasses, style, children: [
|
|
67
|
+
prefix && /* @__PURE__ */ jsx("span", { className: "sg-input-prefix", children: prefix }),
|
|
44
68
|
/* @__PURE__ */ jsx(
|
|
45
69
|
"input",
|
|
46
70
|
{
|
|
47
71
|
id,
|
|
48
72
|
type,
|
|
49
73
|
className: inputClasses,
|
|
50
|
-
value,
|
|
51
|
-
defaultValue,
|
|
74
|
+
value: currentValue,
|
|
52
75
|
placeholder,
|
|
53
76
|
disabled: disabled || loading,
|
|
54
77
|
readOnly,
|
|
55
|
-
"aria-invalid":
|
|
78
|
+
"aria-invalid": resolvedAriaInvalid,
|
|
56
79
|
"aria-required": ariaRequired,
|
|
57
80
|
"aria-readonly": readOnly || void 0,
|
|
58
81
|
"aria-describedby": ariaDescribedBy,
|
|
59
|
-
onChange:
|
|
82
|
+
onChange: handleChange,
|
|
60
83
|
onBlur,
|
|
61
84
|
onFocus
|
|
62
85
|
}
|
|
63
86
|
),
|
|
64
|
-
|
|
87
|
+
showClear && /* @__PURE__ */ jsx(
|
|
88
|
+
"button",
|
|
89
|
+
{
|
|
90
|
+
type: "button",
|
|
91
|
+
className: "sg-input-clear",
|
|
92
|
+
"aria-label": clearLabel,
|
|
93
|
+
onClick: handleClear,
|
|
94
|
+
children: "\xD7"
|
|
95
|
+
}
|
|
96
|
+
),
|
|
97
|
+
loading && /* @__PURE__ */ jsx(Spin, { size: "small", unstyled }),
|
|
98
|
+
suffix && /* @__PURE__ */ jsx("span", { className: "sg-input-suffix", children: suffix })
|
|
65
99
|
] });
|
|
66
100
|
}
|
|
67
101
|
|
|
68
102
|
// src/components/ui/Transition.tsx
|
|
69
|
-
import
|
|
103
|
+
import React2, { useState, useEffect, useRef, useCallback } from "react";
|
|
70
104
|
function Transition({
|
|
71
105
|
visible,
|
|
72
106
|
name = "sg-fade",
|
|
@@ -140,7 +174,7 @@ function Transition({
|
|
|
140
174
|
transitionClass = `${leaveC.to} ${leaveC.active}`;
|
|
141
175
|
break;
|
|
142
176
|
}
|
|
143
|
-
return
|
|
177
|
+
return React2.cloneElement(children, {
|
|
144
178
|
ref: nodeRef,
|
|
145
179
|
className: [children.props.className, transitionClass].filter(Boolean).join(" ")
|
|
146
180
|
});
|
|
@@ -197,4 +231,4 @@ export {
|
|
|
197
231
|
Transition,
|
|
198
232
|
Button
|
|
199
233
|
};
|
|
200
|
-
//# sourceMappingURL=chunk-
|
|
234
|
+
//# sourceMappingURL=chunk-45YW5VSP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/ui/Input.tsx","../src/components/ui/Transition.tsx","../src/components/ui/Button.tsx"],"sourcesContent":["import React from 'react'\nimport { useConfig } from '../ConfigProvider'\nimport type { BaseComponentProps, InteractiveProps, SizableProps } from '../../types'\nimport { Spin } from './Spin'\n\n/** Props for the Input component. */\nexport interface InputProps extends BaseComponentProps, InteractiveProps, SizableProps {\n /** Controlled input value. */\n value?: string\n /** Uncontrolled initial value. */\n defaultValue?: string\n /** Placeholder text when the field is empty. */\n placeholder?: string\n /** Native HTML input type. @default 'text' */\n type?: 'text' | 'email' | 'password' | 'number'\n /**\n * Marks the field as read-only. The value is selectable and submitted\n * but cannot be edited. Sets the HTML `readonly` attribute,\n * `aria-readonly=\"true\"`, and adds the `sg-input-readonly` modifier class.\n * @default false\n */\n readOnly?: boolean\n /** DOM id forwarded to the underlying `<input>`. */\n id?: string\n /**\n * When true, renders a clear (×) button while the field has a value.\n * Disabled and read-only fields hide the button. @default false\n */\n allowClear?: boolean\n /**\n * Validation status badge. Adds `sg-input-wrapper-status-{status}` and\n * `sg-input-status-{status}` modifier classes and sets `aria-invalid` when\n * `error`.\n */\n status?: 'error' | 'warning'\n /** Optional content rendered before the `<input>` (e.g. icon). */\n prefix?: React.ReactNode\n /** Optional content rendered after the `<input>` (e.g. icon, unit). */\n suffix?: React.ReactNode\n /** Exposes invalid state to assistive technologies. */\n 'aria-invalid'?: boolean | 'false' | 'true' | 'grammar' | 'spelling'\n /** Marks the field as required for assistive technologies. */\n 'aria-required'?: boolean | 'false' | 'true'\n /** Connects the input to description / error nodes for assistive technologies. */\n 'aria-describedby'?: string\n /** Called when the text value changes. */\n onChange?: (value: string) => void\n /** Called when the input loses focus. */\n onBlur?: () => void\n /** Called when the input gains focus. */\n onFocus?: () => void\n /** Called when the user activates the built-in clear button. */\n onClear?: () => void\n}\n\n/** Single-line text input with optional loading indicator and configurable HTML type. */\nexport function Input({\n value,\n defaultValue,\n placeholder,\n type = 'text',\n readOnly = false,\n size: sizeProp,\n disabled: disabledProp,\n loading,\n allowClear = false,\n status,\n prefix,\n suffix,\n onChange,\n onBlur,\n onFocus,\n onClear,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-describedby': ariaDescribedBy,\n id,\n className,\n style,\n unstyled,\n}: InputProps) {\n const config = useConfig()\n const size = sizeProp ?? config.size ?? 'middle'\n const disabled = disabledProp ?? config.disabled ?? false\n\n const [internalValue, setInternalValue] = React.useState<string>(defaultValue ?? '')\n const currentValue = value ?? internalValue\n const isControlled = value !== undefined\n\n const wrapperClasses = unstyled\n ? (className ?? '')\n : [\n 'sg-input-wrapper',\n `sg-input-wrapper-${size}`,\n loading ? 'sg-input-wrapper-loading' : '',\n readOnly ? 'sg-input-wrapper-readonly' : '',\n status ? `sg-input-wrapper-status-${status}` : '',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n const inputClasses = unstyled\n ? ''\n : [\n 'sg-input',\n `sg-input-${size}`,\n readOnly ? 'sg-input-readonly' : '',\n status ? `sg-input-status-${status}` : '',\n ]\n .filter(Boolean)\n .join(' ')\n\n const clearLabel = config.locale?.input?.clear ?? 'Clear'\n const showClear = allowClear && !disabled && !readOnly && !loading && currentValue !== ''\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (!isControlled) setInternalValue(e.target.value)\n onChange?.(e.target.value)\n }\n\n const handleClear = () => {\n if (!isControlled) setInternalValue('')\n onChange?.('')\n onClear?.()\n }\n\n const resolvedAriaInvalid = ariaInvalid ?? (status === 'error' ? true : undefined)\n\n return (\n <span className={wrapperClasses} style={style}>\n {prefix && <span className=\"sg-input-prefix\">{prefix}</span>}\n <input\n id={id}\n type={type}\n className={inputClasses}\n value={currentValue}\n placeholder={placeholder}\n disabled={disabled || loading}\n readOnly={readOnly}\n aria-invalid={resolvedAriaInvalid}\n aria-required={ariaRequired}\n aria-readonly={readOnly || undefined}\n aria-describedby={ariaDescribedBy}\n onChange={handleChange}\n onBlur={onBlur}\n onFocus={onFocus}\n />\n {showClear && (\n <button\n type=\"button\"\n className=\"sg-input-clear\"\n aria-label={clearLabel}\n onClick={handleClear}\n >\n ×\n </button>\n )}\n {loading && <Spin size=\"small\" unstyled={unstyled} />}\n {suffix && <span className=\"sg-input-suffix\">{suffix}</span>}\n </span>\n )\n}\n","import React, { useState, useEffect, useRef, useCallback } from 'react'\n\n/** Props for class-based enter/leave animation on a single child element. */\nexport interface TransitionProps {\n /** When `true`, runs enter; when `false`, runs leave (and may unmount). */\n visible: boolean\n /** Base class name prefix for default enter/leave classes (e.g. `sg-fade-enter-from`). @default 'sg-fade' */\n name?: string\n /** Animation length in ms before idle phase and after callbacks. @default 200 */\n duration?: number\n /** Custom initial class for the enter frame (with `-enter-active`). */\n enterFrom?: string\n /** Custom final class for the enter-active frame. */\n enterTo?: string\n /** Custom initial class for the leave frame (with `-leave-active`). */\n leaveFrom?: string\n /** Custom final class for the leave-active frame. */\n leaveTo?: string\n /** Fires once the enter transition timer completes. */\n onAfterEnter?: () => void\n /** Fires once the leave transition timer completes. */\n onAfterLeave?: () => void\n /** Single React element whose `className` will be merged with transition classes. */\n children: React.ReactElement<{ className?: string; ref?: React.Ref<HTMLElement> }>\n /** When `true`, removes the child from the tree after leave; when `false`, keeps it mounted. @default true */\n unmountOnExit?: boolean\n}\n\ntype Phase = 'idle' | 'enter' | 'enter-active' | 'leave' | 'leave-active'\n\n/**\n * Clones a single child and toggles CSS classes over `duration` when `visible` changes, optionally unmounting after leave.\n */\nexport function Transition({\n visible,\n name = 'sg-fade',\n duration = 200,\n enterFrom,\n enterTo,\n leaveFrom,\n leaveTo,\n onAfterEnter,\n onAfterLeave,\n children,\n unmountOnExit = true,\n}: TransitionProps) {\n const [mounted, setMounted] = useState(visible)\n const [phase, setPhase] = useState<Phase>(visible ? 'idle' : 'idle')\n const nodeRef = useRef<HTMLElement | null>(null)\n const timerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n const prevVisible = useRef(visible)\n\n const getEnterClasses = useCallback(() => {\n if (enterFrom && enterTo) return { from: enterFrom, active: `${name}-enter-active`, to: enterTo }\n return { from: `${name}-enter-from`, active: `${name}-enter-active`, to: `${name}-enter-to` }\n }, [name, enterFrom, enterTo])\n\n const getLeaveClasses = useCallback(() => {\n if (leaveFrom && leaveTo) return { from: leaveFrom, active: `${name}-leave-active`, to: leaveTo }\n return { from: `${name}-leave-from`, active: `${name}-leave-active`, to: `${name}-leave-to` }\n }, [name, leaveFrom, leaveTo])\n\n useEffect(() => {\n if (visible === prevVisible.current) return\n prevVisible.current = visible\n clearTimeout(timerRef.current)\n\n if (visible) {\n setMounted(true)\n setPhase('enter')\n requestAnimationFrame(() => {\n requestAnimationFrame(() => setPhase('enter-active'))\n })\n timerRef.current = setTimeout(() => {\n setPhase('idle')\n onAfterEnter?.()\n }, duration)\n } else {\n setPhase('leave')\n requestAnimationFrame(() => {\n requestAnimationFrame(() => setPhase('leave-active'))\n })\n timerRef.current = setTimeout(() => {\n setPhase('idle')\n if (unmountOnExit) setMounted(false)\n onAfterLeave?.()\n }, duration)\n }\n }, [visible, duration, unmountOnExit, onAfterEnter, onAfterLeave])\n\n useEffect(() => {\n return () => clearTimeout(timerRef.current)\n }, [])\n\n if (!mounted && unmountOnExit) return null\n\n const enterC = getEnterClasses()\n const leaveC = getLeaveClasses()\n\n let transitionClass = ''\n switch (phase) {\n case 'enter':\n transitionClass = `${enterC.from} ${enterC.active}`\n break\n case 'enter-active':\n transitionClass = `${enterC.to} ${enterC.active}`\n break\n case 'leave':\n transitionClass = `${leaveC.from} ${leaveC.active}`\n break\n case 'leave-active':\n transitionClass = `${leaveC.to} ${leaveC.active}`\n break\n }\n\n return React.cloneElement(children, {\n ref: nodeRef,\n className: [children.props.className, transitionClass].filter(Boolean).join(' '),\n })\n}\n","import React from 'react'\nimport { Spin } from './Spin'\nimport { useConfig } from '../ConfigProvider'\nimport type { BaseComponentProps, InteractiveProps, SizableProps } from '../../types'\n\n/** Props for the Button component. */\nexport interface ButtonProps extends BaseComponentProps, InteractiveProps, SizableProps {\n /** Visual style variant. @default 'default' */\n type?: 'default' | 'primary' | 'dashed' | 'text' | 'link'\n /** Native HTML button type attribute. @default 'button' */\n htmlType?: 'button' | 'submit' | 'reset'\n /**\n * Visually flags a destructive action. Combines with `type` (e.g. a\n * `danger` `primary` button is solid red, a `danger` `text` is red text).\n * Adds the `sg-button-danger` modifier class.\n * @default false\n */\n danger?: boolean\n /** Stretches the button to fill its parent container. @default false */\n block?: boolean\n /** Click event handler. */\n onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void\n /** Button content. */\n children?: React.ReactNode\n}\n\n/** General-purpose button with multiple visual variants, sizes, and loading state. */\nexport function Button({\n type = 'default',\n size: sizeProp,\n disabled: disabledProp,\n loading,\n htmlType = 'button',\n danger = false,\n block = false,\n onClick,\n children,\n className,\n style,\n unstyled,\n}: ButtonProps) {\n const config = useConfig()\n const size = sizeProp ?? config.size ?? 'middle'\n const disabled = disabledProp ?? config.disabled ?? false\n\n const classes = unstyled\n ? className ?? ''\n : [\n 'sg-button',\n `sg-button-${type}`,\n `sg-button-${size}`,\n danger ? 'sg-button-danger' : '',\n block ? 'sg-button-block' : '',\n loading ? 'sg-button-loading' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n return (\n <button\n type={htmlType}\n className={classes}\n style={style}\n disabled={disabled || loading}\n aria-disabled={disabled || loading}\n aria-busy={loading}\n onClick={onClick}\n >\n {loading && <Spin size=\"small\" unstyled={unstyled} />}\n {children}\n </button>\n )\n}\n"],"mappings":";;;;;;AAAA,OAAO,WAAW;AAkId,SACa,KADb;AA1EG,SAAS,MAAM;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,WAAW;AAAA,EACX,MAAM;AAAA,EACN,UAAU;AAAA,EACV;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB,iBAA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