@fluentui-copilot/react-send-button 0.0.0-nightly-20251010-0406-7df7c6d1.1 → 0.0.0-nightly-20251013-0406-7c7739c8.1
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.json +3 -3
- package/CHANGELOG.md +4 -4
- package/dist/index.d.ts +70 -0
- package/lib/SendButton.js +1 -0
- package/lib/SendButton.js.map +1 -0
- package/lib/components/SendButton/SendButton.js +11 -0
- package/lib/components/SendButton/SendButton.js.map +1 -0
- package/lib/components/SendButton/SendButton.types.js +3 -0
- package/lib/components/SendButton/SendButton.types.js.map +1 -0
- package/lib/components/SendButton/buttonMotion.js +212 -0
- package/lib/components/SendButton/buttonMotion.js.map +1 -0
- package/lib/components/SendButton/index.js +4 -0
- package/lib/components/SendButton/index.js.map +1 -0
- package/lib/components/SendButton/renderSendButton.js +46 -0
- package/lib/components/SendButton/renderSendButton.js.map +1 -0
- package/lib/components/SendButton/useSendButton.js +111 -0
- package/lib/components/SendButton/useSendButton.js.map +1 -0
- package/lib/components/SendButton/useSendButtonStyles.styles.js +270 -0
- package/lib/components/SendButton/useSendButtonStyles.styles.js.map +1 -0
- package/lib/components/SendButton/useSendButtonStyles.styles.raw.js +224 -0
- package/lib/components/SendButton/useSendButtonStyles.styles.raw.js.map +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -0
- package/lib-commonjs/SendButton.js +28 -0
- package/lib-commonjs/SendButton.js.map +1 -0
- package/lib-commonjs/components/SendButton/SendButton.js +21 -0
- package/lib-commonjs/components/SendButton/SendButton.js.map +1 -0
- package/lib-commonjs/components/SendButton/SendButton.types.js +6 -0
- package/lib-commonjs/components/SendButton/SendButton.types.js.map +1 -0
- package/lib-commonjs/components/SendButton/buttonMotion.js +233 -0
- package/lib-commonjs/components/SendButton/buttonMotion.js.map +1 -0
- package/lib-commonjs/components/SendButton/index.js +31 -0
- package/lib-commonjs/components/SendButton/index.js.map +1 -0
- package/lib-commonjs/components/SendButton/renderSendButton.js +54 -0
- package/lib-commonjs/components/SendButton/renderSendButton.js.map +1 -0
- package/lib-commonjs/components/SendButton/useSendButton.js +114 -0
- package/lib-commonjs/components/SendButton/useSendButton.js.map +1 -0
- package/lib-commonjs/components/SendButton/useSendButtonStyles.styles.js +412 -0
- package/lib-commonjs/components/SendButton/useSendButtonStyles.styles.js.map +1 -0
- package/lib-commonjs/components/SendButton/useSendButtonStyles.styles.raw.js +240 -0
- package/lib-commonjs/components/SendButton/useSendButtonStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/index.js +28 -0
- package/lib-commonjs/index.js.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["SendButton.types.ts"],"sourcesContent":["import type { CopilotMode, DesignVersion } from '@fluentui-copilot/react-provider';\nimport type { ARIAButtonSlotProps } from '@fluentui/react-aria';\nimport type { ButtonProps, ButtonState, ComponentProps, ComponentState, Slot } from '@fluentui/react-components';\nimport type { PresenceMotionSlotProps } from '@fluentui/react-motion';\nexport type SendButtonSlots = {\n root: NonNullable<Slot<ARIAButtonSlotProps<'a'>>>;\n sendIcon: NonNullable<Slot<'span'>>;\n stopIcon?: Slot<'span'>;\n /** Stop button's circle background */\n stopBackground: NonNullable<Slot<'div'>>;\n sendButtonMotion: NonNullable<Slot<PresenceMotionSlotProps>>;\n stopButtonMotion: NonNullable<Slot<PresenceMotionSlotProps>>;\n stopBackgroundMotion: NonNullable<Slot<PresenceMotionSlotProps>>;\n};\n\n/**\n * SendButton Props\n */\nexport type SendButtonProps = ComponentProps<Partial<SendButtonSlots>> &\n Pick<ButtonProps, 'appearance' | 'disabled' | 'disabledFocusable' | 'iconPosition' | 'shape' | 'size'> &\n DesignVersion &\n CopilotMode & {\n /**\n * Checks whether query is sending.\n */\n isSending?: boolean;\n isSendIconFilled?: boolean;\n\n /*\n * Use alternate styles when dictation is active\n */\n isDictationActive?: boolean;\n };\n\n/**\n * State used in rendering SendButton\n */\nexport type SendButtonState = ComponentState<SendButtonSlots> &\n Pick<ButtonState, 'appearance' | 'disabled' | 'disabledFocusable' | 'iconPosition' | 'shape' | 'size'> &\n Pick<SendButtonProps, 'isSendIconFilled' | 'isSending'> &\n Pick<Required<SendButtonProps>, 'designVersion' | 'mode' | 'isDictationActive'> & {\n isButtonMotionRunning?: boolean;\n };\n"],"names":[],"rangeMappings":";;","mappings":"AAkCA;;CAEC"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
CircleButtonMotion: function() {
|
|
13
|
+
return CircleButtonMotion;
|
|
14
|
+
},
|
|
15
|
+
SendButtonMotion: function() {
|
|
16
|
+
return SendButtonMotion;
|
|
17
|
+
},
|
|
18
|
+
StopButtonMotion: function() {
|
|
19
|
+
return StopButtonMotion;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const _reactcomponents = require("@fluentui/react-components");
|
|
23
|
+
const scaleSend = 1.2;
|
|
24
|
+
const startScaleStop = 0.5;
|
|
25
|
+
const scaleStop = 1.2;
|
|
26
|
+
const startScaleCircle = 0.1;
|
|
27
|
+
const scaleCircle = 1.1;
|
|
28
|
+
const motionSpeedMultiplier = 1;
|
|
29
|
+
const sendMotion = ()=>{
|
|
30
|
+
const enterKeyframes = [
|
|
31
|
+
{
|
|
32
|
+
keyframes: [
|
|
33
|
+
{
|
|
34
|
+
transform: `scale(0)`
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
duration: 0
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
keyframes: [
|
|
41
|
+
{
|
|
42
|
+
transform: `scale(0)`
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
transform: `scale(${scaleSend})`
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
duration: _reactcomponents.motionTokens.durationNormal * motionSpeedMultiplier,
|
|
49
|
+
easing: _reactcomponents.motionTokens.curveDecelerateMax,
|
|
50
|
+
delay: _reactcomponents.motionTokens.durationSlow * motionSpeedMultiplier
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
keyframes: [
|
|
54
|
+
{
|
|
55
|
+
transform: `scale(${scaleSend})`
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
transform: 'scale(1)'
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
duration: _reactcomponents.motionTokens.durationSlow * motionSpeedMultiplier,
|
|
62
|
+
easing: _reactcomponents.motionTokens.curveDecelerateMid,
|
|
63
|
+
delay: (_reactcomponents.motionTokens.durationSlow + _reactcomponents.motionTokens.durationNormal) * motionSpeedMultiplier
|
|
64
|
+
}
|
|
65
|
+
];
|
|
66
|
+
const exitKeyframes = [
|
|
67
|
+
{
|
|
68
|
+
keyframes: [
|
|
69
|
+
{
|
|
70
|
+
transform: `scale(1)`
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
transform: `scale(0)`
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
duration: _reactcomponents.motionTokens.durationFast * motionSpeedMultiplier,
|
|
77
|
+
easing: _reactcomponents.motionTokens.curveDecelerateMid
|
|
78
|
+
}
|
|
79
|
+
];
|
|
80
|
+
return {
|
|
81
|
+
enter: enterKeyframes,
|
|
82
|
+
exit: exitKeyframes
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
const stopMotion = ()=>{
|
|
86
|
+
const enterKeyframes = [
|
|
87
|
+
{
|
|
88
|
+
keyframes: [
|
|
89
|
+
{
|
|
90
|
+
opacity: 0
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
duration: 0
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
keyframes: [
|
|
97
|
+
{
|
|
98
|
+
opacity: 1
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
duration: 0,
|
|
102
|
+
delay: 30 * motionSpeedMultiplier
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
keyframes: [
|
|
106
|
+
{
|
|
107
|
+
transform: `scale(${startScaleStop})`
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
transform: `scale(1)`
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
duration: _reactcomponents.motionTokens.durationSlower * motionSpeedMultiplier,
|
|
114
|
+
easing: _reactcomponents.motionTokens.curveDecelerateMid
|
|
115
|
+
}
|
|
116
|
+
];
|
|
117
|
+
const exitKeyframes = [
|
|
118
|
+
{
|
|
119
|
+
keyframes: [
|
|
120
|
+
{
|
|
121
|
+
transform: `scale(1)`
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
transform: `scale(${scaleStop})`
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
duration: _reactcomponents.motionTokens.durationFast * motionSpeedMultiplier,
|
|
128
|
+
easing: _reactcomponents.motionTokens.curveDecelerateMax,
|
|
129
|
+
delay: _reactcomponents.motionTokens.durationUltraFast * motionSpeedMultiplier
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
keyframes: [
|
|
133
|
+
{
|
|
134
|
+
transform: `scale(${scaleStop})`
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
transform: 'scale(0)'
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
duration: _reactcomponents.motionTokens.durationFaster,
|
|
141
|
+
easing: _reactcomponents.motionTokens.curveDecelerateMin,
|
|
142
|
+
delay: (_reactcomponents.motionTokens.durationUltraFast + _reactcomponents.motionTokens.durationFast) * motionSpeedMultiplier
|
|
143
|
+
}
|
|
144
|
+
];
|
|
145
|
+
return {
|
|
146
|
+
enter: enterKeyframes,
|
|
147
|
+
exit: exitKeyframes
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
const circleMotion = ()=>{
|
|
151
|
+
const enterKeyframes = [
|
|
152
|
+
{
|
|
153
|
+
keyframes: [
|
|
154
|
+
{
|
|
155
|
+
opacity: 0
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
duration: 0
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
keyframes: [
|
|
162
|
+
{
|
|
163
|
+
opacity: 0
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
opacity: 1
|
|
167
|
+
}
|
|
168
|
+
],
|
|
169
|
+
duration: 0,
|
|
170
|
+
delay: _reactcomponents.motionTokens.durationFaster * motionSpeedMultiplier
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
keyframes: [
|
|
174
|
+
{
|
|
175
|
+
transform: `scale(${startScaleCircle})`
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
transform: `scale(${scaleCircle})`
|
|
179
|
+
}
|
|
180
|
+
],
|
|
181
|
+
duration: _reactcomponents.motionTokens.durationSlow * motionSpeedMultiplier,
|
|
182
|
+
easing: _reactcomponents.motionTokens.curveDecelerateMax,
|
|
183
|
+
delay: _reactcomponents.motionTokens.durationFaster * motionSpeedMultiplier
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
keyframes: [
|
|
187
|
+
{
|
|
188
|
+
transform: `scale(${scaleCircle})`
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
transform: `scale(1)`
|
|
192
|
+
}
|
|
193
|
+
],
|
|
194
|
+
duration: _reactcomponents.motionTokens.durationNormal * motionSpeedMultiplier,
|
|
195
|
+
easing: _reactcomponents.motionTokens.curveDecelerateMin,
|
|
196
|
+
delay: (_reactcomponents.motionTokens.durationSlow + _reactcomponents.motionTokens.durationFaster) * motionSpeedMultiplier
|
|
197
|
+
}
|
|
198
|
+
];
|
|
199
|
+
const exitKeyframes = [
|
|
200
|
+
{
|
|
201
|
+
keyframes: [
|
|
202
|
+
{
|
|
203
|
+
transform: `scale(1)`
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
transform: `scale(${scaleCircle})`
|
|
207
|
+
}
|
|
208
|
+
],
|
|
209
|
+
duration: _reactcomponents.motionTokens.durationFast * motionSpeedMultiplier,
|
|
210
|
+
easing: _reactcomponents.motionTokens.curveDecelerateMax
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
keyframes: [
|
|
214
|
+
{
|
|
215
|
+
transform: `scale(${scaleCircle})`
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
transform: 'scale(0)'
|
|
219
|
+
}
|
|
220
|
+
],
|
|
221
|
+
duration: _reactcomponents.motionTokens.durationFaster * motionSpeedMultiplier,
|
|
222
|
+
easing: _reactcomponents.motionTokens.curveDecelerateMin,
|
|
223
|
+
delay: _reactcomponents.motionTokens.durationFast * motionSpeedMultiplier
|
|
224
|
+
}
|
|
225
|
+
];
|
|
226
|
+
return {
|
|
227
|
+
enter: enterKeyframes,
|
|
228
|
+
exit: exitKeyframes
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
const SendButtonMotion = (0, _reactcomponents.createPresenceComponent)(sendMotion);
|
|
232
|
+
const StopButtonMotion = (0, _reactcomponents.createPresenceComponent)(stopMotion);
|
|
233
|
+
const CircleButtonMotion = (0, _reactcomponents.createPresenceComponent)(circleMotion);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["buttonMotion.ts"],"sourcesContent":["import type { PresenceMotionFn } from '@fluentui/react-components';\nimport { createPresenceComponent, motionTokens } from '@fluentui/react-components';\n\nconst scaleSend = 1.2;\nconst startScaleStop = 0.5;\nconst scaleStop = 1.2;\nconst startScaleCircle = 0.1;\nconst scaleCircle = 1.1;\n\nconst motionSpeedMultiplier = 1;\n\nconst sendMotion: PresenceMotionFn = () => {\n const enterKeyframes = [\n {\n keyframes: [{ transform: `scale(0)` }],\n duration: 0,\n },\n {\n keyframes: [{ transform: `scale(0)` }, { transform: `scale(${scaleSend})` }],\n duration: motionTokens.durationNormal * motionSpeedMultiplier,\n easing: motionTokens.curveDecelerateMax,\n delay: motionTokens.durationSlow * motionSpeedMultiplier,\n },\n {\n keyframes: [{ transform: `scale(${scaleSend})` }, { transform: 'scale(1)' }],\n duration: motionTokens.durationSlow * motionSpeedMultiplier,\n easing: motionTokens.curveDecelerateMid,\n delay: (motionTokens.durationSlow + motionTokens.durationNormal) * motionSpeedMultiplier,\n },\n ];\n\n const exitKeyframes = [\n {\n keyframes: [{ transform: `scale(1)` }, { transform: `scale(0)` }],\n duration: motionTokens.durationFast * motionSpeedMultiplier,\n easing: motionTokens.curveDecelerateMid,\n },\n ];\n\n return {\n enter: enterKeyframes,\n exit: exitKeyframes,\n };\n};\n\nconst stopMotion: PresenceMotionFn = () => {\n const enterKeyframes = [\n {\n keyframes: [{ opacity: 0 }],\n duration: 0,\n },\n {\n keyframes: [{ opacity: 1 }],\n duration: 0,\n delay: 30 * motionSpeedMultiplier, // non-standard motion duration\n },\n {\n keyframes: [{ transform: `scale(${startScaleStop})` }, { transform: `scale(1)` }],\n duration: motionTokens.durationSlower * motionSpeedMultiplier,\n easing: motionTokens.curveDecelerateMid,\n },\n ];\n\n const exitKeyframes = [\n {\n keyframes: [{ transform: `scale(1)` }, { transform: `scale(${scaleStop})` }],\n duration: motionTokens.durationFast * motionSpeedMultiplier,\n easing: motionTokens.curveDecelerateMax,\n delay: motionTokens.durationUltraFast * motionSpeedMultiplier,\n },\n {\n keyframes: [{ transform: `scale(${scaleStop})` }, { transform: 'scale(0)' }],\n duration: motionTokens.durationFaster,\n easing: motionTokens.curveDecelerateMin,\n delay: (motionTokens.durationUltraFast + motionTokens.durationFast) * motionSpeedMultiplier,\n },\n ];\n\n return {\n enter: enterKeyframes,\n exit: exitKeyframes,\n };\n};\n\nconst circleMotion: PresenceMotionFn = () => {\n const enterKeyframes = [\n {\n keyframes: [{ opacity: 0 }],\n duration: 0,\n },\n {\n keyframes: [{ opacity: 0 }, { opacity: 1 }],\n duration: 0,\n delay: motionTokens.durationFaster * motionSpeedMultiplier,\n },\n {\n keyframes: [{ transform: `scale(${startScaleCircle})` }, { transform: `scale(${scaleCircle})` }],\n duration: motionTokens.durationSlow * motionSpeedMultiplier,\n easing: motionTokens.curveDecelerateMax,\n delay: motionTokens.durationFaster * motionSpeedMultiplier,\n },\n {\n keyframes: [{ transform: `scale(${scaleCircle})` }, { transform: `scale(1)` }],\n duration: motionTokens.durationNormal * motionSpeedMultiplier,\n easing: motionTokens.curveDecelerateMin,\n delay: (motionTokens.durationSlow + motionTokens.durationFaster) * motionSpeedMultiplier,\n },\n ];\n\n const exitKeyframes = [\n {\n keyframes: [{ transform: `scale(1)` }, { transform: `scale(${scaleCircle})` }],\n duration: motionTokens.durationFast * motionSpeedMultiplier,\n easing: motionTokens.curveDecelerateMax,\n },\n {\n keyframes: [{ transform: `scale(${scaleCircle})` }, { transform: 'scale(0)' }],\n duration: motionTokens.durationFaster * motionSpeedMultiplier,\n easing: motionTokens.curveDecelerateMin,\n delay: motionTokens.durationFast * motionSpeedMultiplier,\n },\n ];\n\n return {\n enter: enterKeyframes,\n exit: exitKeyframes,\n };\n};\nexport const SendButtonMotion: ReturnType<typeof createPresenceComponent<{}>> = createPresenceComponent(sendMotion);\nexport const StopButtonMotion: ReturnType<typeof createPresenceComponent<{}>> = createPresenceComponent(stopMotion);\nexport const CircleButtonMotion: ReturnType<typeof createPresenceComponent<{}>> = createPresenceComponent(circleMotion);\n"],"names":["CircleButtonMotion","SendButtonMotion","StopButtonMotion","scaleSend","startScaleStop","scaleStop","startScaleCircle","scaleCircle","motionSpeedMultiplier","sendMotion","enterKeyframes","keyframes","transform","duration","motionTokens","durationNormal","easing","curveDecelerateMax","delay","durationSlow","curveDecelerateMid","exitKeyframes","durationFast","enter","exit","stopMotion","opacity","durationSlower","durationUltraFast","durationFaster","curveDecelerateMin","circleMotion","createPresenceComponent"],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F,6BAAAA,CAAaG,kBAAkB;QACzC;QACA;YACEN,WAAW;gBAAC;oBAAEC,WAAW,CAAC,MAAM,EAAEL,YAAY,CAAC,CAAC;gBAAC;gBAAG;oBAAEK,WAAW;gBAAW;aAAE;YAC9EC,UAAUC,6BAAAA,CAAae,cAAc,GAAGrB;YACxCQ,QAAQF,6BAAAA,CAAagB,kBAAkB;YACvCZ,OAAOJ,6BAAAA,CAAaQ,YAAY,GAAGd;QACrC;KACD;IAED,OAAO;QACLe,OAAOb;QACPc,MAAMH;IACR;AACF;AACO,MAAMpB,mBAAmE+B,IAAAA,wCAAAA,EAAwBvB;AACjG,MAAMP,mBAAmE8B,IAAAA,wCAAAA,EAAwBP;AACjG,MAAMzB,qBAAqEgC,IAAAA,wCAAAA,EAAwBD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
SendButton: function() {
|
|
13
|
+
return _SendButton.SendButton;
|
|
14
|
+
},
|
|
15
|
+
renderSendButton_unstable: function() {
|
|
16
|
+
return _renderSendButton.renderSendButton_unstable;
|
|
17
|
+
},
|
|
18
|
+
sendButtonClassNames: function() {
|
|
19
|
+
return _useSendButtonStylesstyles.sendButtonClassNames;
|
|
20
|
+
},
|
|
21
|
+
useSendButtonStyles_unstable: function() {
|
|
22
|
+
return _useSendButtonStylesstyles.useSendButtonStyles_unstable;
|
|
23
|
+
},
|
|
24
|
+
useSendButton_unstable: function() {
|
|
25
|
+
return _useSendButton.useSendButton_unstable;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const _SendButton = require("./SendButton");
|
|
29
|
+
const _renderSendButton = require("./renderSendButton");
|
|
30
|
+
const _useSendButton = require("./useSendButton");
|
|
31
|
+
const _useSendButtonStylesstyles = require("./useSendButtonStyles.styles");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export { SendButton } from './SendButton';\nexport type { SendButtonProps, SendButtonSlots, SendButtonState } from './SendButton.types';\nexport { renderSendButton_unstable } from './renderSendButton';\nexport { useSendButton_unstable } from './useSendButton';\nexport { sendButtonClassNames, useSendButtonStyles_unstable } from './useSendButtonStyles.styles';\n"],"names":["SendButton","renderSendButton_unstable","sendButtonClassNames","useSendButtonStyles_unstable","useSendButton_unstable"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAASA,UAAU;eAAVA,sBAAU;;IAEVC,yBAAyB;eAAzBA,2CAAyB;;IAEzBC,oBAAoB;eAApBA,+CAAoB;;IAAEC,4BAA4B;eAA5BA,uDAA4B;;IADlDC,sBAAsB;eAAtBA,qCAAsB;;;4BAHJ;kCAEe;+BACH;2CAC4B"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "renderSendButton_unstable", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return renderSendButton_unstable;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _jsxruntime = require("@fluentui/react-jsx-runtime/jsx-runtime");
|
|
12
|
+
const _reactcomponents = require("@fluentui/react-components");
|
|
13
|
+
const renderSendButton_unstable = (state)=>{
|
|
14
|
+
if (state.designVersion === 'next') {
|
|
15
|
+
return renderSendButtonNext(state);
|
|
16
|
+
}
|
|
17
|
+
return renderSendButtonCurrent(state);
|
|
18
|
+
};
|
|
19
|
+
function renderSendButtonCurrent(state) {
|
|
20
|
+
(0, _reactcomponents.assertSlots)(state);
|
|
21
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(state.root, {
|
|
22
|
+
children: [
|
|
23
|
+
state.stopIcon && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
24
|
+
children: [
|
|
25
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(state.stopBackgroundMotion, {
|
|
26
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(state.stopBackground, {})
|
|
27
|
+
}),
|
|
28
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(state.stopButtonMotion, {
|
|
29
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(state.stopIcon, {})
|
|
30
|
+
})
|
|
31
|
+
]
|
|
32
|
+
}),
|
|
33
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(state.sendButtonMotion, {
|
|
34
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(state.sendIcon, {})
|
|
35
|
+
})
|
|
36
|
+
]
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function renderSendButtonNext(state) {
|
|
40
|
+
(0, _reactcomponents.assertSlots)(state);
|
|
41
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(state.root, {
|
|
42
|
+
children: [
|
|
43
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(state.stopBackgroundMotion, {
|
|
44
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(state.stopBackground, {})
|
|
45
|
+
}),
|
|
46
|
+
state.stopIcon && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.stopButtonMotion, {
|
|
47
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(state.stopIcon, {})
|
|
48
|
+
}),
|
|
49
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(state.sendButtonMotion, {
|
|
50
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(state.sendIcon, {})
|
|
51
|
+
})
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["renderSendButton.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-components';\nimport type { JSXElement } from '@fluentui/react-components';\nimport type { SendButtonState, SendButtonSlots } from './SendButton.types';\n\n/**\n * Render the final JSX of SendButton\n */\nexport const renderSendButton_unstable = (state: SendButtonState): JSXElement => {\n if (state.designVersion === 'next') {\n return renderSendButtonNext(state);\n }\n\n return renderSendButtonCurrent(state);\n};\n\nfunction renderSendButtonCurrent(state: SendButtonState): JSXElement {\n assertSlots<SendButtonSlots>(state);\n\n return (\n <state.root>\n {state.stopIcon && (\n <>\n <state.stopBackgroundMotion>\n <state.stopBackground />\n </state.stopBackgroundMotion>\n <state.stopButtonMotion>\n <state.stopIcon />\n </state.stopButtonMotion>\n </>\n )}\n <state.sendButtonMotion>\n <state.sendIcon />\n </state.sendButtonMotion>\n </state.root>\n );\n}\n\nfunction renderSendButtonNext(state: SendButtonState): JSXElement {\n assertSlots<SendButtonSlots>(state);\n\n return (\n <state.root>\n <state.stopBackgroundMotion>\n <state.stopBackground />\n </state.stopBackgroundMotion>\n {state.stopIcon && (\n <state.stopButtonMotion>\n <state.stopIcon />\n </state.stopButtonMotion>\n )}\n <state.sendButtonMotion>\n <state.sendIcon />\n </state.sendButtonMotion>\n </state.root>\n );\n}\n"],"names":["renderSendButton_unstable","state","designVersion","renderSendButtonNext","renderSendButtonCurrent","assertSlots","_jsxs","root","stopIcon","_Fragment","_jsx","stopBackgroundMotion","stopBackground","stopButtonMotion","sendButtonMotion","sendIcon"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAUaA;;;eAAAA;;;4BATb;iCAE4B;AAOrB,MAAMA,4BAA4B,CAACC;IACxC,IAAIA,MAAMC,aAAa,KA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__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "useSendButton_unstable", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return useSendButton_unstable;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
|
+
const _reactcomponents = require("@fluentui/react-components");
|
|
14
|
+
const _buttonMotion = require("./buttonMotion");
|
|
15
|
+
const _reacticons = require("@fluentui/react-icons");
|
|
16
|
+
const _reactmotion = require("@fluentui/react-motion");
|
|
17
|
+
const _reactprovider = require("@fluentui-copilot/react-provider");
|
|
18
|
+
const SendIcon = (0, _reacticons.bundleIcon)(_reacticons.SendFilled, _reacticons.SendRegular);
|
|
19
|
+
const useSendButton_unstable = (props, ref)=>{
|
|
20
|
+
/** Used to apply/remove styles when button is animating */ const [isSendMotionRunning, setIsSendMotionRunning] = _react.useState(false);
|
|
21
|
+
const [isStopMotionRunning, setIsStopMotionRunning] = _react.useState(false);
|
|
22
|
+
const isButtonMotionRunning = isSendMotionRunning || isStopMotionRunning;
|
|
23
|
+
const designVersion = (0, _reactprovider.useDesignVersion)(props.designVersion);
|
|
24
|
+
const mode = (0, _reactprovider.useCopilotMode)(props.mode);
|
|
25
|
+
const [visible, setVisible] = _react.useState(false);
|
|
26
|
+
const mountRef = _react.useCallback((elem)=>{
|
|
27
|
+
if (elem) {
|
|
28
|
+
setVisible(true);
|
|
29
|
+
} else {
|
|
30
|
+
setVisible(false);
|
|
31
|
+
}
|
|
32
|
+
}, []);
|
|
33
|
+
const finalRef = (0, _reactcomponents.useMergedRefs)(ref, mountRef);
|
|
34
|
+
const buttonState = (0, _reactcomponents.useButton_unstable)({
|
|
35
|
+
shape: designVersion === 'next' ? 'circular' : undefined,
|
|
36
|
+
...props,
|
|
37
|
+
appearance: 'transparent',
|
|
38
|
+
'aria-disabled': props.disabled ? true : undefined,
|
|
39
|
+
type: 'submit'
|
|
40
|
+
}, finalRef);
|
|
41
|
+
const icon = (()=>{
|
|
42
|
+
if (designVersion === 'next') {
|
|
43
|
+
return mode === 'canvas' ? /*#__PURE__*/ _react.createElement(_reacticons.ArrowRight20Filled, null) : /*#__PURE__*/ _react.createElement(_reacticons.ArrowRight16Filled, null);
|
|
44
|
+
} else {
|
|
45
|
+
if (props.isSendIconFilled || isButtonMotionRunning) {
|
|
46
|
+
return /*#__PURE__*/ _react.createElement(_reacticons.SendFilled, null);
|
|
47
|
+
} else {
|
|
48
|
+
return /*#__PURE__*/ _react.createElement(SendIcon, null);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
})();
|
|
52
|
+
var _props_isDictationActive;
|
|
53
|
+
const state = {
|
|
54
|
+
...buttonState,
|
|
55
|
+
components: {
|
|
56
|
+
root: 'button',
|
|
57
|
+
sendIcon: 'span',
|
|
58
|
+
stopIcon: 'span',
|
|
59
|
+
stopBackground: 'div',
|
|
60
|
+
sendButtonMotion: _buttonMotion.SendButtonMotion,
|
|
61
|
+
stopButtonMotion: _buttonMotion.StopButtonMotion,
|
|
62
|
+
stopBackgroundMotion: _buttonMotion.CircleButtonMotion
|
|
63
|
+
},
|
|
64
|
+
root: buttonState.root,
|
|
65
|
+
sendIcon: _reactcomponents.slot.always(props.sendIcon, {
|
|
66
|
+
elementType: 'span',
|
|
67
|
+
defaultProps: {
|
|
68
|
+
children: icon
|
|
69
|
+
}
|
|
70
|
+
}),
|
|
71
|
+
stopIcon: _reactcomponents.slot.optional(props.stopIcon, {
|
|
72
|
+
elementType: 'span',
|
|
73
|
+
defaultProps: {
|
|
74
|
+
children: designVersion === 'next' ? mode === 'canvas' ? /*#__PURE__*/ _react.createElement(_reacticons.Stop20Filled, null) : /*#__PURE__*/ _react.createElement(_reacticons.Stop16Filled, null) : /*#__PURE__*/ _react.createElement(_reacticons.Stop16Filled, null)
|
|
75
|
+
},
|
|
76
|
+
renderByDefault: true
|
|
77
|
+
}),
|
|
78
|
+
stopBackground: _reactcomponents.slot.always(props.stopBackground, {
|
|
79
|
+
elementType: 'div'
|
|
80
|
+
}),
|
|
81
|
+
sendButtonMotion: (0, _reactmotion.presenceMotionSlot)(props.sendButtonMotion, {
|
|
82
|
+
elementType: _buttonMotion.SendButtonMotion,
|
|
83
|
+
defaultProps: {
|
|
84
|
+
visible: !props.isSending,
|
|
85
|
+
unmountOnExit: true,
|
|
86
|
+
onMotionFinish: ()=>setIsSendMotionRunning(false),
|
|
87
|
+
onMotionStart: ()=>setIsSendMotionRunning(true)
|
|
88
|
+
}
|
|
89
|
+
}),
|
|
90
|
+
stopButtonMotion: (0, _reactmotion.presenceMotionSlot)(props.stopButtonMotion, {
|
|
91
|
+
elementType: _buttonMotion.StopButtonMotion,
|
|
92
|
+
defaultProps: {
|
|
93
|
+
visible: props.isSending,
|
|
94
|
+
unmountOnExit: true,
|
|
95
|
+
onMotionFinish: ()=>setIsStopMotionRunning(false),
|
|
96
|
+
onMotionStart: ()=>setIsStopMotionRunning(true)
|
|
97
|
+
}
|
|
98
|
+
}),
|
|
99
|
+
stopBackgroundMotion: (0, _reactmotion.presenceMotionSlot)(props.stopBackgroundMotion, {
|
|
100
|
+
elementType: _buttonMotion.CircleButtonMotion,
|
|
101
|
+
defaultProps: {
|
|
102
|
+
visible: designVersion === 'next' ? visible : props.isSending,
|
|
103
|
+
unmountOnExit: true
|
|
104
|
+
}
|
|
105
|
+
}),
|
|
106
|
+
isButtonMotionRunning,
|
|
107
|
+
isDictationActive: (_props_isDictationActive = props.isDictationActive) !== null && _props_isDictationActive !== void 0 ? _props_isDictationActive : false,
|
|
108
|
+
isSendIconFilled: props.isSendIconFilled,
|
|
109
|
+
isSending: props.isSending,
|
|
110
|
+
designVersion,
|
|
111
|
+
mode
|
|
112
|
+
};
|
|
113
|
+
return state;
|
|
114
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useSendButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { ButtonProps } from '@fluentui/react-components';\nimport { slot, useButton_unstable, useMergedRefs } from '@fluentui/react-components';\nimport type { SendButtonProps, SendButtonState } from './SendButton.types';\n\nimport { CircleButtonMotion, SendButtonMotion, StopButtonMotion } from './buttonMotion';\nimport {\n bundleIcon,\n SendFilled,\n SendRegular,\n Stop16Filled,\n ArrowRight20Filled,\n Stop20Filled,\n ArrowRight16Filled,\n} from '@fluentui/react-icons';\nimport { presenceMotionSlot } from '@fluentui/react-motion';\nimport { useCopilotMode, useDesignVersion } from '@fluentui-copilot/react-provider';\n\nconst SendIcon = bundleIcon(SendFilled, SendRegular);\n\n/**\n * Create the state required to render SendButton.\n *\n * The returned state can be modified with hooks such as useSendButtonStyles_unstable,\n * before being passed to renderSendButton_unstable.\n *\n * @param props - props from this instance of SendButton\n * @param ref - reference to root HTMLElement of SendButton\n */\nexport const useSendButton_unstable = (\n props: SendButtonProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>,\n): SendButtonState => {\n /** Used to apply/remove styles when button is animating */\n const [isSendMotionRunning, setIsSendMotionRunning] = React.useState(false);\n const [isStopMotionRunning, setIsStopMotionRunning] = React.useState(false);\n const isButtonMotionRunning = isSendMotionRunning || isStopMotionRunning;\n\n const designVersion = useDesignVersion(props.designVersion);\n const mode = useCopilotMode(props.mode);\n\n const [visible, setVisible] = React.useState(false);\n const mountRef = React.useCallback((elem: HTMLElement | null) => {\n if (elem) {\n setVisible(true);\n } else {\n setVisible(false);\n }\n }, []);\n const finalRef = useMergedRefs(ref, mountRef);\n const buttonState = useButton_unstable(\n {\n shape: designVersion === 'next' ? 'circular' : undefined,\n ...(props as ButtonProps),\n appearance: 'transparent',\n 'aria-disabled': props.disabled ? true : undefined,\n type: 'submit',\n },\n finalRef,\n );\n\n const icon = (() => {\n if (designVersion === 'next') {\n return mode === 'canvas' ? <ArrowRight20Filled /> : <ArrowRight16Filled />;\n } else {\n if (props.isSendIconFilled || isButtonMotionRunning) {\n return <SendFilled />;\n } else {\n return <SendIcon />;\n }\n }\n })();\n\n const state: SendButtonState = {\n ...buttonState,\n components: {\n root: 'button',\n sendIcon: 'span',\n stopIcon: 'span',\n stopBackground: 'div',\n sendButtonMotion: SendButtonMotion,\n stopButtonMotion: StopButtonMotion,\n stopBackgroundMotion: CircleButtonMotion,\n },\n root: buttonState.root,\n sendIcon: slot.always(props.sendIcon, {\n elementType: 'span',\n defaultProps: {\n children: icon,\n },\n }),\n stopIcon: slot.optional(props.stopIcon, {\n elementType: 'span',\n defaultProps: {\n children: designVersion === 'next' ? mode === 'canvas' ? <Stop20Filled /> : <Stop16Filled /> : <Stop16Filled />,\n },\n renderByDefault: true,\n }),\n stopBackground: slot.always(props.stopBackground, { elementType: 'div' }),\n sendButtonMotion: presenceMotionSlot<{}>(props.sendButtonMotion, {\n elementType: SendButtonMotion,\n defaultProps: {\n visible: !props.isSending,\n unmountOnExit: true,\n onMotionFinish: () => setIsSendMotionRunning(false),\n onMotionStart: () => setIsSendMotionRunning(true),\n },\n }),\n stopButtonMotion: presenceMotionSlot<{}>(props.stopButtonMotion, {\n elementType: StopButtonMotion,\n defaultProps: {\n visible: props.isSending,\n unmountOnExit: true,\n onMotionFinish: () => setIsStopMotionRunning(false),\n onMotionStart: () => setIsStopMotionRunning(true),\n },\n }),\n stopBackgroundMotion: presenceMotionSlot<{}>(props.stopBackgroundMotion, {\n elementType: CircleButtonMotion,\n defaultProps: {\n visible: designVersion === 'next' ? visible : props.isSending,\n unmountOnExit: true,\n },\n }),\n isButtonMotionRunning,\n isDictationActive: props.isDictationActive ?? false,\n isSendIconFilled: props.isSendIconFilled,\n isSending: props.isSending,\n designVersion,\n mode,\n };\n\n return state;\n};\n"],"names":["useSendButton_unstable","SendIcon","bundleIcon","SendFilled","SendRegular","props","ref","isSendMotionRunning","setIsSendMotionRunning","React","useState","isStopMotionRunning","setIsStopMotionRunning","isButtonMotionRunning","designVersion","useDesignVersion","mode","useCopilotMode","visible","setVisible","mountRef","useCallback","elem","finalRef","useMergedRefs","buttonState","useButton_unstable","shape","undefined","appearance","disabled","type","icon","createElement","ArrowRight20Filled","ArrowRight16Filled","isSendIconFilled","state","components","root","sendIcon","stopIcon","stopBackground","sendButtonMotion","SendButtonMotion","stopButtonMotion","StopButtonMotion","stopBackgroundMotion","CircleButtonMotion","slot","always","elementType","defaultProps","children","optional","Stop20Filled","Stop16Filled","renderByDefault","presenceMotionSlot","isSending","unmountOnExit","onMotionFinish","onMotionStart","isDictationActive"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BA6BaA;;;eAAAA;;;;iEA7BU;iCAEiC;8BAGe;4BAShE;6BAC4B;+BACc;AAEjD,MAAMC,WAAWC,IAAAA,sBAAAA,EAAWC,sBAAAA,EAAYC,uBAAAA;AAWjC,MAAMJ,yBAAyB,CACpCK,OACAC;IAEA,yDAAyD,GACzD,MAAM,CAACC,qBAAqBC,uBAAuB,GAAGC,OAAMC,QAAQ,CAAC;IACrE,MAAM,CAACC,qBAAqBC,uBAAuB,GAAGH,OAAMC,QAAQ,CAAC;IACrE,MAAMG,wBAAwBN,uBAAuBI;IAErD,MAAMG,gBAAgBC,IAAAA,+BAAAA,EAAiBV,MAAMS,aAAa;IAC1D,MAAME,OAAOC,IAAAA,6BAAAA,EAAeZ,MAAMW,IAAI;IAEtC,MAAM,CAACE,SAASC,WAAW,GAAGV,OAAMC,QAAQ,CAAC;IAC7C,MAAMU,WAAWX,OAAMY,WAAW,CAAC,CAACC;QAClC,IAAIA,MAAM;YACRH,WAAW;QACb,OAAO;YACLA,WAAW;QACb;IACF,GAAG,EAAE;IACL,MAAMI,WAAWC,IAAAA,8BAAAA,EAAclB,KAAKc;IACpC,MAAMK,cAAcC,IAAAA,m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