@shmidko61/lc-ui-kit 0.0.4 → 0.1.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.
Files changed (53) hide show
  1. package/dist/accordion.cjs +1 -1
  2. package/dist/accordion.js +1 -1
  3. package/dist/box/box.d.ts +1 -1
  4. package/dist/box/box.types.d.ts +1 -1
  5. package/dist/button/button.helpers.d.ts +1 -1
  6. package/dist/flex/flex.d.ts +6 -2
  7. package/dist/flex/flex.types.d.ts +2 -2
  8. package/dist/grid/grid.d.ts +5 -1
  9. package/dist/grid/grid.types.d.ts +1 -1
  10. package/dist/icons/icons.d.ts +31 -30
  11. package/dist/icons.cjs +1 -1
  12. package/dist/icons.js +32 -36
  13. package/dist/index.cjs +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.js +84 -90
  16. package/dist/input.cjs +1 -1
  17. package/dist/input.js +19 -19
  18. package/dist/media-card.cjs +1 -1
  19. package/dist/media-card.js +41 -42
  20. package/dist/media-gallery.cjs +1 -1
  21. package/dist/media-gallery.js +12 -12
  22. package/dist/modal.cjs +1 -1
  23. package/dist/modal.js +13 -13
  24. package/dist/pagination.cjs +1 -1
  25. package/dist/pagination.js +20 -20
  26. package/dist/picture/picture.d.ts +2 -2
  27. package/dist/picture/picture.helpers.d.ts +21 -3
  28. package/dist/picture/picture.types.d.ts +26 -3
  29. package/dist/picture.cjs +1 -1
  30. package/dist/picture.js +109 -35
  31. package/dist/shared/responsive-style/responsive-style.types.d.ts +1 -1
  32. package/dist/styles.css +1 -1
  33. package/dist/types/typography.types.d.ts +22 -1
  34. package/dist/typography/typography.d.ts +4 -1
  35. package/dist/typography/typography.helpers.d.ts +4 -4
  36. package/dist/typography.cjs +1 -1
  37. package/dist/typography.js +288 -235
  38. package/dist/ui-kit-provider/ui-kit-provider.d.ts +4 -1
  39. package/package.json +3 -2
  40. package/dist/arrow-CS6d64Y4.cjs +0 -1
  41. package/dist/arrow-DBc2opRL.js +0 -5
  42. package/dist/drop-down-CdIuWbLC.cjs +0 -1
  43. package/dist/drop-down-DH2_3qXq.js +0 -5
  44. package/dist/eye-open-5zYaeyLp.cjs +0 -1
  45. package/dist/eye-open-CoTSj5cT.js +0 -5
  46. package/dist/media-picture-BN4saEVT.js +0 -6
  47. package/dist/media-picture-BmERSmsd.cjs +0 -1
  48. package/dist/telephone-DVftjRG9.cjs +0 -1
  49. package/dist/telephone-DvXakgBQ.js +0 -26
  50. package/dist/time-clock-DOwPzcx7.cjs +0 -1
  51. package/dist/time-clock-DjqcZ8tI.js +0 -5
  52. package/dist/x-mark-DId-ylR6.cjs +0 -1
  53. package/dist/x-mark-WU1eT82T.js +0 -5
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),g=require("./arrow-CS6d64Y4.cjs"),u=require("./responsive-style.config-B2m9jVlX.cjs"),_=require("./typography.cjs");function k({boundaryCount:e=1,className:s,currentPage:r,disabled:i=!1,onPageChange:a,pageSize:o,showRangeLabel:h=!0,siblingCount:x=1,totalItems:p,totalPages:t,...d}){const f=Math.max(1,t),c=y(r,1,f),j=$({boundaryCount:e,currentPage:c,siblingCount:x,totalPages:f}),b=c>1&&!i,w=c<f&&!i,M=q({currentPage:c,pageSize:o,totalItems:p,totalPages:f});return n.jsxs("nav",{"aria-label":"Pagination",className:u.cn("inline-flex items-center gap-6",s),...d,children:[h?n.jsx(_.Typography,{as:"span",className:"whitespace-nowrap text-[var(--color-text-secondary)]",variant:"b3",children:M}):null,n.jsxs("div",{className:"inline-flex items-center gap-[6px]",children:[n.jsx(v,{"aria-label":"Предыдущая страница",disabled:!b,onClick:()=>a?.(c-1),children:n.jsx(g.SvgArrow,{className:"h-[9px] w-3"})}),j.map((l,N)=>l==="ellipsis"?n.jsx("span",{"aria-hidden":"true",className:"inline-flex min-h-6 min-w-6 items-center justify-center text-[13px] leading-[18px] text-[var(--color-text-secondary)]",children:"..."},`ellipsis-${N}`):n.jsx(v,{"aria-current":l===c?"page":void 0,"aria-label":`Страница ${l}`,isActive:l===c,disabled:i,onClick:()=>a?.(l),children:l},l)),n.jsx(v,{"aria-label":"Следующая страница",disabled:!w,onClick:()=>a?.(c+1),children:n.jsx(g.SvgArrow,{className:"h-[9px] w-3 rotate-180"})})]})]})}function v({children:e,className:s,disabled:r,isActive:i=!1,...a}){return n.jsx("button",{className:u.cn("inline-flex min-h-6 min-w-6 items-center justify-center rounded-[6px] bg-[var(--color-background-subtle)] px-1 text-[13px] font-normal leading-[18px] text-[var(--color-text-primary)] transition-colors [font-family:var(--font-family)] hover:bg-[color-mix(in_srgb,var(--color-background-subtle)_90%,#000)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color-mix(in_srgb,var(--color-primary-accent)_35%,transparent)] disabled:pointer-events-none disabled:opacity-50 [&_svg]:shrink-0",i&&"bg-[var(--color-primary-accent)] text-[var(--color-background-default)] hover:bg-[color-mix(in_srgb,var(--color-primary-accent)_80%,#fff)]",s),disabled:r,type:"button",...a,children:e})}function $({boundaryCount:e,currentPage:s,siblingCount:r,totalPages:i}){const a=e*2+r*2+3;if(i<=a)return m(1,i);const o=m(1,e),h=m(i-e+1,i),x=Math.max(Math.min(s-r,i-e-r*2-1),e+2),p=Math.min(Math.max(s+r,e+r*2+2),i-e-1),t=[...o];return x>e+2?t.push("ellipsis"):e+1<i-e&&t.push(e+1),t.push(...m(x,p)),p<i-e-1?t.push("ellipsis"):i-e>e&&t.push(i-e),t.push(...h),t}function m(e,s){if(s<e)return[];const r=[];for(let i=e;i<=s;i+=1)r.push(i);return r}function y(e,s,r){return Math.min(Math.max(e,s),r)}function q({currentPage:e,pageSize:s,totalItems:r,totalPages:i}){if(!s||!r)return`${e} из ${i}`;const a=(e-1)*s+1,o=Math.min(e*s,r);return`${a}-${o} из ${r}`}exports.Pagination=k;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),g=require("./icons.cjs"),u=require("./responsive-style.config-B2m9jVlX.cjs"),_=require("./typography.cjs");function k({boundaryCount:e=1,className:n,currentPage:s,disabled:i=!1,onPageChange:a,pageSize:o,showRangeLabel:h=!0,siblingCount:x=1,totalItems:p,totalPages:c,...d}){const f=Math.max(1,c),t=y(s,1,f),j=$({boundaryCount:e,currentPage:t,siblingCount:x,totalPages:f}),b=t>1&&!i,M=t<f&&!i,w=q({currentPage:t,pageSize:o,totalItems:p,totalPages:f});return r.jsxs("nav",{"aria-label":"Pagination",className:u.cn("inline-flex items-center gap-6",n),...d,children:[h?r.jsx(_.Typography,{as:"span",className:"whitespace-nowrap text-[var(--color-text-secondary)]",variant:"b3",children:w}):null,r.jsxs("div",{className:"inline-flex items-center gap-[6px]",children:[r.jsx(v,{"aria-label":"Предыдущая страница",disabled:!b,onClick:()=>a?.(t-1),children:r.jsx(g.ArrowIcon,{className:"h-[9px] w-3"})}),j.map((l,N)=>l==="ellipsis"?r.jsx("span",{"aria-hidden":"true",className:"inline-flex min-h-6 min-w-6 items-center justify-center text-[13px] leading-[18px] text-[var(--color-text-secondary)]",children:"..."},`ellipsis-${N}`):r.jsx(v,{"aria-current":l===t?"page":void 0,"aria-label":`Страница ${l}`,isActive:l===t,disabled:i,onClick:()=>a?.(l),children:l},l)),r.jsx(v,{"aria-label":"Следующая страница",disabled:!M,onClick:()=>a?.(t+1),children:r.jsx(g.ArrowIcon,{className:"h-[9px] w-3 rotate-180"})})]})]})}function v({children:e,className:n,disabled:s,isActive:i=!1,...a}){return r.jsx("button",{className:u.cn("inline-flex min-h-6 min-w-6 items-center justify-center rounded-[6px] bg-[var(--color-background-subtle)] px-1 text-[13px] font-normal leading-[18px] text-[var(--color-text-primary)] transition-colors [font-family:var(--font-family)] hover:bg-[color-mix(in_srgb,var(--color-background-subtle)_90%,#000)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color-mix(in_srgb,var(--color-primary-accent)_35%,transparent)] disabled:pointer-events-none disabled:opacity-50 [&_svg]:shrink-0",i&&"bg-[var(--color-primary-accent)] text-[var(--color-background-default)] hover:bg-[color-mix(in_srgb,var(--color-primary-accent)_80%,#fff)]",n),disabled:s,type:"button",...a,children:e})}function $({boundaryCount:e,currentPage:n,siblingCount:s,totalPages:i}){const a=e*2+s*2+3;if(i<=a)return m(1,i);const o=m(1,e),h=m(i-e+1,i),x=Math.max(Math.min(n-s,i-e-s*2-1),e+2),p=Math.min(Math.max(n+s,e+s*2+2),i-e-1),c=[...o];return x>e+2?c.push("ellipsis"):e+1<i-e&&c.push(e+1),c.push(...m(x,p)),p<i-e-1?c.push("ellipsis"):i-e>e&&c.push(i-e),c.push(...h),c}function m(e,n){if(n<e)return[];const s=[];for(let i=e;i<=n;i+=1)s.push(i);return s}function y(e,n,s){return Math.min(Math.max(e,n),s)}function q({currentPage:e,pageSize:n,totalItems:s,totalPages:i}){if(!n||!s)return`${e} из ${i}`;const a=(e-1)*n+1,o=Math.min(e*n,s);return`${a}-${o} из ${s}`}exports.Pagination=k;
@@ -1,5 +1,5 @@
1
- import { jsxs as g, jsx as c } from "react/jsx-runtime";
2
- import { S as d } from "./arrow-DBc2opRL.js";
1
+ import { jsxs as g, jsx as t } from "react/jsx-runtime";
2
+ import { ArrowIcon as d } from "./icons.js";
3
3
  import { c as b } from "./responsive-style.config-DFuATrIM.js";
