@companix/uikit 0.1.31 → 0.1.33

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.
@@ -1,8 +1,9 @@
1
- export interface ImageBaseProps extends React.ImgHTMLAttributes<HTMLImageElement> {
1
+ export interface ImageBaseProps extends React.HTMLAttributes<HTMLDivElement> {
2
2
  src: string;
3
3
  previewSrc?: string;
4
4
  maskWidth: number;
5
5
  maskHeight: number;
6
6
  enableAspectRatio?: boolean;
7
+ imgAttrs?: Omit<React.ImgHTMLAttributes<HTMLImageElement>, 'src' | 'className'>;
7
8
  }
8
9
  export declare const ImageBase: (props: ImageBaseProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,28 +1,30 @@
1
- import { jsxs as $, jsx as l } from "react/jsx-runtime";
2
- import b from "classnames";
3
- import { useRef as y, useMemo as F, useState as o } from "react";
4
- const L = (a) => {
1
+ import { jsxs as b, jsx as i } from "react/jsx-runtime";
2
+ import y from "classnames";
3
+ import { useRef as F, useMemo as I, useState as o } from "react";
4
+ const C = (a) => {
5
5
  const {
6
6
  previewSrc: e,
7
7
  maskHeight: s,
8
8
  maskWidth: t,
9
- className: n,
10
- src: r,
11
- children: m,
12
- enableAspectRatio: d,
13
- ...g
14
- } = a, p = y(null), f = F(() => I(t, s), [t, s]), [i, h] = o(!1), [v, u] = o(!1), [x, c] = o(!1), w = () => {
15
- v && (u(!1), c(!1));
9
+ className: m,
10
+ src: l,
11
+ children: d,
12
+ enableAspectRatio: g,
13
+ imgAttrs: p,
14
+ ...f
15
+ } = a, h = F(null), u = I(() => N(t, s), [t, s]), [r, v] = o(!1), [x, n] = o(!1), [w, c] = o(!1), $ = () => {
16
+ x && (n(!1), c(!1));
16
17
  };
17
- return /* @__PURE__ */ $(
18
+ return /* @__PURE__ */ b(
18
19
  "div",
19
20
  {
20
- className: b("image-base", { "image-base-loading": !i }, n),
21
- style: d ? { aspectRatio: t / s } : {},
22
- onClick: w,
21
+ className: y("image-base", { "image-base-loading": !r }, m),
22
+ style: g ? { aspectRatio: t / s } : {},
23
+ onClickCapture: $,
24
+ ...f,
23
25
  children: [
24
- !i && /* @__PURE__ */ l("img", { className: "image-base-placeholder", src: f, alt: "" }),
25
- e && e !== r && !i && !x && /* @__PURE__ */ l(
26
+ !r && /* @__PURE__ */ i("img", { className: "image-base-placeholder", src: u, alt: "" }),
27
+ e && e !== l && !r && !w && /* @__PURE__ */ i(
26
28
  "img",
27
29
  {
28
30
  className: "image-base-preview",
@@ -34,25 +36,26 @@ const L = (a) => {
34
36
  alt: ""
35
37
  }
36
38
  ),
37
- /* @__PURE__ */ l(
39
+ /* @__PURE__ */ i(
38
40
  "img",
39
41
  {
40
- ref: p,
42
+ ref: h,
41
43
  className: "image-base-img",
42
- src: r,
44
+ src: l,
43
45
  decoding: "async",
44
- onLoad: () => h(!0),
45
- ...g
46
+ onLoad: () => v(!0),
47
+ onError: () => n(!0),
48
+ ...p
46
49
  }
47
50
  ),
48
- m
51
+ d
49
52
  ]
50
53
  }
51
54
  );
52
- }, I = (a, e) => {
55
+ }, N = (a, e) => {
53
56
  const s = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${a} ${e}" width="${a}" height="${e}" />`;
54
57
  return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(s)}`;
55
58
  };
56
59
  export {
57
- L as ImageBase
60
+ C as ImageBase
58
61
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@companix/uikit",
3
- "version": "0.1.31",
3
+ "version": "0.1.33",
4
4
  "main": "./dist/bundle.es.js",
5
5
  "module": "./dist/bundle.es.js",
6
6
  "types": "./dist/index.d.ts",