@firecms/ui 3.4.0-canary.f6a889a → 3.4.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/dist/components/SearchBar.d.ts +8 -1
- package/dist/index.es.js +45 -31
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +45 -31
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Card.tsx +19 -4
- package/src/components/SearchBar.tsx +9 -1
- package/src/styles.ts +1 -1
package/dist/styles.d.ts
CHANGED
|
@@ -8,5 +8,5 @@ export declare const fieldBackgroundHoverMixin = "hover:bg-opacity-70 dark:hover
|
|
|
8
8
|
export declare const defaultBorderMixin = "border-surface-200 border-opacity-40 dark:border-surface-700 dark:border-opacity-40 border-surface-200/40 dark:border-surface-700/40 ";
|
|
9
9
|
export declare const paperMixin = "bg-white rounded-md dark:bg-surface-950 border border-surface-200 border-opacity-40 dark:border-surface-700 dark:border-opacity-40 border-surface-200/40 dark:border-surface-700/40";
|
|
10
10
|
export declare const cardMixin = "bg-white dark:bg-surface-950 rounded-md border border-surface-200/40 dark:border-surface-700/40 m-1 -p-1";
|
|
11
|
-
export declare const cardClickableMixin = "hover:bg-surface-accent-100 dark:hover:bg-surface-accent-800 hover:ring-2 hover:ring-primary cursor-pointer hover:bg-primary/20 dark:hover:bg-primary/10 ";
|
|
11
|
+
export declare const cardClickableMixin = "hover:bg-surface-accent-100 dark:hover:bg-surface-accent-800 hover:ring-2 hover:ring-primary cursor-pointer hover:bg-primary/20 dark:hover:bg-primary/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ";
|
|
12
12
|
export declare const cardSelectedMixin = "bg-primary-bg dark:bg-primary-bg bg-opacity-30 bg-primary-bg/30 dark:bg-opacity-10 dark:bg-primary-bg/10 ring-1 ring-primary ring-opacity-75 ring-primary/75 bg-primary/10 dark:bg-primary/10 ring-1 ring-primary/75";
|
package/package.json
CHANGED
package/src/components/Card.tsx
CHANGED
|
@@ -15,18 +15,33 @@ const Card = React.forwardRef<HTMLDivElement, CardProps>(({
|
|
|
15
15
|
className,
|
|
16
16
|
onClick,
|
|
17
17
|
style,
|
|
18
|
+
onKeyDown: onKeyDownProp,
|
|
18
19
|
...props
|
|
19
20
|
}, ref) => {
|
|
20
|
-
|
|
21
|
+
|
|
22
|
+
const onKeyDown = useCallback((e: React.KeyboardEvent<HTMLDivElement>) => {
|
|
23
|
+
// Always let a caller supplied handler run first, and let it opt out of
|
|
24
|
+
// the default activation by calling preventDefault().
|
|
25
|
+
onKeyDownProp?.(e);
|
|
26
|
+
if (!onClick || e.defaultPrevented)
|
|
27
|
+
return;
|
|
28
|
+
// Only activate when the card itself is focused. Cards may render their
|
|
29
|
+
// own focusable children (e.g. action buttons), which handle their own
|
|
30
|
+
// activation; their key events must not activate the card as well.
|
|
31
|
+
if (e.target !== e.currentTarget)
|
|
32
|
+
return;
|
|
21
33
|
if (e.key === "Enter" || e.key === " ") {
|
|
22
|
-
|
|
34
|
+
// Without this, Space also performs its default browser action and
|
|
35
|
+
// scrolls the page away from the focused card.
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
onClick();
|
|
23
38
|
}
|
|
24
|
-
}, [onClick]);
|
|
39
|
+
}, [onClick, onKeyDownProp]);
|
|
25
40
|
|
|
26
41
|
return (
|
|
27
42
|
<div
|
|
28
43
|
ref={ref}
|
|
29
|
-
|
|
44
|
+
onKeyDown={onKeyDown}
|
|
30
45
|
role={onClick ? "button" : undefined}
|
|
31
46
|
tabIndex={onClick ? 0 : undefined}
|
|
32
47
|
onClick={onClick}
|
|
@@ -11,6 +11,13 @@ interface SearchBarProps {
|
|
|
11
11
|
onClick?: () => void;
|
|
12
12
|
onTextSearch?: (searchString?: string) => void;
|
|
13
13
|
placeholder?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Text the input is initialised with. Use it when the search term is restored from
|
|
16
|
+
* somewhere else, e.g. a URL query parameter, so that the input reflects the search
|
|
17
|
+
* that is actually being applied. Only read when the component mounts; the search bar
|
|
18
|
+
* owns the text from then on.
|
|
19
|
+
*/
|
|
20
|
+
initialValue?: string;
|
|
14
21
|
expandable?: boolean;
|
|
15
22
|
/**
|
|
16
23
|
* Size of the search bar.
|
|
@@ -35,6 +42,7 @@ export function SearchBar({
|
|
|
35
42
|
onClick,
|
|
36
43
|
onTextSearch,
|
|
37
44
|
placeholder = "Search",
|
|
45
|
+
initialValue,
|
|
38
46
|
expandable = false,
|
|
39
47
|
size = "medium",
|
|
40
48
|
large,
|
|
@@ -46,7 +54,7 @@ export function SearchBar({
|
|
|
46
54
|
inputRef
|
|
47
55
|
}: SearchBarProps) {
|
|
48
56
|
|
|
49
|
-
const [searchText, setSearchText] = useState<string>("");
|
|
57
|
+
const [searchText, setSearchText] = useState<string>(initialValue ?? "");
|
|
50
58
|
const [active, setActive] = useState<boolean>(false);
|
|
51
59
|
|
|
52
60
|
const deferredValues = useDebounceValue(searchText, 200);
|
package/src/styles.ts
CHANGED
|
@@ -8,5 +8,5 @@ export const fieldBackgroundHoverMixin = "hover:bg-opacity-70 dark:hover:bg-surf
|
|
|
8
8
|
export const defaultBorderMixin = "border-surface-200 border-opacity-40 dark:border-surface-700 dark:border-opacity-40 border-surface-200/40 dark:border-surface-700/40 ";
|
|
9
9
|
export const paperMixin = "bg-white rounded-md dark:bg-surface-950 border border-surface-200 border-opacity-40 dark:border-surface-700 dark:border-opacity-40 border-surface-200/40 dark:border-surface-700/40";
|
|
10
10
|
export const cardMixin = "bg-white dark:bg-surface-950 rounded-md border border-surface-200/40 dark:border-surface-700/40 m-1 -p-1";
|
|
11
|
-
export const cardClickableMixin = "hover:bg-surface-accent-100 dark:hover:bg-surface-accent-800 hover:ring-2 hover:ring-primary cursor-pointer hover:bg-primary/20 dark:hover:bg-primary/10 ";
|
|
11
|
+
export const cardClickableMixin = "hover:bg-surface-accent-100 dark:hover:bg-surface-accent-800 hover:ring-2 hover:ring-primary cursor-pointer hover:bg-primary/20 dark:hover:bg-primary/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ";
|
|
12
12
|
export const cardSelectedMixin = "bg-primary-bg dark:bg-primary-bg bg-opacity-30 bg-primary-bg/30 dark:bg-opacity-10 dark:bg-primary-bg/10 ring-1 ring-primary ring-opacity-75 ring-primary/75 bg-primary/10 dark:bg-primary/10 ring-1 ring-primary/75";
|