@xyd-js/framework 0.1.0-xyd.8 → 0.1.0-xyd.85

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.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/dist/Sidebar-CdavG0uc.d.ts +23 -0
  3. package/dist/hydration.d.ts +9 -3
  4. package/dist/hydration.js +189 -191
  5. package/dist/hydration.js.map +1 -1
  6. package/dist/index.d.ts +22 -4
  7. package/dist/index.js +34 -15
  8. package/dist/index.js.map +1 -1
  9. package/dist/react.d.ts +49 -9
  10. package/dist/react.js +446 -528
  11. package/dist/react.js.map +1 -1
  12. package/package.json +19 -16
  13. package/dist/hydration.d.mts +0 -11
  14. package/dist/hydration.mjs +0 -245
  15. package/dist/hydration.mjs.map +0 -1
  16. package/dist/index.d.mts +0 -6
  17. package/dist/index.mjs +0 -1
  18. package/dist/index.mjs.map +0 -1
  19. package/dist/react.d.mts +0 -32
  20. package/dist/react.mjs +0 -651
  21. package/dist/react.mjs.map +0 -1
  22. package/dist/sidebar-Dwf54qYp.d.mts +0 -15
  23. package/dist/sidebar-Dwf54qYp.d.ts +0 -15
  24. package/packages/hydration/README.md +0 -3
  25. package/packages/hydration/index.ts +0 -3
  26. package/packages/hydration/settings-to-props.ts +0 -325
  27. package/packages/react/README.md +0 -3
  28. package/packages/react/components/index.tsx +0 -337
  29. package/packages/react/components/sidebar/index.ts +0 -3
  30. package/packages/react/components/sidebar/sidebar-group.tsx +0 -240
  31. package/packages/react/components/sidebar/sidebar.tsx +0 -127
  32. package/packages/react/contexts/framework.tsx +0 -78
  33. package/packages/react/contexts/index.ts +0 -2
  34. package/packages/react/contexts/ui.tsx +0 -6
  35. package/packages/react/hooks/index.ts +0 -3
  36. package/packages/react/hooks/useMatchedNav.tsx +0 -29
  37. package/packages/react/index.ts +0 -12
  38. package/packages/react/utils/manualHydration.ts +0 -25
  39. package/packages/theme/context.tsx +0 -19
  40. package/packages/theme/index.ts +0 -0
  41. package/postcss.config.cjs +0 -5
  42. package/src/index.ts +0 -1
  43. package/src/types.ts +0 -5
  44. package/tsconfig.json +0 -45
  45. package/tsup.config.ts +0 -28
