@cloud-ru/ds-ai-suggestion 1.0.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.
- package/CHANGELOG.md +8 -0
- package/LICENSE +201 -0
- package/README.md +226 -0
- package/dist/cjs/AiSuggestionParent/AiSuggestionParent.d.ts +7 -0
- package/dist/cjs/AiSuggestionParent/AiSuggestionParent.js +107 -0
- package/dist/cjs/AiSuggestionParent/AiSuggestionParentChip.d.ts +26 -0
- package/dist/cjs/AiSuggestionParent/AiSuggestionParentChip.js +24 -0
- package/dist/cjs/AiSuggestionParent/animation/AnimatedExpandableItem.d.ts +12 -0
- package/dist/cjs/AiSuggestionParent/animation/AnimatedExpandableItem.js +24 -0
- package/dist/cjs/AiSuggestionParent/animation/constants.d.ts +33 -0
- package/dist/cjs/AiSuggestionParent/animation/constants.js +69 -0
- package/dist/cjs/AiSuggestionParent/animation/styles.module.css +23 -0
- package/dist/cjs/AiSuggestionParent/constants.d.ts +9 -0
- package/dist/cjs/AiSuggestionParent/constants.js +12 -0
- package/dist/cjs/AiSuggestionParent/context/AiSuggestionParentGroupContext.d.ts +13 -0
- package/dist/cjs/AiSuggestionParent/context/AiSuggestionParentGroupContext.js +25 -0
- package/dist/cjs/AiSuggestionParent/index.d.ts +4 -0
- package/dist/cjs/AiSuggestionParent/index.js +24 -0
- package/dist/cjs/AiSuggestionParent/styles.module.css +156 -0
- package/dist/cjs/AiSuggestionParent/types.d.ts +44 -0
- package/dist/cjs/AiSuggestionParent/types.js +2 -0
- package/dist/cjs/AiSuggestionParent/utils/hasExclusiveParentGroup.d.ts +2 -0
- package/dist/cjs/AiSuggestionParent/utils/hasExclusiveParentGroup.js +7 -0
- package/dist/cjs/AiSuggestionParent/utils/itemGuards.d.ts +3 -0
- package/dist/cjs/AiSuggestionParent/utils/itemGuards.js +11 -0
- package/dist/cjs/AiSuggestionSimple/AiSuggestionSimple.d.ts +18 -0
- package/dist/cjs/AiSuggestionSimple/AiSuggestionSimple.js +17 -0
- package/dist/cjs/AiSuggestionSimple/constants.d.ts +18 -0
- package/dist/cjs/AiSuggestionSimple/constants.js +21 -0
- package/dist/cjs/AiSuggestionSimple/index.d.ts +3 -0
- package/dist/cjs/AiSuggestionSimple/index.js +24 -0
- package/dist/cjs/AiSuggestionSimple/styles.module.css +138 -0
- package/dist/cjs/AiSuggestionSimple/types.d.ts +5 -0
- package/dist/cjs/AiSuggestionSimple/types.js +2 -0
- package/dist/cjs/AiSuggestionSimple/utils.d.ts +2 -0
- package/dist/cjs/AiSuggestionSimple/utils.js +7 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +18 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/style.css +317 -0
- package/dist/esm/AiSuggestionParent/AiSuggestionParent.d.ts +7 -0
- package/dist/esm/AiSuggestionParent/AiSuggestionParent.js +101 -0
- package/dist/esm/AiSuggestionParent/AiSuggestionParentChip.d.ts +26 -0
- package/dist/esm/AiSuggestionParent/AiSuggestionParentChip.js +18 -0
- package/dist/esm/AiSuggestionParent/animation/AnimatedExpandableItem.d.ts +12 -0
- package/dist/esm/AiSuggestionParent/animation/AnimatedExpandableItem.js +17 -0
- package/dist/esm/AiSuggestionParent/animation/constants.d.ts +33 -0
- package/dist/esm/AiSuggestionParent/animation/constants.js +63 -0
- package/dist/esm/AiSuggestionParent/animation/styles.module.css +23 -0
- package/dist/esm/AiSuggestionParent/constants.d.ts +9 -0
- package/dist/esm/AiSuggestionParent/constants.js +9 -0
- package/dist/esm/AiSuggestionParent/context/AiSuggestionParentGroupContext.d.ts +13 -0
- package/dist/esm/AiSuggestionParent/context/AiSuggestionParentGroupContext.js +21 -0
- package/dist/esm/AiSuggestionParent/index.d.ts +4 -0
- package/dist/esm/AiSuggestionParent/index.js +4 -0
- package/dist/esm/AiSuggestionParent/styles.module.css +156 -0
- package/dist/esm/AiSuggestionParent/types.d.ts +44 -0
- package/dist/esm/AiSuggestionParent/types.js +1 -0
- package/dist/esm/AiSuggestionParent/utils/hasExclusiveParentGroup.d.ts +2 -0
- package/dist/esm/AiSuggestionParent/utils/hasExclusiveParentGroup.js +4 -0
- package/dist/esm/AiSuggestionParent/utils/itemGuards.d.ts +3 -0
- package/dist/esm/AiSuggestionParent/utils/itemGuards.js +7 -0
- package/dist/esm/AiSuggestionSimple/AiSuggestionSimple.d.ts +18 -0
- package/dist/esm/AiSuggestionSimple/AiSuggestionSimple.js +11 -0
- package/dist/esm/AiSuggestionSimple/constants.d.ts +18 -0
- package/dist/esm/AiSuggestionSimple/constants.js +18 -0
- package/dist/esm/AiSuggestionSimple/index.d.ts +3 -0
- package/dist/esm/AiSuggestionSimple/index.js +3 -0
- package/dist/esm/AiSuggestionSimple/styles.module.css +138 -0
- package/dist/esm/AiSuggestionSimple/types.d.ts +5 -0
- package/dist/esm/AiSuggestionSimple/types.js +1 -0
- package/dist/esm/AiSuggestionSimple/utils.d.ts +2 -0
- package/dist/esm/AiSuggestionSimple/utils.js +4 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/style.css +317 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/package.json +45 -0
- package/src/AiSuggestionParent/AiSuggestionParent.tsx +257 -0
- package/src/AiSuggestionParent/AiSuggestionParentChip.tsx +79 -0
- package/src/AiSuggestionParent/animation/AnimatedExpandableItem.tsx +53 -0
- package/src/AiSuggestionParent/animation/constants.ts +77 -0
- package/src/AiSuggestionParent/animation/styles.module.scss +25 -0
- package/src/AiSuggestionParent/constants.ts +10 -0
- package/src/AiSuggestionParent/context/AiSuggestionParentGroupContext.tsx +44 -0
- package/src/AiSuggestionParent/index.ts +4 -0
- package/src/AiSuggestionParent/styles.module.scss +197 -0
- package/src/AiSuggestionParent/types.ts +49 -0
- package/src/AiSuggestionParent/utils/hasExclusiveParentGroup.ts +6 -0
- package/src/AiSuggestionParent/utils/itemGuards.ts +10 -0
- package/src/AiSuggestionSimple/AiSuggestionSimple.tsx +72 -0
- package/src/AiSuggestionSimple/constants.ts +21 -0
- package/src/AiSuggestionSimple/index.ts +3 -0
- package/src/AiSuggestionSimple/styles.module.scss +166 -0
- package/src/AiSuggestionSimple/types.ts +7 -0
- package/src/AiSuggestionSimple/utils.ts +6 -0
- package/src/index.ts +2 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
@charset "UTF-8";
|
|
2
|
+
.label{
|
|
3
|
+
overflow:hidden;
|
|
4
|
+
text-overflow:ellipsis;
|
|
5
|
+
white-space:nowrap;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.icon{
|
|
9
|
+
color:currentcolor;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.chip{
|
|
13
|
+
cursor:pointer;
|
|
14
|
+
position:relative;
|
|
15
|
+
display:inline-flex;
|
|
16
|
+
align-items:center;
|
|
17
|
+
justify-content:center;
|
|
18
|
+
box-sizing:border-box;
|
|
19
|
+
margin:0;
|
|
20
|
+
padding:0;
|
|
21
|
+
border:var(--sn-primitive-strokeWeight-strokeRegular, 1px) solid transparent;
|
|
22
|
+
border-radius:var(--sn-primitive-dimension-full, 10000px);
|
|
23
|
+
font-family:inherit;
|
|
24
|
+
text-decoration:none;
|
|
25
|
+
background-color:transparent;
|
|
26
|
+
outline:0;
|
|
27
|
+
outline-offset:0;
|
|
28
|
+
transition:background-color 120ms ease, border-color 120ms ease, color 120ms ease;
|
|
29
|
+
}
|
|
30
|
+
.chip:disabled, .chip[data-disabled]{
|
|
31
|
+
cursor:not-allowed;
|
|
32
|
+
opacity:var(--sn-theme-effect-opacity-disabled, 0.4);
|
|
33
|
+
}
|
|
34
|
+
.chip:focus-visible{
|
|
35
|
+
background-color:transparent;
|
|
36
|
+
outline:var(--sn-primitive-strokeWeight-strokeSemiBold, 2px) solid var(--sn-theme-color-primary-accent, var(--sn-brand-color-primary-55, var(--sn-brandRole-color-brandA-55, var(--sn-primitive-color-brandA-55, #389f74))));
|
|
37
|
+
outline-offset:var(--sn-primitive-dimension-2, 2px);
|
|
38
|
+
}
|
|
39
|
+
.chip[data-size=s]{
|
|
40
|
+
font-family:var(--sn-regular-label-m-fontFamily, var(--sn-brand-font-fontFamily-regular-label, var(--sn-primitive-fontFamily-brandA-sans, SB Sans Interface)));
|
|
41
|
+
font-weight:var(--sn-regular-label-m-fontWeight, var(--sn-theme-typography-fontWeight-regular-label-m, var(--sn-brand-font-fontWeight-light-regular-label-m, var(--sn-primitive-font-fontWeightValue-550, 550))));
|
|
42
|
+
line-height:var(--sn-regular-label-m-lineHeight, var(--sn-density-typography-roleLabel-lineHeightM, var(--sn-primitive-font-lineHeight-by16, 24px)));
|
|
43
|
+
font-size:var(--sn-regular-label-m-fontSize, var(--sn-density-typography-roleLabel-fontSizeM, var(--sn-primitive-font-fontSize-16, 16px)));
|
|
44
|
+
letter-spacing:var(--sn-regular-label-m-letterSpacing, var(--sn-primitive-font-letterSpacing-s, 0px));
|
|
45
|
+
paragraph-spacing:var(--sn-regular-label-m-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize12, 6px));
|
|
46
|
+
height:var(--sn-primitive-dimension-32, 32px);
|
|
47
|
+
padding-inline:var(--sn-primitive-dimension-4, 4px);
|
|
48
|
+
}
|
|
49
|
+
.chip[data-size=s] .icon{
|
|
50
|
+
display:flex;
|
|
51
|
+
flex-shrink:0;
|
|
52
|
+
align-items:center;
|
|
53
|
+
justify-content:center;
|
|
54
|
+
width:var(--sn-density-size-icon-s, var(--sn-primitive-dimension-24, 24px));
|
|
55
|
+
height:var(--sn-density-size-icon-s, var(--sn-primitive-dimension-24, 24px));
|
|
56
|
+
}
|
|
57
|
+
.chip[data-size=s] .icon > svg{
|
|
58
|
+
max-width:100%;
|
|
59
|
+
max-height:100%;
|
|
60
|
+
}
|
|
61
|
+
.chip[data-size=s] .labelContainer{
|
|
62
|
+
padding-inline:var(--sn-primitive-dimension-4, 4px);
|
|
63
|
+
}
|
|
64
|
+
.chip[data-size=m]{
|
|
65
|
+
font-family:var(--sn-regular-label-l-fontFamily, var(--sn-brand-font-fontFamily-regular-label, var(--sn-primitive-fontFamily-brandA-sans, SB Sans Interface)));
|
|
66
|
+
font-weight:var(--sn-regular-label-l-fontWeight, var(--sn-theme-typography-fontWeight-regular-label-l, var(--sn-brand-font-fontWeight-light-regular-label-l, var(--sn-primitive-font-fontWeightValue-550, 550))));
|
|
67
|
+
line-height:var(--sn-regular-label-l-lineHeight, var(--sn-density-typography-roleLabel-lineHeightL, var(--sn-primitive-font-lineHeight-by20, 28px)));
|
|
68
|
+
font-size:var(--sn-regular-label-l-fontSize, var(--sn-density-typography-roleLabel-fontSizeL, var(--sn-primitive-font-fontSize-20, 20px)));
|
|
69
|
+
letter-spacing:var(--sn-regular-label-l-letterSpacing, var(--sn-primitive-font-letterSpacing-s, 0px));
|
|
70
|
+
paragraph-spacing:var(--sn-regular-label-l-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize14, 7px));
|
|
71
|
+
height:var(--sn-primitive-dimension-40, 40px);
|
|
72
|
+
padding-inline:var(--sn-primitive-dimension-8, 8px);
|
|
73
|
+
}
|
|
74
|
+
.chip[data-size=m] .icon{
|
|
75
|
+
display:flex;
|
|
76
|
+
flex-shrink:0;
|
|
77
|
+
align-items:center;
|
|
78
|
+
justify-content:center;
|
|
79
|
+
width:var(--sn-density-size-icon-s, var(--sn-primitive-dimension-24, 24px));
|
|
80
|
+
height:var(--sn-density-size-icon-s, var(--sn-primitive-dimension-24, 24px));
|
|
81
|
+
}
|
|
82
|
+
.chip[data-size=m] .icon > svg{
|
|
83
|
+
max-width:100%;
|
|
84
|
+
max-height:100%;
|
|
85
|
+
}
|
|
86
|
+
.chip[data-size=m] .labelContainer{
|
|
87
|
+
padding-inline:var(--sn-primitive-dimension-8, 8px);
|
|
88
|
+
}
|
|
89
|
+
.chip:focus-visible{
|
|
90
|
+
background-color:var(--sn-theme-color-primary-background1Level);
|
|
91
|
+
}
|
|
92
|
+
.chip[data-appearance=primary]{
|
|
93
|
+
border-color:var(--sn-theme-color-material-stateLayer-activated-default-filled, var(--sn-brand-color-state-activated-default-background, var(--sn-brandRole-color-brandA-backgroundActivatedDefault, rgba(56, 159, 116, 0.1490196078))));
|
|
94
|
+
}
|
|
95
|
+
.chip[data-appearance=primary] .icon,
|
|
96
|
+
.chip[data-appearance=primary] .label{
|
|
97
|
+
color:var(--sn-theme-color-primary-text, var(--sn-brand-color-primary-45, var(--sn-brandRole-color-brandA-45, var(--sn-primitive-color-brandA-45, #22775b))));
|
|
98
|
+
}
|
|
99
|
+
@media (hover: hover){
|
|
100
|
+
.chip[data-appearance=primary]:hover:not(:disabled, [data-disabled]){
|
|
101
|
+
border-color:var(--sn-theme-color-material-stateLayer-activated-hovered-filled, var(--sn-brand-color-state-activated-hovered-background, var(--sn-brandRole-color-brandA-backgroundActivatedHovered, rgba(56, 159, 116, 0.3490196078))));
|
|
102
|
+
background-color:var(--sn-theme-color-primary-background1Level, var(--sn-brand-color-primary-95, var(--sn-brandRole-color-brandA-95, var(--sn-primitive-color-brandA-95, #f5fdf8))));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
.chip:focus-visible{
|
|
106
|
+
background-color:var(--sn-theme-color-neutral-background1Level);
|
|
107
|
+
}
|
|
108
|
+
.chip[data-appearance=neutral]{
|
|
109
|
+
border-color:var(--sn-theme-color-material-stateLayer-neutral-border-default-borderColor, var(--sn-brand-color-state-neutralBorder-forLightMode-default-borderColor, rgba(159, 166, 198, 0.3019607843)));
|
|
110
|
+
}
|
|
111
|
+
.chip[data-appearance=neutral] .icon,
|
|
112
|
+
.chip[data-appearance=neutral] .label{
|
|
113
|
+
color:var(--sn-theme-color-neutral-text, var(--sn-brand-color-neutral-45, var(--sn-primitive-color-gray-45, #81869c)));
|
|
114
|
+
}
|
|
115
|
+
@media (hover: hover){
|
|
116
|
+
.chip[data-appearance=neutral]:hover:not(:disabled, [data-disabled]){
|
|
117
|
+
border-color:var(--sn-theme-color-material-stateLayer-neutral-border-hovered-borderColor, var(--sn-brand-color-state-neutralBorder-forLightMode-hovered-borderColor, rgba(159, 166, 198, 0.6509803922)));
|
|
118
|
+
background-color:var(--sn-theme-color-neutral-background1Level, var(--sn-brand-color-neutral-95, var(--sn-primitive-color-gray-95, #fdfdfd)));
|
|
119
|
+
}
|
|
120
|
+
.chip[data-appearance=neutral]:hover:not(:disabled, [data-disabled]) .icon, .chip[data-appearance=neutral]:hover:not(:disabled, [data-disabled]) .label{
|
|
121
|
+
color:var(--sn-theme-color-available-version-textMain, var(--sn-brand-color-text-version-main, #41424e));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.content{
|
|
126
|
+
position:relative;
|
|
127
|
+
z-index:1;
|
|
128
|
+
display:inline-flex;
|
|
129
|
+
align-items:center;
|
|
130
|
+
justify-content:center;
|
|
131
|
+
min-width:0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.labelContainer{
|
|
135
|
+
display:inline-flex;
|
|
136
|
+
align-items:center;
|
|
137
|
+
justify-content:center;
|
|
138
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLayerState = getLayerState;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
function getLayerState(appearance) {
|
|
6
|
+
return appearance === constants_1.APPEARANCE.Primary ? constants_1.LAYER_STATE.ActivatedOnBackground : constants_1.LAYER_STATE.EmptyNeutralOnBackground;
|
|
7
|
+
}
|
|
@@ -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("./AiSuggestionParent"), exports);
|
|
18
|
+
__exportStar(require("./AiSuggestionSimple"), exports);
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
.outerChip{
|
|
2
|
+
contain:layout;
|
|
3
|
+
display:inline-flex;
|
|
4
|
+
flex-shrink:0;
|
|
5
|
+
align-items:center;
|
|
6
|
+
justify-content:center;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.innerChip{
|
|
10
|
+
will-change:transform, opacity;
|
|
11
|
+
transform-origin:center;
|
|
12
|
+
display:inline-flex;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.innerChipHidden{
|
|
16
|
+
pointer-events:none;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.triggerWrap{
|
|
20
|
+
display:inline-flex;
|
|
21
|
+
flex-shrink:0;
|
|
22
|
+
margin-right:var(--sn-primitive-dimension-4, 4px);
|
|
23
|
+
}
|
|
24
|
+
.root{
|
|
25
|
+
display:flex;
|
|
26
|
+
flex-wrap:wrap;
|
|
27
|
+
row-gap:var(--sn-primitive-dimension-4, 4px);
|
|
28
|
+
align-items:center;
|
|
29
|
+
min-width:0;
|
|
30
|
+
max-width:100%;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.root[data-flatten]{
|
|
34
|
+
display:contents;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.label{
|
|
38
|
+
overflow:hidden;
|
|
39
|
+
text-overflow:ellipsis;
|
|
40
|
+
white-space:nowrap;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.icon{
|
|
44
|
+
color:currentcolor;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.chevron{
|
|
48
|
+
display:flex;
|
|
49
|
+
flex-shrink:0;
|
|
50
|
+
align-items:center;
|
|
51
|
+
justify-content:center;
|
|
52
|
+
width:var(--sn-density-size-icon-s, var(--sn-primitive-dimension-24, 24px));
|
|
53
|
+
height:var(--sn-density-size-icon-s, var(--sn-primitive-dimension-24, 24px));
|
|
54
|
+
color:currentcolor;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.chip{
|
|
58
|
+
cursor:pointer;
|
|
59
|
+
position:relative;
|
|
60
|
+
display:inline-flex;
|
|
61
|
+
flex-shrink:0;
|
|
62
|
+
align-items:center;
|
|
63
|
+
justify-content:center;
|
|
64
|
+
box-sizing:border-box;
|
|
65
|
+
margin:0;
|
|
66
|
+
padding:0;
|
|
67
|
+
border:var(--sn-primitive-strokeWeight-strokeRegular, 1px) solid var(--sn-theme-color-material-stateLayer-neutral-border-default-borderColor, var(--sn-brand-color-state-neutralBorder-forLightMode-default-borderColor, rgba(159, 166, 198, 0.3019607843)));
|
|
68
|
+
border-radius:var(--sn-primitive-dimension-full, 10000px);
|
|
69
|
+
font-family:inherit;
|
|
70
|
+
text-decoration:none;
|
|
71
|
+
background-color:var(--sn-theme-color-neutral-background1Level, var(--sn-brand-color-neutral-95, var(--sn-primitive-color-gray-95, #fdfdfd)));
|
|
72
|
+
outline:0;
|
|
73
|
+
outline-offset:0;
|
|
74
|
+
transition:background-color 450ms cubic-bezier(1, 0, 0.26, 0.7), border-color 450ms cubic-bezier(1, 0, 0.26, 0.7), color 450ms cubic-bezier(1, 0, 0.26, 0.7), outline-color 120ms ease;
|
|
75
|
+
}
|
|
76
|
+
.chip .icon,
|
|
77
|
+
.chip .label,
|
|
78
|
+
.chip .chevron{
|
|
79
|
+
color:var(--sn-theme-color-neutral-text, var(--sn-brand-color-neutral-45, var(--sn-primitive-color-gray-45, #81869c)));
|
|
80
|
+
}
|
|
81
|
+
.chip:disabled{
|
|
82
|
+
cursor:not-allowed;
|
|
83
|
+
opacity:var(--sn-theme-effect-opacity-disabled, 0.4);
|
|
84
|
+
}
|
|
85
|
+
.chip:not(:disabled):focus-visible{
|
|
86
|
+
outline:var(--sn-primitive-strokeWeight-strokeSemiBold, 2px) solid var(--sn-theme-color-primary-accent, var(--sn-brand-color-primary-55, var(--sn-brandRole-color-brandA-55, var(--sn-primitive-color-brandA-55, #389f74))));
|
|
87
|
+
outline-offset:0;
|
|
88
|
+
}
|
|
89
|
+
.chip[data-activated]{
|
|
90
|
+
border-color:var(--sn-theme-color-primary-accent, var(--sn-brand-color-primary-55, var(--sn-brandRole-color-brandA-55, var(--sn-primitive-color-brandA-55, #389f74))));
|
|
91
|
+
background-color:var(--sn-theme-color-primary-background1Level, var(--sn-brand-color-primary-95, var(--sn-brandRole-color-brandA-95, var(--sn-primitive-color-brandA-95, #f5fdf8))));
|
|
92
|
+
transition:background-color 450ms cubic-bezier(0.7, 0.26, 0, 1.58), border-color 450ms cubic-bezier(0.7, 0.26, 0, 1.58), color 450ms cubic-bezier(0.7, 0.26, 0, 1.58), outline-color 120ms ease;
|
|
93
|
+
}
|
|
94
|
+
.chip[data-activated] .icon,
|
|
95
|
+
.chip[data-activated] .label,
|
|
96
|
+
.chip[data-activated] .chevron{
|
|
97
|
+
color:var(--sn-theme-color-primary-text, var(--sn-brand-color-primary-45, var(--sn-brandRole-color-brandA-45, var(--sn-primitive-color-brandA-45, #22775b))));
|
|
98
|
+
}
|
|
99
|
+
@media (hover: hover){
|
|
100
|
+
.chip[data-activated]:hover:not(:disabled){
|
|
101
|
+
border-color:color-mix(in srgb, var(--sn-theme-color-primary-accent, var(--sn-brand-color-primary-55, var(--sn-brandRole-color-brandA-55, var(--sn-primitive-color-brandA-55, #389f74)))) 80%, transparent);
|
|
102
|
+
background-color:var(--sn-theme-color-primary-background2Level, var(--sn-brand-color-primary-99, var(--sn-brandRole-color-brandA-99, var(--sn-primitive-color-brandA-99, #fbfffc))));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
@media (hover: hover){
|
|
106
|
+
.chip:not([data-activated], :disabled):hover{
|
|
107
|
+
border-color:var(--sn-theme-color-material-stateLayer-neutral-border-hovered-borderColor, var(--sn-brand-color-state-neutralBorder-forLightMode-hovered-borderColor, rgba(159, 166, 198, 0.6509803922)));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
.chip[data-size=s]{
|
|
111
|
+
font-family:var(--sn-regular-label-m-fontFamily, var(--sn-brand-font-fontFamily-regular-label, var(--sn-primitive-fontFamily-brandA-sans, SB Sans Interface)));
|
|
112
|
+
font-weight:var(--sn-regular-label-m-fontWeight, var(--sn-theme-typography-fontWeight-regular-label-m, var(--sn-brand-font-fontWeight-light-regular-label-m, var(--sn-primitive-font-fontWeightValue-550, 550))));
|
|
113
|
+
line-height:var(--sn-regular-label-m-lineHeight, var(--sn-density-typography-roleLabel-lineHeightM, var(--sn-primitive-font-lineHeight-by16, 24px)));
|
|
114
|
+
font-size:var(--sn-regular-label-m-fontSize, var(--sn-density-typography-roleLabel-fontSizeM, var(--sn-primitive-font-fontSize-16, 16px)));
|
|
115
|
+
letter-spacing:var(--sn-regular-label-m-letterSpacing, var(--sn-primitive-font-letterSpacing-s, 0px));
|
|
116
|
+
paragraph-spacing:var(--sn-regular-label-m-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize12, 6px));
|
|
117
|
+
height:var(--sn-primitive-dimension-32, 32px);
|
|
118
|
+
padding-inline:var(--sn-primitive-dimension-4, 4px);
|
|
119
|
+
}
|
|
120
|
+
.chip[data-size=s] .icon{
|
|
121
|
+
display:flex;
|
|
122
|
+
flex-shrink:0;
|
|
123
|
+
align-items:center;
|
|
124
|
+
justify-content:center;
|
|
125
|
+
width:var(--sn-density-size-icon-s, var(--sn-primitive-dimension-24, 24px));
|
|
126
|
+
height:var(--sn-density-size-icon-s, var(--sn-primitive-dimension-24, 24px));
|
|
127
|
+
}
|
|
128
|
+
.chip[data-size=s] .icon > svg{
|
|
129
|
+
display:block;
|
|
130
|
+
width:100%;
|
|
131
|
+
height:100%;
|
|
132
|
+
}
|
|
133
|
+
.chip[data-size=s] .labelContainer{
|
|
134
|
+
padding-inline:var(--sn-primitive-dimension-4, 4px) var(--sn-primitive-dimension-0, 0);
|
|
135
|
+
}
|
|
136
|
+
.chip[data-size=m]{
|
|
137
|
+
font-family:var(--sn-regular-label-l-fontFamily, var(--sn-brand-font-fontFamily-regular-label, var(--sn-primitive-fontFamily-brandA-sans, SB Sans Interface)));
|
|
138
|
+
font-weight:var(--sn-regular-label-l-fontWeight, var(--sn-theme-typography-fontWeight-regular-label-l, var(--sn-brand-font-fontWeight-light-regular-label-l, var(--sn-primitive-font-fontWeightValue-550, 550))));
|
|
139
|
+
line-height:var(--sn-regular-label-l-lineHeight, var(--sn-density-typography-roleLabel-lineHeightL, var(--sn-primitive-font-lineHeight-by20, 28px)));
|
|
140
|
+
font-size:var(--sn-regular-label-l-fontSize, var(--sn-density-typography-roleLabel-fontSizeL, var(--sn-primitive-font-fontSize-20, 20px)));
|
|
141
|
+
letter-spacing:var(--sn-regular-label-l-letterSpacing, var(--sn-primitive-font-letterSpacing-s, 0px));
|
|
142
|
+
paragraph-spacing:var(--sn-regular-label-l-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize14, 7px));
|
|
143
|
+
height:var(--sn-primitive-dimension-40, 40px);
|
|
144
|
+
padding-inline:var(--sn-primitive-dimension-8, 8px);
|
|
145
|
+
}
|
|
146
|
+
.chip[data-size=m] .icon{
|
|
147
|
+
display:flex;
|
|
148
|
+
flex-shrink:0;
|
|
149
|
+
align-items:center;
|
|
150
|
+
justify-content:center;
|
|
151
|
+
width:var(--sn-density-size-icon-s, var(--sn-primitive-dimension-24, 24px));
|
|
152
|
+
height:var(--sn-density-size-icon-s, var(--sn-primitive-dimension-24, 24px));
|
|
153
|
+
}
|
|
154
|
+
.chip[data-size=m] .icon > svg{
|
|
155
|
+
display:block;
|
|
156
|
+
width:100%;
|
|
157
|
+
height:100%;
|
|
158
|
+
}
|
|
159
|
+
.chip[data-size=m] .labelContainer{
|
|
160
|
+
padding-inline:var(--sn-primitive-dimension-8, 8px) var(--sn-primitive-dimension-2, 2px);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.labelContainer{
|
|
164
|
+
display:inline-flex;
|
|
165
|
+
align-items:center;
|
|
166
|
+
justify-content:center;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.chevronIcon{
|
|
170
|
+
display:block;
|
|
171
|
+
max-width:100%;
|
|
172
|
+
max-height:100%;
|
|
173
|
+
transition:transform 450ms cubic-bezier(1, 0, 0.26, 0.7);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.chip[data-activated] .chevronIcon{
|
|
177
|
+
transform:rotate(90deg);
|
|
178
|
+
transition:transform 450ms cubic-bezier(0.7, 0.26, 0, 1.58);
|
|
179
|
+
}
|
|
180
|
+
@charset "UTF-8";
|
|
181
|
+
.label{
|
|
182
|
+
overflow:hidden;
|
|
183
|
+
text-overflow:ellipsis;
|
|
184
|
+
white-space:nowrap;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.icon{
|
|
188
|
+
color:currentcolor;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.chip{
|
|
192
|
+
cursor:pointer;
|
|
193
|
+
position:relative;
|
|
194
|
+
display:inline-flex;
|
|
195
|
+
align-items:center;
|
|
196
|
+
justify-content:center;
|
|
197
|
+
box-sizing:border-box;
|
|
198
|
+
margin:0;
|
|
199
|
+
padding:0;
|
|
200
|
+
border:var(--sn-primitive-strokeWeight-strokeRegular, 1px) solid transparent;
|
|
201
|
+
border-radius:var(--sn-primitive-dimension-full, 10000px);
|
|
202
|
+
font-family:inherit;
|
|
203
|
+
text-decoration:none;
|
|
204
|
+
background-color:transparent;
|
|
205
|
+
outline:0;
|
|
206
|
+
outline-offset:0;
|
|
207
|
+
transition:background-color 120ms ease, border-color 120ms ease, color 120ms ease;
|
|
208
|
+
}
|
|
209
|
+
.chip:disabled, .chip[data-disabled]{
|
|
210
|
+
cursor:not-allowed;
|
|
211
|
+
opacity:var(--sn-theme-effect-opacity-disabled, 0.4);
|
|
212
|
+
}
|
|
213
|
+
.chip:focus-visible{
|
|
214
|
+
background-color:transparent;
|
|
215
|
+
outline:var(--sn-primitive-strokeWeight-strokeSemiBold, 2px) solid var(--sn-theme-color-primary-accent, var(--sn-brand-color-primary-55, var(--sn-brandRole-color-brandA-55, var(--sn-primitive-color-brandA-55, #389f74))));
|
|
216
|
+
outline-offset:var(--sn-primitive-dimension-2, 2px);
|
|
217
|
+
}
|
|
218
|
+
.chip[data-size=s]{
|
|
219
|
+
font-family:var(--sn-regular-label-m-fontFamily, var(--sn-brand-font-fontFamily-regular-label, var(--sn-primitive-fontFamily-brandA-sans, SB Sans Interface)));
|
|
220
|
+
font-weight:var(--sn-regular-label-m-fontWeight, var(--sn-theme-typography-fontWeight-regular-label-m, var(--sn-brand-font-fontWeight-light-regular-label-m, var(--sn-primitive-font-fontWeightValue-550, 550))));
|
|
221
|
+
line-height:var(--sn-regular-label-m-lineHeight, var(--sn-density-typography-roleLabel-lineHeightM, var(--sn-primitive-font-lineHeight-by16, 24px)));
|
|
222
|
+
font-size:var(--sn-regular-label-m-fontSize, var(--sn-density-typography-roleLabel-fontSizeM, var(--sn-primitive-font-fontSize-16, 16px)));
|
|
223
|
+
letter-spacing:var(--sn-regular-label-m-letterSpacing, var(--sn-primitive-font-letterSpacing-s, 0px));
|
|
224
|
+
paragraph-spacing:var(--sn-regular-label-m-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize12, 6px));
|
|
225
|
+
height:var(--sn-primitive-dimension-32, 32px);
|
|
226
|
+
padding-inline:var(--sn-primitive-dimension-4, 4px);
|
|
227
|
+
}
|
|
228
|
+
.chip[data-size=s] .icon{
|
|
229
|
+
display:flex;
|
|
230
|
+
flex-shrink:0;
|
|
231
|
+
align-items:center;
|
|
232
|
+
justify-content:center;
|
|
233
|
+
width:var(--sn-density-size-icon-s, var(--sn-primitive-dimension-24, 24px));
|
|
234
|
+
height:var(--sn-density-size-icon-s, var(--sn-primitive-dimension-24, 24px));
|
|
235
|
+
}
|
|
236
|
+
.chip[data-size=s] .icon > svg{
|
|
237
|
+
max-width:100%;
|
|
238
|
+
max-height:100%;
|
|
239
|
+
}
|
|
240
|
+
.chip[data-size=s] .labelContainer{
|
|
241
|
+
padding-inline:var(--sn-primitive-dimension-4, 4px);
|
|
242
|
+
}
|
|
243
|
+
.chip[data-size=m]{
|
|
244
|
+
font-family:var(--sn-regular-label-l-fontFamily, var(--sn-brand-font-fontFamily-regular-label, var(--sn-primitive-fontFamily-brandA-sans, SB Sans Interface)));
|
|
245
|
+
font-weight:var(--sn-regular-label-l-fontWeight, var(--sn-theme-typography-fontWeight-regular-label-l, var(--sn-brand-font-fontWeight-light-regular-label-l, var(--sn-primitive-font-fontWeightValue-550, 550))));
|
|
246
|
+
line-height:var(--sn-regular-label-l-lineHeight, var(--sn-density-typography-roleLabel-lineHeightL, var(--sn-primitive-font-lineHeight-by20, 28px)));
|
|
247
|
+
font-size:var(--sn-regular-label-l-fontSize, var(--sn-density-typography-roleLabel-fontSizeL, var(--sn-primitive-font-fontSize-20, 20px)));
|
|
248
|
+
letter-spacing:var(--sn-regular-label-l-letterSpacing, var(--sn-primitive-font-letterSpacing-s, 0px));
|
|
249
|
+
paragraph-spacing:var(--sn-regular-label-l-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize14, 7px));
|
|
250
|
+
height:var(--sn-primitive-dimension-40, 40px);
|
|
251
|
+
padding-inline:var(--sn-primitive-dimension-8, 8px);
|
|
252
|
+
}
|
|
253
|
+
.chip[data-size=m] .icon{
|
|
254
|
+
display:flex;
|
|
255
|
+
flex-shrink:0;
|
|
256
|
+
align-items:center;
|
|
257
|
+
justify-content:center;
|
|
258
|
+
width:var(--sn-density-size-icon-s, var(--sn-primitive-dimension-24, 24px));
|
|
259
|
+
height:var(--sn-density-size-icon-s, var(--sn-primitive-dimension-24, 24px));
|
|
260
|
+
}
|
|
261
|
+
.chip[data-size=m] .icon > svg{
|
|
262
|
+
max-width:100%;
|
|
263
|
+
max-height:100%;
|
|
264
|
+
}
|
|
265
|
+
.chip[data-size=m] .labelContainer{
|
|
266
|
+
padding-inline:var(--sn-primitive-dimension-8, 8px);
|
|
267
|
+
}
|
|
268
|
+
.chip:focus-visible{
|
|
269
|
+
background-color:var(--sn-theme-color-primary-background1Level);
|
|
270
|
+
}
|
|
271
|
+
.chip[data-appearance=primary]{
|
|
272
|
+
border-color:var(--sn-theme-color-material-stateLayer-activated-default-filled, var(--sn-brand-color-state-activated-default-background, var(--sn-brandRole-color-brandA-backgroundActivatedDefault, rgba(56, 159, 116, 0.1490196078))));
|
|
273
|
+
}
|
|
274
|
+
.chip[data-appearance=primary] .icon,
|
|
275
|
+
.chip[data-appearance=primary] .label{
|
|
276
|
+
color:var(--sn-theme-color-primary-text, var(--sn-brand-color-primary-45, var(--sn-brandRole-color-brandA-45, var(--sn-primitive-color-brandA-45, #22775b))));
|
|
277
|
+
}
|
|
278
|
+
@media (hover: hover){
|
|
279
|
+
.chip[data-appearance=primary]:hover:not(:disabled, [data-disabled]){
|
|
280
|
+
border-color:var(--sn-theme-color-material-stateLayer-activated-hovered-filled, var(--sn-brand-color-state-activated-hovered-background, var(--sn-brandRole-color-brandA-backgroundActivatedHovered, rgba(56, 159, 116, 0.3490196078))));
|
|
281
|
+
background-color:var(--sn-theme-color-primary-background1Level, var(--sn-brand-color-primary-95, var(--sn-brandRole-color-brandA-95, var(--sn-primitive-color-brandA-95, #f5fdf8))));
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
.chip:focus-visible{
|
|
285
|
+
background-color:var(--sn-theme-color-neutral-background1Level);
|
|
286
|
+
}
|
|
287
|
+
.chip[data-appearance=neutral]{
|
|
288
|
+
border-color:var(--sn-theme-color-material-stateLayer-neutral-border-default-borderColor, var(--sn-brand-color-state-neutralBorder-forLightMode-default-borderColor, rgba(159, 166, 198, 0.3019607843)));
|
|
289
|
+
}
|
|
290
|
+
.chip[data-appearance=neutral] .icon,
|
|
291
|
+
.chip[data-appearance=neutral] .label{
|
|
292
|
+
color:var(--sn-theme-color-neutral-text, var(--sn-brand-color-neutral-45, var(--sn-primitive-color-gray-45, #81869c)));
|
|
293
|
+
}
|
|
294
|
+
@media (hover: hover){
|
|
295
|
+
.chip[data-appearance=neutral]:hover:not(:disabled, [data-disabled]){
|
|
296
|
+
border-color:var(--sn-theme-color-material-stateLayer-neutral-border-hovered-borderColor, var(--sn-brand-color-state-neutralBorder-forLightMode-hovered-borderColor, rgba(159, 166, 198, 0.6509803922)));
|
|
297
|
+
background-color:var(--sn-theme-color-neutral-background1Level, var(--sn-brand-color-neutral-95, var(--sn-primitive-color-gray-95, #fdfdfd)));
|
|
298
|
+
}
|
|
299
|
+
.chip[data-appearance=neutral]:hover:not(:disabled, [data-disabled]) .icon, .chip[data-appearance=neutral]:hover:not(:disabled, [data-disabled]) .label{
|
|
300
|
+
color:var(--sn-theme-color-available-version-textMain, var(--sn-brand-color-text-version-main, #41424e));
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.content{
|
|
305
|
+
position:relative;
|
|
306
|
+
z-index:1;
|
|
307
|
+
display:inline-flex;
|
|
308
|
+
align-items:center;
|
|
309
|
+
justify-content:center;
|
|
310
|
+
min-width:0;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.labelContainer{
|
|
314
|
+
display:inline-flex;
|
|
315
|
+
align-items:center;
|
|
316
|
+
justify-content:center;
|
|
317
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AiSuggestionParentProps } from './types.js';
|
|
2
|
+
type AiSuggestionParentInternalProps = AiSuggestionParentProps & {
|
|
3
|
+
/** Родительская группа раскрыта — управляет видимостью вложенной ветки */
|
|
4
|
+
shown?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare function AiSuggestionParent({ label, icon, size, disabled, expanded: expandedProp, defaultExpanded, onExpandedChange, items, onItemClick, className, shown: shownProp, ...rest }: AiSuggestionParentInternalProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { extractSupportProps, useUncontrolledProp } from '@cloud-ru/ds-utils';
|
|
3
|
+
import cn from 'classnames';
|
|
4
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
5
|
+
import { AiSuggestionSimple } from '../AiSuggestionSimple/index.js';
|
|
6
|
+
import { APPEARANCE, SIZE } from '../AiSuggestionSimple/constants.js';
|
|
7
|
+
import { AiSuggestionParentChip } from './AiSuggestionParentChip.js';
|
|
8
|
+
import { AnimatedExpandableItem, AnimatedTriggerWrap } from './animation/AnimatedExpandableItem.js';
|
|
9
|
+
import { TEST_IDS } from './constants.js';
|
|
10
|
+
import { AiSuggestionParentGroupProvider, useAiSuggestionParentGroup } from './context/AiSuggestionParentGroupContext.js';
|
|
11
|
+
import styles from './styles.module.css';
|
|
12
|
+
import { hasExclusiveParentGroup } from './utils/hasExclusiveParentGroup.js';
|
|
13
|
+
import { isNestedItem, isSuggestionItem } from './utils/itemGuards.js';
|
|
14
|
+
function renderSuggestionLeaf({ item, index, total, shown, size, onLeafClick }) {
|
|
15
|
+
const key = item.key ?? String(index);
|
|
16
|
+
return (_jsx(AnimatedExpandableItem, { index: index, total: total, shown: shown, children: _jsx(AiSuggestionSimple, { label: item.label, icon: item.icon, size: size, disabled: item.disabled, appearance: APPEARANCE.Primary, tabIndex: shown ? 0 : -1, onClick: (event) => {
|
|
17
|
+
event.stopPropagation();
|
|
18
|
+
item.onClick?.(event);
|
|
19
|
+
onLeafClick?.(event);
|
|
20
|
+
} }) }, key));
|
|
21
|
+
}
|
|
22
|
+
function useNestedExpandedState(groupKey, shown) {
|
|
23
|
+
const group = useAiSuggestionParentGroup();
|
|
24
|
+
const isGroupControlled = group !== null && groupKey !== undefined;
|
|
25
|
+
const [localExpanded, setLocalExpanded] = useState(false);
|
|
26
|
+
const expanded = isGroupControlled ? group.expandedKey === groupKey : localExpanded;
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (!shown) {
|
|
29
|
+
if (isGroupControlled && groupKey) {
|
|
30
|
+
group.collapseKey(groupKey);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
setLocalExpanded(false);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}, [group, groupKey, isGroupControlled, shown]);
|
|
37
|
+
const handleExpandedChange = useCallback((next) => {
|
|
38
|
+
if (isGroupControlled && groupKey) {
|
|
39
|
+
group.requestExpand(groupKey);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
setLocalExpanded(next);
|
|
43
|
+
}, [group, groupKey, isGroupControlled]);
|
|
44
|
+
return { expanded, handleExpandedChange };
|
|
45
|
+
}
|
|
46
|
+
function NestedAiSuggestionParent({ index, total, shown, node, size, groupKey, onItemClick, }) {
|
|
47
|
+
const { expanded, handleExpandedChange } = useNestedExpandedState(groupKey, shown);
|
|
48
|
+
const childShown = shown && expanded;
|
|
49
|
+
const items = node.items ?? [];
|
|
50
|
+
const nestedChildren = items.filter(isNestedItem);
|
|
51
|
+
const leaves = items.filter(isSuggestionItem);
|
|
52
|
+
const hasExclusiveGroup = hasExclusiveParentGroup(items);
|
|
53
|
+
const nestedContent = (_jsxs(_Fragment, { children: [nestedChildren.map((child, childIndex) => {
|
|
54
|
+
const childKey = child.key ?? `${node.label}-${child.label ?? childIndex}`;
|
|
55
|
+
return (_jsx(NestedAiSuggestionParent, { index: childIndex, total: nestedChildren.length, shown: childShown, node: child, size: size, groupKey: hasExclusiveGroup ? childKey : undefined, onItemClick: onItemClick }, childKey));
|
|
56
|
+
}), leaves.map((leaf, leafIndex) => renderSuggestionLeaf({
|
|
57
|
+
item: leaf,
|
|
58
|
+
index: leafIndex,
|
|
59
|
+
total: leaves.length,
|
|
60
|
+
shown: childShown,
|
|
61
|
+
size,
|
|
62
|
+
}))] }));
|
|
63
|
+
return (_jsxs(_Fragment, { children: [_jsx(AnimatedExpandableItem, { index: index, total: total, shown: shown, children: _jsx(AiSuggestionParentChip, { label: node.label, icon: node.icon, size: size, disabled: node.disabled, expanded: expanded, onExpandedChange: handleExpandedChange, tabIndex: shown ? 0 : -1 }) }), hasExclusiveGroup ? (_jsx(AiSuggestionParentGroupProvider, { children: nestedContent })) : (nestedContent)] }));
|
|
64
|
+
}
|
|
65
|
+
function wrapExclusiveItems(items, content) {
|
|
66
|
+
return hasExclusiveParentGroup(items) ? (_jsx(AiSuggestionParentGroupProvider, { children: content })) : (content);
|
|
67
|
+
}
|
|
68
|
+
export function AiSuggestionParent({ label = 'Label text', icon, size = SIZE.S, disabled = false, expanded: expandedProp, defaultExpanded = false, onExpandedChange, items = [], onItemClick, className, shown: shownProp = true, ...rest }) {
|
|
69
|
+
const [expanded, setExpanded] = useUncontrolledProp(expandedProp, defaultExpanded, onExpandedChange);
|
|
70
|
+
const shown = shownProp;
|
|
71
|
+
const childShown = shown && expanded;
|
|
72
|
+
const totalItems = items.length;
|
|
73
|
+
const hasExclusiveGroup = hasExclusiveParentGroup(items);
|
|
74
|
+
const rootTestId = rest['data-test-id'] ?? TEST_IDS.root;
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (!shown && expanded) {
|
|
77
|
+
setExpanded(false);
|
|
78
|
+
}
|
|
79
|
+
}, [shown, expanded, setExpanded]);
|
|
80
|
+
const handleExpandedChange = useCallback((next) => {
|
|
81
|
+
if (disabled) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
setExpanded(next);
|
|
85
|
+
}, [disabled, setExpanded]);
|
|
86
|
+
const renderItem = (item, index) => {
|
|
87
|
+
if (isNestedItem(item)) {
|
|
88
|
+
const key = item.key ?? String(index);
|
|
89
|
+
return (_jsx(NestedAiSuggestionParent, { index: index, total: totalItems, shown: childShown, node: item, size: size, groupKey: hasExclusiveGroup ? key : undefined, onItemClick: onItemClick }, key));
|
|
90
|
+
}
|
|
91
|
+
return renderSuggestionLeaf({
|
|
92
|
+
item,
|
|
93
|
+
index,
|
|
94
|
+
total: totalItems,
|
|
95
|
+
shown: childShown,
|
|
96
|
+
size,
|
|
97
|
+
onLeafClick: event => onItemClick?.(index, event),
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
return (_jsxs("div", { className: cn(styles.root, className), ...extractSupportProps(rest), "data-flatten": true, "data-test-id": rootTestId, children: [_jsx(AnimatedTriggerWrap, { children: _jsx(AiSuggestionParentChip, { label: label, icon: icon, size: size, disabled: disabled, expanded: expanded, onExpandedChange: handleExpandedChange, tabIndex: shown ? undefined : -1 }) }), wrapExclusiveItems(items, items.map(renderItem))] }));
|
|
101
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes, MouseEvent, ReactNode } from 'react';
|
|
2
|
+
import { Size } from '../AiSuggestionSimple/types.js';
|
|
3
|
+
export type AiSuggestionParentChipProps = {
|
|
4
|
+
label?: string;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
size?: Size;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
expanded?: boolean;
|
|
9
|
+
onExpandedChange?(expanded: boolean): void;
|
|
10
|
+
chevron?: ReactNode;
|
|
11
|
+
className?: string;
|
|
12
|
+
} & Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'> & {
|
|
13
|
+
onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
14
|
+
};
|
|
15
|
+
export declare const AiSuggestionParentChip: import("react").ForwardRefExoticComponent<{
|
|
16
|
+
label?: string;
|
|
17
|
+
icon?: ReactNode;
|
|
18
|
+
size?: Size;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
expanded?: boolean;
|
|
21
|
+
onExpandedChange?(expanded: boolean): void;
|
|
22
|
+
chevron?: ReactNode;
|
|
23
|
+
className?: string;
|
|
24
|
+
} & Omit<ButtonHTMLAttributes<HTMLButtonElement>, "onClick"> & {
|
|
25
|
+
onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
26
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronRightSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
3
|
+
import { extractSupportProps } from '@cloud-ru/ds-utils';
|
|
4
|
+
import cn from 'classnames';
|
|
5
|
+
import { forwardRef } from 'react';
|
|
6
|
+
import { SIZE } from '../AiSuggestionSimple/constants.js';
|
|
7
|
+
import { TEST_IDS } from './constants.js';
|
|
8
|
+
import styles from './styles.module.css';
|
|
9
|
+
export const AiSuggestionParentChip = forwardRef(function AiSuggestionParentChip({ label = 'Label text', icon, size = SIZE.S, disabled = false, expanded = false, onExpandedChange, chevron, className, type = 'button', onClick, ...rest }, ref) {
|
|
10
|
+
const handleClick = (event) => {
|
|
11
|
+
onClick?.(event);
|
|
12
|
+
if (event.defaultPrevented || disabled) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
onExpandedChange?.(!expanded);
|
|
16
|
+
};
|
|
17
|
+
return (_jsxs("button", { ref: ref, type: type, className: cn(styles.chip, className), ...extractSupportProps(rest), "data-size": size, "data-activated": expanded || undefined, "data-test-id": TEST_IDS.trigger, disabled: disabled, "aria-expanded": expanded, onClick: handleClick, children: [icon !== undefined && (_jsx("span", { className: styles.icon, "aria-hidden": true, children: icon })), label !== undefined && (_jsx("span", { className: styles.labelContainer, children: _jsx("span", { className: styles.label, children: label }) })), _jsx("span", { className: styles.chevron, "data-test-id": TEST_IDS.chevron, "aria-hidden": true, children: chevron ?? _jsx(ChevronRightSVG, { className: styles.chevronIcon, size: 24 }) })] }));
|
|
18
|
+
});
|