@firecms/ui 3.0.0-canary.40 → 3.0.0-canary.42

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 (38) hide show
  1. package/dist/components/CenteredView.d.ts +4 -2
  2. package/dist/components/TextareaAutosize.d.ts +4 -2
  3. package/dist/hooks/index.d.ts +4 -0
  4. package/dist/hooks/useLocaleConfig.d.ts +1 -0
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.es.js +7254 -7242
  7. package/dist/index.es.js.map +1 -1
  8. package/dist/index.umd.js +10 -10
  9. package/dist/index.umd.js.map +1 -1
  10. package/dist/styles.d.ts +3 -3
  11. package/dist/util/index.d.ts +0 -2
  12. package/package.json +4 -2
  13. package/src/components/Autocomplete.tsx +2 -1
  14. package/src/components/Button.tsx +1 -1
  15. package/src/components/CenteredView.tsx +24 -14
  16. package/src/components/Collapse.tsx +2 -1
  17. package/src/components/DateTimeField.tsx +2 -1
  18. package/src/components/ExpandablePanel.tsx +2 -1
  19. package/src/components/FileUpload.tsx +1 -1
  20. package/src/components/InputLabel.tsx +6 -6
  21. package/src/components/Label.tsx +1 -1
  22. package/src/components/MultiSelect.tsx +2 -1
  23. package/src/components/Popover.tsx +2 -1
  24. package/src/components/SearchBar.tsx +1 -1
  25. package/src/components/TextareaAutosize.tsx +1 -1
  26. package/src/components/Tooltip.tsx +2 -1
  27. package/src/components/Typography.tsx +1 -1
  28. package/src/hooks/index.ts +4 -0
  29. package/src/hooks/useLocaleConfig.tsx +18 -0
  30. package/src/index.ts +1 -0
  31. package/src/styles.ts +3 -3
  32. package/src/util/index.ts +0 -2
  33. /package/dist/{util → hooks}/useDebounceValue.d.ts +0 -0
  34. /package/dist/{util → hooks}/useInjectStyles.d.ts +0 -0
  35. /package/dist/{util → hooks}/useOutsideAlerter.d.ts +0 -0
  36. /package/src/{util → hooks}/useDebounceValue.tsx +0 -0
  37. /package/src/{util → hooks}/useInjectStyles.tsx +0 -0
  38. /package/src/{util → hooks}/useOutsideAlerter.tsx +0 -0
package/dist/styles.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  export declare const focusedMixin = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-opacity-75 focus-visible:ring-offset-2 focus-visible:ring-offset-transparent";
2
2
  export declare const focusedInvisibleMixin = "focus:bg-opacity-70 focus:bg-slate-100 focus:dark:bg-gray-800 focus:dark:bg-opacity-60";
3
3
  export declare const focusedClasses = "z-30 outline-none ring-2 ring-primary ring-opacity-75 ring-offset-2 ring-offset-transparent ";
4
- export declare const fieldBackgroundMixin = "bg-opacity-50 bg-slate-200 dark:bg-gray-700 dark:bg-opacity-40 transition duration-150 ease-in-out";
5
- export declare const fieldBackgroundInvisibleMixin = "bg-opacity-0 bg-slate-100 dark:bg-gray-800 dark:bg-opacity-0 transition duration-150 ease-in-out";
4
+ export declare const fieldBackgroundMixin = "bg-opacity-50 bg-slate-200 dark:bg-gray-700 dark:bg-opacity-40 transition duration-100 ease-in-out";
5
+ export declare const fieldBackgroundInvisibleMixin = "bg-opacity-0 bg-slate-100 dark:bg-gray-800 dark:bg-opacity-0 transition duration-100 ease-in-out";
6
6
  export declare const fieldBackgroundDisabledMixin = "dark:bg-gray-800 bg-opacity-80 dark:bg-opacity-90";
7
7
  export declare const fieldBackgroundHoverMixin = "hover:bg-opacity-70 dark:hover:bg-opacity-60";
8
8
  export declare const defaultBorderMixin = "border-gray-100 dark:border-gray-800 dark:border-opacity-80";