@@ -1,78 +0,0 @@
1
- import React, {createContext, useContext} from "react";
2
-
3
- import {Settings} from "@xyd-js/core";
4
- import type {ITOC, IBreadcrumb, INavLinks} from "@xyd-js/ui";
5
-
6
- import {FwSidebarGroupProps} from "../components/sidebar";
7
-
8
- export interface IFramework {
9
- settings: Settings
10
-
11
- sidebarGroups: FwSidebarGroupProps[]
12
-
13
- toc?: ITOC[]
14
-
15
- breadcrumbs?: IBreadcrumb[]
16
-
17
- navlinks?: INavLinks
18
- }
19
-
20
- // TODO: page context + app context?
21
- const framework: IFramework = {
22
- settings: {},
23
- sidebarGroups: []
24
- }
25
- const FrameworkContext = createContext<IFramework>(framework)
26
-
27
- export interface FrameworkProps {
28
- children: React.ReactNode
29
-
30
- settings: Settings,
31
- sidebarGroups: FwSidebarGroupProps[],
32
- toc?: ITOC[],
33
- breadcrumbs?: IBreadcrumb[],
34
- navlinks?: INavLinks
35
- }
36
-
37
- export function Framework(props: FrameworkProps) {
38
- return <FrameworkContext.Provider value={{
39
- settings: props.settings,
40
- sidebarGroups: props.sidebarGroups,
41
- toc: props.toc,
42
- breadcrumbs: props.breadcrumbs,
43
- navlinks: props.navlinks,
44
- }}>
45
- {props.children}
46
- </FrameworkContext.Provider>
47
- }
48
-
49
-
50
- export function useSidebarGroups() {
51
- const ctx = useContext(FrameworkContext)
52
-
53
- return ctx.sidebarGroups
54
- }
55
-
56
- export function useSettings() {
57
- const ctx = useContext(FrameworkContext)
58
-
59
- return ctx.settings
60
- }
61
-
62
- export function useToC() {
63
- const ctx = useContext(FrameworkContext)
64
-
65
- return ctx.toc
66
- }
67
-
68
- export function useBreadcrumbs() {
69
- const ctx = useContext(FrameworkContext)
70
-
71
- return ctx.breadcrumbs
72
- }
73
-
74
- export function useNavLinks() {
75
- const ctx = useContext(FrameworkContext)
76
-
77
- return ctx.navlinks
78
- }
@@ -1,2 +0,0 @@
1
- export * from "./framework"
2
-
@@ -1,6 +0,0 @@
1
- import {createContext} from 'react';
2
-
3
- export const UIContext = createContext({
4
- href: '',
5
- setHref: (v: any) => {}
6
- });
@@ -1,3 +0,0 @@
1
- export {
2
- useMatchedSubNav
3
- } from "./useMatchedNav";
@@ -1,29 +0,0 @@
1
- import {useLocation} from "react-router";
2
-
3
- import {useSettings} from "../contexts";
4
-
5
- import {manualHydration} from "../utils/manualHydration";
6
-
7
- function normalizeHref(href: string) {
8
- if (href.startsWith("/")) {
9
- return href
10
- }
11
-
12
- return `/${href}`
13
- }
14
-
15
- // TODO: better data structures
16
- export function useMatchedSubNav() {
17
- const settings = useSettings()
18
- const location = useLocation()
19
-
20
- const matchedSubnav = settings.structure?.header
21
- ?.filter(item => item.sub)
22
- ?.find(item => normalizeHref(location.pathname).startsWith(normalizeHref(item.sub?.match || "")))
23
-
24
- if (!matchedSubnav) {
25
- return null
26
- }
27
-
28
- return matchedSubnav.sub || null
29
- }
@@ -1,12 +0,0 @@
1
- export * from "./components"
2
-
3
- export {Framework} from "./contexts"
4
- export type {FrameworkProps} from "./contexts"
5
-
6
- export {
7
- useMatchedSubNav
8
- } from "./hooks"
9
-
10
- export type {
11
- FwSidebarGroupProps
12
- } from "./components/sidebar/sidebar"
@@ -1,25 +0,0 @@
1
- import React, {ReactElement} from "react";
2
-
3
- export function manualHydration(obj: any, key = 0): ReactElement<any, string | React.JSXElementConstructor<any>> {
4
- if (typeof obj !== 'object' || obj === null) {
5
- return React.createElement(React.Fragment, {key});
6
- }
7
-
8
- const {type, props} = obj || {};
9
- if (typeof type !== 'string' && typeof type !== 'function') {
10
- return React.createElement(React.Fragment, {key});
11
- }
12
-
13
- let children: ReactElement<any, string | React.JSXElementConstructor<any>>[] = [];
14
- if (props?.children) {
15
- if (Array.isArray(props.children)) {
16
- children = props.children.map((child: any, i) => manualHydration(child, key + i)) || [];
17
- } else {
18
- children = [manualHydration(props.children, key)];
19
- }
20
- }
21
-
22
- const elementProps = {...props, children, key};
23
-
24
- return React.createElement(type, elementProps);
25
- }
@@ -1,19 +0,0 @@
1
- import {createContext, useContext} from "react";
2
-
3
- import type {ITheme} from "@xyd-js/framework";
4
-
5
- const theme = createContext<ITheme<any> | null>(null)
6
-
7
- const Provider = theme.Provider
8
-
9
- // TODO: finish theme context
10
-
11
- export function withTheme(Component) {
12
- return <Provider value={null}>
13
- <Component/>
14
- </Provider>
15
- }
16
-
17
- export function useTheme<T>(): ITheme<any> | null {
18
- return useContext(theme)
19
- }
File without changes
@@ -1,5 +0,0 @@
1
- module.exports = {
2
- plugins: {
3
- autoprefixer: {},
4
- },
5
- }
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export type * from "./types";
package/src/types.ts DELETED
@@ -1,5 +0,0 @@
1
- export interface ITheme<T> {
2
- children: JSX.Element | JSX.Element[]
3
-
4
- themeSettings?: T
5
- }
package/tsconfig.json DELETED
@@ -1,45 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "esnext",
4
- "esModuleInterop": true,
5
- "moduleResolution": "bundler",
6
- "target": "ES6",
7
- "compilerOptions": {
8
- "baseUrl": ".",
9
- "paths": {
10
- "@/components/*": ["@/components/*"],
11
- "@/lib/utils/*": ["@/lib/utils/*"],
12
- "@/components/ui/*": ["@/components/ui/*"],
13
- "@/components/magicui/*": ["@/components/magicui/*"]
14
- }
15
- },
16
- "lib": [
17
- "dom",
18
- "dom.iterable",
19
- "esnext"
20
- ],
21
- "allowJs": true,
22
- "skipLibCheck": true,
23
- "strict": false,
24
- "noEmit": true,
25
- "incremental": false,
26
- "resolveJsonModule": true,
27
- "isolatedModules": true,
28
- "jsx": "preserve",
29
- "plugins": [
30
- {
31
- "name": "next"
32
- }
33
- ],
34
- "strictNullChecks": true
35
- },
36
- "include": [
37
- "next-env.d.ts",
38
- "**/*.ts",
39
- "**/*.tsx",
40
- ".next/types/**/*.ts"
41
- ],
42
- "exclude": [
43
- "node_modules"
44
- ]
45
- }
package/tsup.config.ts DELETED
@@ -1,28 +0,0 @@
1
- import {defineConfig} from 'tsup';
2
-
3
- export default defineConfig({
4
- entry: {
5
- index: 'src/index.ts',
6
- react: 'packages/react/index.ts',
7
- hydration: 'packages/hydration/index.ts',
8
- },
9
- format: ['esm', 'cjs'], // Output both ESM and CJS formats
10
- target: 'node16', // Ensure compatibility with Node.js 16
11
- dts: {
12
- entry: {
13
- index: 'src/index.ts',
14
- react: 'packages/react/index.ts',
15
- hydration: 'packages/hydration/index.ts',
16
- },
17
- resolve: true, // Resolve external types
18
- },
19
- splitting: false, // Disable code splitting
20
- sourcemap: true, // Generate source maps
21
- clean: true, // Clean the output directory before each build
22
- esbuildOptions: (options) => {
23
- options.platform = 'node'; // Ensure the platform is set to Node.js
24
- options.external = ['node:fs/promises', 'react-router']; // Mark 'node:fs/promises' as external
25
- options.loader = {'.js': 'jsx'}; // Ensure proper handling of .js files
26
- },
27
- ignoreWatch: ['node_modules', 'dist', '.git', 'build'] // Exclude unnecessary directories
28
- });