5htp-core 0.5.0-6 → 0.5.0-8
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "5htp-core",
|
|
3
3
|
"description": "Convenient TypeScript framework designed for Performance and Productivity.",
|
|
4
|
-
"version": "0.5.0-
|
|
4
|
+
"version": "0.5.0-8",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/5htp-core.git",
|
|
7
7
|
"license": "MIT",
|
|
@@ -23,7 +23,6 @@ export type Props = {
|
|
|
23
23
|
iconR?: ComponentChild,
|
|
24
24
|
|
|
25
25
|
prefix?: ComponentChild,
|
|
26
|
-
children?: ComponentChild | ComponentChild[],
|
|
27
26
|
suffix?: ComponentChild,
|
|
28
27
|
|
|
29
28
|
tag?: "a" | "button",
|
|
@@ -31,7 +30,6 @@ export type Props = {
|
|
|
31
30
|
shape?: 'default' | 'icon' | 'tile' | 'pill',
|
|
32
31
|
size?: TComponentSize,
|
|
33
32
|
class?: string,
|
|
34
|
-
title?: string,
|
|
35
33
|
|
|
36
34
|
state?: [string, React.StateUpdater<string>],
|
|
37
35
|
active?: boolean,
|
|
@@ -45,7 +43,14 @@ export type Props = {
|
|
|
45
43
|
submenu?: ComponentChild,
|
|
46
44
|
nav?: boolean | 'exact'
|
|
47
45
|
|
|
48
|
-
|
|
46
|
+
// SEO: if icon only, should provinde a hint (aria-label)
|
|
47
|
+
} & ({
|
|
48
|
+
hint: string,
|
|
49
|
+
children?: ComponentChild | ComponentChild[],
|
|
50
|
+
} | {
|
|
51
|
+
children: ComponentChild | ComponentChild[],
|
|
52
|
+
hint?: string,
|
|
53
|
+
}) & (TButtonProps | TLinkProps)
|
|
49
54
|
|
|
50
55
|
export type TButtonProps = {
|
|
51
56
|
|
|
@@ -84,6 +89,7 @@ export default ({
|
|
|
84
89
|
iconR, suffix,
|
|
85
90
|
submenu,
|
|
86
91
|
nav,
|
|
92
|
+
hint,
|
|
87
93
|
|
|
88
94
|
// Style
|
|
89
95
|
class: className,
|
|
@@ -125,6 +131,12 @@ export default ({
|
|
|
125
131
|
props.onClick = () => setActive(id);
|
|
126
132
|
}
|
|
127
133
|
|
|
134
|
+
// Hint
|
|
135
|
+
if (hint !== undefined) {
|
|
136
|
+
props['aria-label'] = hint;
|
|
137
|
+
props.title = hint;
|
|
138
|
+
}
|
|
139
|
+
|
|
128
140
|
// Shape classes
|
|
129
141
|
const classNames: string[] = ['btn'];
|
|
130
142
|
if (className)
|
|
@@ -77,15 +77,21 @@ export default (props: Props) => {
|
|
|
77
77
|
)
|
|
78
78
|
);
|
|
79
79
|
|
|
80
|
-
// Autofocus elements
|
|
81
|
-
focusContent( refContent.current );
|
|
82
|
-
|
|
83
80
|
// Close when the user clicks elsewere tha the popover
|
|
84
81
|
return blurable([ refCont.current, () => show(false) ])
|
|
85
82
|
}
|
|
86
83
|
|
|
87
84
|
}, [shown]);
|
|
88
85
|
|
|
86
|
+
React.useEffect(() => {
|
|
87
|
+
if (position !== undefined) {
|
|
88
|
+
|
|
89
|
+
// Autofocus elements once the final position has been set
|
|
90
|
+
focusContent( refContent.current );
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
}, [position]);
|
|
94
|
+
|
|
89
95
|
/*----------------------------------
|
|
90
96
|
- ATTRIBUTES
|
|
91
97
|
----------------------------------*/
|
|
@@ -41,7 +41,7 @@ export type TInputState<TValue> = {
|
|
|
41
41
|
- HOOKS
|
|
42
42
|
----------------------------------*/
|
|
43
43
|
export function useInput<TValue>(
|
|
44
|
-
{ value: externalValue, onChange, className, ...otherProps }: InputBaseProps<TValue>,
|
|
44
|
+
{ value: externalValue, onChange, className, hint, ...otherProps }: InputBaseProps<TValue>,
|
|
45
45
|
defaultValue: TValue,
|
|
46
46
|
autoCommit: boolean = false
|
|
47
47
|
): [
|
package/src/client/utils/dom.ts
CHANGED
|
@@ -71,7 +71,7 @@ export const focusContent = ( container: HTMLElement ) => {
|
|
|
71
71
|
|
|
72
72
|
const toFocus = container.querySelector<HTMLInputElement | HTMLTextAreaElement | HTMLButtonElement>(
|
|
73
73
|
'input, textarea, button.btn.primary, footer > button.btn'
|
|
74
|
-
)
|
|
74
|
+
) || container; // Is it useful ? Creating unwanted scroll issue on showing popover
|
|
75
75
|
|
|
76
76
|
toFocus?.focus();
|
|
77
77
|
}
|
|
@@ -58,7 +58,7 @@ export default class DocumentRenderer<TRouter extends Router> {
|
|
|
58
58
|
public async page( html: string, page: Page, response: ServerResponse<TRouter> ) {
|
|
59
59
|
|
|
60
60
|
// TODO: can be customized via page / route config
|
|
61
|
-
const canonicalUrl = response.request.
|
|
61
|
+
const canonicalUrl = response.request.url;
|
|
62
62
|
|
|
63
63
|
let attrsBody = {
|
|
64
64
|
className: [...page.bodyClass].join(' '),
|