4
4
  import { Typography as $ } from "./typography.js";
5
5
  function P({
@@ -15,13 +15,13 @@ function P({
15
15
  totalPages: a,
16
16
  ...u
17
17
  }) {
18
- const f = Math.max(1, a), t = A(r, 1, f), M = j({
18
+ const f = Math.max(1, a), c = I(r, 1, f), M = j({
19
19
  boundaryCount: e,
20
- currentPage: t,
20
+ currentPage: c,
21
21
  siblingCount: m,
22
22
  totalPages: f
23
- }), N = t > 1 && !i, k = t < f && !i, w = G({
24
- currentPage: t,
23
+ }), N = c > 1 && !i, k = c < f && !i, w = A({
24
+ currentPage: c,
25
25
  pageSize: o,
26
26
  totalItems: p,
27
27
  totalPages: f
@@ -33,7 +33,7 @@ function P({
33
33
  className: b("inline-flex items-center gap-6", n),
34
34
  ...u,
35
35
  children: [
36
- h ? /* @__PURE__ */ c(
36
+ h ? /* @__PURE__ */ t(
37
37
  $,
38
38
  {
39
39
  as: "span",
@@ -43,17 +43,17 @@ function P({
43
43
  }
44
44
  ) : null,
45
45
  /* @__PURE__ */ g("div", { className: "inline-flex items-center gap-[6px]", children: [
46
- /* @__PURE__ */ c(
46
+ /* @__PURE__ */ t(
47
47
  v,
48
48
  {
49
49
  "aria-label": "Предыдущая страница",
50
50
  disabled: !N,
51
- onClick: () => s?.(t - 1),
52
- children: /* @__PURE__ */ c(d, { className: "h-[9px] w-3" })
51
+ onClick: () => s?.(c - 1),
52
+ children: /* @__PURE__ */ t(d, { className: "h-[9px] w-3" })
53
53
  }
54
54
  ),
55
55
  M.map(
56
- (l, _) => l === "ellipsis" ? /* @__PURE__ */ c(
56
+ (l, _) => l === "ellipsis" ? /* @__PURE__ */ t(
57
57
  "span",
58
58
  {
59
59
  "aria-hidden": "true",
@@ -61,12 +61,12 @@ function P({
61
61
  children: "..."
62
62
  },
63
63
  `ellipsis-${_}`
64
- ) : /* @__PURE__ */ c(
64
+ ) : /* @__PURE__ */ t(
65
65
  v,
66
66
  {
67
- "aria-current": l === t ? "page" : void 0,
67
+ "aria-current": l === c ? "page" : void 0,
68
68
  "aria-label": `Страница ${l}`,
69
- isActive: l === t,
69
+ isActive: l === c,
70
70
  disabled: i,
71
71
  onClick: () => s?.(l),
72
72
  children: l
@@ -74,13 +74,13 @@ function P({
74
74
  l
75
75
  )
76
76
  ),
77
- /* @__PURE__ */ c(
77
+ /* @__PURE__ */ t(
78
78
  v,
79
79
  {
80
80
  "aria-label": "Следующая страница",
81
81
  disabled: !k,
82
- onClick: () => s?.(t + 1),
83
- children: /* @__PURE__ */ c(d, { className: "h-[9px] w-3 rotate-180" })
82
+ onClick: () => s?.(c + 1),
83
+ children: /* @__PURE__ */ t(d, { className: "h-[9px] w-3 rotate-180" })
84
84
  }
85
85
  )
86
86
  ] })
@@ -95,7 +95,7 @@ function v({
95
95
  isActive: i = !1,
96
96
  ...s
97
97
  }) {
98
- return /* @__PURE__ */ c(
98
+ return /* @__PURE__ */ t(
99
99
  "button",
100
100
  {
101
101
  className: b(
@@ -136,10 +136,10 @@ function x(e, n) {
136
136
  r.push(i);
137
137
  return r;
138
138
  }
139
- function A(e, n, r) {
139
+ function I(e, n, r) {
140
140
  return Math.min(Math.max(e, n), r);
141
141
  }
142
- function G({
142
+ function A({
143
143
  currentPage: e,
144
144
  pageSize: n,
145
145
  totalItems: r,
@@ -8,5 +8,5 @@ import { PictureProps } from './picture.types';
8
8
  * внутреннего `img`, а остальные значения преобразуются в `source` с
9
9
  * min-width из общего responsive-конфига ui-kit.
10
10
  */
11
- export declare function Picture({ display, image, sources, ...props }: PictureProps): ReactNode;
12
- export type { PictureBreakpoint, PictureBreakpointSource, PictureBreakpointSources, PictureProps, } from './picture.types';
11
+ export declare function Picture({ display, fill, image, objectFit, objectPosition, sources, md, lg, xl, ...props }: PictureProps): ReactNode;
12
+ export type { PictureBreakpoint, PictureBreakpointProps, PictureBreakpointSource, PictureBreakpointSources, PictureImageLayoutProps, PictureObjectFit, PictureObjectPosition, PictureProps, } from './picture.types';
@@ -1,9 +1,27 @@
1
- import { SourceHTMLAttributes } from 'react';
2
- import { PictureBreakpoint, PictureBreakpointSource, PictureBreakpointSources } from './picture.types';
1
+ import { CSSProperties, SourceHTMLAttributes } from 'react';
2
+ import { BoxBreakpointProps } from '../box/box.types';
3
+ import { ResponsiveStyleBreakpoint } from '../shared/responsive-style/responsive-style.types';
4
+ import { PictureBreakpoint, PictureBreakpointProps, PictureBreakpointSource, PictureBreakpointSources, PictureImageLayoutProps } from './picture.types';
5
+ /** Результат преобразования image-layout props в responsive Tailwind-классы. */
6
+ export type PictureImageTailwindClassNamePlan = {
7
+ /** Классы, применяемые к внутреннему `img`. */
8
+ className: string;
9
+ /** CSS-переменные со значениями для base/md/lg/xl. */
10
+ style: CSSProperties;
11
+ };
12
+ type PictureImageStyleBuildProps = PictureImageLayoutProps & Partial<Record<ResponsiveStyleBreakpoint, PictureImageLayoutProps>>;
13
+ /**
14
+ * Преобразует публичные responsive props изображения в классы и CSS-переменные.
15
+ * Базовая высота `auto` сохраняет прежнее поведение `Picture`.
16
+ */
17
+ export declare function buildPictureImageTailwindClassNamePlan(props: PictureImageStyleBuildProps): PictureImageTailwindClassNamePlan;
18
+ /** Удаляет image-layout props перед передачей breakpoint-настроек в `Box`. */
19
+ export declare function getPictureBoxBreakpointProps({ fill: _fill, objectFit: _objectFit, objectPosition: _objectPosition, ...boxProps }: PictureBreakpointProps): BoxBreakpointProps;
3
20
  export type PictureResolvedBreakpointSource = {
4
21
  breakpoint: Exclude<PictureBreakpoint, 'sm'>;
5
22
  source: PictureBreakpointSource;
6
23
  };
7
- export declare function buildBreakpointSources(sources: PictureBreakpointSources): PictureResolvedBreakpointSource[];
24
+ export declare function buildBreakpointSources(sources: PictureBreakpointSources): Array<PictureResolvedBreakpointSource>;
8
25
  export declare function getSourceSrcSet(source: PictureBreakpointSource): string;
9
26
  export declare function getSourceProps(source: PictureBreakpointSource): SourceHTMLAttributes<HTMLSourceElement>;
27
+ export {};
@@ -1,5 +1,6 @@
1
- import { ImgHTMLAttributes, SourceHTMLAttributes } from 'react';
2
- import { BoxProps } from '../box/box.types';
1
+ import { CSSProperties, ImgHTMLAttributes, SourceHTMLAttributes } from 'react';
2
+ import { BoxBreakpointProps, BoxProps } from '../box/box.types';
3
+ import { ResponsiveStyleBreakpoint } from '../shared/responsive-style/responsive-style.types';
3
4
  /**
4
5
  * Поддерживаемые проектные брейкпоинты для компонента `Picture`.
5
6
  *
@@ -31,13 +32,34 @@ export type PictureBreakpointSource = string | (Omit<SourceHTMLAttributes<HTMLSo
31
32
  export type PictureBreakpointSources = {
32
33
  sm: PictureBreakpointSource;
33
34
  } & Partial<Record<Exclude<PictureBreakpoint, 'sm'>, PictureBreakpointSource>>;
35
+ /** Допустимое CSS-значение способа масштабирования внутреннего `img`. */
36
+ export type PictureObjectFit = NonNullable<CSSProperties['objectFit']>;
37
+ /** Допустимое CSS-положение внутреннего изображения относительно его области. */
38
+ export type PictureObjectPosition = NonNullable<CSSProperties['objectPosition']>;
39
+ /**
40
+ * Настройки отображения внутреннего `img`.
41
+ *
42
+ * `fill` растягивает изображение по высоте и ширине `picture`. Для заметного
43
+ * результата у внешнего `Picture` должна быть задана высота.
44
+ */
45
+ export type PictureImageLayoutProps = {
46
+ /** Растянуть внутренний `img` на всю ширину и высоту `picture`. */
47
+ fill?: boolean;
48
+ /** Способ масштабирования изображения внутри доступной области. */
49
+ objectFit?: PictureObjectFit;
50
+ /** Положение изображения внутри доступной области. */
51
+ objectPosition?: PictureObjectPosition;
52
+ };
53
+ /** Свойства `Picture`, которые можно переопределить на одном breakpoint. */
54
+ export type PictureBreakpointProps = BoxBreakpointProps & PictureImageLayoutProps;
55
+ type PictureResponsiveProps = Partial<Record<ResponsiveStyleBreakpoint, PictureBreakpointProps>>;
34
56
  /**
35
57
  * Свойства компонента `Picture`.
36
58
  *
37
59
  * Компонент наследует свойства `Box`, кроме `as` и `children`: тег всегда
38
60
  * фиксирован как `picture`, а содержимое формируется из `sources` и `image`.
39
61
  */
40
- export type PictureProps = Omit<BoxProps<'picture'>, 'as' | 'children'> & {
62
+ export type PictureProps = Omit<BoxProps<'picture'>, 'as' | 'children' | 'md' | 'lg' | 'xl' | keyof PictureImageLayoutProps> & PictureImageLayoutProps & PictureResponsiveProps & {
41
63
  /**
42
64
  * Атрибуты для внутреннего элемента `img`.
43
65
  *
@@ -54,3 +76,4 @@ export type PictureProps = Omit<BoxProps<'picture'>, 'as' | 'children'> & {
54
76
  */
55
77
  sources: PictureBreakpointSources;
56
78
  };
79
+ export {};
package/dist/picture.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),f=require("./box.cjs"),p=require("./responsive-style.config-B2m9jVlX.cjs");function S(e){return[...p.responsiveBreakpoints].reverse().flatMap(t=>{const i=e[t];return i?[{breakpoint:t,source:i}]:[]})}function o(e){return typeof e=="string"?e:e.srcSet}function y(e){if(typeof e!="string")return e;const t=e.split("?")[0].split("#")[0].split(".").pop()?.toLowerCase(),i={avif:"image/avif",jpeg:"image/jpeg",jpg:"image/jpeg",png:"image/png",webp:"image/webp"};return t&&i[t]?{type:i[t]}:{}}function d({display:e="block",image:t,sources:i,...c}){const{alt:a="",style:g,...u}=t??{},l=o(i.sm),m=S(i);return n.jsxs(f.Box,{...c,as:"picture",display:e,children:[m.map(({breakpoint:r,source:s})=>n.jsx("source",{...y(s),media:`(min-width: ${p.responsiveBreakpointMinWidth[r]})`,srcSet:o(s)},r)),n.jsx("img",{alt:a,src:l,style:{display:"block",height:"auto",width:"100%",...g},...u})]})}exports.Picture=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),B=require("./box.cjs"),g=require("./responsive-style.config-B2m9jVlX.cjs");function d({fill:e,objectFit:t,objectPosition:i},o,s,{classPrefix:c,isBase:n=!1,variablePrefix:r}){const a={height:e===void 0?n?"auto":void 0:e?"100%":"auto",objectFit:t,objectPosition:i},m={height:"height",objectFit:"object-fit",objectPosition:"object-position"};for(const[f,p]of Object.entries(a)){if(p===void 0)continue;const l=m[f],u=`${r}picture-image-${l}`;s[`--${u}`]=String(p),o.push(`${c}[${l}:var(--${u})]`)}}function k(e){const t=[],i={};d(e,t,i,{classPrefix:"",isBase:!0,variablePrefix:""});for(const o of g.responsiveBreakpoints){const s=e[o];s&&d(s,t,i,{classPrefix:`${o}:`,variablePrefix:`${o}-`})}return{className:t.join(" "),style:i}}function P({fill:e,objectFit:t,objectPosition:i,...o}){return o}function N(e){return[...g.responsiveBreakpoints].reverse().flatMap(t=>{const i=e[t];return i?[{breakpoint:t,source:i}]:[]})}function S(e){return typeof e=="string"?e:e.srcSet}function $(e){if(typeof e!="string")return e;const t=e.split("?")[0].split("#")[0].split(".").pop()?.toLowerCase(),i={avif:"image/avif",jpeg:"image/jpeg",jpg:"image/jpeg",png:"image/png",webp:"image/webp"};return t&&i[t]?{type:i[t]}:{}}function w({display:e="block",fill:t,image:i,objectFit:o,objectPosition:s,sources:c,md:n,lg:r,xl:a,...m}){const{alt:f="",className:p,style:l,...u}=i??{},x=S(c.sm),h=N(c),j=k({fill:t,objectFit:o,objectPosition:s,md:n,lg:r,xl:a});return b.jsxs(B.Box,{...m,as:"picture",display:e,md:n?P(n):void 0,lg:r?P(r):void 0,xl:a?P(a):void 0,children:[h.map(({breakpoint:v,source:y})=>b.jsx("source",{...$(y),media:`(min-width: ${g.responsiveBreakpointMinWidth[v]})`,srcSet:S(y)},v)),b.jsx("img",{alt:f,className:g.cn(j.className,p),src:x,style:{display:"block",width:"100%",...j.style,...l},...u})]})}exports.Picture=w;
package/dist/picture.js CHANGED
@@ -1,16 +1,60 @@
1
- import { jsxs as f, jsx as o } from "react/jsx-runtime";
2
- import { Box as u } from "./box.js";
3
- import { a as S, r as y } from "./responsive-style.config-DFuATrIM.js";
4
- function d(e) {
5
- return [...S].reverse().flatMap((t) => {
1
+ import { jsxs as B, jsx as v } from "react/jsx-runtime";
2
+ import { Box as N } from "./box.js";
3
+ import { a as h, r as k, c as $ } from "./responsive-style.config-DFuATrIM.js";
4
+ function y({ fill: e, objectFit: t, objectPosition: i }, o, s, { classPrefix: c, isBase: n = !1, variablePrefix: a }) {
5
+ const r = {
6
+ height: e === void 0 ? n ? "auto" : void 0 : e ? "100%" : "auto",
7
+ objectFit: t,
8
+ objectPosition: i
9
+ }, f = {
10
+ height: "height",
11
+ objectFit: "object-fit",
12
+ objectPosition: "object-position"
13
+ };
14
+ for (const [u, p] of Object.entries(r)) {
15
+ if (p === void 0)
16
+ continue;
17
+ const l = f[u], m = `${a}picture-image-${l}`;
18
+ s[`--${m}`] = String(p), o.push(`${c}[${l}:var(--${m})]`);
19
+ }
20
+ }
21
+ function w(e) {
22
+ const t = [], i = {};
23
+ y(e, t, i, {
24
+ classPrefix: "",
25
+ isBase: !0,
26
+ variablePrefix: ""
27
+ });
28
+ for (const o of h) {
29
+ const s = e[o];
30
+ s && y(s, t, i, {
31
+ classPrefix: `${o}:`,
32
+ variablePrefix: `${o}-`
33
+ });
34
+ }
35
+ return {
36
+ className: t.join(" "),
37
+ style: i
38
+ };
39
+ }
40
+ function g({
41
+ fill: e,
42
+ objectFit: t,
43
+ objectPosition: i,
44
+ ...o
45
+ }) {
46
+ return o;
47
+ }
48
+ function C(e) {
49
+ return [...h].reverse().flatMap((t) => {
6
50
  const i = e[t];
7
51
  return i ? [{ breakpoint: t, source: i }] : [];
8
52
  });
9
53
  }
10
- function s(e) {
54
+ function d(e) {
11
55
  return typeof e == "string" ? e : e.srcSet;
12
56
  }
13
- function h(e) {
57
+ function F(e) {
14
58
  if (typeof e != "string")
15
59
  return e;
16
60
  const t = e.split("?")[0].split("#")[0].split(".").pop()?.toLowerCase(), i = {
@@ -22,34 +66,64 @@ function h(e) {
22
66
  };
23
67
  return t && i[t] ? { type: i[t] } : {};
24
68
  }
25
- function k({ display: e = "block", image: t, sources: i, ...p }) {
26
- const { alt: a = "", style: c, ...m } = t ?? {}, g = s(i.sm), l = d(i);
27
- return /* @__PURE__ */ f(u, { ...p, as: "picture", display: e, children: [
28
- l.map(({ breakpoint: r, source: n }) => /* @__PURE__ */ o(
29
- "source",
30
- {
31
- ...h(n),
32
- media: `(min-width: ${y[r]})`,
33
- srcSet: s(n)
34
- },
35
- r
36
- )),
37
- /* @__PURE__ */ o(
38
- "img",
39
- {
40
- alt: a,
41
- src: g,
42
- style: {
43
- display: "block",
44
- height: "auto",
45
- width: "100%",
46
- ...c
47
- },
48
- ...m
49
- }
50
- )
51
- ] });
69
+ function T({
70
+ display: e = "block",
71
+ fill: t,
72
+ image: i,
73
+ objectFit: o,
74
+ objectPosition: s,
75
+ sources: c,
76
+ md: n,
77
+ lg: a,
78
+ xl: r,
79
+ ...f
80
+ }) {
81
+ const { alt: u = "", className: p, style: l, ...m } = i ?? {}, S = d(c.sm), x = C(c), b = w({
82
+ fill: t,
83
+ objectFit: o,
84
+ objectPosition: s,
85
+ md: n,
86
+ lg: a,
87
+ xl: r
88
+ });
89
+ return /* @__PURE__ */ B(
90
+ N,
91
+ {
92
+ ...f,
93
+ as: "picture",
94
+ display: e,
95
+ md: n ? g(n) : void 0,
96
+ lg: a ? g(a) : void 0,
97
+ xl: r ? g(r) : void 0,
98
+ children: [
99
+ x.map(({ breakpoint: P, source: j }) => /* @__PURE__ */ v(
100
+ "source",
101
+ {
102
+ ...F(j),
103
+ media: `(min-width: ${k[P]})`,
104
+ srcSet: d(j)
105
+ },
106
+ P
107
+ )),
108
+ /* @__PURE__ */ v(
109
+ "img",
110
+ {
111
+ alt: u,
112
+ className: $(b.className, p),
113
+ src: S,
114
+ style: {
115
+ display: "block",
116
+ width: "100%",
117
+ ...b.style,
118
+ ...l
119
+ },
120
+ ...m
121
+ }
122
+ )
123
+ ]
124
+ }
125
+ );
52
126
  }
53
127
  export {
54
- k as Picture
128
+ T as Picture
55
129
  };
@@ -1,6 +1,6 @@
1
1
  import { CSSProperties } from 'react';
2
2
  import { UiKitTypography } from '../../design-tokens/typography.tokens';
3
- import { UiKitColors } from '../../types';
3
+ import { UiKitColors } from '../../types/index';
4
4
  /**
5
5
  * Поддерживаемые responsive breakpoints.
6
6
  *