9
9
  export declare const paperMixin = "bg-white rounded-md dark:bg-gray-950 border dark:border-gray-800 dark:border-opacity-80 border-gray-100";
10
- export declare const cardMixin = "bg-white border border-gray-100 dark:border-transparent rounded-md dark:bg-gray-950 dark:border-gray-800 dark:border-opacity-50 transition duration-200 ease-in-out m-1 -p-1";
10
+ export declare const cardMixin = "bg-white border border-gray-100 dark:border-transparent rounded-md dark:bg-gray-950 dark:border-gray-800 dark:border-opacity-50 transition duration-100 ease-in-out m-1 -p-1";
11
11
  export declare const cardClickableMixin = "hover:bg-primary-bg dark:hover:bg-primary-bg hover:bg-opacity-20 dark:hover:bg-opacity-20 hover:ring-2 hover:ring-primary cursor-pointer";
12
12
  export declare const cardSelectedMixin = "bg-primary-bg dark:bg-primary-bg bg-opacity-30 dark:bg-opacity-10 ring-1 ring-primary ring-opacity-75";
@@ -2,5 +2,3 @@ export * from "./cn";
2
2
  export * from "./debounce";
3
3
  export * from "./chip_colors";
4
4
  export * from "./key_to_icon_component";
5
- export * from "./useInjectStyles";
6
- export * from "./useOutsideAlerter";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@firecms/ui",
3
3
  "type": "module",
4
- "version": "3.0.0-canary.40",
4
+ "version": "3.0.0-canary.42",
5
5
  "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/firecmsco"
@@ -62,7 +62,9 @@
62
62
  "@radix-ui/react-switch": "^1.0.3",
63
63
  "@radix-ui/react-tabs": "^1.0.4",
64
64
  "@radix-ui/react-tooltip": "^1.0.7",
65
+ "clsx": "^2.1.0",
65
66
  "cmdk": "^0.2.1",
67
+ "date-fns": "^3.6.0",
66
68
  "react-datepicker": "^6.4.0",
67
69
  "react-dropzone": "^14.2.3",
68
70
  "react-fast-compare": "^3.2.2",
@@ -114,7 +116,7 @@
114
116
  "src",
115
117
  "tailwind.config.js"
116
118
  ],
117
- "gitHead": "40b01721ac260b6cce7f5d8a3a1d768410e7f20d",
119
+ "gitHead": "d6a2f28e93d3c532dd6efacfccffb91383d5330e",
118
120
  "publishConfig": {
119
121
  "access": "public"
120
122
  }
@@ -2,7 +2,8 @@ import React from "react";
2
2
 
3
3
  import { paperMixin } from "../styles";
4
4
  import { Collapse } from "./Collapse";
5
- import { cn, useOutsideAlerter } from "../util";
5
+ import { cn } from "../util";
6
+ import { useOutsideAlerter } from "../hooks";
6
7
 
