Skip to content

Commit bb5898e

Browse files
authored
[HIGH] Incorporated PR comments of 4846 (#4857)
* Rename to OrgSchema from SchemaOrg * Rename to OrgSchema * Remove unnecessary handleXXX * Remove unnecessary typings * Remove unnecessary undefined * Remove commented CSS * Remove unnecessary handleXXX * Add CSSTokens and rename to CSS custom properties * Rename to CSSTokens and CSS custom properties * Type out useStyleSet * Add entry * Freeze arrays * Typo * Remove as const * Move typecasting outside
1 parent d62393e commit bb5898e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+173
-187
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2727
- Resolves [#4840](https://github.com/microsoft/BotFramework-WebChat/issues/4840). Added feedback buttons in activity status, by [@compulim](https://github.com/compulim), in PR [#4846](https://github.com/microsoft/BotFramework-WebChat/pull/4846)
2828
- Resolves [#4841](https://github.com/microsoft/BotFramework-WebChat/issues/4841). Added link definitions UI in Markdown, by [@compulim](https://github.com/compulim), in PR [#4846](https://github.com/microsoft/BotFramework-WebChat/pull/4846)
2929
- Resolves [#4842](https://github.com/microsoft/BotFramework-WebChat/issues/4842). Added provenance in activity status, by [@compulim](https://github.com/compulim), in PR [#4846](https://github.com/microsoft/BotFramework-WebChat/pull/4846)
30+
- Resolves [#4856](https://github.com/microsoft/BotFramework-WebChat/issues/4856). Added types for `useStyleSet`, by [@compulim](https://github.com/compulim), in PR [#4857](https://github.com/microsoft/BotFramework-WebChat/pull/4857)
3031

3132
## [4.15.9] - 2023-08-25
3233

packages/bundle/src/adaptiveCards/Attachment/AdaptiveCardRenderer.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ import useAdaptiveCardsPackage from '../hooks/useAdaptiveCardsPackage';
2525
import useDisabledModEffect from './AdaptiveCardHacks/useDisabledModEffect';
2626
import usePersistValuesModEffect from './AdaptiveCardHacks/usePersistValuesModEffect';
2727
import useRoleModEffect from './AdaptiveCardHacks/useRoleModEffect';
28+
import useStyleSet from '../../hooks/useStyleSet';
2829
import useValueRef from './AdaptiveCardHacks/private/useValueRef';
2930

3031
const { ErrorBox } = Components;
31-
const { useDisabled, useLocalizer, usePerformCardAction, useRenderMarkdownAsHTML, useScrollToEnd, useStyleSet } = hooks;
32+
const { useDisabled, useLocalizer, usePerformCardAction, useRenderMarkdownAsHTML, useScrollToEnd } = hooks;
3233

3334
const node_env = process.env.node_env || process.env.NODE_ENV;
3435

packages/bundle/src/adaptiveCards/Attachment/AnimationCardContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/* eslint react/no-array-index-key: "off" */
22

3-
import { Components, hooks } from 'botframework-webchat-component';
3+
import { Components } from 'botframework-webchat-component';
44
import PropTypes from 'prop-types';
55
import React, { FC } from 'react';
66
import type { DirectLineAnimationCard } from 'botframework-webchat-core';
77

88
import CommonCard from './CommonCard';
9+
import useStyleSet from '../../hooks/useStyleSet';
910

1011
const { ImageContent, VideoContent } = Components;
11-
const { useStyleSet } = hooks;
1212

1313
type AnimationCardContentProps = {
1414
actionPerformedClassName?: string;

packages/bundle/src/adaptiveCards/Attachment/AudioCardContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/* eslint react/no-array-index-key: "off" */
22

3-
import { Components, hooks } from 'botframework-webchat-component';
3+
import { Components } from 'botframework-webchat-component';
44
import PropTypes from 'prop-types';
55
import React, { FC } from 'react';
66
import type { DirectLineAudioCard } from 'botframework-webchat-core';
77

88
import CommonCard from './CommonCard';
9+
import useStyleSet from '../../hooks/useStyleSet';
910

1011
const { AudioContent } = Components;
11-
const { useStyleSet } = hooks;
1212

1313
type AudioCardContentProps = {
1414
actionPerformedClassName?: string;

packages/bundle/src/adaptiveCards/Attachment/SignInCardContent.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import { hooks } from 'botframework-webchat-component';
21
import PropTypes from 'prop-types';
32
import React, { FC } from 'react';
43
import type { DirectLineSignInCard } from 'botframework-webchat-core';
54

65
import CommonCard from './CommonCard';
7-
8-
const { useStyleSet } = hooks;
6+
import useStyleSet from '../../hooks/useStyleSet';
97

108
type SignInCardContentProps = {
119
actionPerformedClassName?: string;

packages/bundle/src/adaptiveCards/Attachment/VideoCardContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/* eslint react/no-array-index-key: "off" */
22

3-
import { Components, hooks } from 'botframework-webchat-component';
3+
import { Components } from 'botframework-webchat-component';
44
import PropTypes from 'prop-types';
55
import React, { FC } from 'react';
66
import type { DirectLineVideoCard } from 'botframework-webchat-core';
77

88
import CommonCard from './CommonCard';
9+
import useStyleSet from '../../hooks/useStyleSet';
910

10-
const { useStyleSet } = hooks;
1111
const { VideoContent } = Components;
1212

1313
type VideoCardContentProps = {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { hooks } from 'botframework-webchat-component';
2+
3+
import type AdaptiveCardsStyleSet from '../adaptiveCards/AdaptiveCardsStyleSet';
4+
5+
const useMinimalStyleSet = hooks.useStyleSet;
6+
7+
type MinimalStyleSet = ReturnType<typeof useMinimalStyleSet>[0];
8+
9+
export default function useStyleSet(): readonly [MinimalStyleSet & AdaptiveCardsStyleSet] {
10+
const [styleOptions] = useMinimalStyleSet();
11+
12+
return Object.freeze([styleOptions as MinimalStyleSet & AdaptiveCardsStyleSet] as const);
13+
}

packages/bundle/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import ThumbnailCardContent from './adaptiveCards/Attachment/ThumbnailCardConten
2828
import useAdaptiveCardsHostConfig from './adaptiveCards/hooks/useAdaptiveCardsHostConfig';
2929
import useAdaptiveCardsPackage from './adaptiveCards/hooks/useAdaptiveCardsPackage';
3030
import useStyleOptions from './hooks/useStyleOptions';
31+
import useStyleSet from './hooks/useStyleSet';
3132
import VideoCardContent from './adaptiveCards/Attachment/VideoCardContent';
3233

3334
const renderWebChat = coreRenderWebChat.bind(null, ReactWebChat);
@@ -56,7 +57,8 @@ const patchedHooks = {
5657
...hooks,
5758
useAdaptiveCardsHostConfig,
5859
useAdaptiveCardsPackage,
59-
useStyleOptions
60+
useStyleOptions,
61+
useStyleSet
6062
};
6163

6264
const AdditionalComponents = {

packages/component/src/ActivityStatus/OthersActivityStatus.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { type WebChatActivity } from 'botframework-webchat-core';
22
import classNames from 'classnames';
33
import React, { memo, type ReactNode, useMemo } from 'react';
44

5-
import { isReplyAction, type ReplyAction } from '../types/external/SchemaOrg/ReplyAction';
6-
import { isThing, type Thing } from '../types/external/SchemaOrg/Thing';
7-
import { isVoteAction, type VoteAction } from '../types/external/SchemaOrg/VoteAction';
5+
import { isReplyAction, type ReplyAction } from '../types/external/OrgSchema/ReplyAction';
6+
import { isThing, type Thing } from '../types/external/OrgSchema/Thing';
7+
import { isVoteAction, type VoteAction } from '../types/external/OrgSchema/VoteAction';
88
import { type TypeOfArray } from '../types/internal/TypeOfArray';
99
import Feedback from './private/Feedback/Feedback';
1010
import Originator from './private/Originator';

packages/component/src/ActivityStatus/private/Feedback/Feedback.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { hooks } from 'botframework-webchat-api';
22
import { useRefFrom } from 'use-ref-from';
3-
import React, { Fragment, memo, type PropsWithChildren, useCallback, useState, useEffect } from 'react';
3+
import React, { Fragment, memo, type PropsWithChildren, useState, useEffect } from 'react';
44

5-
import { type VoteAction } from '../../../types/external/SchemaOrg/VoteAction';
5+
import { type VoteAction } from '../../../types/external/OrgSchema/VoteAction';
66
import FeedbackVoteButton from './private/VoteButton';
77

88
const { usePonyfill, usePostActivity } = hooks;
@@ -15,14 +15,9 @@ const DEBOUNCE_TIMEOUT = 500;
1515

1616
const Feedback = memo(({ voteActions }: Props) => {
1717
const [{ clearTimeout, setTimeout }] = usePonyfill();
18-
const [selectedVoteAction, setSelectedVoteAction] = useState<VoteAction | undefined>(undefined);
18+
const [selectedVoteAction, setSelectedVoteAction] = useState<VoteAction | undefined>();
1919
const postActivity = usePostActivity();
2020

21-
const handleChange = useCallback<(voteAction: VoteAction) => void>(
22-
voteAction => setSelectedVoteAction(voteAction),
23-
[setSelectedVoteAction]
24-
);
25-
2621
const postActivityRef = useRefFrom(postActivity);
2722

2823
useEffect(() => {
@@ -48,7 +43,7 @@ const Feedback = memo(({ voteActions }: Props) => {
4843
{Array.from(voteActions).map((voteAction, index) => (
4944
<FeedbackVoteButton
5045
key={voteAction['@id'] || voteAction.actionOption || index}
51-
onClick={handleChange}
46+
onClick={setSelectedVoteAction}
5247
pressed={selectedVoteAction === voteAction}
5348
voteAction={voteAction}
5449
/>

0 commit comments

Comments
 (0)