Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
4b9205e
add slots and types for SearchBox
emmayjiang May 31, 2023
1182bf3
fixing react-input version
emmayjiang May 31, 2023
790194f
updating yarn.lock
emmayjiang Jun 1, 2023
3ba7f4d
reorganizing code + alphabetizing package.json
emmayjiang Jun 1, 2023
9dfa1e6
add slots and types for SearchBox
emmayjiang May 31, 2023
536871b
fixing react-input version
emmayjiang May 31, 2023
208d14a
updating yarn.lock
emmayjiang Jun 1, 2023
a2132e7
reorganizing code + alphabetizing package.json
emmayjiang Jun 1, 2023
1abcf33
fix type errors
emmayjiang Jun 1, 2023
9e04463
fix merge conflicts
emmayjiang Jun 1, 2023
7c46d96
rebuild
emmayjiang Jun 5, 2023
1d7698f
styles
emmayjiang Jun 7, 2023
b01fb29
remove pseudoelements from input
emmayjiang Jun 8, 2023
3f46b1f
dismiss button functionality
emmayjiang Jun 8, 2023
d002d4d
packages
emmayjiang Jun 8, 2023
0b33d33
fixes to dismiss button
emmayjiang Jun 8, 2023
c11417b
code revisions following sarah's feedback
emmayjiang Jun 8, 2023
12f9886
styling issues
emmayjiang Jun 8, 2023
881eff8
remove contentBefore slot
emmayjiang Jun 8, 2023
c09bc34
type fixes & handling custom dismiss callback
emmayjiang Jun 9, 2023
fb5fd63
api update
emmayjiang Jun 9, 2023
96824e7
Merge branch 'master' into react-search-create-SearchBox-slots
emmayjiang Jun 12, 2023
525e629
minor nits
emmayjiang Jun 12, 2023
5dac8e5
refactor 'disabled'
emmayjiang Jun 12, 2023
5008246
api update
emmayjiang Jun 12, 2023
024eb53
Update packages/react-components/react-search/src/components/SearchBo…
emmayjiang Jun 12, 2023
713dd7a
api update
emmayjiang Jun 12, 2023
94e109d
api update
emmayjiang Jun 12, 2023
0b654c3
Merge branch 'master' into react-search-create-SearchBox-slots
emmayjiang Jun 13, 2023
8aa06b5
fixing styles errors
emmayjiang Jun 14, 2023
3d66691
update react-icons version
emmayjiang Jun 15, 2023
6a51ee8
fixes to ref + default
emmayjiang Jun 15, 2023
1aace49
fix to ref
emmayjiang Jun 15, 2023
d571f62
api update
emmayjiang Jun 15, 2023
c04b6d7
fix tests
emmayjiang Jun 15, 2023
e9e42db
api update
emmayjiang Jun 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/react-components/react-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@fluentui/scripts-tasks": "*"
},
"dependencies": {
"@fluentui/react-input": "^9.4.16",
"@fluentui/react-jsx-runtime": "9.0.0-alpha.6",
"@fluentui/react-theme": "^9.1.8",
"@fluentui/react-utilities": "^9.9.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';
import { Input } from '@fluentui/react-input';

export type SearchBoxSlots = {
root: Slot<'div'>;
// Root of the component, wrapping the inputs
root: NonNullable<Slot<typeof Input>>;

// Element before the input text, within the input border
contentBefore?: Slot<'span'>;
Comment thread
emmayjiang marked this conversation as resolved.
Outdated

// Last element in the input, within the input border
dismiss?: Slot<'span'>;

// Element after the input text, within the input border
contentAfter?: Slot<'span'>;
};

/**
* SearchBox Props
*/
export type SearchBoxProps = ComponentProps<SearchBoxSlots> & {};
export type SearchBoxProps = ComponentProps<SearchBoxSlots>;

/**
* State used in rendering SearchBox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,19 @@ export const renderSearchBox_unstable = (state: SearchBoxState) => {
const { slots, slotProps } = getSlotsNext<SearchBoxSlots>(state);

// TODO Add additional slots in the appropriate place
return <slots.root {...slotProps.root} />;

return (
<slots.root
{...slotProps.root}
contentBefore={slots.contentBefore && <slots.contentBefore {...slotProps.contentBefore} />}
contentAfter={
slots.contentAfter && (
<slots.contentAfter {...slotProps.contentAfter}>
{slotProps.contentAfter.children}
{slots.dismiss && <slots.dismiss {...slotProps.dismiss} />}
</slots.contentAfter>
)
}
/>
);
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import { getNativeElementProps } from '@fluentui/react-utilities';
import { resolveShorthand } from '@fluentui/react-utilities';
import { Input } from '@fluentui/react-input';
import type { SearchBoxProps, SearchBoxState } from './SearchBox.types';

/**
Expand All @@ -12,17 +13,25 @@ import type { SearchBoxProps, SearchBoxState } from './SearchBox.types';
* @param ref - reference to root HTMLElement of SearchBox
*/
export const useSearchBox_unstable = (props: SearchBoxProps, ref: React.Ref<HTMLElement>): SearchBoxState => {
const { contentBefore, dismiss, contentAfter, ...inputProps } = props;

return {
// TODO add appropriate props/defaults
components: {
// TODO add each slot's element type or component
root: 'div',
root: Input,
contentBefore: 'span',
dismiss: 'span',
contentAfter: 'span',
},

// TODO add appropriate slots
root: {
type: 'search',
...inputProps,
},
// TODO add appropriate slots, for example:
// mySlot: resolveShorthand(props.mySlot),
root: getNativeElementProps('div', {
ref,
...props,
}),
contentBefore: resolveShorthand(contentBefore),
dismiss: resolveShorthand(dismiss, { required: true }),
contentAfter: resolveShorthand(contentAfter, { required: true }),
};
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import * as React from 'react';
import { SearchBox, SearchBoxProps } from '@fluentui/react-search';

export const Default = (props: Partial<SearchBoxProps>) => <SearchBox {...props} />;
import { DismissRegular, FilterRegular, SearchRegular } from '@fluentui/react-icons';

export const Default = (props: Partial<SearchBoxProps>) => (
<SearchBox
{...props}
contentBefore={<SearchRegular />}
contentAfter={<FilterRegular />}
dismiss={<DismissRegular />}
/>
);
3 changes: 1 addition & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23109,7 +23109,7 @@ semver@7.3.4:
dependencies:
lru-cache "^6.0.0"

semver@7.x, semver@^7.0.0, semver@^7.1.1, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@~7.3.0, semver@^7.3.8:
semver@7.x, semver@^7.0.0, semver@^7.1.1, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@~7.3.0:
Comment thread
emmayjiang marked this conversation as resolved.
version "7.3.8"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798"
integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==
Expand All @@ -23121,7 +23121,6 @@ semver@^6.0.0, semver@^6.1.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semve
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==


send@0.17.2:
version "0.17.2"
resolved "https://registry.yarnpkg.com/send/-/send-0.17.2.tgz#926622f76601c41808012c8bf1688fe3906f7820"
Expand Down