@cloud-ru/uikit-product-info-row 0.8.24 → 0.8.25

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 (48) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/cjs/components/InfoGroup/InfoGroup.d.ts +2 -0
  3. package/dist/cjs/components/InfoGroup/InfoGroup.js +26 -0
  4. package/dist/cjs/components/InfoGroup/constants.d.ts +1 -0
  5. package/dist/cjs/components/InfoGroup/constants.js +4 -0
  6. package/dist/cjs/components/InfoGroup/index.d.ts +2 -0
  7. package/dist/cjs/components/InfoGroup/index.js +5 -0
  8. package/dist/cjs/components/InfoGroup/types.d.ts +19 -0
  9. package/dist/cjs/components/InfoGroup/types.js +2 -0
  10. package/dist/cjs/components/InfoGroup/utils/index.d.ts +1 -0
  11. package/dist/cjs/components/InfoGroup/utils/index.js +5 -0
  12. package/dist/cjs/components/InfoGroup/utils/typeGuards.d.ts +5 -0
  13. package/dist/cjs/components/InfoGroup/utils/typeGuards.js +13 -0
  14. package/dist/cjs/components/InfoGroup/utils/useGetContent.d.ts +4 -0
  15. package/dist/cjs/components/InfoGroup/utils/useGetContent.js +34 -0
  16. package/dist/cjs/components/InfoRow/InfoRow.d.ts +26 -0
  17. package/dist/cjs/components/InfoRow/InfoRow.js +39 -0
  18. package/dist/cjs/components/InfoRow/index.d.ts +1 -0
  19. package/dist/cjs/components/InfoRow/index.js +6 -0
  20. package/dist/cjs/components/InfoRow/styles.module.css +72 -0
  21. package/dist/cjs/components/index.d.ts +2 -0
  22. package/dist/cjs/components/index.js +18 -0
  23. package/dist/cjs/index.d.ts +1 -0
  24. package/dist/cjs/index.js +17 -0
  25. package/dist/esm/components/InfoGroup/InfoGroup.d.ts +2 -0
  26. package/dist/esm/components/InfoGroup/InfoGroup.js +23 -0
  27. package/dist/esm/components/InfoGroup/constants.d.ts +1 -0
  28. package/dist/esm/components/InfoGroup/constants.js +1 -0
  29. package/dist/esm/components/InfoGroup/index.d.ts +2 -0
  30. package/dist/esm/components/InfoGroup/index.js +1 -0
  31. package/dist/esm/components/InfoGroup/types.d.ts +19 -0
  32. package/dist/esm/components/InfoGroup/types.js +1 -0
  33. package/dist/esm/components/InfoGroup/utils/index.d.ts +1 -0
  34. package/dist/esm/components/InfoGroup/utils/index.js +1 -0
  35. package/dist/esm/components/InfoGroup/utils/typeGuards.d.ts +5 -0
  36. package/dist/esm/components/InfoGroup/utils/typeGuards.js +5 -0
  37. package/dist/esm/components/InfoGroup/utils/useGetContent.d.ts +4 -0
  38. package/dist/esm/components/InfoGroup/utils/useGetContent.js +31 -0
  39. package/dist/esm/components/InfoRow/InfoRow.d.ts +26 -0
  40. package/dist/esm/components/InfoRow/InfoRow.js +32 -0
  41. package/dist/esm/components/InfoRow/index.d.ts +1 -0
  42. package/dist/esm/components/InfoRow/index.js +1 -0
  43. package/dist/esm/components/InfoRow/styles.module.css +72 -0
  44. package/dist/esm/components/index.d.ts +2 -0
  45. package/dist/esm/components/index.js +2 -0
  46. package/dist/esm/index.d.ts +1 -0
  47. package/dist/esm/index.js +1 -0
  48. package/package.json +4 -3
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 0.8.25 (2025-11-12)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **PD-3377:** contributors update to publish all packages ([719fd3e](https://gitverse.ru/cloud-ru-tech/uikit-product/commits/719fd3e1249e247443b125c47ea408d92c8395c3))
12
+
13
+
14
+
15
+
16
+
6
17
  ## 0.8.24 (2025-11-12)
7
18
 
8
19
  ### Only dependencies have been changed
@@ -0,0 +1,2 @@
1
+ import { DataType, InfoGroupProps } from './types';
2
+ export declare function InfoGroup<T extends DataType>({ data, items, className, loading }: InfoGroupProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.InfoGroup = InfoGroup;
15
+ const jsx_runtime_1 = require("react/jsx-runtime");
16
+ const InfoRow_1 = require("../InfoRow");
17
+ const utils_1 = require("./utils");
18
+ function InfoGroup({ data, items, className, loading }) {
19
+ const getContent = (0, utils_1.useGetContent)();
20
+ return ((0, jsx_runtime_1.jsx)("div", { className: className, children: items.map((_a, index) => {
21
+ var _b;
22
+ var { label, accessorKey, render } = _a, rest = __rest(_a, ["label", "accessorKey", "render"]);
23
+ const content = getContent({ data, render, accessorKey });
24
+ return ((0, jsx_runtime_1.jsx)(InfoRow_1.InfoRow, Object.assign({ label: label, content: content, topDivider: index === 0, bottomDivider: true, loading: loading }, rest), (_b = accessorKey) !== null && _b !== void 0 ? _b : label));
25
+ }) }));
26
+ }
@@ -0,0 +1 @@
1
+ export declare const NO_DATA_PLACEHOLDER = "\u2014";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NO_DATA_PLACEHOLDER = void 0;
4
+ exports.NO_DATA_PLACEHOLDER = '—';
@@ -0,0 +1,2 @@
1
+ export { InfoGroup } from './InfoGroup';
2
+ export { type InfoGroupProps, type InfoGroupItem } from './types';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InfoGroup = void 0;
4
+ var InfoGroup_1 = require("./InfoGroup");
5
+ Object.defineProperty(exports, "InfoGroup", { enumerable: true, get: function () { return InfoGroup_1.InfoGroup; } });
@@ -0,0 +1,19 @@
1
+ import { ReactNode } from 'react';
2
+ import { InfoRowPropsBase } from '../InfoRow/InfoRow';
3
+ export type DataType = Record<string, unknown>;
4
+ type PropsWithAccessorKey<T extends DataType> = {
5
+ accessorKey: keyof T;
6
+ render?: never;
7
+ } & Omit<InfoRowPropsBase, 'content'>;
8
+ type PropsWithRender<T extends DataType> = {
9
+ render: (data: T, noDataPlaceholder: string) => ReactNode;
10
+ accessorKey?: never;
11
+ } & Omit<InfoRowPropsBase, 'content'>;
12
+ export type InfoGroupItem<T extends DataType> = PropsWithRender<T> | PropsWithAccessorKey<T>;
13
+ export type InfoGroupProps<T extends DataType> = {
14
+ data: T | undefined;
15
+ items: InfoGroupItem<T>[];
16
+ className?: string;
17
+ loading?: boolean;
18
+ };
19
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export { useGetContent } from './useGetContent';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useGetContent = void 0;
4
+ var useGetContent_1 = require("./useGetContent");
5
+ Object.defineProperty(exports, "useGetContent", { enumerable: true, get: function () { return useGetContent_1.useGetContent; } });
@@ -0,0 +1,5 @@
1
+ export declare const isNil: (value: unknown) => value is undefined | null;
2
+ export declare const isBoolean: (value: unknown) => value is boolean;
3
+ export declare const isString: (value: unknown) => value is string;
4
+ export declare const isArray: <T>(value: unknown) => value is Array<T>;
5
+ export declare const isObject: (value: unknown) => value is object;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isObject = exports.isArray = exports.isString = exports.isBoolean = exports.isNil = void 0;
4
+ const isNil = (value) => value === undefined || value === null;
5
+ exports.isNil = isNil;
6
+ const isBoolean = (value) => typeof value === 'boolean';
7
+ exports.isBoolean = isBoolean;
8
+ const isString = (value) => typeof value === 'string';
9
+ exports.isString = isString;
10
+ const isArray = (value) => Array.isArray(value);
11
+ exports.isArray = isArray;
12
+ const isObject = (value) => typeof value === 'object' && !(0, exports.isArray)(value);
13
+ exports.isObject = isObject;
@@ -0,0 +1,4 @@
1
+ import { DataType, InfoGroupItem, InfoGroupProps } from '../types';
2
+ type Props<T extends DataType> = Pick<InfoGroupProps<T>, 'data'> & Pick<InfoGroupItem<T>, 'accessorKey' | 'render'>;
3
+ export declare function useGetContent(): <T extends DataType>({ data, accessorKey, render }: Props<T>) => import("react").ReactNode;
4
+ export {};
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useGetContent = useGetContent;
4
+ const uikit_product_locale_1 = require("@sbercloud/uikit-product-locale");
5
+ const constants_1 = require("../constants");
6
+ const typeGuards_1 = require("./typeGuards");
7
+ function useGetContent() {
8
+ const { t } = (0, uikit_product_locale_1.useLocale)('InfoRow');
9
+ return function getContent({ data, accessorKey, render }) {
10
+ if (!data) {
11
+ return constants_1.NO_DATA_PLACEHOLDER;
12
+ }
13
+ const value = accessorKey ? data[accessorKey] : undefined;
14
+ if (!(0, typeGuards_1.isNil)(value)) {
15
+ if ((0, typeGuards_1.isBoolean)(value)) {
16
+ return value ? t('booleanValueTrue') : t('booleanValueFalse');
17
+ }
18
+ if ((0, typeGuards_1.isString)(value)) {
19
+ return value ? value : constants_1.NO_DATA_PLACEHOLDER;
20
+ }
21
+ if ((0, typeGuards_1.isArray)(value)) {
22
+ return value.length ? value.join(', ') : constants_1.NO_DATA_PLACEHOLDER;
23
+ }
24
+ if ((0, typeGuards_1.isObject)(value)) {
25
+ return Object.keys(value).length ? JSON.stringify(value) : constants_1.NO_DATA_PLACEHOLDER;
26
+ }
27
+ return String(value);
28
+ }
29
+ if (render) {
30
+ return render(data, constants_1.NO_DATA_PLACEHOLDER);
31
+ }
32
+ return constants_1.NO_DATA_PLACEHOLDER;
33
+ };
34
+ }
@@ -0,0 +1,26 @@
1
+ import { ReactNode } from 'react';
2
+ import { WithSupportProps } from '@sbercloud/uikit-product-utils';
3
+ import { ButtonTonalProps } from '@snack-uikit/button';
4
+ import { QuestionTooltipProps, TooltipProps } from '@snack-uikit/tooltip';
5
+ type RowActionButton = {
6
+ tip?: Pick<TooltipProps, 'trigger' | 'tip' | 'placement' | 'disableMaxWidth' | 'open' | 'onOpenChange'> | string;
7
+ } & Omit<ButtonTonalProps, 'size' | 'appearance' | 'label'>;
8
+ export type InfoRowPropsBase = {
9
+ label: string;
10
+ labelTruncate?: number;
11
+ labelTooltip?: Pick<QuestionTooltipProps, 'trigger' | 'tip' | 'placement' | 'disableMaxWidth' | 'open' | 'onOpenChange'> | string;
12
+ topDivider?: boolean;
13
+ bottomDivider?: boolean;
14
+ className?: string;
15
+ content?: ReactNode;
16
+ rowActions?: {
17
+ first: RowActionButton;
18
+ second?: RowActionButton;
19
+ };
20
+ loading?: boolean;
21
+ width?: 'fixed' | 'full';
22
+ };
23
+ export type InfoRowProps = WithSupportProps<InfoRowPropsBase>;
24
+ export declare function withTip(children: ReactNode, tip?: TooltipProps | string): string | number | boolean | Iterable<ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
25
+ export declare function InfoRow({ label, topDivider, bottomDivider, className, labelTooltip, content, rowActions, labelTruncate, loading, width, ...rest }: InfoRowProps): import("react/jsx-runtime").JSX.Element;
26
+ export {};
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.withTip = withTip;
18
+ exports.InfoRow = InfoRow;
19
+ const jsx_runtime_1 = require("react/jsx-runtime");
20
+ const classnames_1 = __importDefault(require("classnames"));
21
+ const uikit_product_utils_1 = require("@sbercloud/uikit-product-utils");
22
+ const button_1 = require("@snack-uikit/button");
23
+ const divider_1 = require("@snack-uikit/divider");
24
+ const skeleton_1 = require("@snack-uikit/skeleton");
25
+ const tooltip_1 = require("@snack-uikit/tooltip");
26
+ const truncate_string_1 = require("@snack-uikit/truncate-string");
27
+ const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
28
+ function withTip(children, tip) {
29
+ if (!tip) {
30
+ return children;
31
+ }
32
+ return typeof tip === 'string' ? (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { tip: tip, children: children }) : (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, Object.assign({}, tip, { children: children }));
33
+ }
34
+ function InfoRow(_a) {
35
+ var { label, topDivider = true, bottomDivider = true, className, labelTooltip, content, rowActions, labelTruncate = 1, loading = false, width = 'fixed' } = _a, rest = __rest(_a, ["label", "topDivider", "bottomDivider", "className", "labelTooltip", "content", "rowActions", "labelTruncate", "loading", "width"]);
36
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, (0, uikit_product_utils_1.extractSupportProps)(rest), { className: (0, classnames_1.default)(styles_module_scss_1.default.wrapper, className), "data-width": width, children: [topDivider && (0, jsx_runtime_1.jsx)(divider_1.Divider, { weight: 'regular' }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.infoRow, children: [(0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.labelLayout, children: [(0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { text: label, maxLines: labelTruncate }), labelTooltip &&
37
+ (typeof labelTooltip === 'string' ? ((0, jsx_runtime_1.jsx)(tooltip_1.QuestionTooltip, { tip: labelTooltip, size: 'xs', placement: 'top', trigger: 'hover', tabIndex: -1 })) : ((0, jsx_runtime_1.jsx)(tooltip_1.QuestionTooltip, Object.assign({}, labelTooltip, { size: 'xs' }))))] }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.contentLayout, children: [(0, jsx_runtime_1.jsx)(skeleton_1.SkeletonContextProvider, { loading: loading, children: (0, jsx_runtime_1.jsx)(skeleton_1.WithSkeleton, { skeleton: (0, jsx_runtime_1.jsx)(skeleton_1.SkeletonText, { width: '100%', lines: 1 }), children: (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.content, children: content }) }) }), rowActions && ((0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.rowActions, children: [withTip((0, jsx_runtime_1.jsx)(button_1.ButtonTonal, Object.assign({}, rowActions.first, { disabled: loading || rowActions.first.disabled, appearance: 'neutral', size: 's' })), rowActions.first.tip), rowActions.second &&
38
+ withTip((0, jsx_runtime_1.jsx)(button_1.ButtonTonal, Object.assign({}, rowActions.second, { disabled: loading || rowActions.second.disabled, appearance: 'neutral', size: 's' })), rowActions.second.tip)] }))] })] }), bottomDivider && (0, jsx_runtime_1.jsx)(divider_1.Divider, { weight: 'regular' })] })));
39
+ }
@@ -0,0 +1 @@
1
+ export { InfoRow, type InfoRowProps, withTip } from './InfoRow';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withTip = exports.InfoRow = void 0;
4
+ var InfoRow_1 = require("./InfoRow");
5
+ Object.defineProperty(exports, "InfoRow", { enumerable: true, get: function () { return InfoRow_1.InfoRow; } });
6
+ Object.defineProperty(exports, "withTip", { enumerable: true, get: function () { return InfoRow_1.withTip; } });
@@ -0,0 +1,72 @@
1
+ .wrapper{
2
+ width:calc(200px + var(--dimension-3m, 24px) + 496px);
3
+ }
4
+ .wrapper[data-width=full]{
5
+ width:100%;
6
+ }
7
+
8
+ .infoRow{
9
+ padding:calc(var(--dimension-1m, 8px) + var(--dimension-050m, 4px)) 0;
10
+ display:flex;
11
+ -moz-column-gap:var(--dimension-3m, 24px);
12
+ column-gap:var(--dimension-3m, 24px);
13
+ width:100%;
14
+ align-items:center;
15
+ }
16
+
17
+ .labelLayout{
18
+ font-family:var(--light-label-l-font-family, SB Sans Interface);
19
+ font-weight:var(--light-label-l-font-weight, Regular);
20
+ line-height:var(--light-label-l-line-height, 20px);
21
+ font-size:var(--light-label-l-font-size, 14px);
22
+ letter-spacing:var(--light-label-l-letter-spacing, 0px);
23
+ paragraph-spacing:var(--light-label-l-paragraph-spacing, 7.7px);
24
+ position:relative;
25
+ width:200px;
26
+ color:var(--sys-neutral-text-main, #41424e);
27
+ display:flex;
28
+ -moz-column-gap:4px;
29
+ column-gap:4px;
30
+ align-items:center;
31
+ justify-content:flex-start;
32
+ height:100%;
33
+ }
34
+
35
+ .contentLayout{
36
+ position:relative;
37
+ display:flex;
38
+ align-items:center;
39
+ justify-content:space-between;
40
+ flex-grow:1;
41
+ flex-shrink:1;
42
+ flex-basis:0;
43
+ -moz-column-gap:12px;
44
+ column-gap:12px;
45
+ }
46
+ [data-width=fixed] .contentLayout{
47
+ width:496px;
48
+ }
49
+
50
+ .content{
51
+ font-family:var(--sans-body-m-font-family, SB Sans Interface);
52
+ font-weight:var(--sans-body-m-font-weight, Regular);
53
+ line-height:var(--sans-body-m-line-height, 20px);
54
+ font-size:var(--sans-body-m-font-size, 14px);
55
+ letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
56
+ paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
57
+ position:relative;
58
+ min-width:0;
59
+ color:var(--sys-neutral-text-main, #41424e);
60
+ display:flex;
61
+ height:100%;
62
+ flex:1;
63
+ justify-content:flex-start;
64
+ align-items:flex-start;
65
+ overflow-wrap:anywhere;
66
+ }
67
+
68
+ .rowActions{
69
+ display:flex;
70
+ align-items:center;
71
+ gap:8px;
72
+ }
@@ -0,0 +1,2 @@
1
+ export * from './InfoRow';
2
+ export * from './InfoGroup';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./InfoRow"), exports);
18
+ __exportStar(require("./InfoGroup"), exports);
@@ -0,0 +1 @@
1
+ export * from './components';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./components"), exports);
@@ -0,0 +1,2 @@
1
+ import { DataType, InfoGroupProps } from './types';
2
+ export declare function InfoGroup<T extends DataType>({ data, items, className, loading }: InfoGroupProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,23 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { InfoRow } from '../InfoRow';
14
+ import { useGetContent } from './utils';
15
+ export function InfoGroup({ data, items, className, loading }) {
16
+ const getContent = useGetContent();
17
+ return (_jsx("div", { className: className, children: items.map((_a, index) => {
18
+ var _b;
19
+ var { label, accessorKey, render } = _a, rest = __rest(_a, ["label", "accessorKey", "render"]);
20
+ const content = getContent({ data, render, accessorKey });
21
+ return (_jsx(InfoRow, Object.assign({ label: label, content: content, topDivider: index === 0, bottomDivider: true, loading: loading }, rest), (_b = accessorKey) !== null && _b !== void 0 ? _b : label));
22
+ }) }));
23
+ }
@@ -0,0 +1 @@
1
+ export declare const NO_DATA_PLACEHOLDER = "\u2014";
@@ -0,0 +1 @@
1
+ export const NO_DATA_PLACEHOLDER = '—';
@@ -0,0 +1,2 @@
1
+ export { InfoGroup } from './InfoGroup';
2
+ export { type InfoGroupProps, type InfoGroupItem } from './types';
@@ -0,0 +1 @@
1
+ export { InfoGroup } from './InfoGroup';
@@ -0,0 +1,19 @@
1
+ import { ReactNode } from 'react';
2
+ import { InfoRowPropsBase } from '../InfoRow/InfoRow';
3
+ export type DataType = Record<string, unknown>;
4
+ type PropsWithAccessorKey<T extends DataType> = {
5
+ accessorKey: keyof T;
6
+ render?: never;
7
+ } & Omit<InfoRowPropsBase, 'content'>;
8
+ type PropsWithRender<T extends DataType> = {
9
+ render: (data: T, noDataPlaceholder: string) => ReactNode;
10
+ accessorKey?: never;
11
+ } & Omit<InfoRowPropsBase, 'content'>;
12
+ export type InfoGroupItem<T extends DataType> = PropsWithRender<T> | PropsWithAccessorKey<T>;
13
+ export type InfoGroupProps<T extends DataType> = {
14
+ data: T | undefined;
15
+ items: InfoGroupItem<T>[];
16
+ className?: string;
17
+ loading?: boolean;
18
+ };
19
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export { useGetContent } from './useGetContent';
@@ -0,0 +1 @@
1
+ export { useGetContent } from './useGetContent';
@@ -0,0 +1,5 @@
1
+ export declare const isNil: (value: unknown) => value is undefined | null;
2
+ export declare const isBoolean: (value: unknown) => value is boolean;
3
+ export declare const isString: (value: unknown) => value is string;
4
+ export declare const isArray: <T>(value: unknown) => value is Array<T>;
5
+ export declare const isObject: (value: unknown) => value is object;
@@ -0,0 +1,5 @@
1
+ export const isNil = (value) => value === undefined || value === null;
2
+ export const isBoolean = (value) => typeof value === 'boolean';
3
+ export const isString = (value) => typeof value === 'string';
4
+ export const isArray = (value) => Array.isArray(value);
5
+ export const isObject = (value) => typeof value === 'object' && !isArray(value);
@@ -0,0 +1,4 @@
1
+ import { DataType, InfoGroupItem, InfoGroupProps } from '../types';
2
+ type Props<T extends DataType> = Pick<InfoGroupProps<T>, 'data'> & Pick<InfoGroupItem<T>, 'accessorKey' | 'render'>;
3
+ export declare function useGetContent(): <T extends DataType>({ data, accessorKey, render }: Props<T>) => import("react").ReactNode;
4
+ export {};
@@ -0,0 +1,31 @@
1
+ import { useLocale } from '@sbercloud/uikit-product-locale';
2
+ import { NO_DATA_PLACEHOLDER } from '../constants';
3
+ import { isArray, isBoolean, isNil, isObject, isString } from './typeGuards';
4
+ export function useGetContent() {
5
+ const { t } = useLocale('InfoRow');
6
+ return function getContent({ data, accessorKey, render }) {
7
+ if (!data) {
8
+ return NO_DATA_PLACEHOLDER;
9
+ }
10
+ const value = accessorKey ? data[accessorKey] : undefined;
11
+ if (!isNil(value)) {
12
+ if (isBoolean(value)) {
13
+ return value ? t('booleanValueTrue') : t('booleanValueFalse');
14
+ }
15
+ if (isString(value)) {
16
+ return value ? value : NO_DATA_PLACEHOLDER;
17
+ }
18
+ if (isArray(value)) {
19
+ return value.length ? value.join(', ') : NO_DATA_PLACEHOLDER;
20
+ }
21
+ if (isObject(value)) {
22
+ return Object.keys(value).length ? JSON.stringify(value) : NO_DATA_PLACEHOLDER;
23
+ }
24
+ return String(value);
25
+ }
26
+ if (render) {
27
+ return render(data, NO_DATA_PLACEHOLDER);
28
+ }
29
+ return NO_DATA_PLACEHOLDER;
30
+ };
31
+ }
@@ -0,0 +1,26 @@
1
+ import { ReactNode } from 'react';
2
+ import { WithSupportProps } from '@sbercloud/uikit-product-utils';
3
+ import { ButtonTonalProps } from '@snack-uikit/button';
4
+ import { QuestionTooltipProps, TooltipProps } from '@snack-uikit/tooltip';
5
+ type RowActionButton = {
6
+ tip?: Pick<TooltipProps, 'trigger' | 'tip' | 'placement' | 'disableMaxWidth' | 'open' | 'onOpenChange'> | string;
7
+ } & Omit<ButtonTonalProps, 'size' | 'appearance' | 'label'>;
8
+ export type InfoRowPropsBase = {
9
+ label: string;
10
+ labelTruncate?: number;
11
+ labelTooltip?: Pick<QuestionTooltipProps, 'trigger' | 'tip' | 'placement' | 'disableMaxWidth' | 'open' | 'onOpenChange'> | string;
12
+ topDivider?: boolean;
13
+ bottomDivider?: boolean;
14
+ className?: string;
15
+ content?: ReactNode;
16
+ rowActions?: {
17
+ first: RowActionButton;
18
+ second?: RowActionButton;
19
+ };
20
+ loading?: boolean;
21
+ width?: 'fixed' | 'full';
22
+ };
23
+ export type InfoRowProps = WithSupportProps<InfoRowPropsBase>;
24
+ export declare function withTip(children: ReactNode, tip?: TooltipProps | string): string | number | boolean | Iterable<ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
25
+ export declare function InfoRow({ label, topDivider, bottomDivider, className, labelTooltip, content, rowActions, labelTruncate, loading, width, ...rest }: InfoRowProps): import("react/jsx-runtime").JSX.Element;
26
+ export {};
@@ -0,0 +1,32 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import cn from 'classnames';
14
+ import { extractSupportProps } from '@sbercloud/uikit-product-utils';
15
+ import { ButtonTonal } from '@snack-uikit/button';
16
+ import { Divider } from '@snack-uikit/divider';
17
+ import { SkeletonContextProvider, SkeletonText, WithSkeleton } from '@snack-uikit/skeleton';
18
+ import { QuestionTooltip, Tooltip } from '@snack-uikit/tooltip';
19
+ import { TruncateString } from '@snack-uikit/truncate-string';
20
+ import styles from './styles.module.css';
21
+ export function withTip(children, tip) {
22
+ if (!tip) {
23
+ return children;
24
+ }
25
+ return typeof tip === 'string' ? _jsx(Tooltip, { tip: tip, children: children }) : _jsx(Tooltip, Object.assign({}, tip, { children: children }));
26
+ }
27
+ export function InfoRow(_a) {
28
+ var { label, topDivider = true, bottomDivider = true, className, labelTooltip, content, rowActions, labelTruncate = 1, loading = false, width = 'fixed' } = _a, rest = __rest(_a, ["label", "topDivider", "bottomDivider", "className", "labelTooltip", "content", "rowActions", "labelTruncate", "loading", "width"]);
29
+ return (_jsxs("div", Object.assign({}, extractSupportProps(rest), { className: cn(styles.wrapper, className), "data-width": width, children: [topDivider && _jsx(Divider, { weight: 'regular' }), _jsxs("div", { className: styles.infoRow, children: [_jsxs("div", { className: styles.labelLayout, children: [_jsx(TruncateString, { text: label, maxLines: labelTruncate }), labelTooltip &&
30
+ (typeof labelTooltip === 'string' ? (_jsx(QuestionTooltip, { tip: labelTooltip, size: 'xs', placement: 'top', trigger: 'hover', tabIndex: -1 })) : (_jsx(QuestionTooltip, Object.assign({}, labelTooltip, { size: 'xs' }))))] }), _jsxs("div", { className: styles.contentLayout, children: [_jsx(SkeletonContextProvider, { loading: loading, children: _jsx(WithSkeleton, { skeleton: _jsx(SkeletonText, { width: '100%', lines: 1 }), children: _jsx("div", { className: styles.content, children: content }) }) }), rowActions && (_jsxs("div", { className: styles.rowActions, children: [withTip(_jsx(ButtonTonal, Object.assign({}, rowActions.first, { disabled: loading || rowActions.first.disabled, appearance: 'neutral', size: 's' })), rowActions.first.tip), rowActions.second &&
31
+ withTip(_jsx(ButtonTonal, Object.assign({}, rowActions.second, { disabled: loading || rowActions.second.disabled, appearance: 'neutral', size: 's' })), rowActions.second.tip)] }))] })] }), bottomDivider && _jsx(Divider, { weight: 'regular' })] })));
32
+ }
@@ -0,0 +1 @@
1
+ export { InfoRow, type InfoRowProps, withTip } from './InfoRow';
@@ -0,0 +1 @@
1
+ export { InfoRow, withTip } from './InfoRow';
@@ -0,0 +1,72 @@
1
+ .wrapper{
2
+ width:calc(200px + var(--dimension-3m, 24px) + 496px);
3
+ }
4
+ .wrapper[data-width=full]{
5
+ width:100%;
6
+ }
7
+
8
+ .infoRow{
9
+ padding:calc(var(--dimension-1m, 8px) + var(--dimension-050m, 4px)) 0;
10
+ display:flex;
11
+ -moz-column-gap:var(--dimension-3m, 24px);
12
+ column-gap:var(--dimension-3m, 24px);
13
+ width:100%;
14
+ align-items:center;
15
+ }
16
+
17
+ .labelLayout{
18
+ font-family:var(--light-label-l-font-family, SB Sans Interface);
19
+ font-weight:var(--light-label-l-font-weight, Regular);
20
+ line-height:var(--light-label-l-line-height, 20px);
21
+ font-size:var(--light-label-l-font-size, 14px);
22
+ letter-spacing:var(--light-label-l-letter-spacing, 0px);
23
+ paragraph-spacing:var(--light-label-l-paragraph-spacing, 7.7px);
24
+ position:relative;
25
+ width:200px;
26
+ color:var(--sys-neutral-text-main, #41424e);
27
+ display:flex;
28
+ -moz-column-gap:4px;
29
+ column-gap:4px;
30
+ align-items:center;
31
+ justify-content:flex-start;
32
+ height:100%;
33
+ }
34
+
35
+ .contentLayout{
36
+ position:relative;
37
+ display:flex;
38
+ align-items:center;
39
+ justify-content:space-between;
40
+ flex-grow:1;
41
+ flex-shrink:1;
42
+ flex-basis:0;
43
+ -moz-column-gap:12px;
44
+ column-gap:12px;
45
+ }
46
+ [data-width=fixed] .contentLayout{
47
+ width:496px;
48
+ }
49
+
50
+ .content{
51
+ font-family:var(--sans-body-m-font-family, SB Sans Interface);
52
+ font-weight:var(--sans-body-m-font-weight, Regular);
53
+ line-height:var(--sans-body-m-line-height, 20px);
54
+ font-size:var(--sans-body-m-font-size, 14px);
55
+ letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
56
+ paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
57
+ position:relative;
58
+ min-width:0;
59
+ color:var(--sys-neutral-text-main, #41424e);
60
+ display:flex;
61
+ height:100%;
62
+ flex:1;
63
+ justify-content:flex-start;
64
+ align-items:flex-start;
65
+ overflow-wrap:anywhere;
66
+ }
67
+
68
+ .rowActions{
69
+ display:flex;
70
+ align-items:center;
71
+ gap:8px;
72
+ }
@@ -0,0 +1,2 @@
1
+ export * from './InfoRow';
2
+ export * from './InfoGroup';
@@ -0,0 +1,2 @@
1
+ export * from './InfoRow';
2
+ export * from './InfoGroup';
@@ -0,0 +1 @@
1
+ export * from './components';
@@ -0,0 +1 @@
1
+ export * from './components';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloud-ru/uikit-product-info-row",
3
3
  "title": "Info Row",
4
- "version": "0.8.24",
4
+ "version": "0.8.25",
5
5
  "sideEffects": [
6
6
  "*.css",
7
7
  "*.woff",
@@ -30,13 +30,14 @@
30
30
  "name": "Akhremenko Grigorii",
31
31
  "url": "https://github.com/AGrigorii"
32
32
  },
33
+ "contributors": [],
33
34
  "license": "Apache-2.0",
34
35
  "publishConfig": {
35
36
  "access": "public"
36
37
  },
37
38
  "scripts": {},
38
39
  "dependencies": {
39
- "@cloud-ru/uikit-product-utils": "7.0.0",
40
+ "@cloud-ru/uikit-product-utils": "7.0.1",
40
41
  "@snack-uikit/button": "0.19.7",
41
42
  "@snack-uikit/divider": "3.2.3",
42
43
  "@snack-uikit/skeleton": "0.6.2",
@@ -47,5 +48,5 @@
47
48
  "peerDependencies": {
48
49
  "@cloud-ru/uikit-product-locale": "*"
49
50
  },
50
- "gitHead": "e8bd79bc92b26a8f52611972eec98a867536ccd3"
51
+ "gitHead": "9c11b1e33e716c874534a1c162266c8591f2ed03"
51
52
  }