@cloudwick/astral-ui-cli 2.0.1 → 2.2.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/README.md +17 -5
- package/dist/index.js +1235 -139
- package/dist/index.js.map +1 -1
- package/dist/templates/constants/index.ts +1 -0
- package/dist/templates/constants/keyboardKey.ts +1 -0
- package/dist/templates/css/fonts.min.css +1 -1
- package/dist/templates/fonts/NotoSans-Bold.woff2 +0 -0
- package/dist/templates/fonts/NotoSans-BoldItalic.woff2 +0 -0
- package/dist/templates/fonts/NotoSans-Italic.woff2 +0 -0
- package/dist/templates/fonts/NotoSans-Medium.woff2 +0 -0
- package/dist/templates/fonts/NotoSans-MediumItalic.woff2 +0 -0
- package/dist/templates/fonts/NotoSans-Regular.woff2 +0 -0
- package/dist/templates/fonts/NotoSans-SemiBold.woff2 +0 -0
- package/dist/templates/fonts/NotoSans-SemiBoldItalic.woff2 +0 -0
- package/dist/templates/hooks/index.ts +20 -1
- package/dist/templates/hooks/useAsyncOptions.ts +346 -0
- package/dist/templates/hooks/useAsyncOptionsReducer.ts +182 -0
- package/dist/templates/hooks/useAvailableProjection.ts +77 -0
- package/dist/templates/hooks/useDebouncedCallback.ts +42 -0
- package/dist/templates/hooks/useFilterQuery.ts +145 -0
- package/dist/templates/hooks/useIgnoredPropWarning.ts +17 -0
- package/dist/templates/hooks/useInfiniteScroll.ts +63 -0
- package/dist/templates/hooks/useIsTruncated.ts +63 -0
- package/dist/templates/hooks/useListboxKeyboardNav.ts +120 -0
- package/dist/templates/hooks/useOnValueChange.ts +17 -0
- package/dist/templates/hooks/usePrefetchBaseline.ts +38 -0
- package/dist/templates/schema/components-config.schema.json +3 -0
- package/dist/templates/tailwind/tailwind.config.js +8 -8
- package/dist/templates/utils/devWarn.ts +9 -0
- package/dist/templates/utils/elementUtils.ts +26 -0
- package/dist/templates/utils/index.ts +7 -1
- package/dist/templates/utils/matchesQuery.ts +23 -0
- package/dist/templates/utils/mergeUnique.ts +24 -0
- package/dist/templates/utils/resolveLoadErrors.ts +40 -0
- package/dist/templates/utils/resolveReloadControls.ts +31 -0
- package/package.json +2 -2
- package/dist/templates/fonts/Inter_18pt-Bold.ttf +0 -0
- package/dist/templates/fonts/Inter_18pt-BoldItalic.ttf +0 -0
- package/dist/templates/fonts/Inter_18pt-Italic.ttf +0 -0
- package/dist/templates/fonts/Inter_18pt-Medium.ttf +0 -0
- package/dist/templates/fonts/Inter_18pt-MediumItalic.ttf +0 -0
- package/dist/templates/fonts/Inter_18pt-Regular.ttf +0 -0
- package/dist/templates/fonts/Inter_18pt-SemiBold.ttf +0 -0
- package/dist/templates/fonts/Inter_18pt-SemiBoldItalic.ttf +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
// Type-only, so it is erased at compile time — no runtime import edge back into `hooks`.
|
|
4
|
+
import type { TAsyncRequest } from "../hooks/useAsyncOptions";
|
|
5
|
+
|
|
6
|
+
// The three surfaces render the same two failures, so the wording lives here rather than in each of
|
|
7
|
+
// them — a default that differs per component is a difference nobody chose.
|
|
8
|
+
const DEFAULT_LOAD_ERROR = "Couldn't load options.";
|
|
9
|
+
const DEFAULT_LOAD_MORE_ERROR = "Couldn't load more.";
|
|
10
|
+
|
|
11
|
+
interface IResolveLoadErrorsArgs {
|
|
12
|
+
/** `null` means no failure — the only thing that decides whether either slot is filled. */
|
|
13
|
+
errorKind: TAsyncRequest | null;
|
|
14
|
+
loadErrorMessage?: ReactNode;
|
|
15
|
+
loadMoreErrorMessage?: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface IResolvedLoadErrors {
|
|
19
|
+
/** Set when the whole list failed. Mutually exclusive with `loadMoreError`. */
|
|
20
|
+
loadError?: ReactNode;
|
|
21
|
+
/** Set when a page append failed. The rows the user was reading stay on screen. */
|
|
22
|
+
loadMoreError?: ReactNode;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Splits one failure into the two slots a surface renders. The `errorKind === "more"` branch is the
|
|
27
|
+
* line that keeps a failed page append from blanking a list the user was already reading.
|
|
28
|
+
*/
|
|
29
|
+
export function resolveLoadErrors({
|
|
30
|
+
errorKind,
|
|
31
|
+
loadErrorMessage,
|
|
32
|
+
loadMoreErrorMessage
|
|
33
|
+
}: IResolveLoadErrorsArgs ): IResolvedLoadErrors {
|
|
34
|
+
if ( errorKind === null ) {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
return errorKind === "more"
|
|
38
|
+
? { loadMoreError: loadMoreErrorMessage ?? DEFAULT_LOAD_MORE_ERROR }
|
|
39
|
+
: { loadError: loadErrorMessage ?? DEFAULT_LOAD_ERROR };
|
|
40
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
interface IResolveReloadControlsArgs {
|
|
2
|
+
isAsync: boolean;
|
|
3
|
+
/** The async source's own reload trio. */
|
|
4
|
+
source: { errorKind: string | null; isReloading: boolean; reload: () => void };
|
|
5
|
+
/** Consumer overrides. Each wins outright — a consumer driving their own refresh keeps it. */
|
|
6
|
+
onReload?: () => void;
|
|
7
|
+
isReloading?: boolean;
|
|
8
|
+
showReloadButton?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface IResolvedReloadControls {
|
|
12
|
+
onReload?: () => void;
|
|
13
|
+
isReloading?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Decides whether the surface gets a reload affordance at all. Off by default so async mode doesn't
|
|
18
|
+
* grow UI nobody asked for, and auto-shown while an error is displayed — where it is the only retry.
|
|
19
|
+
*/
|
|
20
|
+
export function resolveReloadControls({
|
|
21
|
+
isAsync,
|
|
22
|
+
source,
|
|
23
|
+
onReload,
|
|
24
|
+
isReloading,
|
|
25
|
+
showReloadButton = false
|
|
26
|
+
}: IResolveReloadControlsArgs ): IResolvedReloadControls {
|
|
27
|
+
return {
|
|
28
|
+
onReload: onReload ?? ( isAsync && ( showReloadButton || source.errorKind !== null ) ? source.reload : undefined ),
|
|
29
|
+
isReloading: isReloading ?? ( isAsync ? source.isReloading : undefined )
|
|
30
|
+
};
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudwick/astral-ui-cli",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "CLI for installing Astral UI components in any codebase",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -59,4 +59,4 @@
|
|
|
59
59
|
"engines": {
|
|
60
60
|
"node": ">=18.0.0"
|
|
61
61
|
}
|
|
62
|
-
}
|
|
62
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|