@taicode/common-web 3.7.4 → 3.7.7
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/LICENSE +21 -0
- package/package.json +12 -13
- package/styles.css +2 -0
- package/output/components/alert-dialog.d.ts +0 -20
- package/output/components/alert-dialog.d.ts.map +0 -1
- package/output/components/alert-dialog.js +0 -65
- package/output/components/alert.d.ts +0 -11
- package/output/components/alert.d.ts.map +0 -1
- package/output/components/alert.js +0 -38
- package/output/components/avatar.d.ts +0 -13
- package/output/components/avatar.d.ts.map +0 -1
- package/output/components/avatar.js +0 -40
- package/output/components/badge.d.ts +0 -11
- package/output/components/badge.d.ts.map +0 -1
- package/output/components/badge.js +0 -39
- package/output/components/button.d.ts +0 -12
- package/output/components/button.d.ts.map +0 -1
- package/output/components/button.js +0 -48
- package/output/components/calendar.d.ts +0 -13
- package/output/components/calendar.d.ts.map +0 -1
- package/output/components/calendar.js +0 -57
- package/output/components/card.d.ts +0 -13
- package/output/components/card.d.ts.map +0 -1
- package/output/components/card.js +0 -43
- package/output/components/chart.d.ts +0 -56
- package/output/components/chart.d.ts.map +0 -1
- package/output/components/chart.js +0 -127
- package/output/components/checkbox.d.ts +0 -5
- package/output/components/checkbox.d.ts.map +0 -1
- package/output/components/checkbox.js +0 -21
- package/output/components/command.d.ts +0 -20
- package/output/components/command.d.ts.map +0 -1
- package/output/components/command.js +0 -55
- package/output/components/dialog.d.ts +0 -20
- package/output/components/dialog.d.ts.map +0 -1
- package/output/components/dialog.js +0 -58
- package/output/components/direction.d.ts +0 -9
- package/output/components/direction.d.ts.map +0 -1
- package/output/components/direction.js +0 -10
- package/output/components/drawer.d.ts +0 -14
- package/output/components/drawer.d.ts.map +0 -1
- package/output/components/drawer.js +0 -56
- package/output/components/dropdown-menu.d.ts +0 -29
- package/output/components/dropdown-menu.d.ts.map +0 -1
- package/output/components/dropdown-menu.js +0 -78
- package/output/components/field.d.ts +0 -39
- package/output/components/field.d.ts.map +0 -1
- package/output/components/field.js +0 -102
- package/output/components/footer/index.d.ts +0 -27
- package/output/components/footer/index.d.ts.map +0 -1
- package/output/components/footer/index.js +0 -17
- package/output/components/form.d.ts +0 -26
- package/output/components/form.d.ts.map +0 -1
- package/output/components/form.js +0 -69
- package/output/components/index.d.ts +0 -46
- package/output/components/index.d.ts.map +0 -1
- package/output/components/index.js +0 -45
- package/output/components/input-group.d.ts +0 -17
- package/output/components/input-group.d.ts.map +0 -1
- package/output/components/input-group.js +0 -75
- package/output/components/input.d.ts +0 -4
- package/output/components/input.d.ts.map +0 -1
- package/output/components/input.js +0 -19
- package/output/components/item.d.ts +0 -25
- package/output/components/item.d.ts.map +0 -1
- package/output/components/item.js +0 -89
- package/output/components/json-view/index.d.ts +0 -11
- package/output/components/json-view/index.d.ts.map +0 -1
- package/output/components/json-view/index.js +0 -52
- package/output/components/json-view/lazy/index.d.ts +0 -18
- package/output/components/json-view/lazy/index.d.ts.map +0 -1
- package/output/components/json-view/lazy/index.js +0 -22
- package/output/components/kbd.d.ts +0 -4
- package/output/components/kbd.d.ts.map +0 -1
- package/output/components/kbd.js +0 -22
- package/output/components/label.d.ts +0 -5
- package/output/components/label.d.ts.map +0 -1
- package/output/components/label.js +0 -20
- package/output/components/list-actions/index.d.ts +0 -23
- package/output/components/list-actions/index.d.ts.map +0 -1
- package/output/components/list-actions/index.js +0 -15
- package/output/components/loading-button/index.d.ts +0 -44
- package/output/components/loading-button/index.d.ts.map +0 -1
- package/output/components/loading-button/index.js +0 -75
- package/output/components/loading-button/index.test.d.ts +0 -2
- package/output/components/loading-button/index.test.d.ts.map +0 -1
- package/output/components/loading-button/index.test.js +0 -203
- package/output/components/native-select.d.ts +0 -9
- package/output/components/native-select.d.ts.map +0 -1
- package/output/components/native-select.js +0 -28
- package/output/components/page-back-button/index.d.ts +0 -8
- package/output/components/page-back-button/index.d.ts.map +0 -1
- package/output/components/page-back-button/index.js +0 -7
- package/output/components/page-state.d.ts +0 -19
- package/output/components/page-state.d.ts.map +0 -1
- package/output/components/page-state.js +0 -13
- package/output/components/pagination/index.d.ts +0 -34
- package/output/components/pagination/index.d.ts.map +0 -1
- package/output/components/pagination/index.js +0 -75
- package/output/components/popover.d.ts +0 -11
- package/output/components/popover.d.ts.map +0 -1
- package/output/components/popover.js +0 -44
- package/output/components/progress.d.ts +0 -5
- package/output/components/progress.d.ts.map +0 -1
- package/output/components/progress.js +0 -21
- package/output/components/radio-group.d.ts +0 -6
- package/output/components/radio-group.d.ts.map +0 -1
- package/output/components/radio-group.js +0 -25
- package/output/components/route-pending-indicator/index.d.ts +0 -20
- package/output/components/route-pending-indicator/index.d.ts.map +0 -1
- package/output/components/route-pending-indicator/index.js +0 -17
- package/output/components/scroll-area.d.ts +0 -6
- package/output/components/scroll-area.d.ts.map +0 -1
- package/output/components/scroll-area.js +0 -24
- package/output/components/searchable-select/index.d.ts +0 -41
- package/output/components/searchable-select/index.d.ts.map +0 -1
- package/output/components/searchable-select/index.js +0 -46
- package/output/components/select.d.ts +0 -17
- package/output/components/select.d.ts.map +0 -1
- package/output/components/select.js +0 -58
- package/output/components/separator.d.ts +0 -5
- package/output/components/separator.d.ts.map +0 -1
- package/output/components/separator.js +0 -20
- package/output/components/sheet.d.ts +0 -16
- package/output/components/sheet.d.ts.map +0 -1
- package/output/components/sheet.js +0 -58
- package/output/components/sidebar.d.ts +0 -78
- package/output/components/sidebar.d.ts.map +0 -1
- package/output/components/sidebar.js +0 -233
- package/output/components/size-provider/index.d.ts +0 -2
- package/output/components/size-provider/index.d.ts.map +0 -1
- package/output/components/size-provider/index.js +0 -1
- package/output/components/size-provider/size-provider.d.ts +0 -9
- package/output/components/size-provider/size-provider.d.ts.map +0 -1
- package/output/components/size-provider/size-provider.js +0 -29
- package/output/components/skeleton.d.ts +0 -3
- package/output/components/skeleton.d.ts.map +0 -1
- package/output/components/skeleton.js +0 -18
- package/output/components/sonner.d.ts +0 -8
- package/output/components/sonner.d.ts.map +0 -1
- package/output/components/sonner.js +0 -34
- package/output/components/spinner.d.ts +0 -3
- package/output/components/spinner.d.ts.map +0 -1
- package/output/components/spinner.js +0 -19
- package/output/components/switch.d.ts +0 -8
- package/output/components/switch.d.ts.map +0 -1
- package/output/components/switch.js +0 -20
- package/output/components/table.d.ts +0 -11
- package/output/components/table.d.ts.map +0 -1
- package/output/components/table.js +0 -47
- package/output/components/tabs.d.ts +0 -12
- package/output/components/tabs.d.ts.map +0 -1
- package/output/components/tabs.js +0 -45
- package/output/components/textarea.d.ts +0 -4
- package/output/components/textarea.d.ts.map +0 -1
- package/output/components/textarea.js +0 -19
- package/output/components/theme-switcher.d.ts +0 -6
- package/output/components/theme-switcher.d.ts.map +0 -1
- package/output/components/theme-switcher.js +0 -19
- package/output/components/toaster/index.d.ts +0 -16
- package/output/components/toaster/index.d.ts.map +0 -1
- package/output/components/toaster/index.js +0 -70
- package/output/components/toggle-group.d.ts +0 -12
- package/output/components/toggle-group.d.ts.map +0 -1
- package/output/components/toggle-group.js +0 -38
- package/output/components/toggle.d.ts +0 -10
- package/output/components/toggle.d.ts.map +0 -1
- package/output/components/toggle.js +0 -38
- package/output/components/tooltip.d.ts +0 -8
- package/output/components/tooltip.d.ts.map +0 -1
- package/output/components/tooltip.js +0 -33
- package/output/features/confirm-dialog/index.d.ts +0 -41
- package/output/features/confirm-dialog/index.d.ts.map +0 -1
- package/output/features/confirm-dialog/index.js +0 -19
- package/output/features/input-confirm/index.d.ts +0 -26
- package/output/features/input-confirm/index.d.ts.map +0 -1
- package/output/features/input-confirm/index.js +0 -59
- package/output/features/signin/context.d.ts +0 -14
- package/output/features/signin/context.d.ts.map +0 -1
- package/output/features/signin/context.js +0 -13
- package/output/features/signin/index.d.ts +0 -58
- package/output/features/signin/index.d.ts.map +0 -1
- package/output/features/signin/index.js +0 -137
- package/output/features/signin/service.d.ts +0 -92
- package/output/features/signin/service.d.ts.map +0 -1
- package/output/features/signin/service.js +0 -519
- package/output/features/signin/service.test.d.ts +0 -2
- package/output/features/signin/service.test.d.ts.map +0 -1
- package/output/features/signin/service.test.js +0 -211
- package/output/features/signin/types.d.ts +0 -63
- package/output/features/signin/types.d.ts.map +0 -1
- package/output/features/signin/types.js +0 -1
- package/output/hooks/use-loading/index.d.ts +0 -6
- package/output/hooks/use-loading/index.d.ts.map +0 -1
- package/output/hooks/use-loading/index.js +0 -14
- package/output/hooks/use-loading/index.test.d.ts +0 -2
- package/output/hooks/use-loading/index.test.d.ts.map +0 -1
- package/output/hooks/use-loading/index.test.js +0 -24
- package/output/hooks/use-mobile/index.d.ts +0 -2
- package/output/hooks/use-mobile/index.d.ts.map +0 -1
- package/output/hooks/use-mobile/index.js +0 -16
- package/output/hooks/use-observer/index.d.ts +0 -2
- package/output/hooks/use-observer/index.d.ts.map +0 -1
- package/output/hooks/use-observer/index.js +0 -1
- package/output/hooks/use-observer/use-observer.d.ts +0 -3
- package/output/hooks/use-observer/use-observer.d.ts.map +0 -1
- package/output/hooks/use-observer/use-observer.js +0 -16
- package/output/hooks/use-observer/use-observer.test.d.ts +0 -2
- package/output/hooks/use-observer/use-observer.test.d.ts.map +0 -1
- package/output/hooks/use-observer/use-observer.test.js +0 -134
- package/output/hooks/use-offline/index.d.ts +0 -6
- package/output/hooks/use-offline/index.d.ts.map +0 -1
- package/output/hooks/use-offline/index.js +0 -19
- package/output/layout/app/index.d.ts +0 -34
- package/output/layout/app/index.d.ts.map +0 -1
- package/output/layout/app/index.js +0 -34
- package/output/layout/dashboard/index.d.ts +0 -76
- package/output/layout/dashboard/index.d.ts.map +0 -1
- package/output/layout/dashboard/index.js +0 -84
- package/output/layout/index.d.ts +0 -3
- package/output/layout/index.d.ts.map +0 -1
- package/output/layout/index.js +0 -2
- package/output/services/cache-api/cache-api.d.ts +0 -23
- package/output/services/cache-api/cache-api.d.ts.map +0 -1
- package/output/services/cache-api/cache-api.js +0 -145
- package/output/services/cache-api/cache-api.test.d.ts +0 -2
- package/output/services/cache-api/cache-api.test.d.ts.map +0 -1
- package/output/services/cache-api/cache-api.test.js +0 -610
- package/output/services/cache-api/index.d.ts +0 -2
- package/output/services/cache-api/index.d.ts.map +0 -1
- package/output/services/cache-api/index.js +0 -1
- package/output/services/cached-fetch/index.d.ts +0 -50
- package/output/services/cached-fetch/index.d.ts.map +0 -1
- package/output/services/cached-fetch/index.js +0 -196
- package/output/services/service/index.d.ts +0 -2
- package/output/services/service/index.d.ts.map +0 -1
- package/output/services/service/index.js +0 -1
- package/output/services/service/service.d.ts +0 -135
- package/output/services/service/service.d.ts.map +0 -1
- package/output/services/service/service.js +0 -276
- package/output/services/service/service.test.d.ts +0 -2
- package/output/services/service/service.test.d.ts.map +0 -1
- package/output/services/service/service.test.js +0 -1399
- package/output/services/side-cache/index.d.ts +0 -2
- package/output/services/side-cache/index.d.ts.map +0 -1
- package/output/services/side-cache/index.js +0 -1
- package/output/services/side-cache/side-cache.d.ts +0 -11
- package/output/services/side-cache/side-cache.d.ts.map +0 -1
- package/output/services/side-cache/side-cache.js +0 -161
- package/output/services/side-cache/side-cache.test.d.ts +0 -2
- package/output/services/side-cache/side-cache.test.d.ts.map +0 -1
- package/output/services/side-cache/side-cache.test.js +0 -271
- package/output/utils/avatar/index.d.ts +0 -28
- package/output/utils/avatar/index.d.ts.map +0 -1
- package/output/utils/avatar/index.js +0 -35
- package/output/utils/delay/index.d.ts +0 -2
- package/output/utils/delay/index.d.ts.map +0 -1
- package/output/utils/delay/index.js +0 -5
- package/output/utils/form/index.d.ts +0 -3
- package/output/utils/form/index.d.ts.map +0 -1
- package/output/utils/form/index.js +0 -1
- package/output/utils/merge-class-names/index.d.ts +0 -3
- package/output/utils/merge-class-names/index.d.ts.map +0 -1
- package/output/utils/merge-class-names/index.js +0 -5
- package/output/utils/merge-class-names/index.test.d.ts +0 -2
- package/output/utils/merge-class-names/index.test.d.ts.map +0 -1
- package/output/utils/merge-class-names/index.test.js +0 -7
- package/output/utils/performance/index.d.ts +0 -82
- package/output/utils/performance/index.d.ts.map +0 -1
- package/output/utils/performance/index.js +0 -129
- package/output/utils/redirect/index.d.ts +0 -6
- package/output/utils/redirect/index.d.ts.map +0 -1
- package/output/utils/redirect/index.js +0 -32
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { type VariantProps } from "class-variance-authority";
|
|
3
|
-
import { Separator } from "./separator.js";
|
|
4
|
-
type ItemParams = {
|
|
5
|
-
asChild?: boolean;
|
|
6
|
-
};
|
|
7
|
-
declare function ItemGroup(params: React.ComponentProps<"div">): React.JSX.Element;
|
|
8
|
-
declare function ItemSeparator(params: React.ComponentProps<typeof Separator>): React.JSX.Element;
|
|
9
|
-
declare const itemVariants: (props?: ({
|
|
10
|
-
variant?: "default" | "outline" | "muted" | null | undefined;
|
|
11
|
-
size?: "default" | "xs" | "sm" | null | undefined;
|
|
12
|
-
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
13
|
-
declare function Item(params: React.ComponentProps<"div"> & VariantProps<typeof itemVariants> & ItemParams): React.JSX.Element;
|
|
14
|
-
declare const itemMediaVariants: (props?: ({
|
|
15
|
-
variant?: "default" | "icon" | "image" | null | undefined;
|
|
16
|
-
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
17
|
-
declare function ItemMedia(params: React.ComponentProps<"div"> & VariantProps<typeof itemMediaVariants>): React.JSX.Element;
|
|
18
|
-
declare function ItemContent(params: React.ComponentProps<"div">): React.JSX.Element;
|
|
19
|
-
declare function ItemTitle(params: React.ComponentProps<"div">): React.JSX.Element;
|
|
20
|
-
declare function ItemDescription(params: React.ComponentProps<"p">): React.JSX.Element;
|
|
21
|
-
declare function ItemActions(params: React.ComponentProps<"div">): React.JSX.Element;
|
|
22
|
-
declare function ItemHeader(params: React.ComponentProps<"div">): React.JSX.Element;
|
|
23
|
-
declare function ItemFooter(params: React.ComponentProps<"div">): React.JSX.Element;
|
|
24
|
-
export { Item, ItemMedia, ItemContent, ItemActions, ItemGroup, ItemSeparator, ItemTitle, ItemDescription, ItemHeader, ItemFooter, };
|
|
25
|
-
//# sourceMappingURL=item.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../source/components/item.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAIjE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,KAAK,UAAU,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAEvC,iBAAS,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,qBAarD;AAED,iBAAS,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,SAAS,CAAC,qBAapE;AAED,QAAA,MAAM,YAAY;;;8EAoBjB,CAAA;AAED,iBAAS,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,GAC/C,YAAY,CAAC,OAAO,YAAY,CAAC,GAAG,UAAU,qBAkB/C;AAED,QAAA,MAAM,iBAAiB;;8EActB,CAAA;AAED,iBAAS,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,YAAY,CAAC,OAAO,iBAAiB,CAAC,qBAc9F;AAED,iBAAS,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,qBAYvD;AAED,iBAAS,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,qBAYrD;AAED,iBAAS,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,qBAYzD;AAED,iBAAS,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,qBASvD;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,qBAYtD;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,qBAYtD;AAED,OAAO,EACL,IAAI,EACJ,SAAS,EACT,WAAW,EACX,WAAW,EACX,SAAS,EACT,aAAa,EACb,SAAS,EACT,eAAe,EACf,UAAU,EACV,UAAU,GACX,CAAA"}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import * as React from "react";
|
|
14
|
-
import { cva } from "class-variance-authority";
|
|
15
|
-
import { Slot } from "radix-ui";
|
|
16
|
-
import { mergeClassNames } from "../utils/merge-class-names/index.js";
|
|
17
|
-
import { Separator } from "./separator.js";
|
|
18
|
-
function ItemGroup(params) {
|
|
19
|
-
const { className } = params, props = __rest(params, ["className"]);
|
|
20
|
-
return (_jsx("div", Object.assign({ role: "list", "data-slot": "item-group", className: mergeClassNames("gap-4 has-[[data-size=sm]]:gap-2.5 has-[[data-size=xs]]:gap-2 group/item-group flex w-full flex-col", className) }, props)));
|
|
21
|
-
}
|
|
22
|
-
function ItemSeparator(params) {
|
|
23
|
-
const { className } = params, props = __rest(params, ["className"]);
|
|
24
|
-
return (_jsx(Separator, Object.assign({ "data-slot": "item-separator", orientation: "horizontal", className: mergeClassNames("my-2", className) }, props)));
|
|
25
|
-
}
|
|
26
|
-
const itemVariants = cva("[a]:hover:bg-muted rounded-md border text-sm w-full group/item focus-visible:border-ring focus-visible:ring-ring/50 flex items-center flex-wrap outline-none transition-colors duration-100 focus-visible:ring-[3px] [a]:transition-colors", {
|
|
27
|
-
variants: {
|
|
28
|
-
variant: {
|
|
29
|
-
default: "border-transparent",
|
|
30
|
-
outline: "border-border",
|
|
31
|
-
muted: "bg-muted/50 border-transparent",
|
|
32
|
-
},
|
|
33
|
-
size: {
|
|
34
|
-
default: "gap-3.5 px-4 py-3.5",
|
|
35
|
-
sm: "gap-2.5 px-3 py-2.5",
|
|
36
|
-
xs: "gap-2 px-2.5 py-2 [[data-slot=dropdown-menu-content]_&]:p-0",
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
defaultVariants: {
|
|
40
|
-
variant: "default",
|
|
41
|
-
size: "default",
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
function Item(params) {
|
|
45
|
-
const { className, variant = "default", size = "default", asChild = false } = params, props = __rest(params, ["className", "variant", "size", "asChild"]);
|
|
46
|
-
const Comp = asChild ? Slot.Root : "div";
|
|
47
|
-
return (_jsx(Comp, Object.assign({ "data-slot": "item", "data-variant": variant, "data-size": size, className: mergeClassNames(itemVariants({ variant, size, className })) }, props)));
|
|
48
|
-
}
|
|
49
|
-
const itemMediaVariants = cva("gap-2 group-has-[[data-slot=item-description]]/item:translate-y-0.5 group-has-[[data-slot=item-description]]/item:self-start flex shrink-0 items-center justify-center [&_svg]:pointer-events-none", {
|
|
50
|
-
variants: {
|
|
51
|
-
variant: {
|
|
52
|
-
default: "bg-transparent",
|
|
53
|
-
icon: "[&_svg:not([class*='size-'])]:size-4",
|
|
54
|
-
image: "size-10 overflow-hidden rounded-sm group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 [&_img]:size-full [&_img]:object-cover",
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
defaultVariants: {
|
|
58
|
-
variant: "default",
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
function ItemMedia(params) {
|
|
62
|
-
const { className, variant = "default" } = params, props = __rest(params, ["className", "variant"]);
|
|
63
|
-
return (_jsx("div", Object.assign({ "data-slot": "item-media", "data-variant": variant, className: mergeClassNames(itemMediaVariants({ variant, className })) }, props)));
|
|
64
|
-
}
|
|
65
|
-
function ItemContent(params) {
|
|
66
|
-
const { className } = params, props = __rest(params, ["className"]);
|
|
67
|
-
return (_jsx("div", Object.assign({ "data-slot": "item-content", className: mergeClassNames("gap-1 group-data-[size=xs]/item:gap-0 flex flex-1 flex-col [&+[data-slot=item-content]]:flex-none", className) }, props)));
|
|
68
|
-
}
|
|
69
|
-
function ItemTitle(params) {
|
|
70
|
-
const { className } = params, props = __rest(params, ["className"]);
|
|
71
|
-
return (_jsx("div", Object.assign({ "data-slot": "item-title", className: mergeClassNames("gap-2 text-sm leading-snug font-medium underline-offset-4 line-clamp-1 flex w-fit items-center", className) }, props)));
|
|
72
|
-
}
|
|
73
|
-
function ItemDescription(params) {
|
|
74
|
-
const { className } = params, props = __rest(params, ["className"]);
|
|
75
|
-
return (_jsx("p", Object.assign({ "data-slot": "item-description", className: mergeClassNames("text-muted-foreground text-left text-sm leading-normal group-data-[size=xs]/item:text-xs [&>a:hover]:text-primary line-clamp-2 font-normal [&>a]:underline [&>a]:underline-offset-4", className) }, props)));
|
|
76
|
-
}
|
|
77
|
-
function ItemActions(params) {
|
|
78
|
-
const { className } = params, props = __rest(params, ["className"]);
|
|
79
|
-
return (_jsx("div", Object.assign({ "data-slot": "item-actions", className: mergeClassNames("gap-2 flex items-center", className) }, props)));
|
|
80
|
-
}
|
|
81
|
-
function ItemHeader(params) {
|
|
82
|
-
const { className } = params, props = __rest(params, ["className"]);
|
|
83
|
-
return (_jsx("div", Object.assign({ "data-slot": "item-header", className: mergeClassNames("gap-2 flex basis-full items-center justify-between", className) }, props)));
|
|
84
|
-
}
|
|
85
|
-
function ItemFooter(params) {
|
|
86
|
-
const { className } = params, props = __rest(params, ["className"]);
|
|
87
|
-
return (_jsx("div", Object.assign({ "data-slot": "item-footer", className: mergeClassNames("gap-2 flex basis-full items-center justify-between", className) }, props)));
|
|
88
|
-
}
|
|
89
|
-
export { Item, ItemMedia, ItemContent, ItemActions, ItemGroup, ItemSeparator, ItemTitle, ItemDescription, ItemHeader, ItemFooter, };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import 'jsoneditor/dist/jsoneditor.css';
|
|
2
|
-
export interface JsonViewProps {
|
|
3
|
-
value?: unknown;
|
|
4
|
-
onChange?: (value: unknown) => void;
|
|
5
|
-
readonly?: boolean;
|
|
6
|
-
className?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare const JsonView: ((props: JsonViewProps) => import("react").JSX.Element) & {
|
|
9
|
-
displayName: string;
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/components/json-view/index.tsx"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAA;AAkBvC,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,eAAO,MAAM,QAAQ,WAAoB,aAAa;;CA+CpD,CAAA"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import 'jsoneditor/dist/jsoneditor.css';
|
|
3
|
-
import JSONEditor from 'jsoneditor';
|
|
4
|
-
import { observer } from 'mobx-react-lite';
|
|
5
|
-
import { useEffect, useRef } from 'react';
|
|
6
|
-
import { mergeClassNames } from '../../utils/merge-class-names/index.js';
|
|
7
|
-
export const JsonView = observer((props) => {
|
|
8
|
-
const { value, onChange, readonly = false, className } = props;
|
|
9
|
-
const containerRef = useRef(null);
|
|
10
|
-
const editorRef = useRef(null);
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
if (!containerRef.current)
|
|
13
|
-
return;
|
|
14
|
-
const options = {
|
|
15
|
-
mode: 'code',
|
|
16
|
-
modes: readonly ? ['view', 'code'] : ['tree', 'code', 'form', 'view'],
|
|
17
|
-
onChange: () => {
|
|
18
|
-
if (onChange && editorRef.current && !readonly) {
|
|
19
|
-
try {
|
|
20
|
-
const json = editorRef.current.get();
|
|
21
|
-
onChange(json);
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
console.error('Invalid JSON', error);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
const EditorCtor = JSONEditor;
|
|
30
|
-
editorRef.current = new EditorCtor(containerRef.current, options);
|
|
31
|
-
editorRef.current.set(value || {});
|
|
32
|
-
return () => {
|
|
33
|
-
var _a;
|
|
34
|
-
(_a = editorRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
35
|
-
};
|
|
36
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
-
}, []);
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
if (editorRef.current) {
|
|
40
|
-
try {
|
|
41
|
-
const currentValue = editorRef.current.get();
|
|
42
|
-
if (JSON.stringify(currentValue) !== JSON.stringify(value)) {
|
|
43
|
-
editorRef.current.set(value || {});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
catch (_a) {
|
|
47
|
-
editorRef.current.set(value || {});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}, [value]);
|
|
51
|
-
return _jsx("div", { ref: containerRef, className: mergeClassNames('h-96 w-full', className) });
|
|
52
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { JsonViewProps } from '../index.js';
|
|
2
|
-
/**
|
|
3
|
-
* JsonView 的 Lazy Loading Wrapper
|
|
4
|
-
*
|
|
5
|
-
* 优化原因:
|
|
6
|
-
* - jsoneditor 库体积很大(~200-300 KB)
|
|
7
|
-
* - 不是所有页面都需要 JSON 编辑器
|
|
8
|
-
* - 使用 lazy loading 减少首屏加载体积
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```tsx
|
|
12
|
-
* import { JsonView } from '@taicode/common-web/components/json-view/lazy'
|
|
13
|
-
*
|
|
14
|
-
* <JsonView value={data} onChange={handleChange} />
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export declare function JsonView(props: JsonViewProps): import("react").JSX.Element;
|
|
18
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../source/components/json-view/lazy/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAKhD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,+BAY5C"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { lazy, Suspense } from 'react';
|
|
3
|
-
// Lazy load JsonView 组件(包含大型 jsoneditor 库)
|
|
4
|
-
const JsonViewLazy = lazy(() => import('../index.js').then(m => ({ default: m.JsonView })));
|
|
5
|
-
/**
|
|
6
|
-
* JsonView 的 Lazy Loading Wrapper
|
|
7
|
-
*
|
|
8
|
-
* 优化原因:
|
|
9
|
-
* - jsoneditor 库体积很大(~200-300 KB)
|
|
10
|
-
* - 不是所有页面都需要 JSON 编辑器
|
|
11
|
-
* - 使用 lazy loading 减少首屏加载体积
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```tsx
|
|
15
|
-
* import { JsonView } from '@taicode/common-web/components/json-view/lazy'
|
|
16
|
-
*
|
|
17
|
-
* <JsonView value={data} onChange={handleChange} />
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export function JsonView(props) {
|
|
21
|
-
return (_jsx(Suspense, { fallback: _jsx("div", { className: "flex h-48 items-center justify-center rounded-md border border-zinc-200 dark:border-zinc-800", children: _jsx("div", { className: "text-sm text-zinc-500 dark:text-zinc-400", children: "Loading JSON Editor..." }) }), children: _jsx(JsonViewLazy, Object.assign({}, props)) }));
|
|
22
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"kbd.d.ts","sourceRoot":"","sources":["../../source/components/kbd.tsx"],"names":[],"mappings":"AAEA,iBAAS,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,+BAY/C;AAED,iBAAS,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,+BASpD;AAED,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAA"}
|
package/output/components/kbd.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { mergeClassNames } from "../utils/merge-class-names/index.js";
|
|
14
|
-
function Kbd(params) {
|
|
15
|
-
const { className } = params, props = __rest(params, ["className"]);
|
|
16
|
-
return (_jsx("kbd", Object.assign({ "data-slot": "kbd", className: mergeClassNames("bg-muted text-muted-foreground [[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10 h-5 w-fit min-w-5 gap-1 rounded-sm px-1 font-sans text-xs font-medium [&_svg:not([class*='size-'])]:size-3 pointer-events-none inline-flex items-center justify-center select-none", className) }, props)));
|
|
17
|
-
}
|
|
18
|
-
function KbdGroup(params) {
|
|
19
|
-
const { className } = params, props = __rest(params, ["className"]);
|
|
20
|
-
return (_jsx("kbd", Object.assign({ "data-slot": "kbd-group", className: mergeClassNames("gap-1 inline-flex items-center", className) }, props)));
|
|
21
|
-
}
|
|
22
|
-
export { Kbd, KbdGroup };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"label.d.ts","sourceRoot":"","sources":["../../source/components/label.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,KAAK,IAAI,cAAc,EAAE,MAAM,UAAU,CAAA;AAIlD,iBAAS,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,IAAI,CAAC,qBAYtE;AAED,OAAO,EAAE,KAAK,EAAE,CAAA"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import * as React from 'react';
|
|
14
|
-
import { Label as LabelPrimitive } from 'radix-ui';
|
|
15
|
-
import { mergeClassNames } from '../utils/merge-class-names/index.js';
|
|
16
|
-
function Label(params) {
|
|
17
|
-
const { className } = params, props = __rest(params, ["className"]);
|
|
18
|
-
return (_jsx(LabelPrimitive.Root, Object.assign({ "data-slot": "label", className: mergeClassNames('gap-2 text-sm leading-none font-medium group-data-[disabled=true]:opacity-50 peer-disabled:opacity-50 flex items-center select-none group-data-[disabled=true]:pointer-events-none peer-disabled:cursor-not-allowed', className) }, props)));
|
|
19
|
-
}
|
|
20
|
-
export { Label };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
type RefreshButtonProps = {
|
|
2
|
-
onClick: () => void;
|
|
3
|
-
loading?: boolean;
|
|
4
|
-
label?: string;
|
|
5
|
-
};
|
|
6
|
-
export declare function RefreshButton(props: RefreshButtonProps): import("react").JSX.Element;
|
|
7
|
-
type ResetButtonProps = {
|
|
8
|
-
onClick: () => void;
|
|
9
|
-
label?: string;
|
|
10
|
-
};
|
|
11
|
-
export declare function ResetButton(props: ResetButtonProps): import("react").JSX.Element;
|
|
12
|
-
type FilterActionsProps = {
|
|
13
|
-
onApply: () => void;
|
|
14
|
-
onReset: () => void;
|
|
15
|
-
onRefresh?: () => void;
|
|
16
|
-
loading?: boolean;
|
|
17
|
-
applyLabel?: string;
|
|
18
|
-
resetLabel?: string;
|
|
19
|
-
refreshLabel?: string;
|
|
20
|
-
};
|
|
21
|
-
export declare function FilterActions(props: FilterActionsProps): import("react").JSX.Element;
|
|
22
|
-
export {};
|
|
23
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/components/list-actions/index.tsx"],"names":[],"mappings":"AAIA,KAAK,kBAAkB,GAAG;IACxB,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,+BAQtD;AAED,KAAK,gBAAgB,GAAG;IACtB,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,+BAQlD;AAED,KAAK,kBAAkB,GAAG;IACxB,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,+BAatD"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { RefreshCwIcon, RotateCcwIcon, SearchIcon } from 'lucide-react';
|
|
3
|
-
import { Button } from '../button.js';
|
|
4
|
-
export function RefreshButton(props) {
|
|
5
|
-
const { onClick, loading = false, label = 'Refresh' } = props;
|
|
6
|
-
return (_jsx(Button, { variant: "outline", size: "icon", className: "size-9", onClick: onClick, disabled: loading, "aria-label": label, title: label, children: _jsx(RefreshCwIcon, { className: loading ? 'size-4 animate-spin' : 'size-4' }) }));
|
|
7
|
-
}
|
|
8
|
-
export function ResetButton(props) {
|
|
9
|
-
const { onClick, label = 'Reset' } = props;
|
|
10
|
-
return (_jsx(Button, { onClick: onClick, variant: "outline", size: "icon", className: "size-9", "aria-label": label, title: label, children: _jsx(RotateCcwIcon, { className: "size-4" }) }));
|
|
11
|
-
}
|
|
12
|
-
export function FilterActions(props) {
|
|
13
|
-
const { onApply, onReset, onRefresh, loading = false, applyLabel = 'Filter', resetLabel = 'Reset', refreshLabel = 'Refresh' } = props;
|
|
14
|
-
return (_jsxs("div", { className: "flex shrink-0 items-center gap-2", children: [_jsxs(Button, { onClick: onApply, className: "h-9", children: [_jsx(SearchIcon, { className: "size-4" }), applyLabel] }), _jsx(ResetButton, { onClick: onReset, label: resetLabel }), onRefresh && _jsx(RefreshButton, { onClick: onRefresh, loading: loading, label: refreshLabel })] }));
|
|
15
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import React, { type ComponentPropsWithoutRef, type ElementType } from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* 多态组件的 Props 类型
|
|
4
|
-
*/
|
|
5
|
-
type PolymorphicProps<T extends ElementType> = {
|
|
6
|
-
as?: T;
|
|
7
|
-
loading?: boolean;
|
|
8
|
-
loadingText?: string;
|
|
9
|
-
loadingIcon?: React.ReactNode;
|
|
10
|
-
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void | Promise<void>;
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
children?: React.ReactNode;
|
|
13
|
-
} & Omit<ComponentPropsWithoutRef<T>, 'as' | 'loading' | 'loadingText' | 'loadingIcon' | 'onClick'>;
|
|
14
|
-
/**
|
|
15
|
-
* LoadingButton 组件
|
|
16
|
-
*
|
|
17
|
-
* 支持任意组件作为基础按钮,在异步操作时自动显示 loading 状态
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```tsx
|
|
21
|
-
* // 使用默认 button
|
|
22
|
-
* <LoadingButton onClick={async () => await save()}>
|
|
23
|
-
* 保存
|
|
24
|
-
* </LoadingButton>
|
|
25
|
-
*
|
|
26
|
-
* // 使用自定义组件
|
|
27
|
-
* <LoadingButton as={MyButton} onClick={async () => await save()}>
|
|
28
|
-
* 保存
|
|
29
|
-
* </LoadingButton>
|
|
30
|
-
*
|
|
31
|
-
* // 自定义 loading 图标
|
|
32
|
-
* <LoadingButton loadingIcon={<MySpinner />} onClick={async () => await save()}>
|
|
33
|
-
* 保存
|
|
34
|
-
* </LoadingButton>
|
|
35
|
-
*
|
|
36
|
-
* // 手动控制 loading 状态
|
|
37
|
-
* <LoadingButton loading={isLoading}>
|
|
38
|
-
* 保存
|
|
39
|
-
* </LoadingButton>
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export declare const LoadingButton: React.ForwardRefExoticComponent<Omit<PolymorphicProps<React.ElementType>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
43
|
-
export {};
|
|
44
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/components/loading-button/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAqC,KAAK,wBAAwB,EAAE,KAAK,WAAW,EAAE,MAAM,OAAO,CAAA;AAkCjH;;GAEG;AACH,KAAK,gBAAgB,CAAC,CAAC,SAAS,WAAW,IAAI;IAC7C,EAAE,CAAC,EAAE,CAAC,CAAA;IACN,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC7B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9E,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,GAAG,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,IAAI,GAAG,SAAS,GAAG,aAAa,GAAG,aAAa,GAAG,SAAS,CAAC,CAAA;AAEnG;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,aAAa,4HAkEzB,CAAA"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
-
import React, { useState, useCallback, forwardRef } from 'react';
|
|
14
|
-
function isPromiseLike(value) {
|
|
15
|
-
return value != null && typeof value === 'object' && 'then' in value && typeof value.then === 'function';
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Loading 指示器组件
|
|
19
|
-
*/
|
|
20
|
-
function LoadingSpinner({ className = '' }) {
|
|
21
|
-
return (_jsxs("svg", { className: `animate-spin ${className}`, xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [_jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), _jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }));
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* LoadingButton 组件
|
|
25
|
-
*
|
|
26
|
-
* 支持任意组件作为基础按钮,在异步操作时自动显示 loading 状态
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```tsx
|
|
30
|
-
* // 使用默认 button
|
|
31
|
-
* <LoadingButton onClick={async () => await save()}>
|
|
32
|
-
* 保存
|
|
33
|
-
* </LoadingButton>
|
|
34
|
-
*
|
|
35
|
-
* // 使用自定义组件
|
|
36
|
-
* <LoadingButton as={MyButton} onClick={async () => await save()}>
|
|
37
|
-
* 保存
|
|
38
|
-
* </LoadingButton>
|
|
39
|
-
*
|
|
40
|
-
* // 自定义 loading 图标
|
|
41
|
-
* <LoadingButton loadingIcon={<MySpinner />} onClick={async () => await save()}>
|
|
42
|
-
* 保存
|
|
43
|
-
* </LoadingButton>
|
|
44
|
-
*
|
|
45
|
-
* // 手动控制 loading 状态
|
|
46
|
-
* <LoadingButton loading={isLoading}>
|
|
47
|
-
* 保存
|
|
48
|
-
* </LoadingButton>
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
export const LoadingButton = forwardRef(function LoadingButton(_a, ref) {
|
|
52
|
-
var { as, loading: externalLoading, loadingText, loadingIcon, onClick, disabled, children, className = '' } = _a, props = __rest(_a, ["as", "loading", "loadingText", "loadingIcon", "onClick", "disabled", "children", "className"]);
|
|
53
|
-
const [internalLoading, setInternalLoading] = useState(false);
|
|
54
|
-
const loading = externalLoading !== null && externalLoading !== void 0 ? externalLoading : internalLoading;
|
|
55
|
-
const handleClick = useCallback((event) => {
|
|
56
|
-
if (!onClick || loading || disabled)
|
|
57
|
-
return;
|
|
58
|
-
const result = onClick(event);
|
|
59
|
-
// 如果返回 Promise-like,自动管理 loading 状态
|
|
60
|
-
// 使用 then 而不是 finally,因为 PromiseLike 不保证有 finally 方法
|
|
61
|
-
if (isPromiseLike(result)) {
|
|
62
|
-
setInternalLoading(true);
|
|
63
|
-
result.then(() => setInternalLoading(false), () => setInternalLoading(false));
|
|
64
|
-
}
|
|
65
|
-
}, [onClick, loading, disabled]);
|
|
66
|
-
// 使用 as prop 或默认 button
|
|
67
|
-
const Component = as || 'button';
|
|
68
|
-
// 默认 button 样式(仅当使用默认 button 时应用)
|
|
69
|
-
const defaultButtonClass = !as
|
|
70
|
-
? 'inline-flex items-center justify-center gap-2 rounded-[var(--radius)] bg-[var(--primary)] px-4 py-2 text-sm font-medium text-[var(--primary-foreground)] shadow-sm transition-opacity hover:opacity-90 focus:outline-none focus:ring-2 focus:ring-[var(--ring)] focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed'
|
|
71
|
-
: '';
|
|
72
|
-
const finalClassName = `${defaultButtonClass} ${className}`.trim();
|
|
73
|
-
return (_jsx(Component, Object.assign({ ref: ref, onClick: handleClick, disabled: disabled || loading, className: finalClassName }, props, { children: loading ? (_jsxs(_Fragment, { children: [loadingIcon || _jsx(LoadingSpinner, { className: "size-4" }), loadingText || children] })) : (children) })));
|
|
74
|
-
});
|
|
75
|
-
LoadingButton.displayName = 'LoadingButton';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../source/components/loading-button/index.test.tsx"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAA"}
|