@fluentui/react-search 0.0.0-nightly-20240411-0405.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +590 -0
  2. package/LICENSE +15 -0
  3. package/README.md +35 -0
  4. package/dist/index.d.ts +70 -0
  5. package/lib/SearchBox.js +1 -0
  6. package/lib/SearchBox.js.map +1 -0
  7. package/lib/components/SearchBox/SearchBox.js +12 -0
  8. package/lib/components/SearchBox/SearchBox.js.map +1 -0
  9. package/lib/components/SearchBox/SearchBox.types.js +1 -0
  10. package/lib/components/SearchBox/SearchBox.types.js.map +1 -0
  11. package/lib/components/SearchBox/index.js +5 -0
  12. package/lib/components/SearchBox/index.js.map +1 -0
  13. package/lib/components/SearchBox/renderSearchBox.js +19 -0
  14. package/lib/components/SearchBox/renderSearchBox.js.map +1 -0
  15. package/lib/components/SearchBox/useSearchBox.js +102 -0
  16. package/lib/components/SearchBox/useSearchBox.js.map +1 -0
  17. package/lib/components/SearchBox/useSearchBoxStyles.styles.js +99 -0
  18. package/lib/components/SearchBox/useSearchBoxStyles.styles.js.map +1 -0
  19. package/lib/index.js +1 -0
  20. package/lib/index.js.map +1 -0
  21. package/lib-commonjs/SearchBox.js +6 -0
  22. package/lib-commonjs/SearchBox.js.map +1 -0
  23. package/lib-commonjs/components/SearchBox/SearchBox.js +21 -0
  24. package/lib-commonjs/components/SearchBox/SearchBox.js.map +1 -0
  25. package/lib-commonjs/components/SearchBox/SearchBox.types.js +6 -0
  26. package/lib-commonjs/components/SearchBox/SearchBox.types.js.map +1 -0
  27. package/lib-commonjs/components/SearchBox/index.js +10 -0
  28. package/lib-commonjs/components/SearchBox/index.js.map +1 -0
  29. package/lib-commonjs/components/SearchBox/renderSearchBox.js +27 -0
  30. package/lib-commonjs/components/SearchBox/renderSearchBox.js.map +1 -0
  31. package/lib-commonjs/components/SearchBox/useSearchBox.js +105 -0
  32. package/lib-commonjs/components/SearchBox/useSearchBox.js.map +1 -0
  33. package/lib-commonjs/components/SearchBox/useSearchBoxStyles.styles.js +161 -0
  34. package/lib-commonjs/components/SearchBox/useSearchBoxStyles.styles.js.map +1 -0
  35. package/lib-commonjs/index.js +28 -0
  36. package/lib-commonjs/index.js.map +1 -0
  37. package/package.json +65 -0
@@ -0,0 +1,70 @@
1
+ /// <reference types="react" />
2
+
3
+ import type { ComponentProps } from '@fluentui/react-utilities';
4
+ import type { ComponentState } from '@fluentui/react-utilities';
5
+ import type { ForwardRefComponent } from '@fluentui/react-utilities';
6
+ import type { InputOnChangeData } from '@fluentui/react-input';
7
+ import type { InputProps } from '@fluentui/react-input';
8
+ import type { InputSlots } from '@fluentui/react-input';
9
+ import type { InputState } from '@fluentui/react-input';
10
+ import * as React_2 from 'react';
11
+ import type { Slot } from '@fluentui/react-utilities';
12
+ import type { SlotClassNames } from '@fluentui/react-utilities';
13
+
14
+ /**
15
+ * Render the final JSX of SearchBox
16
+ */
17
+ export declare const renderSearchBox_unstable: (state: SearchBoxState) => JSX.Element;
18
+
19
+ /**
20
+ * SearchBox component - TODO: add more docs
21
+ */
22
+ export declare const SearchBox: ForwardRefComponent<SearchBoxProps>;
23
+
24
+ /** Overloaded onChange event type, used to merge functionality of regular text entry and the dismiss button */
25
+ export declare type SearchBoxChangeEvent = React_2.ChangeEvent<HTMLInputElement> | React_2.MouseEvent<HTMLSpanElement>;
26
+
27
+ export declare const searchBoxClassNames: SlotClassNames<SearchBoxSlots>;
28
+
29
+ /**
30
+ * SearchBox Props
31
+ */
32
+ export declare type SearchBoxProps = Omit<ComponentProps<Partial<SearchBoxSlots>, 'input'>, 'children' | 'defaultValue' | 'onChange' | 'size' | 'type' | 'value'> & Omit<InputProps, 'onChange'> & {
33
+ /**
34
+ * Custom onChange callback.
35
+ * Will be traditionally supplied with a React.ChangeEvent<HTMLInputElement> for usual character entry.
36
+ * When the dismiss button is clicked, this will be called with an event of type React.MouseEvent<HTMLSpanElement>
37
+ * and an empty string as the `value` property of the data parameter
38
+ */
39
+ onChange?: (event: SearchBoxChangeEvent, data: InputOnChangeData) => void;
40
+ };
41
+
42
+ export declare type SearchBoxSlots = InputSlots & {
43
+ /** Last element in the input, within the input border */
44
+ dismiss?: Slot<'span'>;
45
+ };
46
+
47
+ /**
48
+ * State used in rendering SearchBox
49
+ */
50
+ export declare type SearchBoxState = ComponentState<SearchBoxSlots> & InputState & Required<Pick<InputState, 'size'>> & Required<Pick<SearchBoxProps, 'disabled'>> & {
51
+ focused: boolean;
52
+ };
53
+
54
+ /**
55
+ * Create the state required to render SearchBox.
56
+ *
57
+ * The returned state can be modified with hooks such as useSearchBoxStyles_unstable,
58
+ * before being passed to renderSearchBox_unstable.
59
+ *
60
+ * @param props - props from this instance of SearchBox
61
+ * @param ref - reference to root HTMLElement of SearchBox
62
+ */
63
+ export declare const useSearchBox_unstable: (props: SearchBoxProps, ref: React_2.Ref<HTMLInputElement>) => SearchBoxState;
64
+
65
+ /**
66
+ * Apply styling to the SearchBox slots based on the state
67
+ */
68
+ export declare const useSearchBoxStyles_unstable: (state: SearchBoxState) => SearchBoxState;
69
+
70
+ export { }
@@ -0,0 +1 @@
1
+ export * from './components/SearchBox/index';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["SearchBox.ts"],"sourcesContent":["export * from './components/SearchBox/index';\n"],"names":[],"mappings":"AAAA,cAAc,+BAA+B"}
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import { useSearchBox_unstable } from './useSearchBox';
3
+ import { renderSearchBox_unstable } from './renderSearchBox';
4
+ import { useSearchBoxStyles_unstable } from './useSearchBoxStyles.styles';
5
+ /**
6
+ * SearchBox component - TODO: add more docs
7
+ */ export const SearchBox = /*#__PURE__*/ React.forwardRef((props, ref)=>{
8
+ const state = useSearchBox_unstable(props, ref);
9
+ useSearchBoxStyles_unstable(state);
10
+ return renderSearchBox_unstable(state);
11
+ });
12
+ SearchBox.displayName = 'SearchBox';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["SearchBox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useSearchBox_unstable } from './useSearchBox';\nimport { renderSearchBox_unstable } from './renderSearchBox';\nimport { useSearchBoxStyles_unstable } from './useSearchBoxStyles.styles';\nimport type { SearchBoxProps } from './SearchBox.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * SearchBox component - TODO: add more docs\n */\nexport const SearchBox: ForwardRefComponent<SearchBoxProps> = React.forwardRef((props, ref) => {\n const state = useSearchBox_unstable(props, ref);\n\n useSearchBoxStyles_unstable(state);\n return renderSearchBox_unstable(state);\n});\n\nSearchBox.displayName = 'SearchBox';\n"],"names":["React","useSearchBox_unstable","renderSearchBox_unstable","useSearchBoxStyles_unstable","SearchBox","forwardRef","props","ref","state","displayName"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,qBAAqB,QAAQ,iBAAiB;AACvD,SAASC,wBAAwB,QAAQ,oBAAoB;AAC7D,SAASC,2BAA2B,QAAQ,8BAA8B;AAI1E;;CAEC,GACD,OAAO,MAAMC,0BAAiDJ,MAAMK,UAAU,CAAC,CAACC,OAAOC;IACrF,MAAMC,QAAQP,sBAAsBK,OAAOC;IAE3CJ,4BAA4BK;IAC5B,OAAON,yBAAyBM;AAClC,GAAG;AAEHJ,UAAUK,WAAW,GAAG"}
@@ -0,0 +1 @@
1
+ import * as React from 'react';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["SearchBox.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport type { InputOnChangeData, InputProps, InputSlots, InputState } from '@fluentui/react-input';\n\nexport type SearchBoxSlots = InputSlots & {\n /** Last element in the input, within the input border */\n dismiss?: Slot<'span'>;\n};\n\n/**\n * SearchBox Props\n */\nexport type SearchBoxProps = Omit<\n ComponentProps<Partial<SearchBoxSlots>, 'input'>,\n // `children` is unsupported. The rest of these native props have customized definitions.\n 'children' | 'defaultValue' | 'onChange' | 'size' | 'type' | 'value'\n> &\n Omit<InputProps, 'onChange'> & {\n /**\n * Custom onChange callback.\n * Will be traditionally supplied with a React.ChangeEvent<HTMLInputElement> for usual character entry.\n * When the dismiss button is clicked, this will be called with an event of type React.MouseEvent<HTMLSpanElement>\n * and an empty string as the `value` property of the data parameter\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\n onChange?: (event: SearchBoxChangeEvent, data: InputOnChangeData) => void;\n };\n\n/**\n * State used in rendering SearchBox\n */\nexport type SearchBoxState = ComponentState<SearchBoxSlots> &\n InputState &\n Required<Pick<InputState, 'size'>> &\n Required<Pick<SearchBoxProps, 'disabled'>> & {\n focused: boolean;\n };\n\n/** Overloaded onChange event type, used to merge functionality of regular text entry and the dismiss button */\nexport type SearchBoxChangeEvent = React.ChangeEvent<HTMLInputElement> | React.MouseEvent<HTMLSpanElement>;\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
@@ -0,0 +1,5 @@
1
+ export * from './SearchBox';
2
+ export * from './SearchBox.types';
3
+ export * from './renderSearchBox';
4
+ export * from './useSearchBox';
5
+ export * from './useSearchBoxStyles.styles';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './SearchBox';\nexport * from './SearchBox.types';\nexport * from './renderSearchBox';\nexport * from './useSearchBox';\nexport * from './useSearchBoxStyles.styles';\n"],"names":[],"mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,oBAAoB;AAClC,cAAc,oBAAoB;AAClC,cAAc,iBAAiB;AAC/B,cAAc,8BAA8B"}
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@fluentui/react-jsx-runtime/jsx-runtime";
2
+ import { assertSlots } from '@fluentui/react-utilities';
3
+ /**
4
+ * Render the final JSX of SearchBox
5
+ */ export const renderSearchBox_unstable = (state)=>{
6
+ assertSlots(state);
7
+ return /*#__PURE__*/ _jsxs(state.root, {
8
+ children: [
9
+ state.contentBefore && /*#__PURE__*/ _jsx(state.contentBefore, {}),
10
+ /*#__PURE__*/ _jsx(state.input, {}),
11
+ state.contentAfter && /*#__PURE__*/ _jsxs(state.contentAfter, {
12
+ children: [
13
+ state.contentAfter.children,
14
+ state.dismiss && /*#__PURE__*/ _jsx(state.dismiss, {})
15
+ ]
16
+ })
17
+ ]
18
+ });
19
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["renderSearchBox.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { SearchBoxState, SearchBoxSlots } from './SearchBox.types';\n\n/**\n * Render the final JSX of SearchBox\n */\nexport const renderSearchBox_unstable = (state: SearchBoxState) => {\n assertSlots<SearchBoxSlots>(state);\n\n return (\n <state.root>\n {state.contentBefore && <state.contentBefore />}\n <state.input />\n {state.contentAfter && (\n <state.contentAfter>\n {state.contentAfter.children}\n {state.dismiss && <state.dismiss />}\n </state.contentAfter>\n )}\n </state.root>\n );\n};\n"],"names":["assertSlots","renderSearchBox_unstable","state","root","contentBefore","input","contentAfter","children","dismiss"],"mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,4BAA4B;AAGxD;;CAEC,GACD,OAAO,MAAMC,2BAA2B,CAACC;IACvCF,YAA4BE;IAE5B,qBACE,MAACA,MAAMC,IAAI;;YACRD,MAAME,aAAa,kBAAI,KAACF,MAAME,aAAa;0BAC5C,KAACF,MAAMG,KAAK;YACXH,MAAMI,YAAY,kBACjB,MAACJ,MAAMI,YAAY;;oBAChBJ,MAAMI,YAAY,CAACC,QAAQ;oBAC3BL,MAAMM,OAAO,kBAAI,KAACN,MAAMM,OAAO;;;;;AAK1C,EAAE"}
@@ -0,0 +1,102 @@
1
+ import * as React from 'react';
2
+ import { isResolvedShorthand, mergeCallbacks, slot, useControllableState, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';
3
+ import { useInput_unstable } from '@fluentui/react-input';
4
+ import { DismissRegular, SearchRegular } from '@fluentui/react-icons';
5
+ /**
6
+ * Create the state required to render SearchBox.
7
+ *
8
+ * The returned state can be modified with hooks such as useSearchBoxStyles_unstable,
9
+ * before being passed to renderSearchBox_unstable.
10
+ *
11
+ * @param props - props from this instance of SearchBox
12
+ * @param ref - reference to root HTMLElement of SearchBox
13
+ */ export const useSearchBox_unstable = (props, ref)=>{
14
+ const { size = 'medium', disabled = false, root, contentBefore, dismiss, contentAfter, ...inputProps } = props;
15
+ const searchBoxRootRef = React.useRef(null);
16
+ const searchBoxRef = React.useRef(null);
17
+ const [value, setValue] = useControllableState({
18
+ state: props.value,
19
+ defaultState: props.defaultValue,
20
+ initialState: ''
21
+ });
22
+ // Tracks the focus of the component for the contentAfter and dismiss button
23
+ const [focused, setFocused] = React.useState(false);
24
+ const onFocus = useEventCallback(()=>{
25
+ setFocused(true);
26
+ });
27
+ const onBlur = useEventCallback((ev)=>{
28
+ var _searchBoxRootRef_current;
29
+ setFocused(!!((_searchBoxRootRef_current = searchBoxRootRef.current) === null || _searchBoxRootRef_current === void 0 ? void 0 : _searchBoxRootRef_current.contains(ev.relatedTarget)));
30
+ });
31
+ const rootProps = slot.resolveShorthand(root);
32
+ const handleDismissClick = useEventCallback((event)=>{
33
+ var _props_onChange;
34
+ if (isResolvedShorthand(dismiss)) {
35
+ var _dismiss_onClick;
36
+ (_dismiss_onClick = dismiss.onClick) === null || _dismiss_onClick === void 0 ? void 0 : _dismiss_onClick.call(dismiss, event);
37
+ }
38
+ const newValue = '';
39
+ setValue(newValue);
40
+ (_props_onChange = props.onChange) === null || _props_onChange === void 0 ? void 0 : _props_onChange.call(props, event, {
41
+ value: newValue
42
+ });
43
+ });
44
+ const inputState = useInput_unstable({
45
+ type: 'search',
46
+ disabled,
47
+ size,
48
+ value,
49
+ root: slot.always({
50
+ ...rootProps,
51
+ ref: useMergedRefs(rootProps === null || rootProps === void 0 ? void 0 : rootProps.ref, searchBoxRootRef),
52
+ onFocus: useEventCallback(mergeCallbacks(rootProps === null || rootProps === void 0 ? void 0 : rootProps.onFocus, onFocus)),
53
+ onBlur: useEventCallback(mergeCallbacks(rootProps === null || rootProps === void 0 ? void 0 : rootProps.onBlur, onBlur))
54
+ }, {
55
+ elementType: 'span'
56
+ }),
57
+ contentBefore: slot.optional(contentBefore, {
58
+ renderByDefault: true,
59
+ defaultProps: {
60
+ children: /*#__PURE__*/ React.createElement(SearchRegular, null)
61
+ },
62
+ elementType: 'span'
63
+ }),
64
+ contentAfter: slot.optional(contentAfter, {
65
+ renderByDefault: true,
66
+ elementType: 'span'
67
+ }),
68
+ ...inputProps,
69
+ onChange: useEventCallback((ev)=>{
70
+ var _props_onChange;
71
+ const newValue = ev.target.value;
72
+ (_props_onChange = props.onChange) === null || _props_onChange === void 0 ? void 0 : _props_onChange.call(props, ev, {
73
+ value: newValue
74
+ });
75
+ setValue(newValue);
76
+ })
77
+ }, useMergedRefs(searchBoxRef, ref));
78
+ const state = {
79
+ ...inputState,
80
+ components: {
81
+ ...inputState.components,
82
+ dismiss: 'span'
83
+ },
84
+ dismiss: slot.optional(dismiss, {
85
+ defaultProps: {
86
+ children: /*#__PURE__*/ React.createElement(DismissRegular, null),
87
+ role: 'button',
88
+ 'aria-label': 'clear',
89
+ tabIndex: -1
90
+ },
91
+ renderByDefault: true,
92
+ elementType: 'span'
93
+ }),
94
+ disabled,
95
+ focused,
96
+ size
97
+ };
98
+ if (state.dismiss) {
99
+ state.dismiss.onClick = handleDismissClick;
100
+ }
101
+ return state;
102
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useSearchBox.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n isResolvedShorthand,\n mergeCallbacks,\n slot,\n useControllableState,\n useEventCallback,\n useMergedRefs,\n} from '@fluentui/react-utilities';\nimport { useInput_unstable } from '@fluentui/react-input';\nimport { DismissRegular, SearchRegular } from '@fluentui/react-icons';\nimport type { ExtractSlotProps } from '@fluentui/react-utilities';\nimport type { SearchBoxSlots, SearchBoxProps, SearchBoxState } from './SearchBox.types';\n\n/**\n * Create the state required to render SearchBox.\n *\n * The returned state can be modified with hooks such as useSearchBoxStyles_unstable,\n * before being passed to renderSearchBox_unstable.\n *\n * @param props - props from this instance of SearchBox\n * @param ref - reference to root HTMLElement of SearchBox\n */\nexport const useSearchBox_unstable = (props: SearchBoxProps, ref: React.Ref<HTMLInputElement>): SearchBoxState => {\n const { size = 'medium', disabled = false, root, contentBefore, dismiss, contentAfter, ...inputProps } = props;\n\n const searchBoxRootRef = React.useRef<HTMLDivElement>(null);\n const searchBoxRef = React.useRef<HTMLInputElement>(null);\n\n const [value, setValue] = useControllableState({\n state: props.value,\n defaultState: props.defaultValue,\n initialState: '',\n });\n\n // Tracks the focus of the component for the contentAfter and dismiss button\n const [focused, setFocused] = React.useState(false);\n\n const onFocus = useEventCallback(() => {\n setFocused(true);\n });\n\n const onBlur: React.FocusEventHandler<HTMLSpanElement> = useEventCallback(ev => {\n setFocused(!!searchBoxRootRef.current?.contains(ev.relatedTarget));\n });\n\n const rootProps = slot.resolveShorthand(root);\n\n const handleDismissClick = useEventCallback((event: React.MouseEvent<HTMLSpanElement>) => {\n if (isResolvedShorthand(dismiss)) {\n dismiss.onClick?.(event);\n }\n const newValue = '';\n setValue(newValue);\n props.onChange?.(event, { value: newValue });\n });\n\n const inputState = useInput_unstable(\n {\n type: 'search',\n disabled,\n size,\n value,\n root: slot.always<ExtractSlotProps<SearchBoxSlots['root']>>(\n {\n ...rootProps,\n ref: useMergedRefs(rootProps?.ref, searchBoxRootRef),\n onFocus: useEventCallback(mergeCallbacks(rootProps?.onFocus, onFocus)),\n onBlur: useEventCallback(mergeCallbacks(rootProps?.onBlur, onBlur)),\n },\n {\n elementType: 'span',\n },\n ),\n contentBefore: slot.optional(contentBefore, {\n renderByDefault: true,\n defaultProps: {\n children: <SearchRegular />,\n },\n elementType: 'span',\n }),\n contentAfter: slot.optional(contentAfter, {\n renderByDefault: true,\n elementType: 'span',\n }),\n ...inputProps,\n onChange: useEventCallback(ev => {\n const newValue = ev.target.value;\n props.onChange?.(ev, { value: newValue });\n setValue(newValue);\n }),\n },\n useMergedRefs(searchBoxRef, ref),\n );\n\n const state: SearchBoxState = {\n ...inputState,\n components: {\n ...inputState.components,\n dismiss: 'span',\n },\n dismiss: slot.optional(dismiss, {\n defaultProps: {\n children: <DismissRegular />,\n role: 'button',\n 'aria-label': 'clear',\n tabIndex: -1,\n },\n renderByDefault: true,\n elementType: 'span',\n }),\n disabled,\n focused,\n size,\n };\n\n if (state.dismiss) {\n state.dismiss.onClick = handleDismissClick;\n }\n\n return state;\n};\n"],"names":["React","isResolvedShorthand","mergeCallbacks","slot","useControllableState","useEventCallback","useMergedRefs","useInput_unstable","DismissRegular","SearchRegular","useSearchBox_unstable","props","ref","size","disabled","root","contentBefore","dismiss","contentAfter","inputProps","searchBoxRootRef","useRef","searchBoxRef","value","setValue","state","defaultState","defaultValue","initialState","focused","setFocused","useState","onFocus","onBlur","ev","current","contains","relatedTarget","rootProps","resolveShorthand","handleDismissClick","event","onClick","newValue","onChange","inputState","type","always","elementType","optional","renderByDefault","defaultProps","children","target","components","role","tabIndex"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,mBAAmB,EACnBC,cAAc,EACdC,IAAI,EACJC,oBAAoB,EACpBC,gBAAgB,EAChBC,aAAa,QACR,4BAA4B;AACnC,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,cAAc,EAAEC,aAAa,QAAQ,wBAAwB;AAItE;;;;;;;;CAQC,GACD,OAAO,MAAMC,wBAAwB,CAACC,OAAuBC;IAC3D,MAAM,EAAEC,OAAO,QAAQ,EAAEC,WAAW,KAAK,EAAEC,IAAI,EAAEC,aAAa,EAAEC,OAAO,EAAEC,YAAY,EAAE,GAAGC,YAAY,GAAGR;IAEzG,MAAMS,mBAAmBpB,MAAMqB,MAAM,CAAiB;IACtD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C3C;YACb;YACAuC,aAAa;QACf;QACA9B,cAAcf,KAAK8C,QAAQ,CAAC/B,cAAc;YACxCgC,iBAAiB;YACjBF,aAAa;QACf;QACA,GAAG7B,UAAU;QACbyB,UAAUvC,iBAAiB6B,CAAAA;gBAEzBvB;YADA,MAAMgC,WAAWT,GAAGmB,MAAM,CAAC9B,KAAK;aAChCZ,kBAAAA,MAAMiC,QAAQ,cAAdjC,sCAAAA,qBAAAA,OAAiBuB,IAAI;gBAAEX,OAAOoB;YAAS;YACvCnB,SAASmB;QACX;IACF,GACArC,cAAcgB,cAAcV;IAG9B,MAAMa,QAAwB;QAC5B,GAAGoB,UAAU;QACbS,YAAY;YACV,GAAGT,WAAWS,UAAU;YACxBrC,SAAS;QACX;QACAA,SAASd,KAAK8C,QAAQ,CAAChC,SAAS;YAC9BkC,cAAc;gBACZC,wBAAU,oBAAC5C;gBACX+C,MAAM;gBACN,cAAc;gBACdC,UAAU,CAAC;YACb;YACAN,iBAAiB;YACjBF,aAAa;QACf;QACAlC;QACAe;QACAhB;IACF;IAEA,IAAIY,MAAMR,OAAO,EAAE;QACjBQ,MAAMR,OAAO,CAACyB,OAAO,GAAGF;IAC1B;IAEA,OAAOf;AACT,EAAE"}
@@ -0,0 +1,99 @@
1
+ import { __resetStyles, __styles, mergeClasses } from '@griffel/react';
2
+ import { tokens } from '@fluentui/react-theme';
3
+ import { useInputStyles_unstable } from '@fluentui/react-input';
4
+ export const searchBoxClassNames = {
5
+ root: 'fui-SearchBox',
6
+ dismiss: 'fui-SearchBox__dismiss',
7
+ contentAfter: 'fui-SearchBox__contentAfter',
8
+ contentBefore: 'fui-SearchBox__contentBefore',
9
+ input: 'fui-SearchBox__input'
10
+ };
11
+ /**
12
+ * Styles for the root slot
13
+ */
14
+ const useRootStyles = /*#__PURE__*/__styles({
15
+ small: {
16
+ i8kkvl: "fjuset5",
17
+ B2u0y6b: "f1xzfw5u",
18
+ uwmqm3: ["fk8j09s", "fdw0yi8"],
19
+ z189sj: ["fdw0yi8", "fk8j09s"]
20
+ },
21
+ medium: {
22
+ i8kkvl: "fjuset5",
23
+ B2u0y6b: "f1xzfw5u",
24
+ uwmqm3: ["f1f5gg8d", "f1vdfbxk"],
25
+ z189sj: ["f1vdfbxk", "f1f5gg8d"]
26
+ },
27
+ large: {
28
+ i8kkvl: "fjuset5",
29
+ B2u0y6b: "f1xzfw5u",
30
+ uwmqm3: ["f1ng84yb", "f11gcy0p"],
31
+ z189sj: ["f11gcy0p", "f1ng84yb"]
32
+ },
33
+ input: {
34
+ uwmqm3: ["fk8j09s", "fdw0yi8"],
35
+ z189sj: ["fhxju0i", "f1cnd47f"],
36
+ Boqhc8c: "f18izjht",
37
+ B8uat0v: "fcoa6sg"
38
+ }
39
+ }, {
40
+ d: [".fjuset5{column-gap:0;}", ".f1xzfw5u{max-width:468px;}", ".fk8j09s{padding-left:var(--spacingHorizontalSNudge);}", ".fdw0yi8{padding-right:var(--spacingHorizontalSNudge);}", ".f1f5gg8d{padding-left:var(--spacingHorizontalS);}", ".f1vdfbxk{padding-right:var(--spacingHorizontalS);}", ".f1ng84yb{padding-left:var(--spacingHorizontalMNudge);}", ".f11gcy0p{padding-right:var(--spacingHorizontalMNudge);}", ".fhxju0i{padding-right:0;}", ".f1cnd47f{padding-left:0;}", ".f18izjht::-webkit-search-decoration{display:none;}", ".fcoa6sg::-webkit-search-cancel-button{display:none;}"]
41
+ });
42
+ const useContentAfterStyles = /*#__PURE__*/__styles({
43
+ contentAfter: {
44
+ uwmqm3: ["f1uw59to", "fw5db7e"],
45
+ i8kkvl: "f1ufnopg"
46
+ },
47
+ rest: {
48
+ abs64n: "fk73vx1",
49
+ Bqenvij: "fniina8",
50
+ a9b677: "f3tsq5r"
51
+ }
52
+ }, {
53
+ d: [".f1uw59to{padding-left:var(--spacingHorizontalM);}", ".fw5db7e{padding-right:var(--spacingHorizontalM);}", ".f1ufnopg{column-gap:var(--spacingHorizontalXS);}", ".fk73vx1{opacity:0;}", ".fniina8{height:0;}", ".f3tsq5r{width:0;}"]
54
+ });
55
+ const useDismissClassName = /*#__PURE__*/__resetStyles("r1pvzcuu", null, [".r1pvzcuu{box-sizing:border-box;color:var(--colorNeutralForeground3);display:flex;cursor:pointer;}", ".r1pvzcuu>svg{font-size:20px;}"]);
56
+ const useDismissStyles = /*#__PURE__*/__styles({
57
+ disabled: {
58
+ sj55zd: "f1s2aq7o"
59
+ },
60
+ small: {
61
+ kwki1k: "f3u2cy0"
62
+ },
63
+ medium: {},
64
+ large: {
65
+ kwki1k: "fa420co"
66
+ }
67
+ }, {
68
+ d: [".f1s2aq7o{color:var(--colorNeutralForegroundDisabled);}", ".f3u2cy0>svg{font-size:16px;}", ".fa420co>svg{font-size:24px;}"]
69
+ });
70
+ /**
71
+ * Apply styling to the SearchBox slots based on the state
72
+ */
73
+ export const useSearchBoxStyles_unstable = state => {
74
+ const {
75
+ disabled,
76
+ focused,
77
+ size
78
+ } = state;
79
+ const rootStyles = useRootStyles();
80
+ const contentAfterStyles = useContentAfterStyles();
81
+ const dismissClassName = useDismissClassName();
82
+ const dismissStyles = useDismissStyles();
83
+ state.root.className = mergeClasses(searchBoxClassNames.root, rootStyles[size], state.root.className);
84
+ state.input.className = mergeClasses(searchBoxClassNames.input, rootStyles.input, state.input.className);
85
+ if (state.dismiss) {
86
+ state.dismiss.className = mergeClasses(searchBoxClassNames.dismiss, dismissClassName, disabled && dismissStyles.disabled, dismissStyles[size], state.dismiss.className);
87
+ }
88
+ if (state.contentBefore) {
89
+ state.contentBefore.className = mergeClasses(searchBoxClassNames.contentBefore, state.contentBefore.className);
90
+ }
91
+ if (state.contentAfter) {
92
+ state.contentAfter.className = mergeClasses(searchBoxClassNames.contentAfter, contentAfterStyles.contentAfter, !focused && contentAfterStyles.rest, state.contentAfter.className);
93
+ } else if (state.dismiss) {
94
+ state.dismiss.className = mergeClasses(state.dismiss.className, contentAfterStyles.contentAfter);
95
+ }
96
+ useInputStyles_unstable(state);
97
+ return state;
98
+ };
99
+ //# sourceMappingURL=useSearchBoxStyles.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__resetStyles","__styles","mergeClasses","tokens","useInputStyles_unstable","searchBoxClassNames","root","dismiss","contentAfter","contentBefore","input","useRootStyles","small","i8kkvl","B2u0y6b","uwmqm3","z189sj","medium","large","Boqhc8c","B8uat0v","d","useContentAfterStyles","rest","abs64n","Bqenvij","a9b677","useDismissClassName","useDismissStyles","disabled","sj55zd","kwki1k","useSearchBoxStyles_unstable","state","focused","size","rootStyles","contentAfterStyles","dismissClassName","dismissStyles","className"],"sources":["useSearchBoxStyles.styles.js"],"sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\nimport { useInputStyles_unstable } from '@fluentui/react-input';\nexport const searchBoxClassNames = {\n root: 'fui-SearchBox',\n dismiss: 'fui-SearchBox__dismiss',\n contentAfter: 'fui-SearchBox__contentAfter',\n contentBefore: 'fui-SearchBox__contentBefore',\n input: 'fui-SearchBox__input'\n};\n/**\n * Styles for the root slot\n */ const useRootStyles = makeStyles({\n small: {\n columnGap: 0,\n maxWidth: '468px',\n paddingLeft: tokens.spacingHorizontalSNudge,\n paddingRight: tokens.spacingHorizontalSNudge\n },\n medium: {\n columnGap: 0,\n maxWidth: '468px',\n paddingLeft: tokens.spacingHorizontalS,\n paddingRight: tokens.spacingHorizontalS\n },\n large: {\n columnGap: 0,\n maxWidth: '468px',\n paddingLeft: tokens.spacingHorizontalMNudge,\n paddingRight: tokens.spacingHorizontalMNudge\n },\n input: {\n paddingLeft: tokens.spacingHorizontalSNudge,\n paddingRight: 0,\n // removes the WebKit pseudoelement styling\n '::-webkit-search-decoration': {\n display: 'none'\n },\n '::-webkit-search-cancel-button': {\n display: 'none'\n }\n }\n});\nconst useContentAfterStyles = makeStyles({\n contentAfter: {\n paddingLeft: tokens.spacingHorizontalM,\n columnGap: tokens.spacingHorizontalXS\n },\n rest: {\n opacity: 0,\n height: 0,\n width: 0\n }\n});\nconst useDismissClassName = makeResetStyles({\n boxSizing: 'border-box',\n color: tokens.colorNeutralForeground3,\n display: 'flex',\n // special case styling for icons (most common case) to ensure they're centered vertically\n // size: medium (default)\n '> svg': {\n fontSize: '20px'\n },\n cursor: 'pointer'\n});\nconst useDismissStyles = makeStyles({\n disabled: {\n color: tokens.colorNeutralForegroundDisabled\n },\n // Ensure resizable icons show up with the proper font size\n small: {\n '> svg': {\n fontSize: '16px'\n }\n },\n medium: {\n },\n large: {\n '> svg': {\n fontSize: '24px'\n }\n }\n});\n/**\n * Apply styling to the SearchBox slots based on the state\n */ export const useSearchBoxStyles_unstable = (state)=>{\n const { disabled, focused, size } = state;\n const rootStyles = useRootStyles();\n const contentAfterStyles = useContentAfterStyles();\n const dismissClassName = useDismissClassName();\n const dismissStyles = useDismissStyles();\n state.root.className = mergeClasses(searchBoxClassNames.root, rootStyles[size], state.root.className);\n state.input.className = mergeClasses(searchBoxClassNames.input, rootStyles.input, state.input.className);\n if (state.dismiss) {\n state.dismiss.className = mergeClasses(searchBoxClassNames.dismiss, dismissClassName, disabled && dismissStyles.disabled, dismissStyles[size], state.dismiss.className);\n }\n if (state.contentBefore) {\n state.contentBefore.className = mergeClasses(searchBoxClassNames.contentBefore, state.contentBefore.className);\n }\n if (state.contentAfter) {\n state.contentAfter.className = mergeClasses(searchBoxClassNames.contentAfter, contentAfterStyles.contentAfter, !focused && contentAfterStyles.rest, state.contentAfter.className);\n } else if (state.dismiss) {\n state.dismiss.className = mergeClasses(state.dismiss.className, contentAfterStyles.contentAfter);\n }\n useInputStyles_unstable(state);\n return state;\n};\n"],"mappings":"AAAA,SAAAA,aAAA,EAAAC,QAAA,EAAsCC,YAAY,QAAQ,gBAAgB;AAC1E,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,uBAAuB,QAAQ,uBAAuB;AAC/D,OAAO,MAAMC,mBAAmB,GAAG;EAC/BC,IAAI,EAAE,eAAe;EACrBC,OAAO,EAAE,wBAAwB;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AK;AAChB,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1 @@
1
+ export { SearchBox, renderSearchBox_unstable, searchBoxClassNames, useSearchBoxStyles_unstable, useSearchBox_unstable } from './SearchBox';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export {\n SearchBox,\n renderSearchBox_unstable,\n searchBoxClassNames,\n useSearchBoxStyles_unstable,\n useSearchBox_unstable,\n} from './SearchBox';\nexport type { SearchBoxChangeEvent, SearchBoxProps, SearchBoxSlots, SearchBoxState } from './SearchBox';\n"],"names":["SearchBox","renderSearchBox_unstable","searchBoxClassNames","useSearchBoxStyles_unstable","useSearchBox_unstable"],"mappings":"AAAA,SACEA,SAAS,EACTC,wBAAwB,EACxBC,mBAAmB,EACnBC,2BAA2B,EAC3BC,qBAAqB,QAChB,cAAc"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _export_star = require("@swc/helpers/_/_export_star");
6
+ _export_star._(require("./components/SearchBox/index"), exports);
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["SearchBox.js"],"sourcesContent":["export * from './components/SearchBox/index';\n"],"names":[],"mappings":";;;;;uBAAc"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "SearchBox", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return SearchBox;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ const _useSearchBox = require("./useSearchBox");
14
+ const _renderSearchBox = require("./renderSearchBox");
15
+ const _useSearchBoxStylesstyles = require("./useSearchBoxStyles.styles");
16
+ const SearchBox = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
17
+ const state = (0, _useSearchBox.useSearchBox_unstable)(props, ref);
18
+ (0, _useSearchBoxStylesstyles.useSearchBoxStyles_unstable)(state);
19
+ return (0, _renderSearchBox.renderSearchBox_unstable)(state);
20
+ });
21
+ SearchBox.displayName = 'SearchBox';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["SearchBox.js"],"sourcesContent":["import * as React from 'react';\nimport { useSearchBox_unstable } from './useSearchBox';\nimport { renderSearchBox_unstable } from './renderSearchBox';\nimport { useSearchBoxStyles_unstable } from './useSearchBoxStyles.styles';\n/**\n * SearchBox component - TODO: add more docs\n */ export const SearchBox = /*#__PURE__*/ React.forwardRef((props, ref)=>{\n const state = useSearchBox_unstable(props, ref);\n useSearchBoxStyles_unstable(state);\n return renderSearchBox_unstable(state);\n});\nSearchBox.displayName = 'SearchBox';\n"],"names":["SearchBox","React","forwardRef","props","ref","state","useSearchBox_unstable","useSearchBoxStyles_unstable","renderSearchBox_unstable","displayName"],"mappings":";;;;+BAMiBA;;;eAAAA;;;;iEANM;8BACe;iCACG;0CACG;AAGjC,MAAMA,YAAY,WAAW,GAAGC,OAAMC,UAAU,CAAC,CAACC,OAAOC;IAChE,MAAMC,QAAQC,IAAAA,mCAAqB,EAACH,OAAOC;IAC3CG,IAAAA,qDAA2B,EAACF;IAC5B,OAAOG,IAAAA,yCAAwB,EAACH;AACpC;AACAL,UAAUS,WAAW,GAAG"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
6
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["SearchBox.types.js"],"sourcesContent":["import * as React from 'react';\n"],"names":[],"mappings":";;;;;iEAAuB"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _export_star = require("@swc/helpers/_/_export_star");
6
+ _export_star._(require("./SearchBox"), exports);
7
+ _export_star._(require("./SearchBox.types"), exports);
8
+ _export_star._(require("./renderSearchBox"), exports);
9
+ _export_star._(require("./useSearchBox"), exports);
10
+ _export_star._(require("./useSearchBoxStyles.styles"), exports);
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.js"],"sourcesContent":["export * from './SearchBox';\nexport * from './SearchBox.types';\nexport * from './renderSearchBox';\nexport * from './useSearchBox';\nexport * from './useSearchBoxStyles.styles';\n"],"names":[],"mappings":";;;;;uBAAc;uBACA;uBACA;uBACA;uBACA"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "renderSearchBox_unstable", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return renderSearchBox_unstable;
9
+ }
10
+ });
11
+ const _jsxruntime = require("@fluentui/react-jsx-runtime/jsx-runtime");
12
+ const _reactutilities = require("@fluentui/react-utilities");
13
+ const renderSearchBox_unstable = (state)=>{
14
+ (0, _reactutilities.assertSlots)(state);
15
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(state.root, {
16
+ children: [
17
+ state.contentBefore && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.contentBefore, {}),
18
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(state.input, {}),
19
+ state.contentAfter && /*#__PURE__*/ (0, _jsxruntime.jsxs)(state.contentAfter, {
20
+ children: [
21
+ state.contentAfter.children,
22
+ state.dismiss && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.dismiss, {})
23
+ ]
24
+ })
25
+ ]
26
+ });
27
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["renderSearchBox.js"],"sourcesContent":[" import { jsx as _jsx, jsxs as _jsxs } from \"@fluentui/react-jsx-runtime/jsx-runtime\";\nimport { assertSlots } from '@fluentui/react-utilities';\n/**\n * Render the final JSX of SearchBox\n */ export const renderSearchBox_unstable = (state)=>{\n assertSlots(state);\n return /*#__PURE__*/ _jsxs(state.root, {\n children: [\n state.contentBefore && /*#__PURE__*/ _jsx(state.contentBefore, {}),\n /*#__PURE__*/ _jsx(state.input, {}),\n state.contentAfter && /*#__PURE__*/ _jsxs(state.contentAfter, {\n children: [\n state.contentAfter.children,\n state.dismiss && /*#__PURE__*/ _jsx(state.dismiss, {})\n ]\n })\n ]\n });\n};\n"],"names":["renderSearchBox_unstable","state","assertSlots","_jsxs","root","children","contentBefore","_jsx","input","contentAfter","dismiss"],"mappings":";;;;+BAIiBA;;;eAAAA;;;4BAJ4B;gCACjB;AAGjB,MAAMA,2BAA2B,CAACC;IACzCC,IAAAA,2BAAW,EAACD;IACZ,OAAO,WAAW,GAAGE,IAAAA,gBAAK,EAACF,MAAMG,IAAI,EAAE;QACnCC,UAAU;YACNJ,MAAMK,aAAa,IAAI,WAAW,GAAGC,IAAAA,eAAI,EAACN,MAAMK,aAAa,EAAE,CAAC;YAChE,WAAW,GAAGC,IAAAA,eAAI,EAACN,MAAMO,KAAK,EAAE,CAAC;YACjCP,MAAMQ,YAAY,IAAI,WAAW,GAAGN,IAAAA,gBAAK,EAACF,MAAMQ,YAAY,EAAE;gBAC1DJ,UAAU;oBACNJ,MAAMQ,YAAY,CAACJ,QAAQ;oBAC3BJ,MAAMS,OAAO,IAAI,WAAW,GAAGH,IAAAA,eAAI,EAACN,MAAMS,OAAO,EAAE,CAAC;iBACvD;YACL;SACH;IACL;AACJ"}
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useSearchBox_unstable", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return useSearchBox_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 _reactutilities = require("@fluentui/react-utilities");
14
+ const _reactinput = require("@fluentui/react-input");
15
+ const _reacticons = require("@fluentui/react-icons");
16
+ const useSearchBox_unstable = (props, ref)=>{
17
+ const { size = 'medium', disabled = false, root, contentBefore, dismiss, contentAfter, ...inputProps } = props;
18
+ const searchBoxRootRef = _react.useRef(null);
19
+ const searchBoxRef = _react.useRef(null);
20
+ const [value, setValue] = (0, _reactutilities.useControllableState)({
21
+ state: props.value,
22
+ defaultState: props.defaultValue,
23
+ initialState: ''
24
+ });
25
+ // Tracks the focus of the component for the contentAfter and dismiss button
26
+ const [focused, setFocused] = _react.useState(false);
27
+ const onFocus = (0, _reactutilities.useEventCallback)(()=>{
28
+ setFocused(true);
29
+ });
30
+ const onBlur = (0, _reactutilities.useEventCallback)((ev)=>{
31
+ var _searchBoxRootRef_current;
32
+ setFocused(!!((_searchBoxRootRef_current = searchBoxRootRef.current) === null || _searchBoxRootRef_current === void 0 ? void 0 : _searchBoxRootRef_current.contains(ev.relatedTarget)));
33
+ });
34
+ const rootProps = _reactutilities.slot.resolveShorthand(root);
35
+ const handleDismissClick = (0, _reactutilities.useEventCallback)((event)=>{
36
+ var _props_onChange;
37
+ if ((0, _reactutilities.isResolvedShorthand)(dismiss)) {
38
+ var _dismiss_onClick;
39
+ (_dismiss_onClick = dismiss.onClick) === null || _dismiss_onClick === void 0 ? void 0 : _dismiss_onClick.call(dismiss, event);
40
+ }
41
+ const newValue = '';
42
+ setValue(newValue);
43
+ (_props_onChange = props.onChange) === null || _props_onChange === void 0 ? void 0 : _props_onChange.call(props, event, {
44
+ value: newValue
45
+ });
46
+ });
47
+ const inputState = (0, _reactinput.useInput_unstable)({
48
+ type: 'search',
49
+ disabled,
50
+ size,
51
+ value,
52
+ root: _reactutilities.slot.always({
53
+ ...rootProps,
54
+ ref: (0, _reactutilities.useMergedRefs)(rootProps === null || rootProps === void 0 ? void 0 : rootProps.ref, searchBoxRootRef),
55
+ onFocus: (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)(rootProps === null || rootProps === void 0 ? void 0 : rootProps.onFocus, onFocus)),
56
+ onBlur: (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)(rootProps === null || rootProps === void 0 ? void 0 : rootProps.onBlur, onBlur))
57
+ }, {
58
+ elementType: 'span'
59
+ }),
60
+ contentBefore: _reactutilities.slot.optional(contentBefore, {
61
+ renderByDefault: true,
62
+ defaultProps: {
63
+ children: /*#__PURE__*/ _react.createElement(_reacticons.SearchRegular, null)
64
+ },
65
+ elementType: 'span'
66
+ }),
67
+ contentAfter: _reactutilities.slot.optional(contentAfter, {
68
+ renderByDefault: true,
69
+ elementType: 'span'
70
+ }),
71
+ ...inputProps,
72
+ onChange: (0, _reactutilities.useEventCallback)((ev)=>{
73
+ var _props_onChange;
74
+ const newValue = ev.target.value;
75
+ (_props_onChange = props.onChange) === null || _props_onChange === void 0 ? void 0 : _props_onChange.call(props, ev, {
76
+ value: newValue
77
+ });
78
+ setValue(newValue);
79
+ })
80
+ }, (0, _reactutilities.useMergedRefs)(searchBoxRef, ref));
81
+ const state = {
82
+ ...inputState,
83
+ components: {
84
+ ...inputState.components,
85
+ dismiss: 'span'
86
+ },
87
+ dismiss: _reactutilities.slot.optional(dismiss, {
88
+ defaultProps: {
89
+ children: /*#__PURE__*/ _react.createElement(_reacticons.DismissRegular, null),
90
+ role: 'button',
91
+ 'aria-label': 'clear',
92
+ tabIndex: -1
93
+ },
94
+ renderByDefault: true,
95
+ elementType: 'span'
96
+ }),
97
+ disabled,
98
+ focused,
99
+ size
100
+ };
101
+ if (state.dismiss) {
102
+ state.dismiss.onClick = handleDismissClick;
103
+ }
104
+ return state;
105
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useSearchBox.js"],"sourcesContent":["import * as React from 'react';\nimport { isResolvedShorthand, mergeCallbacks, slot, useControllableState, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport { useInput_unstable } from '@fluentui/react-input';\nimport { DismissRegular, SearchRegular } from '@fluentui/react-icons';\n/**\n * Create the state required to render SearchBox.\n *\n * The returned state can be modified with hooks such as useSearchBoxStyles_unstable,\n * before being passed to renderSearchBox_unstable.\n *\n * @param props - props from this instance of SearchBox\n * @param ref - reference to root HTMLElement of SearchBox\n */ export const useSearchBox_unstable = (props, ref)=>{\n const { size = 'medium', disabled = false, root, contentBefore, dismiss, contentAfter, ...inputProps } = props;\n const searchBoxRootRef = React.useRef(null);\n const searchBoxRef = React.useRef(null);\n const [value, setValue] = useControllableState({\n state: props.value,\n defaultState: props.defaultValue,\n initialState: ''\n });\n // Tracks the focus of the component for the contentAfter and dismiss button\n const [focused, setFocused] = React.useState(false);\n const onFocus = useEventCallback(()=>{\n setFocused(true);\n });\n const onBlur = useEventCallback((ev)=>{\n var _searchBoxRootRef_current;\n setFocused(!!((_searchBoxRootRef_current = searchBoxRootRef.current) === null || _searchBoxRootRef_current === void 0 ? void 0 : _searchBoxRootRef_current.contains(ev.relatedTarget)));\n });\n const rootProps = slot.resolveShorthand(root);\n const handleDismissClick = useEventCallback((event)=>{\n var _props_onChange;\n if (isResolvedShorthand(dismiss)) {\n var _dismiss_onClick;\n (_dismiss_onClick = dismiss.onClick) === null || _dismiss_onClick === void 0 ? void 0 : _dismiss_onClick.call(dismiss, event);\n }\n const newValue = '';\n setValue(newValue);\n (_props_onChange = props.onChange) === null || _props_onChange === void 0 ? void 0 : _props_onChange.call(props, event, {\n value: newValue\n });\n });\n const inputState = useInput_unstable({\n type: 'search',\n disabled,\n size,\n value,\n root: slot.always({\n ...rootProps,\n ref: useMergedRefs(rootProps === null || rootProps === void 0 ? void 0 : rootProps.ref, searchBoxRootRef),\n onFocus: useEventCallback(mergeCallbacks(rootProps === null || rootProps === void 0 ? void 0 : rootProps.onFocus, onFocus)),\n onBlur: useEventCallback(mergeCallbacks(rootProps === null || rootProps === void 0 ? void 0 : rootProps.onBlur, onBlur))\n }, {\n elementType: 'span'\n }),\n contentBefore: slot.optional(contentBefore, {\n renderByDefault: true,\n defaultProps: {\n children: /*#__PURE__*/ React.createElement(SearchRegular, null)\n },\n elementType: 'span'\n }),\n contentAfter: slot.optional(contentAfter, {\n renderByDefault: true,\n elementType: 'span'\n }),\n ...inputProps,\n onChange: useEventCallback((ev)=>{\n var _props_onChange;\n const newValue = ev.target.value;\n (_props_onChange = props.onChange) === null || _props_onChange === void 0 ? void 0 : _props_onChange.call(props, ev, {\n value: newValue\n });\n setValue(newValue);\n })\n }, useMergedRefs(searchBoxRef, ref));\n const state = {\n ...inputState,\n components: {\n ...inputState.components,\n dismiss: 'span'\n },\n dismiss: slot.optional(dismiss, {\n defaultProps: {\n children: /*#__PURE__*/ React.createElement(DismissRegular, null),\n role: 'button',\n 'aria-label': 'clear',\n tabIndex: -1\n },\n renderByDefault: true,\n elementType: 'span'\n }),\n disabled,\n focused,\n size\n };\n if (state.dismiss) {\n state.dismiss.onClick = handleDismissClick;\n }\n return state;\n};\n"],"names":["useSearchBox_unstable","props","ref","size","disabled","root","contentBefore","dismiss","contentAfter","inputProps","searchBoxRootRef","React","useRef","searchBoxRef","value","setValue","useControllableState","state","defaultState","defaultValue","initialState","focused","setFocused","useState","onFocus","useEventCallback","onBlur","ev","_searchBoxRootRef_current","current","contains","relatedTarget","rootProps","slot","resolveShorthand","handleDismissClick","event","_props_onChange","isResolvedShorthand","_dismiss_onClick","onClick","call","newValue","onChange","inputState","useInput_unstable","type","always","useMergedRefs","mergeCallbacks","elementType","optional","renderByDefault","defaultProps","children","createElement","SearchRegular","target","components","DismissRegular","role","tabIndex"],"mappings":";;;;+BAYiBA;;;eAAAA;;;;iEAZM;gCAC0F;4BAC/E;4BACY;AASnC,MAAMA,wBAAwB,CAACC,OAAOC;IAC7C,MAAM,EAAEC,OAAO,QAAQ,EAAEC,WAAW,KAAK,EAAEC,IAAI,EAAEC,aAAa,EAAEC,OAAO,EAAEC,YAAY,EAAE,GAAGC,YAAY,GAAGR;IACzG,MAAMS,mBAAmBC,OAAMC,MAAM,CAAC;IACtC,MAAMC,eAAeF,OAAMC,MAAM,CAAC;IAClC,MAAM,CAACE,OAAOC,SAAS,GAAGC,IA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