asheeui 1.1.0 → 2.0.0
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 +201 -21
- package/NOTICE +10 -0
- package/README.md +3 -1
- package/dist/components/accordion/Accordion.d.ts +1 -1
- package/dist/components/centered/Centered.d.ts +49 -0
- package/dist/components/centered/Centered.d.ts.map +1 -0
- package/dist/components/centered/Centered.js +32 -0
- package/dist/components/centered/centered-config.d.ts +63 -0
- package/dist/components/centered/centered-config.d.ts.map +1 -0
- package/dist/components/centered/centered-config.js +17 -0
- package/dist/components/centered/centered-styles.d.ts +11 -0
- package/dist/components/centered/centered-styles.d.ts.map +1 -0
- package/dist/components/centered/centered-styles.js +9 -0
- package/dist/components/centered/index.d.ts +3 -0
- package/dist/components/centered/index.d.ts.map +1 -0
- package/dist/components/centered/index.js +3 -0
- package/dist/components/chip/Chip.d.ts +8 -0
- package/dist/components/chip/Chip.d.ts.map +1 -1
- package/dist/components/chip/Chip.js +15 -15
- package/dist/components/data-table/DataTable.d.ts +137 -0
- package/dist/components/data-table/DataTable.d.ts.map +1 -0
- package/dist/components/data-table/DataTable.js +101 -0
- package/dist/components/data-table/data-table-config.d.ts +75 -0
- package/dist/components/data-table/data-table-config.d.ts.map +1 -0
- package/dist/components/data-table/data-table-config.js +24 -0
- package/dist/components/data-table/data-table-styles.d.ts +25 -0
- package/dist/components/data-table/data-table-styles.d.ts.map +1 -0
- package/dist/components/data-table/data-table-styles.js +5 -0
- package/dist/components/data-table/index.d.ts +3 -0
- package/dist/components/data-table/index.d.ts.map +1 -0
- package/dist/components/data-table/index.js +3 -0
- package/dist/components/docs-layout/DocsLayout.d.ts +94 -0
- package/dist/components/docs-layout/DocsLayout.d.ts.map +1 -0
- package/dist/components/docs-layout/DocsLayout.js +62 -0
- package/dist/components/docs-layout/docs-layout-config.d.ts +61 -0
- package/dist/components/docs-layout/docs-layout-config.d.ts.map +1 -0
- package/dist/components/docs-layout/docs-layout-config.js +22 -0
- package/dist/components/docs-layout/docs-layout-styles.d.ts +31 -0
- package/dist/components/docs-layout/docs-layout-styles.d.ts.map +1 -0
- package/dist/components/docs-layout/docs-layout-styles.js +5 -0
- package/dist/components/docs-layout/index.d.ts +3 -0
- package/dist/components/docs-layout/index.d.ts.map +1 -0
- package/dist/components/docs-layout/index.js +3 -0
- package/dist/components/empty-state/EmptyState.d.ts +19 -1
- package/dist/components/empty-state/EmptyState.d.ts.map +1 -1
- package/dist/components/empty-state/EmptyState.js +10 -9
- package/dist/components/error-state/ErrorState.d.ts +98 -0
- package/dist/components/error-state/ErrorState.d.ts.map +1 -0
- package/dist/components/error-state/ErrorState.js +57 -0
- package/dist/components/error-state/error-state-config.d.ts +66 -0
- package/dist/components/error-state/error-state-config.d.ts.map +1 -0
- package/dist/components/error-state/error-state-config.js +20 -0
- package/dist/components/error-state/error-state-styles.d.ts +17 -0
- package/dist/components/error-state/error-state-styles.d.ts.map +1 -0
- package/dist/components/error-state/error-state-styles.js +5 -0
- package/dist/components/error-state/index.d.ts +3 -0
- package/dist/components/error-state/index.d.ts.map +1 -0
- package/dist/components/error-state/index.js +3 -0
- package/dist/components/file-upload/FileUpload.d.ts +112 -0
- package/dist/components/file-upload/FileUpload.d.ts.map +1 -0
- package/dist/components/file-upload/FileUpload.js +83 -0
- package/dist/components/file-upload/file-upload-config.d.ts +41 -0
- package/dist/components/file-upload/file-upload-config.d.ts.map +1 -0
- package/dist/components/file-upload/file-upload-config.js +16 -0
- package/dist/components/file-upload/file-upload-styles.d.ts +22 -0
- package/dist/components/file-upload/file-upload-styles.d.ts.map +1 -0
- package/dist/components/file-upload/file-upload-styles.js +9 -0
- package/dist/components/file-upload/file-upload.helpers.d.ts +26 -0
- package/dist/components/file-upload/file-upload.helpers.d.ts.map +1 -0
- package/dist/components/file-upload/file-upload.helpers.js +17 -0
- package/dist/components/file-upload/index.d.ts +3 -0
- package/dist/components/file-upload/index.d.ts.map +1 -0
- package/dist/components/file-upload/index.js +4 -0
- package/dist/components/loading-state/LoadingState.d.ts +57 -0
- package/dist/components/loading-state/LoadingState.d.ts.map +1 -0
- package/dist/components/loading-state/LoadingState.js +44 -0
- package/dist/components/loading-state/index.d.ts +3 -0
- package/dist/components/loading-state/index.d.ts.map +1 -0
- package/dist/components/loading-state/index.js +3 -0
- package/dist/components/loading-state/loading-state-config.d.ts +49 -0
- package/dist/components/loading-state/loading-state-config.d.ts.map +1 -0
- package/dist/components/loading-state/loading-state-config.js +18 -0
- package/dist/components/loading-state/loading-state-styles.d.ts +12 -0
- package/dist/components/loading-state/loading-state-styles.d.ts.map +1 -0
- package/dist/components/loading-state/loading-state-styles.js +9 -0
- package/dist/components/marketing-layout/MarketingLayout.d.ts +83 -0
- package/dist/components/marketing-layout/MarketingLayout.d.ts.map +1 -0
- package/dist/components/marketing-layout/MarketingLayout.js +40 -0
- package/dist/components/marketing-layout/index.d.ts +3 -0
- package/dist/components/marketing-layout/index.d.ts.map +1 -0
- package/dist/components/marketing-layout/index.js +3 -0
- package/dist/components/marketing-layout/marketing-layout-config.d.ts +60 -0
- package/dist/components/marketing-layout/marketing-layout-config.d.ts.map +1 -0
- package/dist/components/marketing-layout/marketing-layout-config.js +16 -0
- package/dist/components/marketing-layout/marketing-layout-styles.d.ts +8 -0
- package/dist/components/marketing-layout/marketing-layout-styles.d.ts.map +1 -0
- package/dist/components/marketing-layout/marketing-layout-styles.js +8 -0
- package/dist/components/search-input/SearchInput.d.ts +111 -0
- package/dist/components/search-input/SearchInput.d.ts.map +1 -0
- package/dist/components/search-input/SearchInput.js +86 -0
- package/dist/components/search-input/index.d.ts +3 -0
- package/dist/components/search-input/index.d.ts.map +1 -0
- package/dist/components/search-input/index.js +3 -0
- package/dist/components/search-input/search-input-config.d.ts +55 -0
- package/dist/components/search-input/search-input-config.d.ts.map +1 -0
- package/dist/components/search-input/search-input-config.js +20 -0
- package/dist/components/search-input/search-input-styles.d.ts +16 -0
- package/dist/components/search-input/search-input-styles.d.ts.map +1 -0
- package/dist/components/search-input/search-input-styles.js +9 -0
- package/dist/components/section-kit/ActionGroup.d.ts +8 -1
- package/dist/components/section-kit/ActionGroup.d.ts.map +1 -1
- package/dist/components/section-kit/ActionGroup.js +13 -9
- package/dist/components/section-kit/SkipLink.d.ts +50 -0
- package/dist/components/section-kit/SkipLink.d.ts.map +1 -0
- package/dist/components/section-kit/SkipLink.js +14 -0
- package/dist/components/section-kit/index.d.ts +5 -4
- package/dist/components/section-kit/index.d.ts.map +1 -1
- package/dist/components/section-kit/index.js +1 -0
- package/dist/components/sidebar-layout/SidebarLayout.d.ts.map +1 -1
- package/dist/components/sidebar-layout/SidebarLayout.js +25 -25
- package/dist/components/sidebar-layout/sidebar-layout-styles.d.ts +10 -3
- package/dist/components/sidebar-layout/sidebar-layout-styles.d.ts.map +1 -1
- package/dist/components/sidebar-layout/sidebar-layout-styles.js +2 -2
- package/dist/components/split/Split.d.ts +68 -0
- package/dist/components/split/Split.d.ts.map +1 -0
- package/dist/components/split/Split.js +36 -0
- package/dist/components/split/index.d.ts +3 -0
- package/dist/components/split/index.d.ts.map +1 -0
- package/dist/components/split/index.js +3 -0
- package/dist/components/split/split-config.d.ts +83 -0
- package/dist/components/split/split-config.d.ts.map +1 -0
- package/dist/components/split/split-config.js +20 -0
- package/dist/components/split/split-styles.d.ts +36 -0
- package/dist/components/split/split-styles.d.ts.map +1 -0
- package/dist/components/split/split-styles.js +76 -0
- package/dist/components/stepper/Stepper.d.ts +94 -0
- package/dist/components/stepper/Stepper.d.ts.map +1 -0
- package/dist/components/stepper/Stepper.js +71 -0
- package/dist/components/stepper/index.d.ts +3 -0
- package/dist/components/stepper/index.d.ts.map +1 -0
- package/dist/components/stepper/index.js +3 -0
- package/dist/components/stepper/stepper-config.d.ts +51 -0
- package/dist/components/stepper/stepper-config.d.ts.map +1 -0
- package/dist/components/stepper/stepper-config.js +16 -0
- package/dist/components/stepper/stepper-styles.d.ts +30 -0
- package/dist/components/stepper/stepper-styles.d.ts.map +1 -0
- package/dist/components/stepper/stepper-styles.js +25 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +93 -73
- package/dist/shared/spacing.d.ts +8 -0
- package/dist/shared/spacing.d.ts.map +1 -1
- package/dist/shared/spacing.js +9 -1
- package/package.json +5 -3
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DocsLayout component styles for AsheeUI.
|
|
3
|
+
* This file provides the static class mappings for the documentation
|
|
4
|
+
* composition: the page shell, the article column, the table of contents column
|
|
5
|
+
* and the article body's reading measure.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* The page shell.
|
|
9
|
+
* It wraps the application shell rather than replacing it, so the skip link can
|
|
10
|
+
* be the first focusable element of the page.
|
|
11
|
+
*/
|
|
12
|
+
export declare const DOCS_LAYOUT_CLASS = "flex min-h-dvh w-full flex-col bg-background";
|
|
13
|
+
/** The application shell inside the page shell. */
|
|
14
|
+
export declare const DOCS_LAYOUT_SHELL_CLASS = "flex-1";
|
|
15
|
+
/**
|
|
16
|
+
* The article column.
|
|
17
|
+
* It is the region the skip link leads to, so it takes focus when the link is
|
|
18
|
+
* followed.
|
|
19
|
+
*/
|
|
20
|
+
export declare const DOCS_LAYOUT_ARTICLE_CLASS = "flex w-full min-w-0 flex-col";
|
|
21
|
+
/**
|
|
22
|
+
* The reading measure of the article body.
|
|
23
|
+
* A documentation page is read rather than scanned, so the body keeps a readable
|
|
24
|
+
* line length while the columns around it may be wider.
|
|
25
|
+
*/
|
|
26
|
+
export declare const DOCS_LAYOUT_BODY_CLASS = "flex flex-col gap-6 max-w-3xl";
|
|
27
|
+
/** The table of contents column. */
|
|
28
|
+
export declare const DOCS_LAYOUT_TOC_CLASS = "hidden w-full xl:block xl:w-64 xl:shrink-0";
|
|
29
|
+
/** Keeps the table of contents in view while the article scrolls. */
|
|
30
|
+
export declare const DOCS_LAYOUT_TOC_STICKY_CLASS = "xl:sticky xl:top-0 xl:self-start";
|
|
31
|
+
//# sourceMappingURL=docs-layout-styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-layout-styles.d.ts","sourceRoot":"","sources":["../../../src/components/docs-layout/docs-layout-styles.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,iDAAiD,CAAC;AAEhF,mDAAmD;AACnD,eAAO,MAAM,uBAAuB,WAAW,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,iCAAiC,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,kCAAkC,CAAC;AAEtE,oCAAoC;AACpC,eAAO,MAAM,qBAAqB,+CACY,CAAC;AAE/C,qEAAqE;AACrE,eAAO,MAAM,4BAA4B,qCAAqC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
//#region src/components/docs-layout/docs-layout-styles.ts
|
|
3
|
+
var e = "flex min-h-dvh w-full flex-col bg-background", t = "flex-1", n = "flex w-full min-w-0 flex-col", r = "flex flex-col gap-6 max-w-3xl", i = "hidden w-full xl:block xl:w-64 xl:shrink-0", a = "xl:sticky xl:top-0 xl:self-start";
|
|
4
|
+
//#endregion
|
|
5
|
+
export { n as DOCS_LAYOUT_ARTICLE_CLASS, r as DOCS_LAYOUT_BODY_CLASS, e as DOCS_LAYOUT_CLASS, t as DOCS_LAYOUT_SHELL_CLASS, i as DOCS_LAYOUT_TOC_CLASS, a as DOCS_LAYOUT_TOC_STICKY_CLASS };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/docs-layout/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC"}
|
|
@@ -30,6 +30,13 @@ export interface EmptyStateProps extends BaseEmptyStateProps {
|
|
|
30
30
|
* @default "div"
|
|
31
31
|
*/
|
|
32
32
|
as?: ElementType;
|
|
33
|
+
/**
|
|
34
|
+
* Actions that carry a React handler.
|
|
35
|
+
* A configured action describes a destination rather than a callback, so an
|
|
36
|
+
* action that runs one (a retry, a dismissal) is passed here and rendered in
|
|
37
|
+
* the same group as the configured actions.
|
|
38
|
+
*/
|
|
39
|
+
actions?: ReactNode;
|
|
33
40
|
/** Content below the actions. */
|
|
34
41
|
children?: ReactNode;
|
|
35
42
|
}
|
|
@@ -65,10 +72,21 @@ export interface EmptyStateProps extends BaseEmptyStateProps {
|
|
|
65
72
|
* icon={<SearchIcon />}
|
|
66
73
|
* title="No campaigns match that filter"
|
|
67
74
|
* description="Try a different name, or clear the filter to see everything."
|
|
68
|
-
* primaryAction={{ label: "
|
|
75
|
+
* primaryAction={{ label: "See all campaigns", href: "/campaigns" }}
|
|
69
76
|
* />
|
|
70
77
|
* ```
|
|
71
78
|
*
|
|
79
|
+
* A configured action describes a destination, so an action that runs a handler
|
|
80
|
+
* is passed as a child instead:
|
|
81
|
+
*
|
|
82
|
+
* ```tsx
|
|
83
|
+
* <EmptyState title="No campaigns match that filter">
|
|
84
|
+
* <Button variant="solid" onClick={clearFilters}>
|
|
85
|
+
* Clear filters
|
|
86
|
+
* </Button>
|
|
87
|
+
* </EmptyState>
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
72
90
|
* @see Skeleton - The loading presentation of the same region.
|
|
73
91
|
* @see Alert - An inline message that is not a whole region.
|
|
74
92
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmptyState.d.ts","sourceRoot":"","sources":["../../../src/components/empty-state/EmptyState.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAKjD,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,sBAAsB,CAAC;AAS9B,KAAK,mBAAmB,GAAG,gBAAgB,GACzC,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,mBAAmB;IAC1D,kCAAkC;IAClC,IAAI,CAAC,EAAE,SAAS,CAAC;IAEjB,6DAA6D;IAC7D,KAAK,EAAE,SAAS,CAAC;IAEjB,uCAAuC;IACvC,WAAW,CAAC,EAAE,SAAS,CAAC;IAExB,8EAA8E;IAC9E,aAAa,CAAC,EAAE,YAAY,CAAC;IAE7B,oEAAoE;IACpE,eAAe,CAAC,EAAE,YAAY,CAAC;IAE/B;;;;;OAKG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAE1B;;;;;OAKG;IACH,EAAE,CAAC,EAAE,WAAW,CAAC;IAEjB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED
|
|
1
|
+
{"version":3,"file":"EmptyState.d.ts","sourceRoot":"","sources":["../../../src/components/empty-state/EmptyState.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAKjD,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,sBAAsB,CAAC;AAS9B,KAAK,mBAAmB,GAAG,gBAAgB,GACzC,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,mBAAmB;IAC1D,kCAAkC;IAClC,IAAI,CAAC,EAAE,SAAS,CAAC;IAEjB,6DAA6D;IAC7D,KAAK,EAAE,SAAS,CAAC;IAEjB,uCAAuC;IACvC,WAAW,CAAC,EAAE,SAAS,CAAC;IAExB,8EAA8E;IAC9E,aAAa,CAAC,EAAE,YAAY,CAAC;IAE7B,oEAAoE;IACpE,eAAe,CAAC,EAAE,YAAY,CAAC;IAE/B;;;;;OAKG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAE1B;;;;;OAKG;IACH,EAAE,CAAC,EAAE,WAAW,CAAC;IAEjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IAEpB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,UAAU,4GAwEtB,CAAC"}
|
|
@@ -10,20 +10,20 @@ import { EMPTY_STATE_CLASS as o, EMPTY_STATE_ICON_CLASS as s, EMPTY_STATE_ICON_S
|
|
|
10
10
|
import { forwardRef as u } from "react";
|
|
11
11
|
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
12
12
|
//#region src/components/empty-state/EmptyState.tsx
|
|
13
|
-
var p = u(({ icon: u, title: p, description: m, primaryAction: h, secondaryAction: g, type: _, size: v, panel: y, role: b, as: x, className: S,
|
|
14
|
-
let
|
|
13
|
+
var p = u(({ icon: u, title: p, description: m, primaryAction: h, secondaryAction: g, type: _, size: v, panel: y, role: b, as: x, className: S, actions: C, children: w, ...T }, E) => {
|
|
14
|
+
let D = t(), O = n({
|
|
15
15
|
type: _,
|
|
16
16
|
size: v,
|
|
17
17
|
panel: y
|
|
18
|
-
},
|
|
18
|
+
}, D.components?.emptystate, a);
|
|
19
19
|
return /* @__PURE__ */ f(x ?? "div", {
|
|
20
|
-
ref:
|
|
20
|
+
ref: E,
|
|
21
21
|
role: b,
|
|
22
|
-
className: e(o, l[
|
|
23
|
-
...
|
|
22
|
+
className: e(o, l[O.size], O.panel && "rounded-md border border-border bg-background", S),
|
|
23
|
+
...T,
|
|
24
24
|
children: [
|
|
25
25
|
u && /* @__PURE__ */ d("div", {
|
|
26
|
-
className: e(s[
|
|
26
|
+
className: e(s[O.type], c[O.size]),
|
|
27
27
|
children: u
|
|
28
28
|
}),
|
|
29
29
|
/* @__PURE__ */ d(r, {
|
|
@@ -35,9 +35,10 @@ var p = u(({ icon: u, title: p, description: m, primaryAction: h, secondaryActio
|
|
|
35
35
|
/* @__PURE__ */ d(i, {
|
|
36
36
|
primaryAction: h,
|
|
37
37
|
secondaryAction: g,
|
|
38
|
-
align: "center"
|
|
38
|
+
align: "center",
|
|
39
|
+
children: C
|
|
39
40
|
}),
|
|
40
|
-
|
|
41
|
+
w
|
|
41
42
|
]
|
|
42
43
|
});
|
|
43
44
|
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ElementType, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { ActionConfig } from '../../shared';
|
|
3
|
+
import { ErrorStateConfig } from './error-state-config';
|
|
4
|
+
type BaseErrorStateProps = ErrorStateConfig & Omit<HTMLAttributes<HTMLDivElement>, "color" | "title">;
|
|
5
|
+
/**
|
|
6
|
+
* Props for the ErrorState component.
|
|
7
|
+
*/
|
|
8
|
+
export interface ErrorStateProps extends BaseErrorStateProps {
|
|
9
|
+
/**
|
|
10
|
+
* What failed, in the reader's terms.
|
|
11
|
+
*/
|
|
12
|
+
title: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* What the reader can do about it.
|
|
15
|
+
*/
|
|
16
|
+
description?: ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* The technical detail, typically the message a request returned.
|
|
19
|
+
* It is rendered inside a disclosure rather than in the open, because it is
|
|
20
|
+
* written for a developer rather than for the reader.
|
|
21
|
+
*/
|
|
22
|
+
detail?: ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* Called when the reader asks to try again.
|
|
25
|
+
* Its presence is what renders the retry control.
|
|
26
|
+
*/
|
|
27
|
+
onRetry?: () => void;
|
|
28
|
+
/**
|
|
29
|
+
* The emphasised action, when the way out is a destination rather than a
|
|
30
|
+
* retry.
|
|
31
|
+
*/
|
|
32
|
+
primaryAction?: ActionConfig;
|
|
33
|
+
/**
|
|
34
|
+
* The supporting action.
|
|
35
|
+
*/
|
|
36
|
+
secondaryAction?: ActionConfig;
|
|
37
|
+
/**
|
|
38
|
+
* Icon shown above the title.
|
|
39
|
+
* Defaults to the framework's error icon.
|
|
40
|
+
*/
|
|
41
|
+
icon?: ReactNode;
|
|
42
|
+
/**
|
|
43
|
+
* Element to render.
|
|
44
|
+
* Defaults to a `div`.
|
|
45
|
+
*
|
|
46
|
+
* @default "div"
|
|
47
|
+
*/
|
|
48
|
+
as?: ElementType;
|
|
49
|
+
/**
|
|
50
|
+
* Content below the actions.
|
|
51
|
+
*/
|
|
52
|
+
children?: ReactNode;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A region whose content could not be loaded.
|
|
56
|
+
*
|
|
57
|
+
* The state is an `alert` by default, because it usually replaces content after
|
|
58
|
+
* a request failed and therefore has to be announced. A state that is part of
|
|
59
|
+
* the page from the start, such as a not-found page, passes `role="none"` so it
|
|
60
|
+
* is not announced as a change that just happened.
|
|
61
|
+
*
|
|
62
|
+
* A retry is a React handler rather than a configured action, because a
|
|
63
|
+
* configured action describes a destination. It is rendered in the same group as
|
|
64
|
+
* any configured actions, so the two arrangements agree.
|
|
65
|
+
*
|
|
66
|
+
* @param props - ErrorState configuration options and element attributes.
|
|
67
|
+
* @param props.title - What failed.
|
|
68
|
+
* @param props.description - What the reader can do about it.
|
|
69
|
+
* @param props.detail - The technical message, inside a disclosure.
|
|
70
|
+
* @param props.onRetry - Called when the reader asks to try again.
|
|
71
|
+
* @param props.primaryAction - The emphasised action.
|
|
72
|
+
* @param props.secondaryAction - The supporting action.
|
|
73
|
+
* @param props.size - Density. Defaults to "md".
|
|
74
|
+
* @param props.panel - Draw the state as a panel. Defaults to true.
|
|
75
|
+
* @param props.role - How the state is announced. Defaults to "alert".
|
|
76
|
+
* @param props.retryLabel - Wording of the retry control. Defaults to "Try
|
|
77
|
+
* again".
|
|
78
|
+
* @param props.detailLabel - Wording of the disclosure. Defaults to "Technical
|
|
79
|
+
* details".
|
|
80
|
+
* @param props.as - Element to render. Defaults to "div".
|
|
81
|
+
* @returns The rendered state.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```tsx
|
|
85
|
+
* <ErrorState
|
|
86
|
+
* title="Invoices could not be loaded"
|
|
87
|
+
* description="The request timed out. Trying again usually works."
|
|
88
|
+
* detail={error.message}
|
|
89
|
+
* onRetry={refetch}
|
|
90
|
+
* />
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @see EmptyState - The presentation for a region that has nothing in it.
|
|
94
|
+
* @see LoadingState - The presentation for a region that has not arrived yet.
|
|
95
|
+
*/
|
|
96
|
+
export declare const ErrorState: import('react').ForwardRefExoticComponent<ErrorStateProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
97
|
+
export {};
|
|
98
|
+
//# sourceMappingURL=ErrorState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorState.d.ts","sourceRoot":"","sources":["../../../src/components/error-state/ErrorState.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAIjD,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,sBAAsB,CAAC;AAO9B,KAAK,mBAAmB,GAAG,gBAAgB,GACzC,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,mBAAmB;IAC1D;;OAEG;IACH,KAAK,EAAE,SAAS,CAAC;IAEjB;;OAEG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IAExB;;;;OAIG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;IAEnB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAErB;;;OAGG;IACH,aAAa,CAAC,EAAE,YAAY,CAAC;IAE7B;;OAEG;IACH,eAAe,CAAC,EAAE,YAAY,CAAC;IAE/B;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IAEjB;;;;;OAKG;IACH,EAAE,CAAC,EAAE,WAAW,CAAC;IAEjB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,eAAO,MAAM,UAAU,4GAwEtB,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { useAsheeConfig as e } from "../../libs/context.js";
|
|
4
|
+
import { resolveConfigCascade as t } from "../../utils/resolve-token.js";
|
|
5
|
+
import { ErrorIcon as n } from "../../icons/ErrorIcon.js";
|
|
6
|
+
import { Button as r } from "../button/Button.js";
|
|
7
|
+
import { EmptyState as i } from "../empty-state/EmptyState.js";
|
|
8
|
+
import { FALLBACK_ERROR_STATE_CONFIG as a } from "./error-state-config.js";
|
|
9
|
+
import "./error-state-styles.js";
|
|
10
|
+
import { forwardRef as o } from "react";
|
|
11
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
12
|
+
//#region src/components/error-state/ErrorState.tsx
|
|
13
|
+
var l = o(({ title: o, description: l, detail: u, onRetry: d, primaryAction: f, secondaryAction: p, icon: m, size: h, panel: g, role: _, retryLabel: v, detailLabel: y, as: b, className: x, children: S, ...C }, w) => {
|
|
14
|
+
let T = e(), E = t({
|
|
15
|
+
size: h,
|
|
16
|
+
panel: g,
|
|
17
|
+
role: _,
|
|
18
|
+
retryLabel: v,
|
|
19
|
+
detailLabel: y
|
|
20
|
+
}, T.components?.errorstate, a);
|
|
21
|
+
return /* @__PURE__ */ c(i, {
|
|
22
|
+
...C,
|
|
23
|
+
ref: w,
|
|
24
|
+
as: b,
|
|
25
|
+
className: x,
|
|
26
|
+
type: "error",
|
|
27
|
+
size: E.size,
|
|
28
|
+
panel: E.panel,
|
|
29
|
+
role: E.role === "none" ? void 0 : E.role,
|
|
30
|
+
icon: m ?? /* @__PURE__ */ s(n, {}),
|
|
31
|
+
title: o,
|
|
32
|
+
description: l,
|
|
33
|
+
primaryAction: f,
|
|
34
|
+
secondaryAction: p,
|
|
35
|
+
actions: d ? /* @__PURE__ */ s(r, {
|
|
36
|
+
type: "button",
|
|
37
|
+
variant: "solid",
|
|
38
|
+
color: "danger",
|
|
39
|
+
size: E.size,
|
|
40
|
+
onClick: d,
|
|
41
|
+
children: E.retryLabel
|
|
42
|
+
}) : void 0,
|
|
43
|
+
children: [u && /* @__PURE__ */ c("details", {
|
|
44
|
+
className: "w-full max-w-2xl text-left text-sm text-foreground/70",
|
|
45
|
+
children: [/* @__PURE__ */ s("summary", {
|
|
46
|
+
className: "cursor-pointer font-medium text-foreground",
|
|
47
|
+
children: E.detailLabel
|
|
48
|
+
}), /* @__PURE__ */ s("div", {
|
|
49
|
+
className: "mt-2 overflow-x-auto rounded-md border border-border bg-background p-3 font-mono text-xs",
|
|
50
|
+
children: u
|
|
51
|
+
})]
|
|
52
|
+
}), S]
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
l.displayName = "ErrorState";
|
|
56
|
+
//#endregion
|
|
57
|
+
export { l as ErrorState };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Size } from '../../shared';
|
|
2
|
+
/**
|
|
3
|
+
* How the failed region announces itself.
|
|
4
|
+
*
|
|
5
|
+
* - `alert`: it is announced as soon as it appears, which is right when it
|
|
6
|
+
* replaces content after a request failed.
|
|
7
|
+
* - `status`: it is announced politely, which is right when the failure is not
|
|
8
|
+
* the result of the reader's last action.
|
|
9
|
+
* - `none`: it is not announced, which is right when it is part of the page's
|
|
10
|
+
* initial markup, such as a not-found page.
|
|
11
|
+
*/
|
|
12
|
+
export type ErrorStateRole = "alert" | "status" | "none";
|
|
13
|
+
/**
|
|
14
|
+
* Theme configuration options for the ErrorState component.
|
|
15
|
+
*
|
|
16
|
+
* Set under `components.errorstate` in the AsheeUI config. Values feed the
|
|
17
|
+
* component-level tier of the theme cascade.
|
|
18
|
+
*/
|
|
19
|
+
export interface ErrorStateConfig {
|
|
20
|
+
/**
|
|
21
|
+
* Density of the state.
|
|
22
|
+
*
|
|
23
|
+
* @default "md"
|
|
24
|
+
*/
|
|
25
|
+
size?: Size;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the state is drawn as a panel.
|
|
28
|
+
*
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
31
|
+
panel?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* How the state is announced.
|
|
34
|
+
*
|
|
35
|
+
* @default "alert"
|
|
36
|
+
*/
|
|
37
|
+
role?: ErrorStateRole;
|
|
38
|
+
/**
|
|
39
|
+
* Wording of the retry control.
|
|
40
|
+
*
|
|
41
|
+
* @default "Try again"
|
|
42
|
+
*/
|
|
43
|
+
retryLabel?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Wording of the disclosure that holds the technical detail.
|
|
46
|
+
*
|
|
47
|
+
* @default "Technical details"
|
|
48
|
+
*/
|
|
49
|
+
detailLabel?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Default config values registered for the ErrorState component.
|
|
53
|
+
* A panel and an announcement are the defaults because this state usually
|
|
54
|
+
* replaces a region after a request failed.
|
|
55
|
+
*/
|
|
56
|
+
export declare const defaultErrorStateConfig: ErrorStateConfig;
|
|
57
|
+
declare module "../../libs/registry" {
|
|
58
|
+
interface ComponentTypeConfigRegistry {
|
|
59
|
+
errorstate: ErrorStateConfig;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Hard fallback values used when no config tier provides a value.
|
|
64
|
+
*/
|
|
65
|
+
export declare const FALLBACK_ERROR_STATE_CONFIG: Required<ErrorStateConfig>;
|
|
66
|
+
//# sourceMappingURL=error-state-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-state-config.d.ts","sourceRoot":"","sources":["../../../src/components/error-state/error-state-config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,IAAI,CAAC,EAAE,IAAI,CAAC;IAEZ;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;;OAIG;IACH,IAAI,CAAC,EAAE,cAAc,CAAC;IAEtB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,gBAMrC,CAAC;AAEF,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,2BAA2B;QACnC,UAAU,EAAE,gBAAgB,CAAC;KAC9B;CACF;AAID;;GAEG;AACH,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,gBAAgB,CAMlE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { registerComponentDefaults as e } from "../../libs/registry.js";
|
|
3
|
+
//#region src/components/error-state/error-state-config.ts
|
|
4
|
+
var t = {
|
|
5
|
+
size: "md",
|
|
6
|
+
panel: !0,
|
|
7
|
+
role: "alert",
|
|
8
|
+
retryLabel: "Try again",
|
|
9
|
+
detailLabel: "Technical details"
|
|
10
|
+
};
|
|
11
|
+
e("errorstate", t);
|
|
12
|
+
var n = {
|
|
13
|
+
size: "md",
|
|
14
|
+
panel: !0,
|
|
15
|
+
role: "alert",
|
|
16
|
+
retryLabel: "Try again",
|
|
17
|
+
detailLabel: "Technical details"
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { n as FALLBACK_ERROR_STATE_CONFIG, t as defaultErrorStateConfig };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ErrorState component styles for AsheeUI.
|
|
3
|
+
* This file provides the static class mappings for the failed-region
|
|
4
|
+
* presentation: the disclosure that holds the technical detail and its body.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The disclosure.
|
|
8
|
+
* It is the platform's own `details` element rather than a framework component,
|
|
9
|
+
* because a detail a reader opens has to work when scripting is unavailable, and
|
|
10
|
+
* because it is not application state.
|
|
11
|
+
*/
|
|
12
|
+
export declare const ERROR_STATE_DETAIL_CLASS = "w-full max-w-2xl text-left text-sm text-foreground/70";
|
|
13
|
+
/** The summary a reader activates to open the detail. */
|
|
14
|
+
export declare const ERROR_STATE_DETAIL_SUMMARY_CLASS = "cursor-pointer font-medium text-foreground";
|
|
15
|
+
/** The detail body, which keeps the technical text as it was written. */
|
|
16
|
+
export declare const ERROR_STATE_DETAIL_BODY_CLASS = "mt-2 overflow-x-auto rounded-md border border-border bg-background p-3 font-mono text-xs";
|
|
17
|
+
//# sourceMappingURL=error-state-styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-state-styles.d.ts","sourceRoot":"","sources":["../../../src/components/error-state/error-state-styles.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,0DACoB,CAAC;AAE1D,yDAAyD;AACzD,eAAO,MAAM,gCAAgC,+CACC,CAAC;AAE/C,yEAAyE;AACzE,eAAO,MAAM,6BAA6B,6FACkD,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
//#region src/components/error-state/error-state-styles.ts
|
|
3
|
+
var e = "w-full max-w-2xl text-left text-sm text-foreground/70", t = "cursor-pointer font-medium text-foreground", n = "mt-2 overflow-x-auto rounded-md border border-border bg-background p-3 font-mono text-xs";
|
|
4
|
+
//#endregion
|
|
5
|
+
export { n as ERROR_STATE_DETAIL_BODY_CLASS, e as ERROR_STATE_DETAIL_CLASS, t as ERROR_STATE_DETAIL_SUMMARY_CLASS };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/error-state/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from 'react';
|
|
2
|
+
import { FieldStatus } from '../field/field-config';
|
|
3
|
+
import { FileUploadConfig } from './file-upload-config';
|
|
4
|
+
type BaseFileUploadProps = FileUploadConfig & Omit<InputHTMLAttributes<HTMLInputElement>, "children" | "className" | "onChange" | "size" | "type" | "value">;
|
|
5
|
+
/**
|
|
6
|
+
* Props for the FileUpload component.
|
|
7
|
+
*/
|
|
8
|
+
export interface FileUploadProps extends BaseFileUploadProps {
|
|
9
|
+
/**
|
|
10
|
+
* Called with the files the reader chose, once the ones over the size limit
|
|
11
|
+
* have been left out. The field owns nothing: the consumer keeps the list and
|
|
12
|
+
* passes it back through `files`.
|
|
13
|
+
*/
|
|
14
|
+
onFilesSelected: (files: File[]) => void;
|
|
15
|
+
/**
|
|
16
|
+
* The files that have been chosen, which the field lists and can remove.
|
|
17
|
+
*/
|
|
18
|
+
files?: File[];
|
|
19
|
+
/**
|
|
20
|
+
* Called with the file the reader removed.
|
|
21
|
+
* Its presence is what draws a remove control beside each file.
|
|
22
|
+
*/
|
|
23
|
+
onRemove?: (file: File) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Largest file the field accepts, in bytes.
|
|
26
|
+
* A larger file is left out and reported here rather than being passed on to
|
|
27
|
+
* be rejected later.
|
|
28
|
+
*/
|
|
29
|
+
maxSize?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Label of the field.
|
|
32
|
+
*/
|
|
33
|
+
label?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Description shown under the label.
|
|
36
|
+
*/
|
|
37
|
+
description?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Message shown under the field.
|
|
40
|
+
*/
|
|
41
|
+
message?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Validation status of the field.
|
|
44
|
+
*
|
|
45
|
+
* @default "default"
|
|
46
|
+
*/
|
|
47
|
+
status?: FieldStatus;
|
|
48
|
+
/**
|
|
49
|
+
* Whether the field is unavailable.
|
|
50
|
+
*
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
isDisabled?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Whether the field must be filled in before the form is submitted.
|
|
56
|
+
*
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
required?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Extra classes for the field wrapper.
|
|
62
|
+
*/
|
|
63
|
+
className?: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A field that accepts files.
|
|
67
|
+
*
|
|
68
|
+
* The zone is a label for the field, so a pointer opens the picker, a keyboard
|
|
69
|
+
* reaches the field, and a screen reader reads the zone as the field's name.
|
|
70
|
+
* Files dropped on the zone take the same path as files chosen from the picker,
|
|
71
|
+
* which is what keeps the size limit from being skipped.
|
|
72
|
+
*
|
|
73
|
+
* The field owns nothing: it reports what was chosen and lists what the consumer
|
|
74
|
+
* passes back, which is what lets one component serve a plain form and a form
|
|
75
|
+
* library that owns the files.
|
|
76
|
+
*
|
|
77
|
+
* @param props - FileUpload configuration options and field attributes.
|
|
78
|
+
* @param props.onFilesSelected - Called with the accepted files.
|
|
79
|
+
* @param props.files - The files that have been chosen.
|
|
80
|
+
* @param props.onRemove - Called with the file the reader removed.
|
|
81
|
+
* @param props.maxSize - Largest accepted file, in bytes.
|
|
82
|
+
* @param props.accept - The kinds of file the picker offers.
|
|
83
|
+
* @param props.multiple - Whether more than one file may be chosen.
|
|
84
|
+
* @param props.label - Label of the field.
|
|
85
|
+
* @param props.description - Description under the label.
|
|
86
|
+
* @param props.message - Message under the field.
|
|
87
|
+
* @param props.status - Validation status. Defaults to "default".
|
|
88
|
+
* @param props.isDisabled - Whether the field is unavailable. Defaults to false.
|
|
89
|
+
* @param props.size - Density of the zone. Defaults to "md".
|
|
90
|
+
* @param props.buttonLabel - Name of the control. Defaults to "Choose files".
|
|
91
|
+
* @param props.hint - Instruction in the zone. Defaults to "Drag files here".
|
|
92
|
+
* @returns The rendered field.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```tsx
|
|
96
|
+
* <FileUpload
|
|
97
|
+
* label="Attachments"
|
|
98
|
+
* accept="application/pdf"
|
|
99
|
+
* multiple
|
|
100
|
+
* maxSize={5 * 1024 * 1024}
|
|
101
|
+
* files={files}
|
|
102
|
+
* onFilesSelected={(chosen) => setFiles((current) => [...current, ...chosen])}
|
|
103
|
+
* onRemove={(file) => setFiles((current) => current.filter((f) => f !== file))}
|
|
104
|
+
* />
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* @see Input - The text field, which shares the field contract.
|
|
108
|
+
* @see Chip - The token the field uses for a chosen file.
|
|
109
|
+
*/
|
|
110
|
+
export declare const FileUpload: import('react').ForwardRefExoticComponent<FileUploadProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
111
|
+
export {};
|
|
112
|
+
//# sourceMappingURL=FileUpload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileUpload.d.ts","sourceRoot":"","sources":["../../../src/components/file-upload/FileUpload.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAGL,KAAK,mBAAmB,EAIzB,MAAM,OAAO,CAAC;AAMf,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAY9B,KAAK,mBAAmB,GAAG,gBAAgB,GACzC,IAAI,CACF,mBAAmB,CAAC,gBAAgB,CAAC,EACrC,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAClE,CAAC;AAEJ;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,mBAAmB;IAC1D;;;;OAIG;IACH,eAAe,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IAEzC;;OAEG;IACH,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IAEf;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAEhC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,eAAO,MAAM,UAAU,8GAkKtB,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn as e } from "../../utils/cn.js";
|
|
4
|
+
import { useAsheeConfig as t } from "../../libs/context.js";
|
|
5
|
+
import { resolveConfigCascade as n } from "../../utils/resolve-token.js";
|
|
6
|
+
import { FieldShell as r } from "../field/FieldShell.js";
|
|
7
|
+
import { Chip as i } from "../chip/Chip.js";
|
|
8
|
+
import { describeRejectedFiles as a } from "./file-upload.helpers.js";
|
|
9
|
+
import { FALLBACK_FILE_UPLOAD_CONFIG as o } from "./file-upload-config.js";
|
|
10
|
+
import { FILE_UPLOAD_BUTTON_CLASS as s, FILE_UPLOAD_HINT_CLASS as c, FILE_UPLOAD_INPUT_CLASS as l, FILE_UPLOAD_SIZE_CLASS as u, FILE_UPLOAD_ZONE_CLASS as d } from "./file-upload-styles.js";
|
|
11
|
+
import { forwardRef as f, useId as p, useRef as m, useState as h } from "react";
|
|
12
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
13
|
+
//#region src/components/file-upload/FileUpload.tsx
|
|
14
|
+
var v = f(({ onFilesSelected: f, files: v, onRemove: y, maxSize: b, label: x, description: S, message: C, status: w, isDisabled: T, required: E, buttonLabel: D, hint: O, size: k, className: A, id: j, ...M }, N) => {
|
|
15
|
+
let P = t(), F = p(), I = j ?? F, L = n({
|
|
16
|
+
buttonLabel: D,
|
|
17
|
+
hint: O,
|
|
18
|
+
size: k
|
|
19
|
+
}, P.components?.fileupload, o), [R, z] = h(!1), [B, V] = h(""), H = m(null), U = (e) => {
|
|
20
|
+
H.current = e, typeof N == "function" ? N(e) : N && (N.current = e);
|
|
21
|
+
}, W = (e) => {
|
|
22
|
+
let t = Array.from(e ?? []);
|
|
23
|
+
if (t.length === 0) return;
|
|
24
|
+
let n = b === void 0 ? t : t.filter((e) => e.size <= b), r = t.length - n.length;
|
|
25
|
+
V(r === 0 ? "" : a(r, b ?? 0)), n.length > 0 && f(n);
|
|
26
|
+
}, G = (e) => {
|
|
27
|
+
e.preventDefault(), z(!1), !T && W(e.dataTransfer?.files ?? null);
|
|
28
|
+
}, K = () => {
|
|
29
|
+
W(H.current?.files ?? null);
|
|
30
|
+
}, q = C ?? B, J = C ? w ?? "default" : B ? "error" : "default", Y = e(d, u[L.size], R && "border-primary bg-primary/10", T && "cursor-not-allowed opacity-60 hover:border-border");
|
|
31
|
+
return /* @__PURE__ */ g("div", {
|
|
32
|
+
className: e("flex w-full min-w-0 flex-col", A),
|
|
33
|
+
children: /* @__PURE__ */ _(r, {
|
|
34
|
+
id: I,
|
|
35
|
+
label: x,
|
|
36
|
+
description: S,
|
|
37
|
+
message: q,
|
|
38
|
+
status: J,
|
|
39
|
+
required: E,
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ g("input", {
|
|
42
|
+
...M,
|
|
43
|
+
ref: U,
|
|
44
|
+
id: I,
|
|
45
|
+
type: "file",
|
|
46
|
+
className: l,
|
|
47
|
+
disabled: T,
|
|
48
|
+
onChange: K
|
|
49
|
+
}),
|
|
50
|
+
/* @__PURE__ */ g("label", {
|
|
51
|
+
htmlFor: I,
|
|
52
|
+
className: Y,
|
|
53
|
+
onDragOver: (e) => {
|
|
54
|
+
e.preventDefault(), T || z(!0);
|
|
55
|
+
},
|
|
56
|
+
onDragLeave: () => z(!1),
|
|
57
|
+
onDrop: G,
|
|
58
|
+
children: /* @__PURE__ */ _("span", {
|
|
59
|
+
className: "flex flex-wrap items-baseline justify-center gap-1 text-sm",
|
|
60
|
+
children: [/* @__PURE__ */ g("span", {
|
|
61
|
+
className: s,
|
|
62
|
+
children: L.buttonLabel
|
|
63
|
+
}), /* @__PURE__ */ _("span", {
|
|
64
|
+
className: c,
|
|
65
|
+
children: ["or ", L.hint.toLowerCase()]
|
|
66
|
+
})]
|
|
67
|
+
})
|
|
68
|
+
}),
|
|
69
|
+
v && v.length > 0 && /* @__PURE__ */ g("ul", {
|
|
70
|
+
className: "flex flex-wrap gap-2 pt-1",
|
|
71
|
+
children: v.map((e) => /* @__PURE__ */ g("li", { children: /* @__PURE__ */ g(i, {
|
|
72
|
+
closeLabel: `Remove ${e.name}`,
|
|
73
|
+
onClose: y ? () => y(e) : void 0,
|
|
74
|
+
children: e.name
|
|
75
|
+
}) }, `${e.name}-${e.lastModified}`))
|
|
76
|
+
})
|
|
77
|
+
]
|
|
78
|
+
})
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
v.displayName = "FileUpload";
|
|
82
|
+
//#endregion
|
|
83
|
+
export { v as FileUpload };
|