@cloudwick/astral-ui-cli 0.2.1 → 0.2.2

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.
@@ -1,7 +1,6 @@
1
1
  export * from "./numberUtils";
2
2
  export * from "./stringUtils";
3
- export { useOnScreen } from "./useOnScreen";
3
+ export * from "./findParentAttribute";
4
4
  export { debounce } from "./debounce";
5
5
  export { useWindowSize } from "./useWindowSize";
6
- export * from "./findParentAttribute";
7
6
  export { cn } from "./cn";
@@ -1,4 +1,3 @@
1
- import React from "react";
2
1
  /**
3
2
  * Function to convert file size in bytes to human readable format
4
3
  * @param size - size of the file in bytes
@@ -9,5 +8,5 @@ import React from "react";
9
8
  */
10
9
  export function readableFileSize( size: number ): string {
11
10
  const i = size !== 0 ? Math.floor( Math.log( size ) / Math.log( 1024 )) : 0;
12
- return `${Number(( size / Math.pow( 1024, i )).toFixed( 2 )) } ${ [ "B", "kB", "MB", "GB", "TB" ][i]}`;
11
+ return `${Number(( size / Math.pow( 1024, i )).toFixed( 2 ))} ${[ "B", "kB", "MB", "GB", "TB" ][i]}`;
13
12
  }
@@ -1,4 +1 @@
1
- export * from "./getInitials";
2
- export { PlaceholderText } from "./placeholderText";
3
- export { regexSearch } from "./regexSearch";
4
1
  export { readableFileSize } from "./fileSize";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudwick/astral-ui-cli",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "CLI for installing Astral UI components in any codebase",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -62,4 +62,4 @@
62
62
  "engines": {
63
63
  "node": ">=18.0.0"
64
64
  }
