ab-nextjs-core 0.1.0 → 0.1.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.
- package/README.md +44 -8
- package/ab-app-layout/index.tsx +107 -0
- package/ab-app-layout/styles.module.css +145 -0
- package/ab-aside-layout/index.tsx +188 -0
- package/ab-aside-layout/styles.module.css +160 -0
- package/ab-linear-progress/index.tsx +71 -0
- package/ab-main-layout/index.tsx +114 -0
- package/ab-main-layout/styles.module.css +167 -0
- package/ab-page-provider/index.tsx +157 -0
- package/ab-screen-layout/index.tsx +101 -0
- package/ab-screen-layout/styles.module.css +134 -0
- package/index.ts +58 -0
- package/package.json +58 -6
- package/server/ab-app-layout/index.tsx +113 -0
- package/server/ab-app-layout/styles.module.css +145 -0
- package/server/ab-aside-layout/index.tsx +117 -0
- package/server/ab-aside-layout/styles.module.css +155 -0
- package/server/ab-main-layout/index.tsx +119 -0
- package/server/ab-main-layout/styles.module.css +167 -0
- package/server/ab-screen-layout/index.tsx +107 -0
- package/server/ab-screen-layout/styles.module.css +134 -0
- package/types/css.d.ts +4 -0
- package/types/index.d.ts +14 -0
- package/.github/ab-logo-dark.svg +0 -12
- package/.github/ab-logo-light.svg +0 -9
- package/.github/nextjs-logoname-dark.svg +0 -28
- package/.github/nextjs-logoname-light.svg +0 -25
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license MIT
|
|
3
|
+
* ~~~~~~~~~~~~
|
|
4
|
+
* ab-nextjs-core
|
|
5
|
+
* ~~~~~~~~~~~~
|
|
6
|
+
* Copyright (c) 2026 Abraham Ukachi. The abElements Project.
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the 'Software'), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*
|
|
26
|
+
* @project: ab-nextjs-core
|
|
27
|
+
* @authors: Abraham Ukachi <abraham.ukachi@laplateforme.io>
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
32
|
+
* MOTTO: We'll always do more 😜!!!
|
|
33
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
import type { ReactElement } from 'react';
|
|
37
|
+
import clsx from 'clsx';
|
|
38
|
+
|
|
39
|
+
export interface AbLinearProgressProps {
|
|
40
|
+
className?: string;
|
|
41
|
+
color?: string;
|
|
42
|
+
hidden?: boolean;
|
|
43
|
+
isIndeterminate?: boolean;
|
|
44
|
+
progress?: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Minimal linear-progress stub (API parity with LYD chrome).
|
|
49
|
+
*/
|
|
50
|
+
const AbLinearProgress = ({
|
|
51
|
+
className,
|
|
52
|
+
hidden = true,
|
|
53
|
+
progress = 25,
|
|
54
|
+
}: AbLinearProgressProps): ReactElement => {
|
|
55
|
+
return (
|
|
56
|
+
<div
|
|
57
|
+
className={clsx(['AbLinearProgress', className])}
|
|
58
|
+
hidden={hidden}
|
|
59
|
+
role="progressbar"
|
|
60
|
+
aria-valuenow={progress}
|
|
61
|
+
aria-hidden={hidden ? true : undefined}
|
|
62
|
+
>
|
|
63
|
+
<div
|
|
64
|
+
className="h-full bg-current opacity-60"
|
|
65
|
+
style={{ width: `${Math.min(100, Math.max(0, progress))}%` }}
|
|
66
|
+
/>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default AbLinearProgress;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license MIT
|
|
3
|
+
* ~~~~~~~~~~~~
|
|
4
|
+
* ab-nextjs-core
|
|
5
|
+
* ~~~~~~~~~~~~
|
|
6
|
+
* Copyright (c) 2026 Abraham Ukachi. The abElements Project.
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the 'Software'), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*
|
|
26
|
+
* @project: ab-nextjs-core
|
|
27
|
+
* @authors: Abraham Ukachi <abraham.ukachi@laplateforme.io>
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
32
|
+
* MOTTO: We'll always do more 😜!!!
|
|
33
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
'use client';
|
|
37
|
+
|
|
38
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
39
|
+
import clsx from 'clsx';
|
|
40
|
+
import AbLinearProgress from '../ab-linear-progress';
|
|
41
|
+
import styles from './styles.module.css';
|
|
42
|
+
|
|
43
|
+
export interface AbMainLayoutProps {
|
|
44
|
+
orientation: 'vertical' | 'horizontal';
|
|
45
|
+
className?: string;
|
|
46
|
+
hidden?: boolean;
|
|
47
|
+
pageName?: string;
|
|
48
|
+
screenName?: string;
|
|
49
|
+
header?: ReactNode;
|
|
50
|
+
content?: ReactNode;
|
|
51
|
+
footer?: ReactNode;
|
|
52
|
+
children?: ReactNode;
|
|
53
|
+
menus?: ReactNode;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Client markup mirror of server AbMainLayout. */
|
|
57
|
+
const AbMainLayout = ({
|
|
58
|
+
orientation,
|
|
59
|
+
className,
|
|
60
|
+
hidden,
|
|
61
|
+
pageName,
|
|
62
|
+
screenName,
|
|
63
|
+
header,
|
|
64
|
+
content,
|
|
65
|
+
footer,
|
|
66
|
+
children,
|
|
67
|
+
menus,
|
|
68
|
+
}: AbMainLayoutProps): ReactElement => {
|
|
69
|
+
return (
|
|
70
|
+
<main
|
|
71
|
+
className={clsx(
|
|
72
|
+
['AbMainLayout', 'group-mainLayout', styles.abMainLayout, className],
|
|
73
|
+
{ 'has-screen-name': !!screenName },
|
|
74
|
+
)}
|
|
75
|
+
style={{ maxHeight: screenName ? 'initial' : undefined }}
|
|
76
|
+
hidden={hidden}
|
|
77
|
+
data-page-name={pageName}
|
|
78
|
+
data-screen-name={screenName}
|
|
79
|
+
>
|
|
80
|
+
<div className={clsx(['HeaderWrapper', styles.abMainLayout__headerWrapper])}>
|
|
81
|
+
{header}
|
|
82
|
+
</div>
|
|
83
|
+
<div
|
|
84
|
+
className={clsx([
|
|
85
|
+
'ContentWrapper',
|
|
86
|
+
styles.abMainLayout__contentWrapper,
|
|
87
|
+
orientation === 'horizontal' && 'md:!flex-row',
|
|
88
|
+
])}
|
|
89
|
+
data-orientation={orientation ? orientation.toString() : undefined}
|
|
90
|
+
>
|
|
91
|
+
{content ?? children}
|
|
92
|
+
</div>
|
|
93
|
+
<div className={clsx(['FooterWrapper', styles.abMainLayout__footerWrapper])}>
|
|
94
|
+
{footer}
|
|
95
|
+
</div>
|
|
96
|
+
<div className={clsx(['Backdrop', styles.abMainLayout__backdrop])} hidden />
|
|
97
|
+
<div className={clsx(['Menus', styles.abMainLayout__menus])} hidden>
|
|
98
|
+
{menus}
|
|
99
|
+
</div>
|
|
100
|
+
<div className={clsx(['Dialogs', styles.abMainLayout__dialogs])} hidden />
|
|
101
|
+
<div className={clsx(['Toasts', styles.abMainLayout__toasts])} hidden />
|
|
102
|
+
<AbLinearProgress
|
|
103
|
+
className="absolute top-0 left-0 right-0 z-50 !w-1/2 place-self-center !my-1 3xl:!my-2 !mx-auto !h-0.5 lg:!h-1 3xl:!h-1.5"
|
|
104
|
+
color="secondary"
|
|
105
|
+
hidden={true}
|
|
106
|
+
isIndeterminate={true}
|
|
107
|
+
progress={25}
|
|
108
|
+
/>
|
|
109
|
+
<canvas className={clsx(['Canvas', styles.abMainLayout__canvas])} />
|
|
110
|
+
</main>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export default AbMainLayout;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license MIT
|
|
3
|
+
* ~~~~~~~~~~~~
|
|
4
|
+
* ab-nextjs-core
|
|
5
|
+
* ~~~~~~~~~~~~
|
|
6
|
+
* Copyright (c) 2026 Abraham Ukachi. The abElements Project.
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the 'Software'), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*
|
|
26
|
+
* @project: ab-nextjs-core
|
|
27
|
+
* @name: AB Main Layout - Component Stylesheet (plain CSS, Tailwind-independent)
|
|
28
|
+
* @file: ab-main-layout/styles.module.css
|
|
29
|
+
* @type: CSS Module
|
|
30
|
+
* @authors: Abraham Ukachi <abraham.ukachi@laplateforme.io>
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
35
|
+
* MOTTO: We'll always do more 😜!!!
|
|
36
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
/* ===== AB MAIN LAYOUT STYLES ===== */
|
|
41
|
+
|
|
42
|
+
.abMainLayout {
|
|
43
|
+
position: relative;
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
width: 100%;
|
|
47
|
+
height: 100%;
|
|
48
|
+
overflow: hidden;
|
|
49
|
+
z-index: 20;
|
|
50
|
+
background-color: var(--color-background, var(--surface, #ffffff));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@media (max-width: 639px) {
|
|
54
|
+
.abMainLayout { max-height: calc(100vh - 60px); }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@media (max-width: 767px) {
|
|
58
|
+
.abMainLayout { max-height: calc(100vh - 64px); }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@media (min-width: 1536px) {
|
|
62
|
+
.abMainLayout { border-radius: 1.5rem; }
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
:global(.dark) .abMainLayout,
|
|
66
|
+
:global([data-theme="dark"]) .abMainLayout {
|
|
67
|
+
background-color: var(--color-dark-background, var(--surface, #0a0a0a));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.abMainLayout__headerWrapper {
|
|
71
|
+
position: relative;
|
|
72
|
+
display: flex;
|
|
73
|
+
flex-direction: column;
|
|
74
|
+
width: 100%;
|
|
75
|
+
height: auto;
|
|
76
|
+
z-index: 20;
|
|
77
|
+
pointer-events: none;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.abMainLayout__contentWrapper {
|
|
81
|
+
position: relative;
|
|
82
|
+
display: flex;
|
|
83
|
+
flex-direction: column;
|
|
84
|
+
width: 100%;
|
|
85
|
+
height: fit-content;
|
|
86
|
+
flex-grow: 1;
|
|
87
|
+
flex: 1 1 0%;
|
|
88
|
+
justify-content: space-between;
|
|
89
|
+
z-index: 10;
|
|
90
|
+
overflow: auto;
|
|
91
|
+
overflow-x: hidden;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.abMainLayout__footerWrapper {
|
|
95
|
+
position: relative;
|
|
96
|
+
display: flex;
|
|
97
|
+
flex-direction: column;
|
|
98
|
+
width: 100%;
|
|
99
|
+
height: auto;
|
|
100
|
+
z-index: 20;
|
|
101
|
+
pointer-events: none;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.abMainLayout__footerWrapper::before {
|
|
105
|
+
content: "";
|
|
106
|
+
position: absolute;
|
|
107
|
+
inset: 0;
|
|
108
|
+
width: 100%;
|
|
109
|
+
height: 100%;
|
|
110
|
+
z-index: -1;
|
|
111
|
+
transform: translateY(-100%);
|
|
112
|
+
background-image: linear-gradient(to bottom, transparent, var(--color-background, var(--surface, #ffffff)));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
:global(.dark) .abMainLayout__footerWrapper::before,
|
|
116
|
+
:global([data-theme="dark"]) .abMainLayout__footerWrapper::before {
|
|
117
|
+
background-image: linear-gradient(to bottom, transparent, var(--color-dark-background, var(--surface, #0a0a0a)));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.abMainLayout__backdrop {
|
|
121
|
+
position: absolute;
|
|
122
|
+
inset: 0;
|
|
123
|
+
width: 100%;
|
|
124
|
+
height: 100%;
|
|
125
|
+
z-index: 40;
|
|
126
|
+
backdrop-filter: blur(12px);
|
|
127
|
+
background-color: rgb(0 0 0 / 0.1);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
:global(.dark) .abMainLayout__backdrop,
|
|
131
|
+
:global([data-theme="dark"]) .abMainLayout__backdrop {
|
|
132
|
+
background-color: rgb(0 0 0 / 0.5);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.abMainLayout__menus {
|
|
136
|
+
position: absolute;
|
|
137
|
+
inset: 0;
|
|
138
|
+
width: 100%;
|
|
139
|
+
height: 100%;
|
|
140
|
+
z-index: 50;
|
|
141
|
+
padding-bottom: 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.abMainLayout__dialogs,
|
|
145
|
+
.abMainLayout__toasts {
|
|
146
|
+
position: absolute;
|
|
147
|
+
inset: 0;
|
|
148
|
+
width: 100%;
|
|
149
|
+
height: 100%;
|
|
150
|
+
z-index: 50;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.abMainLayout__toasts { animation: abCoreFadeIn 300ms ease-in-out; }
|
|
154
|
+
|
|
155
|
+
.abMainLayout__canvas {
|
|
156
|
+
position: absolute;
|
|
157
|
+
inset: 0;
|
|
158
|
+
width: 100%;
|
|
159
|
+
height: 100%;
|
|
160
|
+
pointer-events: none;
|
|
161
|
+
z-index: 50;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@keyframes abCoreFadeIn {
|
|
165
|
+
from { opacity: 0; }
|
|
166
|
+
to { opacity: 1; }
|
|
167
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license MIT
|
|
3
|
+
* ~~~~~~~~~~~~
|
|
4
|
+
* ab-nextjs-core
|
|
5
|
+
* ~~~~~~~~~~~~
|
|
6
|
+
* Copyright (c) 2026 Abraham Ukachi. The abElements Project.
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the 'Software'), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*
|
|
26
|
+
* @project: ab-nextjs-core
|
|
27
|
+
* @authors: Abraham Ukachi <abraham.ukachi@laplateforme.io>
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
32
|
+
* MOTTO: We'll always do more 😜!!!
|
|
33
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
'use client';
|
|
37
|
+
|
|
38
|
+
import {
|
|
39
|
+
createContext,
|
|
40
|
+
useCallback,
|
|
41
|
+
useContext,
|
|
42
|
+
useMemo,
|
|
43
|
+
useState,
|
|
44
|
+
type ReactElement,
|
|
45
|
+
type ReactNode,
|
|
46
|
+
} from 'react';
|
|
47
|
+
|
|
48
|
+
export interface AbPageContextValue {
|
|
49
|
+
isAsideOpen: boolean;
|
|
50
|
+
isAsideOpenOnMobile: boolean;
|
|
51
|
+
asideDuration: number;
|
|
52
|
+
asideElement: HTMLElement | null;
|
|
53
|
+
setAsideElement: (el: HTMLElement | null) => void;
|
|
54
|
+
isAsideOpening: boolean;
|
|
55
|
+
isAsideClosing: boolean;
|
|
56
|
+
isAsideLoading: boolean;
|
|
57
|
+
setAsideOpen: (open: boolean) => void;
|
|
58
|
+
setAsideOpenOnMobile: (open: boolean) => void;
|
|
59
|
+
setAsideLoading: (loading: boolean) => void;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const defaultValue: AbPageContextValue = {
|
|
63
|
+
isAsideOpen: true,
|
|
64
|
+
isAsideOpenOnMobile: false,
|
|
65
|
+
asideDuration: 300,
|
|
66
|
+
asideElement: null,
|
|
67
|
+
setAsideElement: () => {},
|
|
68
|
+
isAsideOpening: false,
|
|
69
|
+
isAsideClosing: false,
|
|
70
|
+
isAsideLoading: false,
|
|
71
|
+
setAsideOpen: () => {},
|
|
72
|
+
setAsideOpenOnMobile: () => {},
|
|
73
|
+
setAsideLoading: () => {},
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const AbPageContext = createContext<AbPageContextValue>(defaultValue);
|
|
77
|
+
|
|
78
|
+
export interface AbPageProviderProps {
|
|
79
|
+
children?: ReactNode;
|
|
80
|
+
/** Initial aside open state (default true so shells render visibly). */
|
|
81
|
+
defaultAsideOpen?: boolean;
|
|
82
|
+
asideDuration?: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Minimal page contract for client AbAsideLayout (LYD useLydPage aside slice).
|
|
87
|
+
* Not a port of LydPageProvider — only aside open/loading/element state.
|
|
88
|
+
*/
|
|
89
|
+
export function AbPageProvider({
|
|
90
|
+
children,
|
|
91
|
+
defaultAsideOpen = true,
|
|
92
|
+
asideDuration = 300,
|
|
93
|
+
}: AbPageProviderProps): ReactElement {
|
|
94
|
+
const [isAsideOpen, setAsideOpen] = useState(defaultAsideOpen);
|
|
95
|
+
const [isAsideOpenOnMobile, setAsideOpenOnMobile] = useState(false);
|
|
96
|
+
const [isAsideOpening, setAsideOpening] = useState(false);
|
|
97
|
+
const [isAsideClosing, setAsideClosing] = useState(false);
|
|
98
|
+
const [isAsideLoading, setAsideLoading] = useState(false);
|
|
99
|
+
const [asideElement, setAsideElementState] = useState<HTMLElement | null>(null);
|
|
100
|
+
|
|
101
|
+
const setAsideElement = useCallback((el: HTMLElement | null) => {
|
|
102
|
+
setAsideElementState(el);
|
|
103
|
+
}, []);
|
|
104
|
+
|
|
105
|
+
const setAsideOpenSafe = useCallback((open: boolean) => {
|
|
106
|
+
if (open) {
|
|
107
|
+
setAsideOpening(true);
|
|
108
|
+
setAsideOpen(true);
|
|
109
|
+
window.setTimeout(() => setAsideOpening(false), asideDuration);
|
|
110
|
+
} else {
|
|
111
|
+
setAsideClosing(true);
|
|
112
|
+
window.setTimeout(() => {
|
|
113
|
+
setAsideOpen(false);
|
|
114
|
+
setAsideClosing(false);
|
|
115
|
+
}, asideDuration);
|
|
116
|
+
}
|
|
117
|
+
}, [asideDuration]);
|
|
118
|
+
|
|
119
|
+
const value = useMemo<AbPageContextValue>(
|
|
120
|
+
() => ({
|
|
121
|
+
isAsideOpen,
|
|
122
|
+
isAsideOpenOnMobile,
|
|
123
|
+
asideDuration,
|
|
124
|
+
asideElement,
|
|
125
|
+
setAsideElement,
|
|
126
|
+
isAsideOpening,
|
|
127
|
+
isAsideClosing,
|
|
128
|
+
isAsideLoading,
|
|
129
|
+
setAsideOpen: setAsideOpenSafe,
|
|
130
|
+
setAsideOpenOnMobile,
|
|
131
|
+
setAsideLoading,
|
|
132
|
+
}),
|
|
133
|
+
[
|
|
134
|
+
isAsideOpen,
|
|
135
|
+
isAsideOpenOnMobile,
|
|
136
|
+
asideDuration,
|
|
137
|
+
asideElement,
|
|
138
|
+
setAsideElement,
|
|
139
|
+
isAsideOpening,
|
|
140
|
+
isAsideClosing,
|
|
141
|
+
isAsideLoading,
|
|
142
|
+
setAsideOpenSafe,
|
|
143
|
+
],
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
return <AbPageContext.Provider value={value}>{children}</AbPageContext.Provider>;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Hook contract used by client AbAsideLayout.
|
|
151
|
+
* Returns safe defaults when used outside AbPageProvider.
|
|
152
|
+
*/
|
|
153
|
+
export function useAbPage(): AbPageContextValue {
|
|
154
|
+
return useContext(AbPageContext);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export default AbPageProvider;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license MIT
|
|
3
|
+
* ~~~~~~~~~~~~
|
|
4
|
+
* ab-nextjs-core
|
|
5
|
+
* ~~~~~~~~~~~~
|
|
6
|
+
* Copyright (c) 2026 Abraham Ukachi. The abElements Project.
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the 'Software'), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*
|
|
26
|
+
* @project: ab-nextjs-core
|
|
27
|
+
* @authors: Abraham Ukachi <abraham.ukachi@laplateforme.io>
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
32
|
+
* MOTTO: We'll always do more 😜!!!
|
|
33
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
'use client';
|
|
37
|
+
|
|
38
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
39
|
+
import clsx from 'clsx';
|
|
40
|
+
import AbLinearProgress from '../ab-linear-progress';
|
|
41
|
+
import styles from './styles.module.css';
|
|
42
|
+
|
|
43
|
+
export interface AbScreenLayoutProps {
|
|
44
|
+
orientation: 'vertical' | 'horizontal';
|
|
45
|
+
className?: string;
|
|
46
|
+
hidden?: boolean;
|
|
47
|
+
screenName?: string;
|
|
48
|
+
header?: ReactNode;
|
|
49
|
+
content?: ReactNode;
|
|
50
|
+
footer?: ReactNode;
|
|
51
|
+
children?: ReactNode;
|
|
52
|
+
menus?: ReactNode;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Client markup mirror of server AbScreenLayout. */
|
|
56
|
+
const AbScreenLayout = ({
|
|
57
|
+
orientation,
|
|
58
|
+
className,
|
|
59
|
+
hidden,
|
|
60
|
+
screenName,
|
|
61
|
+
header,
|
|
62
|
+
content,
|
|
63
|
+
footer,
|
|
64
|
+
children,
|
|
65
|
+
menus,
|
|
66
|
+
}: AbScreenLayoutProps): ReactElement => {
|
|
67
|
+
return (
|
|
68
|
+
<div
|
|
69
|
+
className={clsx(['AbScreenLayout', styles.abScreenLayout, className])}
|
|
70
|
+
hidden={hidden}
|
|
71
|
+
data-screen-name={screenName}
|
|
72
|
+
data-orientation={orientation ?? ''}
|
|
73
|
+
>
|
|
74
|
+
<div className={clsx(['HeaderWrapper', styles.abScreenLayout__headerWrapper])}>
|
|
75
|
+
{header}
|
|
76
|
+
</div>
|
|
77
|
+
<div className={clsx(['ContentWrapper', styles.abScreenLayout__contentWrapper])}>
|
|
78
|
+
{content ?? children}
|
|
79
|
+
</div>
|
|
80
|
+
<div className={clsx(['FooterWrapper', styles.abScreenLayout__footerWrapper])}>
|
|
81
|
+
{footer}
|
|
82
|
+
</div>
|
|
83
|
+
<div id="backdrop" className={clsx(['Backdrop', styles.abScreenLayout__backdrop])} hidden />
|
|
84
|
+
<div id="menus" className={clsx(['Menus', styles.abScreenLayout__menus])} hidden>
|
|
85
|
+
{menus}
|
|
86
|
+
</div>
|
|
87
|
+
<div id="dialogs" className={clsx(['Dialogs', styles.abScreenLayout__dialogs])} hidden />
|
|
88
|
+
<div id="toasts" className={clsx(['Toasts', styles.abScreenLayout__toasts])} hidden />
|
|
89
|
+
<AbLinearProgress
|
|
90
|
+
className="absolute top-0 left-0 right-0 z-50 !h-0.5 lg:!h-1"
|
|
91
|
+
color="secondary"
|
|
92
|
+
hidden={true}
|
|
93
|
+
isIndeterminate={true}
|
|
94
|
+
progress={25}
|
|
95
|
+
/>
|
|
96
|
+
<canvas className={clsx(['Canvas', styles.abScreenLayout__canvas])} />
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export default AbScreenLayout;
|