@uxf/ui 1.0.0-beta.87 → 1.0.0-beta.88

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 (37) hide show
  1. package/_private-utils/get-provider-config.js +4 -0
  2. package/config/icons-config.d.ts +1 -1
  3. package/config/icons-config.js +1 -1
  4. package/config/icons.d.ts +14 -14
  5. package/config/icons.js +14 -14
  6. package/context/context.d.ts +3 -0
  7. package/context/use-component-context.d.ts +1 -1
  8. package/css/raster-image.css +5 -0
  9. package/image-gallery/components/gallery.js +2 -1
  10. package/image-gallery/image-gallery.stories.js +3 -2
  11. package/image-gallery/types.d.ts +2 -2
  12. package/package.json +8 -7
  13. package/raster-image/raster-image.d.ts +18 -7
  14. package/raster-image/raster-image.js +21 -8
  15. package/raster-image/raster-image.stories.d.ts +22 -1
  16. package/raster-image/raster-image.stories.js +2 -2
  17. package/scripts/generate-tw-tokens.js +94 -0
  18. package/tw-tokens/tw-box-shadow.d.ts +11 -0
  19. package/tw-tokens/tw-box-shadow.js +14 -0
  20. package/tw-tokens/tw-colors.d.ts +328 -0
  21. package/tw-tokens/tw-colors.js +331 -0
  22. package/tw-tokens/tw-containers.d.ts +8 -0
  23. package/tw-tokens/tw-containers.js +11 -0
  24. package/tw-tokens/tw-font-size.d.ts +42 -0
  25. package/tw-tokens/tw-font-size.js +19 -0
  26. package/tw-tokens/tw-font-weight.d.ts +12 -0
  27. package/tw-tokens/tw-font-weight.js +15 -0
  28. package/tw-tokens/tw-line-height.d.ts +17 -0
  29. package/tw-tokens/tw-line-height.js +20 -0
  30. package/tw-tokens/tw-screens.d.ts +8 -0
  31. package/tw-tokens/tw-screens.js +11 -0
  32. package/tw-tokens/tw-spacing.d.ts +39 -0
  33. package/tw-tokens/tw-spacing.js +42 -0
  34. package/tw-tokens/tw-z-index.d.ts +19 -0
  35. package/tw-tokens/tw-z-index.js +22 -0
  36. package/utils/image.d.ts +13 -8
  37. package/utils/image.js +77 -18
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ // this file is generated automatically, do not change anything manually in the contents of this file
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.twFontSize = void 0;
5
+ exports.twFontSize = {
6
+ xs: ["0.75rem", { lineHeight: "1rem" }],
7
+ sm: ["0.875rem", { lineHeight: "1.25rem" }],
8
+ base: ["1rem", { lineHeight: "1.5rem" }],
9
+ lg: ["1.125rem", { lineHeight: "1.75rem" }],
10
+ xl: ["1.25rem", { lineHeight: "1.75rem" }],
11
+ "2xl": ["1.5rem", { lineHeight: "2rem" }],
12
+ "3xl": ["1.875rem", { lineHeight: "2.25rem" }],
13
+ "4xl": ["2.25rem", { lineHeight: "2.5rem" }],
14
+ "5xl": ["3rem", { lineHeight: "1" }],
15
+ "6xl": ["3.75rem", { lineHeight: "1" }],
16
+ "7xl": ["4.5rem", { lineHeight: "1" }],
17
+ "8xl": ["6rem", { lineHeight: "1" }],
18
+ "9xl": ["8rem", { lineHeight: "1" }],
19
+ };
@@ -0,0 +1,12 @@
1
+ export declare const twFontWeight: {
2
+ thin: string;
3
+ extralight: string;
4
+ light: string;
5
+ normal: string;
6
+ medium: string;
7
+ semibold: string;
8
+ bold: string;
9
+ extrabold: string;
10
+ black: string;
11
+ };
12
+ export declare type TwFontWeight = typeof twFontWeight;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ // this file is generated automatically, do not change anything manually in the contents of this file
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.twFontWeight = void 0;
5
+ exports.twFontWeight = {
6
+ thin: "100",
7
+ extralight: "200",
8
+ light: "300",
9
+ normal: "400",
10
+ medium: "500",
11
+ semibold: "600",
12
+ bold: "700",
13
+ extrabold: "800",
14
+ black: "900",
15
+ };
@@ -0,0 +1,17 @@
1
+ export declare const twLineHeight: {
2
+ 3: string;
3
+ 4: string;
4
+ 5: string;
5
+ 6: string;
6
+ 7: string;
7
+ 8: string;
8
+ 9: string;
9
+ 10: string;
10
+ none: string;
11
+ tight: string;
12
+ snug: string;
13
+ normal: string;
14
+ relaxed: string;
15
+ loose: string;
16
+ };
17
+ export declare type TwLineHeight = typeof twLineHeight;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ // this file is generated automatically, do not change anything manually in the contents of this file
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.twLineHeight = void 0;
5
+ exports.twLineHeight = {
6
+ 3: ".75rem",
7
+ 4: "1rem",
8
+ 5: "1.25rem",
9
+ 6: "1.5rem",
10
+ 7: "1.75rem",
11
+ 8: "2rem",
12
+ 9: "2.25rem",
13
+ 10: "2.5rem",
14
+ none: "1",
15
+ tight: "1.25",
16
+ snug: "1.375",
17
+ normal: "1.5",
18
+ relaxed: "1.625",
19
+ loose: "2",
20
+ };
@@ -0,0 +1,8 @@
1
+ export declare const twScreens: {
2
+ xs: string;
3
+ sm: string;
4
+ md: string;
5
+ lg: string;
6
+ xl: string;
7
+ };
8
+ export declare type TwScreens = typeof twScreens;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ // this file is generated automatically, do not change anything manually in the contents of this file
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.twScreens = void 0;
5
+ exports.twScreens = {
6
+ xs: "36em",
7
+ sm: "48em",
8
+ md: "62em",
9
+ lg: "75em",
10
+ xl: "90em",
11
+ };
@@ -0,0 +1,39 @@
1
+ export declare const twSpacing: {
2
+ 0: string;
3
+ 1: string;
4
+ 2: string;
5
+ 3: string;
6
+ 4: string;
7
+ 5: string;
8
+ 6: string;
9
+ 7: string;
10
+ 8: string;
11
+ 9: string;
12
+ 10: string;
13
+ 11: string;
14
+ 12: string;
15
+ 14: string;
16
+ 16: string;
17
+ 20: string;
18
+ 24: string;
19
+ 28: string;
20
+ 32: string;
21
+ 36: string;
22
+ 40: string;
23
+ 44: string;
24
+ 48: string;
25
+ 52: string;
26
+ 56: string;
27
+ 60: string;
28
+ 64: string;
29
+ 72: string;
30
+ 80: string;
31
+ 96: string;
32
+ px: string;
33
+ 0.5: string;
34
+ 1.5: string;
35
+ 2.5: string;
36
+ 3.5: string;
37
+ inherit: string;
38
+ };
39
+ export declare type TwSpacing = typeof twSpacing;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ // this file is generated automatically, do not change anything manually in the contents of this file
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.twSpacing = void 0;
5
+ exports.twSpacing = {
6
+ 0: "0px",
7
+ 1: "0.25rem",
8
+ 2: "0.5rem",
9
+ 3: "0.75rem",
10
+ 4: "1rem",
11
+ 5: "1.25rem",
12
+ 6: "1.5rem",
13
+ 7: "1.75rem",
14
+ 8: "2rem",
15
+ 9: "2.25rem",
16
+ 10: "2.5rem",
17
+ 11: "2.75rem",
18
+ 12: "3rem",
19
+ 14: "3.5rem",
20
+ 16: "4rem",
21
+ 20: "5rem",
22
+ 24: "6rem",
23
+ 28: "7rem",
24
+ 32: "8rem",
25
+ 36: "9rem",
26
+ 40: "10rem",
27
+ 44: "11rem",
28
+ 48: "12rem",
29
+ 52: "13rem",
30
+ 56: "14rem",
31
+ 60: "15rem",
32
+ 64: "16rem",
33
+ 72: "18rem",
34
+ 80: "20rem",
35
+ 96: "24rem",
36
+ px: "1px",
37
+ 0.5: "0.125rem",
38
+ 1.5: "0.375rem",
39
+ 2.5: "0.625rem",
40
+ 3.5: "0.875rem",
41
+ inherit: "inherit",
42
+ };
@@ -0,0 +1,19 @@
1
+ export declare const twZIndex: {
2
+ 0: string;
3
+ 1: string;
4
+ 10: string;
5
+ 20: string;
6
+ 30: string;
7
+ 40: string;
8
+ 50: string;
9
+ auto: string;
10
+ focus: string;
11
+ fixed: string;
12
+ menu: string;
13
+ header: string;
14
+ modal: string;
15
+ dropdown: string;
16
+ flashMessage: string;
17
+ tooltip: string;
18
+ };
19
+ export declare type TwZIndex = typeof twZIndex;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ // this file is generated automatically, do not change anything manually in the contents of this file
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.twZIndex = void 0;
5
+ exports.twZIndex = {
6
+ 0: "0",
7
+ 1: "1",
8
+ 10: "10",
9
+ 20: "20",
10
+ 30: "30",
11
+ 40: "40",
12
+ 50: "50",
13
+ auto: "auto",
14
+ focus: "5",
15
+ fixed: "10",
16
+ menu: "25",
17
+ header: "50",
18
+ modal: "100",
19
+ dropdown: "200",
20
+ flashMessage: "250",
21
+ tooltip: "300",
22
+ };
package/utils/image.d.ts CHANGED
@@ -1,9 +1,14 @@
1
- import { ResizerImageProps } from "@uxf/core/utils/resizer";
2
- import { ReactElement } from "react";
3
- export interface FileResponse {
4
- extension: string;
5
- namespace?: string | null;
6
- uuid: string;
1
+ import { ImageSource, ResizerImageProps } from "@uxf/core/utils/resizer";
2
+ import { FC } from "react";
3
+ export declare type Dimension = number | "auto";
4
+ export declare function getImgUniqueIdentifier(src: ImageSource): string | undefined;
5
+ export declare function getImgSrcSet(src?: ImageSource, width?: Dimension, height?: Dimension, options?: ResizerImageProps): string | undefined;
6
+ interface ImageSourcesProps {
7
+ breakpointIndex?: number;
8
+ breakpoints?: string[];
9
+ height: Dimension;
10
+ src: ImageSource;
11
+ width: Dimension;
7
12
  }
8
- export declare function getImgSrcSet(file?: FileResponse, width?: number, height?: number, options?: ResizerImageProps): string | null;
9
- export declare function getImgSources(file?: FileResponse, width?: number, height?: number): ReactElement | null;
13
+ export declare const ImgSources: FC<ImageSourcesProps>;
14
+ export {};
package/utils/image.js CHANGED
@@ -3,28 +3,87 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getImgSources = exports.getImgSrcSet = void 0;
6
+ exports.ImgSources = exports.getImgSrcSet = exports.getImgUniqueIdentifier = void 0;
7
7
  const resizer_1 = require("@uxf/core/utils/resizer");
8
8
  const react_1 = __importDefault(require("react"));
9
- const TYPES = ["avif", "webp"];
10
- function getImgSrcSet(file, width = 200, height = 300, options = {}) {
11
- if (!file || !file.uuid || !file.extension || file.extension === "svg") {
12
- return null;
9
+ function toFileResponse(src) {
10
+ return typeof src !== "string" && "uuid" in src ? src : undefined;
11
+ }
12
+ function toStaticImageData(src) {
13
+ return typeof src !== "string" && "src" in src ? src : undefined;
14
+ }
15
+ function getImgExtension(src) {
16
+ const ext = src.slice(src.lastIndexOf(".") + 1);
17
+ return ext.length > 1 ? ext : undefined;
18
+ }
19
+ function getImgUniqueIdentifier(src) {
20
+ var _a;
21
+ const fileResponse = toFileResponse(src);
22
+ const staticImageData = toStaticImageData(src);
23
+ return typeof src === "string" ? src : (_a = fileResponse === null || fileResponse === void 0 ? void 0 : fileResponse.uuid) !== null && _a !== void 0 ? _a : staticImageData === null || staticImageData === void 0 ? void 0 : staticImageData.src;
24
+ }
25
+ exports.getImgUniqueIdentifier = getImgUniqueIdentifier;
26
+ const HIDPI_SIZES = [3, 2, 1];
27
+ function getImgSrcSet(src, width, height, options = {}) {
28
+ if (!src) {
29
+ return undefined;
30
+ }
31
+ let f;
32
+ let h = height !== null && height !== void 0 ? height : "auto";
33
+ let w = width !== null && width !== void 0 ? width : "auto";
34
+ if (typeof src === "string") {
35
+ const extension = getImgExtension(src);
36
+ if (extension === "svg") {
37
+ return undefined;
38
+ }
39
+ f = extension;
40
+ }
41
+ const fileResponse = toFileResponse(src);
42
+ if (fileResponse) {
43
+ if (!fileResponse.uuid || fileResponse.extension === "svg") {
44
+ return undefined;
45
+ }
46
+ f = fileResponse.extension;
47
+ }
48
+ const staticImageData = toStaticImageData(src);
49
+ if (staticImageData) {
50
+ const extension = getImgExtension(staticImageData.src);
51
+ if (!staticImageData.src || extension === "svg") {
52
+ return undefined;
53
+ }
54
+ f = extension;
55
+ h = h || staticImageData.height;
56
+ w = w || staticImageData.width;
13
57
  }
14
- const toFormat = TYPES.includes(file.extension) ? "png" : file.extension;
15
- return [3, 2, 1]
16
- .map((size) => (0, resizer_1.resizerImageUrl)(file, width * size, height * size, { toFormat, ...options }) +
17
- (size > 1 ? ` ${size}x` : ""))
18
- .join(", ");
58
+ const toFormat = f !== null && f !== void 0 ? f : "png";
59
+ if (typeof h === "number" || typeof w === "number") {
60
+ return HIDPI_SIZES.map((size) => (0, resizer_1.resizerImageUrl)(src, w * size, h * size, {
61
+ toFormat,
62
+ ...options,
63
+ }) + (size > 1 ? ` ${size}x` : "")).join(", ");
64
+ }
65
+ return (0, resizer_1.resizerImageUrl)(src, w, h, { toFormat, ...options });
19
66
  }
20
67
  exports.getImgSrcSet = getImgSrcSet;
21
- function getImgSources(file, width = 200, height = 300) {
22
- if (!file || !file.uuid || !file.extension || file.extension === "svg") {
68
+ const EXTENSIONS = ["avif", "webp", undefined];
69
+ const ImgSources = (props) => {
70
+ if (!props.src || (typeof props.src === "string" && getImgExtension(props.src) === "svg")) {
23
71
  return null;
24
72
  }
25
- return (react_1.default.createElement(react_1.default.Fragment, null, TYPES.map((type) => {
26
- var _a;
27
- return (react_1.default.createElement("source", { key: type, srcSet: (_a = getImgSrcSet(file, width, height, { toFormat: type })) !== null && _a !== void 0 ? _a : undefined, type: `image/${type}` }));
28
- })));
29
- }
30
- exports.getImgSources = getImgSources;
73
+ const fileResponse = toFileResponse(props.src);
74
+ if (fileResponse && (!fileResponse.uuid || fileResponse.extension === "svg")) {
75
+ return null;
76
+ }
77
+ const staticImageData = toStaticImageData(props.src);
78
+ if (staticImageData && (!staticImageData.src || getImgExtension(staticImageData.src))) {
79
+ return null;
80
+ }
81
+ let media;
82
+ if (props.breakpoints && props.breakpointIndex) {
83
+ media = `(min-width: ${props.breakpoints[props.breakpointIndex]})`;
84
+ }
85
+ return (react_1.default.createElement(react_1.default.Fragment, null,
86
+ EXTENSIONS.map((type) => (react_1.default.createElement("source", { key: type, media: media, srcSet: getImgSrcSet(props.src, props.width, props.height, { toFormat: type }), type: `image/${type}` }))),
87
+ react_1.default.createElement("source", { media: media, srcSet: getImgSrcSet(props.src, props.width, props.height, {}) })));
88
+ };
89
+ exports.ImgSources = ImgSources;