65
- }
65
+ }
@@ -1,38 +0,0 @@
1
- // disable eslint on entire file because we don't want to enforce prop types,
2
- // this is a utility function that should be used in a component that already has prop types
3
- // and we don't want to force prop types on this utility function
4
- /* eslint-disable */
5
-
6
- /**
7
- * Returns a createElement() type based on the props of the Component.
8
- * Useful for calculating what type a component should render as.
9
- *
10
- * @param {function} Component A function or ReactClass.
11
- * @param {object} props A ReactElement props object
12
- * @param {function} [getDefault] A function that returns a default element type.
13
- * @returns {string|function} A ReactElement type
14
- */
15
- function getElementType(
16
- Component: React.ComponentType<any>, componentProps: { [key: string]: any },
17
- getDefault?: () => any ): string | React.ComponentType<any> {
18
- const { defaultProps = {} } = Component;
19
-
20
- // user defined "as" element type
21
- if ( componentProps.as && componentProps.as !== defaultProps.as ) {
22
- return componentProps.as;
23
- }
24
-
25
- // get computed default element type
26
- if ( getDefault ) {
27
- const defaultAs = getDefault();
28
- if ( defaultAs ) {
29
- return defaultAs;
30
- }
31
- }
32
-
33
- // use defaultProps.as or 'div'
34
- return defaultProps.as || "div";
35
- }
36
- /* eslint-enable */
37
-
38
- export default getElementType;
@@ -1,22 +0,0 @@
1
- import React, { ReactElement } from "react";
2
- /**
3
- * This method accepts a string and returns a string representation
4
- * of the value shrunk to 2 characters representing the Initials.
5
- * @param {string} value - The value to be converted to Initials
6
- * @returns {string} - The 2character string of the initials extracted from the given value string.
7
- * @example <caption>Example usage of getInitials method.</caption>
8
- * // returns SP
9
- * getInitials('Susheel Pogaku');
10
- */
11
- export const getInitials = ( value:string ): string => {
12
- return value
13
- ?.match( /(^\S\S?|\b\S)?/g )?.join( "" )
14
- ?.match( /(^\S|\S$)?/g )?.join( "" )
15
- ?.toUpperCase() ?? "AU";
16
- };
17
-
18
- export const GetInitials = ( value:string ): ReactElement => {
19
- return <React.Fragment>
20
- {getInitials( value )}
21
- </React.Fragment>;
22
- };
@@ -1,93 +0,0 @@
1
- import React, { ReactElement } from "react";
2
-
3
- type TVariant = "lorem" | "space" | "startrek";
4
-
5
- export interface IPlaceholderTextProps {
6
- paragraphs?: number;
7
- sentences?: number;
8
- variant?: TVariant;
9
- }
10
-
11
- const getRandomSentences = (
12
- source: string[],
13
- sentences: number
14
- ): string => {
15
- const result = new Array( sentences );
16
- let sourceLength = source.length;
17
- const taken = new Array( sourceLength );
18
- if ( sentences <= sourceLength ) {
19
- while ( sentences-- ) {
20
- const x = Math.floor( Math.random() * sourceLength );
21
- result[sentences] = source[x in taken ? taken[x] : x];
22
- taken[x] = --sourceLength in taken ? taken[sourceLength] : sourceLength;
23
- }
24
- }
25
- return result.join( " " ).replace( /\s+/g, " " ).trim();
26
- };
27
-
28
- export const placeholderText = ( sentences:number, variant: TVariant = "lorem" as TVariant ): string => {
29
- const wordCollection = variants?.[variant] ?? variants.lorem;
30
- const paragraph = getRandomSentences( wordCollection, sentences );
31
- return paragraph;
32
- };
33
-
34
- export const PlaceholderText = ({
35
- paragraphs = 2,
36
- sentences = 4,
37
- variant = "lorem"
38
- }: IPlaceholderTextProps ): ReactElement => {
39
- let text = "";
40
- for ( let i = 0; i < paragraphs; i++ ){
41
- const paragraph = `<p>${placeholderText( sentences, variant )}</p>`;
42
- text += paragraph;
43
- }
44
- return <div className="space-y-2 text-start dark:text-secondary-200" dangerouslySetInnerHTML={{ __html: text }}></div>;
45
- };
46
-
47
- export default PlaceholderText;
48
-
49
- const variants = {
50
- "lorem": [
51
- "Lorem ipsum dolor sit amet , consectetur adipiscing",
52
- "elit sed do eiusmod tempor incididunt ut labore",
53
- "et dolore magna aliqua. Ut enim ad minim veniam, ",
54
- "quis nostrud exercitation ullamco laboris nisi ut",
55
- "aliquip ex ea commodo consequat Duis aute irure",
56
- "dolor in reprehenderit in voluptate velit esse cillum",
57
- "dolore eu fugiat nulla pariatur Excepteur sint,",
58
- "occaecat cupidatat non proident sunt in culpa qui",
59
- "aliquip ex ea commodo consequat Duis aute irure",
60
- "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet",
61
- "elit sed do eiusmod tempor incididunt ut labore",
62
- "officia deserunt mollit anim id est laborum"
63
- ],
64
- "space": [
65
- "There is no atmosphere in space and sound cannot travel without a medium.",
66
- "Mercury is closest planet to sun, but venus is the hottest planet in solar system.",
67
- "There are between 100-400 billion stars, approximately, in the galaxy.",
68
- "There is a planet made of diamonds twice the size of earth.",
69
- "One teaspoonful of neutron star would weigh the same as the entire human population.",
70
- "In fact, cosmic expansion is actually accelerating.",
71
- "Black holes are known for their voracious appetites;",
72
- "Neptune only recently finished its first full post-discovery orbit in 2011.",
73
- "Not all planets form and stay around stars.",
74
- "We are all made of stardust. It sounds like a line from a poem.",
75
- "It takes 230 million years for our solar system to complete one single orbit around the Milky Way.",
76
- "Polaris, our North Star, is not leaving us anytime soon."
77
- ],
78
- "startrek": [
79
- "There are four lights!",
80
- "Things are only impossible until they are not!",
81
- "Sokath, his eyes uncovered! Captain Picard is stuck on planet.",
82
- "Logic is the beginning of wisdom, not the end.",
83
- "Live long, and prosper.",
84
- "Resistance is futile.",
85
- "It is possible to commit no errors and still lose, that is not a weakness, that is life.",
86
- "Without freedom of choice there is no creativity.",
87
- "You can use logic to justify almost anything. That's its power. And its flaw.",
88
- "Mr. Data, set heading to Alpha Quadrant, maximum warp, Engage !",
89
- "Change is the essential process of all existence.",
90
- "Insufficient facts always invite danger.",
91
- "What does God need with a starship."
92
- ]
93
- };
@@ -1,29 +0,0 @@
1
- /**
2
- * Function to verify if a string exists within another string using regex
3
- *
4
- * @param {string} stringToSearchFor
5
- * @param {string} stringToSearchIn
6
- * @param {boolean} caseSensitive (optional) default false
7
- * @returns {boolean} True if the stringToSearchFor is found, false otherwise.
8
- */
9
-
10
- export const regexSearch = (
11
- stringToSearchFor: string,
12
- stringToSearchIn: string,
13
- caseSensitive = false
14
- ): boolean => {
15
- if ( !stringToSearchFor ){
16
- return true;
17
- }
18
- if ( !stringToSearchIn ) {
19
- return false;
20
- }
21
-
22
- try {
23
- const regex = new RegExp( stringToSearchFor, caseSensitive ? "g" : "gi" );
24
- return regex.test( stringToSearchIn );
25
- } catch ( error: unknown ) {
26
- console.error( "Invalid regular expression:", ( error as Error )?.message );
27
- return false;
28
- }
29
- };
@@ -1,22 +0,0 @@
1
- import { useEffect, useState, useMemo } from "react";
2
-
3
- export function useOnScreen( ref: React.RefObject<Element> ): boolean {
4
-
5
- const [ isIntersecting, setIntersecting ] = useState<boolean>( false );
6
-
7
- const observer = useMemo(() => new IntersectionObserver(
8
- ([entry]) => setIntersecting( entry.isIntersecting )
9
- ), []);
10
-
11
- useEffect(() => {
12
- if ( ref.current ) {
13
- observer.observe( ref.current );
14
- }
15
- // Remove the observer as soon as the component is unmounted
16
- return () => {
17
- observer.disconnect();
18
- };
19
- }, [ ref, observer ]);
20
-
21
- return isIntersecting;
22
- }