7
8
  export type AutocompleteProps = {
8
9
  children: React.ReactNode;
@@ -50,7 +50,7 @@ const ButtonInner = React.forwardRef<
50
50
  // Outlined Variants
51
51
  "border border-primary text-primary hover:bg-primary-bg": variant === "outlined" && color === "primary" && !disabled,
52
52
  "border border-secondary text-secondary hover:bg-secondary-bg": variant === "outlined" && color === "secondary" && !disabled,
53
- "border border-red-500 text-red-500 hover:bg-red-500": variant === "outlined" && color === "error" && !disabled,
53
+ "border border-red-500 text-red-500 hover:bg-red-500 hover:text-white": variant === "outlined" && color === "error" && !disabled,
54
54
  "border border-slate-400 text-text-primary dark:text-text-primary-dark hover:bg-slate-200": variant === "outlined" && color === "text" && !disabled,
55
55
  // Disabled states for all variants
56
56
  "border border-transparent opacity-50": variant === "text" && disabled,
@@ -2,23 +2,33 @@ import React from "react";
2
2
  import { Container } from "./Container";
3
3
  import { cn } from "../util";
4
4
 
5
- export function CenteredView({
6
- children,
7
- maxWidth,
8
- className,
9
- fullScreen
10
- }: {
5
+ export type CenteredViewProps = {
11
6
  children: React.ReactNode;
12
7
  maxWidth?: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl";
8
+ outerClassName?: string;
13
9
  className?: string;
14
10
  fullScreen?: boolean;
15
- }) {
11
+ };
16
12
 
17
- return <div className={cn("flex flex-col flex-grow", fullScreen ? "h-screen" : "h-full")}>
18
- <Container className={cn("m-auto", className)}
19
- maxWidth={maxWidth}>
20
- {children}
21
- </Container>
22
- </div>
13
+ export const CenteredView = React.forwardRef<HTMLDivElement, CenteredViewProps>(({
14
+ children,
15
+ maxWidth,
16
+ outerClassName,
17
+ className,
18
+ fullScreen,
19
+ ...rest
20
+ }, ref) => { // Notice how the ref is now received as the second argument
23
21
 
24
- }
22
+ return (
23
+ <div ref={ref}
24
+ className={cn("flex flex-col flex-grow", fullScreen ? "h-screen" : "h-full", outerClassName)}
25
+ {...rest}>
26
+ <Container className={cn("m-auto", className)} maxWidth={maxWidth}>
27
+ {children}
28
+ </Container>
29
+ </div>
30
+ );
31
+
32
+ });
33
+
34
+ CenteredView.displayName = "CenteredView";
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
2
  import * as Collapsible from "@radix-ui/react-collapsible";
3
3
 
4
- import { cn, useInjectStyles } from "../util";
4
+ import { cn } from "../util";
5
+ import { useInjectStyles } from "../hooks";
5
6
 
6
7
  interface CollapseProps {
7
8
  children?: React.ReactNode;
@@ -12,8 +12,9 @@ import {
12
12
  paperMixin
13
13
  } from "../styles";
14
14
  import { InputLabel } from "./InputLabel";
15
- import { cn, useInjectStyles } from "../util";
16
15
  import { Typography } from "./Typography";
16
+ import { cn } from "../util";
17
+ import { useInjectStyles } from "../hooks";
17
18
 
18
19
  interface DateTimeFieldProps {
19
20
  value?: Date;
@@ -3,7 +3,8 @@ import React, { PropsWithChildren, useEffect, useState } from "react";
3
3
  import * as Collapsible from "@radix-ui/react-collapsible";
4
4
  import { defaultBorderMixin, fieldBackgroundMixin, focusedMixin } from "../styles";
5
5
  import { ExpandMoreIcon } from "../icons";
6
- import { cn, useInjectStyles } from "../util";
6
+ import { cn } from "../util";
7
+ import { useInjectStyles } from "../hooks";
7
8
 
8
9
  export function ExpandablePanel({
9
10
  title,
@@ -38,7 +38,7 @@ export function FileUpload({
38
38
  disabled,
39
39
  maxFiles,
40
40
  title,
41
- uploadDescription = "Drag and drop a file here or click",
41
+ uploadDescription,
42
42
  children,
43
43
  preventDropOnDocument = true,
44
44
  size
@@ -8,6 +8,12 @@ export type InputLabelProps = {
8
8
  shrink?: boolean;
9
9
  } & React.LabelHTMLAttributes<HTMLLabelElement>;
10
10
 
11
+ const defaultClasses = {
12
+ root: "origin-left transition-transform block whitespace-nowrap overflow-hidden text-overflow-ellipsis max-w-full",
13
+ shrink: "transform translate-y-[2px] scale-75 translate-x-[12px]",
14
+ expanded: "translate-x-[16px] top-0 transform translate-y-[16px] scale-100"
15
+ };
16
+
11
17
  export const InputLabel = React.forwardRef<HTMLLabelElement, InputLabelProps>(function InputLabel(inProps, ref) {
12
18
  const {
13
19
  shrink,
@@ -15,12 +21,6 @@ export const InputLabel = React.forwardRef<HTMLLabelElement, InputLabelProps>(fu
15
21
  ...other
16
22
  } = inProps;
17
23
 
18
- const defaultClasses = {
19
- root: "origin-left transition-transform block whitespace-nowrap overflow-hidden text-overflow-ellipsis max-w-full",
20
- shrink: "transform translate-y-[2px] scale-75 translate-x-[12px]",
21
- expanded: "translate-x-[16px] top-0 transform translate-y-[16px] scale-100"
22
- };
23
-
24
24
  const computedClassName = cn(defaultClasses.root,
25
25
  {
26
26
  [defaultClasses.shrink]: shrink,
@@ -9,7 +9,7 @@ const Label = React.forwardRef<
9
9
  >(({ className, ...props }, ref) => (
10
10
  <LabelPrimitive.Root
11
11
  ref={ref}
12
- className={cn("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", defaultBorderMixin, className)}
12
+ className={cn("text-sm font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70", defaultBorderMixin, className)}
13
13
  {...props}
14
14
  />
15
15
  ))
@@ -6,8 +6,9 @@ import { Command as CommandPrimitive } from "cmdk";
6
6
 
7
7
  import { ExpandMoreIcon } from "../icons";
8
8
  import { fieldBackgroundDisabledMixin, fieldBackgroundHoverMixin, fieldBackgroundMixin, focusedMixin } from "../styles";
9
- import { cn, useOutsideAlerter } from "../util";
9
+ import { cn } from "../util";
10
10
  import { SelectInputLabel } from "./common/SelectInputLabel";
11
+ import { useOutsideAlerter } from "../hooks";
11
12
 
12
13
  export type MultiSelectProps = {
13
14
  open?: boolean,
@@ -2,7 +2,8 @@ import React from "react";
2
2
  import * as PopoverPrimitive from "@radix-ui/react-popover";
3
3
 
4
4
  import { paperMixin } from "../styles";
5
- import { cn, useInjectStyles } from "../util";
5
+ import { cn } from "../util";
6
+ import { useInjectStyles } from "../hooks";
6
7
 
7
8
  export type PopoverSide = "top" | "right" | "bottom" | "left";
8
9
  export type PopoverAlign = "start" | "center" | "end";
@@ -4,7 +4,7 @@ import { defaultBorderMixin, focusedMixin } from "../styles";
4
4
  import { CircularProgress, IconButton } from "./index";
5
5
  import { ClearIcon, SearchIcon } from "../icons";
6
6
  import { cn } from "../util";
7
- import { useDebounceValue } from "../util/useDebounceValue";
7
+ import { useDebounceValue } from "../hooks";
8
8
 
9
9
  interface SearchBarProps {
10
10
  onClick?: () => void;
@@ -288,7 +288,7 @@ export const TextareaAutosize = React.forwardRef(function TextareaAutosize(
288
288
  />
289
289
  </React.Fragment>
290
290
  );
291
- });
291
+ }) as React.FC<TextareaAutosizeProps & { ref?: React.ForwardedRef<Element> }>;
292
292
 
293
293
  export type TextareaAutosizeProps = Omit<React.InputHTMLAttributes<HTMLTextAreaElement>, "onResize"> & {
294
294
 
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
2
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
3
3
 
4
- import { cn, useInjectStyles } from "../util";
4
+ import { cn } from "../util";
5
+ import { useInjectStyles } from "../hooks";
5
6
 
6
7
  export type TooltipProps = {
7
8
  open?: boolean,
@@ -87,7 +87,7 @@ export function Typography<C extends React.ElementType>(
87
87
  variantToClasses[variant],
88
88
  color ? colorToClasses[color] : "",
89
89
  align !== "inherit" && `text-${align}`,
90
- gutterBottom && "mb-[0.35em]",
90
+ gutterBottom && "mb-2",
91
91
  noWrap && "truncate",
92
92
  paragraph && "mb-3",
93
93
  className
@@ -0,0 +1,4 @@
1
+ export * from "./useLocaleConfig";
2
+ export * from "./useInjectStyles";
3
+ export * from "./useOutsideAlerter";
4
+ export * from "./useDebounceValue";
@@ -0,0 +1,18 @@
1
+ import * as locales from "date-fns/locale";
2
+ // @ts-ignore
3
+ import { registerLocale, setDefaultLocale } from "react-datepicker";
4
+ import { useEffect } from "react";
5
+
6
+ export function useLocaleConfig(locale?: string) {
7
+ useEffect(() => {
8
+ if (!locale) {
9
+ return;
10
+ }
11
+ // @ts-ignore
12
+ const dateFnsLocale = locales[locale];
13
+ if (dateFnsLocale) {
14
+ registerLocale(locale, dateFnsLocale);
15
+ setDefaultLocale(locale);
16
+ }
17
+ }, [locale])
18
+ }
package/src/index.ts CHANGED
@@ -2,3 +2,4 @@ export * from "./components";
2
2
  export * from "./styles";
3
3
  export * from "./util";
4
4
  export * from "./icons";
5
+ export * from "./hooks";
package/src/styles.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  export const focusedMixin = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-opacity-75 focus-visible:ring-offset-2 focus-visible:ring-offset-transparent";
2
2
  export const focusedInvisibleMixin = "focus:bg-opacity-70 focus:bg-slate-100 focus:dark:bg-gray-800 focus:dark:bg-opacity-60";
3
3
  export const focusedClasses = "z-30 outline-none ring-2 ring-primary ring-opacity-75 ring-offset-2 ring-offset-transparent ";
4
- export const fieldBackgroundMixin = "bg-opacity-50 bg-slate-200 dark:bg-gray-700 dark:bg-opacity-40 transition duration-150 ease-in-out";
5
- export const fieldBackgroundInvisibleMixin = "bg-opacity-0 bg-slate-100 dark:bg-gray-800 dark:bg-opacity-0 transition duration-150 ease-in-out";
4
+ export const fieldBackgroundMixin = "bg-opacity-50 bg-slate-200 dark:bg-gray-700 dark:bg-opacity-40 transition duration-100 ease-in-out";
5
+ export const fieldBackgroundInvisibleMixin = "bg-opacity-0 bg-slate-100 dark:bg-gray-800 dark:bg-opacity-0 transition duration-100 ease-in-out";
6
6
  export const fieldBackgroundDisabledMixin = "dark:bg-gray-800 bg-opacity-80 dark:bg-opacity-90";
7
7
  export const fieldBackgroundHoverMixin = "hover:bg-opacity-70 dark:hover:bg-opacity-60";
8
8
  export const defaultBorderMixin = "border-gray-100 dark:border-gray-800 dark:border-opacity-80";
9
9
  export const paperMixin = "bg-white rounded-md dark:bg-gray-950 border dark:border-gray-800 dark:border-opacity-80 border-gray-100";
10
- export const cardMixin = "bg-white border border-gray-100 dark:border-transparent rounded-md dark:bg-gray-950 dark:border-gray-800 dark:border-opacity-50 transition duration-200 ease-in-out m-1 -p-1";
10
+ export const cardMixin = "bg-white border border-gray-100 dark:border-transparent rounded-md dark:bg-gray-950 dark:border-gray-800 dark:border-opacity-50 transition duration-100 ease-in-out m-1 -p-1";
11
11
  export const cardClickableMixin = "hover:bg-primary-bg dark:hover:bg-primary-bg hover:bg-opacity-20 dark:hover:bg-opacity-20 hover:ring-2 hover:ring-primary cursor-pointer";
12
12
  export const cardSelectedMixin = "bg-primary-bg dark:bg-primary-bg bg-opacity-30 dark:bg-opacity-10 ring-1 ring-primary ring-opacity-75";
package/src/util/index.ts CHANGED
@@ -2,5 +2,3 @@ export * from "./cn";
2
2
  export * from "./debounce";
3
3
  export * from "./chip_colors";
4
4
  export * from "./key_to_icon_component";
5
- export * from "./useInjectStyles";
6
- export * from "./useOutsideAlerter";
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes